/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #F0E68C 100%);
    min-height: 100vh;
    color: #2C3E50;
    line-height: 1.6;
}

/* Container */
.storybook-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Header */
.story-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border-radius: 15px;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.story-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.story-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 600;
}

/* Story Pages */
.story-main {
    position: relative;
    min-height: 600px;
}

.story-page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.story-page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.story-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
    align-items: start;
}

/* Image Styles */
.story-image-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: white;
    padding: 10px;
}

.story-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    transition: transform 0.3s ease;
}

.story-image:hover {
    transform: scale(1.02);
}

/* Text Styles */
.story-text {
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.story-text h2 {
    font-family: 'Fredoka One', cursive;
    color: #E74C3C;
    font-size: 1.8rem;
    margin-bottom: 20px;
    text-align: center;
}

.story-text p {
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-align: justify;
    color: #34495E;
}

/* Audio Controls */
.audio-controls {
    text-align: center;
    margin-bottom: 20px;
}

.audio-btn {
    background: linear-gradient(45deg, #9B59B6, #8E44AD);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(155, 89, 182, 0.3);
}

.audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(155, 89, 182, 0.4);
}

.audio-btn:active {
    transform: translateY(0);
}

.audio-btn.playing {
    background: linear-gradient(45deg, #E74C3C, #C0392B);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Navigation */
.story-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0;
    padding: 20px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 15px;
}

.nav-btn {
    background: linear-gradient(45deg, #3498DB, #2980B9);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 120px;
}

.nav-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.page-indicator {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2C3E50;
    background: white;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.current-page {
    color: #E74C3C;
    font-weight: bold;
}

/* Auto-play Controls */
.auto-play-controls {
    text-align: center;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.auto-play-btn, .stop-audio-btn {
    background: linear-gradient(45deg, #27AE60, #229954);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.stop-audio-btn {
    background: linear-gradient(45deg, #E74C3C, #C0392B);
}

.auto-play-btn:hover, .stop-audio-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.auto-play-btn.active {
    background: linear-gradient(45deg, #F39C12, #E67E22);
}

/* Footer */
.story-footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: rgba(149, 165, 166, 0.1);
    border-radius: 15px;
    color: #7F8C8D;
}

.story-footer p {
    margin-bottom: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .storybook-container {
        margin: 10px;
        padding: 15px;
    }
    
    .story-title {
        font-size: 2rem;
    }
    
    .story-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .story-text {
        padding: 15px;
    }
    
    .story-text h2 {
        font-size: 1.5rem;
    }
    
    .story-text p {
        font-size: 1rem;
    }
    
    .story-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .auto-play-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .auto-play-btn, .stop-audio-btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .story-title {
        font-size: 1.8rem;
    }
    
    .story-subtitle {
        font-size: 1rem;
    }
    
    .story-text h2 {
        font-size: 1.3rem;
    }
    
    .story-text p {
        font-size: 0.95rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility */
.nav-btn:focus, .audio-btn:focus, .auto-play-btn:focus, .stop-audio-btn:focus {
    outline: 3px solid #F39C12;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .storybook-container {
        box-shadow: none;
        background: white;
    }
    
    .audio-controls, .story-navigation, .auto-play-controls {
        display: none;
    }
    
    .story-page {
        display: block !important;
        page-break-after: always;
    }
    
    .story-page:last-child {
        page-break-after: avoid;
    }
}