/**
 * StoryFlow Frontend Styles
 *
 * @package StoryFlow
 * @version 1.0.0
 */

/* Main Container */
.storyflow-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    position: relative;
    overflow: hidden;
}

.storyflow-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* Story Header */
.storyflow-story-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.storyflow-story-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.storyflow-story-description {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin: 0;
    font-style: italic;
}

/* Progress Bar */
.storyflow-progress-container {
    margin-bottom: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
}

.storyflow-progress-label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.storyflow-progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.storyflow-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.storyflow-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.storyflow-progress-text {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.5rem;
    text-align: center;
}

/* Story Content */
.storyflow-story-content {
    margin-bottom: 2rem;
    transition: opacity 0.3s ease;
}

.storyflow-node {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.storyflow-node-title {
    margin-bottom: 1.5rem;
}

.storyflow-node-title h3 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    text-align: center;
}

.storyflow-text {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #2c3e50;
    margin-bottom: 2rem;
    text-align: justify;
}

.storyflow-text p {
    margin-bottom: 1.2rem;
}

.storyflow-text p:last-child {
    margin-bottom: 0;
}

/* Media Elements */
.storyflow-image {
    margin: 2rem 0;
    text-align: center;
}

.storyflow-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.storyflow-image img:hover {
    transform: scale(1.02);
}

.storyflow-image-caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #7f8c8d;
    font-style: italic;
}

.storyflow-audio {
    margin: 2rem 0;
    text-align: center;
}

.storyflow-audio audio {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.storyflow-audio-description {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #7f8c8d;
}

.storyflow-video {
    margin: 2rem 0;
    text-align: center;
}

.storyflow-video video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Choice Buttons */
.storyflow-choices {
    margin-top: 2rem;
}

.storyflow-choices-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.storyflow-choice-prompt {
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.storyflow-choices-list {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.storyflow-choice-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.storyflow-choice-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.storyflow-choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

.storyflow-choice-btn:hover::before {
    left: 100%;
}

.storyflow-choice-btn:active {
    transform: translateY(0);
}

.storyflow-choice-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.storyflow-choice-btn.storyflow-choice-selected {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    animation: pulse 0.6s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.choice-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.choice-text {
    flex: 1;
    font-weight: 500;
}

.choice-description {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
    margin-top: 0.5rem;
    display: block;
}

.choice-hint {
    margin-left: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: help;
}

/* Story Ending */
.storyflow-ending {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin: 2rem 0;
    border: 2px solid #dee2e6;
}

.storyflow-ending-message {
    margin-bottom: 1.5rem;
}

.storyflow-ending-message h3 {
    font-size: 2rem;
    color: #28a745;
    margin: 0 0 1rem 0;
    font-weight: 700;
}

.storyflow-ending-message p {
    font-size: 1.1rem;
    color: #6c757d;
    margin: 0;
}

.storyflow-ending-score {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    display: inline-block;
}

.score-label {
    font-weight: 600;
    color: #495057;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    margin-left: 0.5rem;
}

.storyflow-ending-achievement {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%);
    color: white;
    border-radius: 8px;
    display: inline-block;
    font-weight: 600;
}

.achievement-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

/* Controls */
.storyflow-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.storyflow-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.storyflow-restart-btn {
    background: #6c757d;
    color: white;
}

.storyflow-restart-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.storyflow-back-btn {
    background: #17a2b8;
    color: white;
}

.storyflow-back-btn:hover {
    background: #138496;
    transform: translateY(-1px);
}

/* Share Section */
.storyflow-share {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    display: none;
}

.storyflow-share h4 {
    margin: 0 0 1rem 0;
    color: #495057;
    font-size: 1.1rem;
}

.storyflow-share-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.storyflow-share-buttons a {
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.share-facebook {
    background: #3b5998;
    color: white;
}

.share-facebook:hover {
    background: #2d4373;
    color: white;
}

.share-twitter {
    background: #1da1f2;
    color: white;
}

.share-twitter:hover {
    background: #0d8bd9;
    color: white;
}

.share-whatsapp {
    background: #25d366;
    color: white;
}

.share-whatsapp:hover {
    background: #128c7e;
    color: white;
}

.share-linkedin {
    background: #0077b5;
    color: white;
}

.share-linkedin:hover {
    background: #005582;
    color: white;
}

/* Export Section */
.storyflow-export {
    margin-top: 1rem;
    text-align: center;
    display: none;
}

.storyflow-export-pdf {
    background: #dc3545;
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.storyflow-export-pdf:hover {
    background: #c82333;
    color: white;
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .storyflow-container {
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 8px;
    }
    
    .storyflow-story-title {
        font-size: 2rem;
    }
    
    .storyflow-choices-list {
        gap: 0.8rem;
    }
    
    .storyflow-choice-btn {
        padding: 1rem;
        font-size: 0.95rem;
    }
    
    .storyflow-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .storyflow-share-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .storyflow-share-buttons a {
        width: 200px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .storyflow-container {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    .storyflow-story-title {
        font-size: 1.8rem;
    }
    
    .storyflow-text {
        font-size: 1rem;
    }
    
    .storyflow-choice-btn {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .storyflow-container {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .storyflow-story-title,
    .storyflow-text {
        color: #ecf0f1;
    }
    
    .storyflow-progress-container {
        background: #34495e;
    }
    
    .storyflow-ending {
        background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
        border-color: #4a5f7a;
    }
    
    .storyflow-share {
        background: #34495e;
    }
}

/* Custom Theme Classes */
.storyflow-theme-dark {
    background: #2c3e50;
    color: #ecf0f1;
}

.storyflow-theme-dark .storyflow-story-title,
.storyflow-theme-dark .storyflow-text {
    color: #ecf0f1;
}

.storyflow-theme-minimal {
    box-shadow: none;
    border: 1px solid #e9ecef;
    background: #fafafa;
}

.storyflow-theme-classic {
    font-family: "Times New Roman", serif;
    background: #f8f6f0;
    color: #2c2c2c;
    border: 2px solid #d4c4a8;
}

.storyflow-theme-classic .storyflow-choice-btn {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    font-family: inherit;
}

/* Loading States */
.storyflow-loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.storyflow-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #dee2e6;
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility Improvements */
.storyflow-choice-btn:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.storyflow-container:focus-within {
    outline: none;
}

/* Print Styles */
@media print {
    .storyflow-container {
        box-shadow: none;
        border: 1px solid #ccc;
        margin: 0;
        padding: 1rem;
    }
    
    .storyflow-controls,
    .storyflow-share,
    .storyflow-export,
    .storyflow-progress-container {
        display: none !important;
    }
    
    .storyflow-choice-btn {
        background: #f8f9fa !important;
        color: #333 !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* Animation for smooth transitions */
.storyflow-fade-transition {
    transition: opacity 0.3s ease-in-out;
}

.storyflow-fade-transition.fade-out {
    opacity: 0;
}

.storyflow-fade-transition.fade-in {
    opacity: 1;
}

/* Custom scrollbar for webkit browsers */
.storyflow-container::-webkit-scrollbar {
    width: 8px;
}

.storyflow-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.storyflow-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.storyflow-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}