/* CSS Custom Properties */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --background-color: #EDEEF7;
    --surface-color: #E4FBFF;
    --text-dark: #2D3748;
    --text-light: #4A5568;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(120, 104, 230, 0.15);
    --shadow-hover: 0 8px 24px rgba(120, 104, 230, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --paper-texture: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="1" stitchTiles="stitch"/><feColorMatrix type="saturate" values="0"/></filter></defs><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.03"/></svg>');
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--background-color);
    background-image: var(--paper-texture);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow);
}

.header__title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.header__icon {
    font-size: 2rem;
    animation: pulse 2s infinite;
}

.header__subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

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

/* Main Content */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Control Panel */
.control-panel {
    background: white;
    background-image: var(--paper-texture);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(120, 104, 230, 0.1);
}

/* Play Controls */
.play-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.play-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    min-width: 150px;
    justify-content: center;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

.play-btn.playing {
    background: linear-gradient(135deg, var(--accent-color), #ff9999);
}

.stop-btn {
    background: #6B7280;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    min-width: 150px;
    justify-content: center;
}

.stop-btn:hover {
    background: #4B5563;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Volume Control */
.volume-control {
    margin-bottom: 2rem;
}

.volume-control__label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.volume-slider {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(120, 104, 230, 0.1);
}

.volume-icon {
    font-size: 1.2rem;
    min-width: 24px;
}

.slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #E5E7EB;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.volume-value {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: right;
}

/* Timer Section */
.timer-section {
    text-align: center;
}

.timer-section__title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.timer-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.timer-btn {
    background: var(--surface-color);
    color: var(--text-dark);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-width: 80px;
}

.timer-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-1px);
}

.timer-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.timer-display {
    margin-top: 1rem;
}

.timer-display__time {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.timer-stop-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.timer-stop-btn:hover {
    background: #ff9999;
}

/* Sound Grid */
.sound-grid {
    background: white;
    background-image: var(--paper-texture);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(120, 104, 230, 0.1);
}

.sound-grid__title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-dark);
}

.sound-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Sound Card */
.sound-card {
    background: var(--surface-color);
    background-image: var(--paper-texture);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border: 2px solid transparent;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.sound-card:hover {
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.sound-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.sound-card.active .sound-card__icon {
    animation: bounce 1s infinite;
}

.sound-card__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sound-card__icon {
    font-size: 2rem;
    min-width: 40px;
}

.sound-card__title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.sound-card__controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sound-card__volume {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sound-card__volume .slider {
    height: 6px;
}

.sound-card__volume .volume-value {
    font-size: 0.9rem;
    min-width: 35px;
}

.sound-card.active .sound-card__volume .slider::-webkit-slider-thumb {
    background: white;
}

.sound-card.active .sound-card__volume .slider::-moz-range-thumb {
    background: white;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    background: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FECACA;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.error-icon {
    font-size: 1.2rem;
}

.error-text {
    flex: 1;
}

.error-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #B91C1C;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer */
.footer {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer__text {
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer__text a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer__text a:hover {
    color: white;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header__title {
        font-size: 2rem;
    }
    
    .control-panel,
    .sound-grid {
        padding: 1.5rem;
    }
    
    .play-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .play-btn,
    .stop-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .timer-controls {
        gap: 0.3rem;
    }
    
    .timer-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        min-width: 60px;
    }
    
    .sound-cards {
        grid-template-columns: 1fr;
    }
    
    .sound-card__controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .sound-card__volume {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }
    
    .header__title {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .main {
        padding: 1rem 0;
    }
    
    .control-panel,
    .sound-grid {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .volume-slider {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .timer-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .timer-btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
    
    .sound-card {
        border-width: 3px;
    }
}

/* Focus styles for accessibility */
button:focus,
input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header,
    .footer {
        background: none !important;
        color: black !important;
    }
    
    .control-panel,
    .sound-grid {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
