* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #181c25;
    min-height: 100vh;
    color: #333;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.cache-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #495057;
}

main {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    position: relative;
}

.player-section {
    display: flex;
    flex-direction: column;
    max-height: calc(-40px + 100vh);
    max-width: calc(-40px + 100vw);
}

.audio-list {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-height: calc(-40px + 100vh);
    overflow-y: auto;
}

.audio-list h2 {
    margin-bottom: 15px;
    color: #333;
}

.folder-navigation {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.folder-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}

.nav-item {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.nav-item.expanded {
    background: #e3f2fd;
    border-color: #2196F3;
}

.nav-item-header {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.nav-item-header:hover {
    background: #e9ecef;
}

.nav-item.expanded .nav-item-header {
    background: #e3f2fd;
}

.nav-item-content h4 {
    margin: 0;
    color: #333;
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.nav-item.expanded .nav-item-content h4 {
    color: #1976d2;
}

.nav-item-toggle {
    font-size: 0.8rem;
    color: #666;
    transition: transform 0.2s ease;
}

.nav-item.expanded .nav-item-toggle {
    transform: rotate(180deg);
}

.nav-item-files {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.nav-item.expanded .nav-item-files {
    max-height: 400px;
    overflow-y: auto;
}

.section-accordion {
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.section-header {
    padding: 8px 16px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
    background: #f1f3f4;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.section-header:hover {
    background: #e9ecef;
}

.section-name {
    flex: 1;
}

.section-toggle {
    font-size: 0.7rem;
    color: #666;
    transition: transform 0.2s ease;
}

.section-files {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.section-accordion.expanded .section-files {
    max-height: 300px;
    overflow-y: auto;
}

.section-accordion.expanded .section-header {
    background: #e3f2fd;
    color: #1976d2;
}


.folder-header {
    margin: 20px 0 10px 0;
    padding: 10px 0;
    border-bottom: 2px solid #2196F3;
}

.folder-header h3 {
    color: #2196F3;
    margin-bottom: 4px;
}

.folder-description {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.audio-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 4px 0;
}

.folder-tag {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.duration {
    color: #666;
    font-size: 0.8rem;
}

.no-files {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-style: italic;
}

.audio-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.audio-item:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.audio-item.playing {
    background: #e3f2fd;
    border-left: 4px solid #2196F3;
}

.audio-info {
    width: 100%;
}

.audio-title {
    font-weight: 500;
    margin-bottom: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.audio-status {
    font-size: 0.8rem;
    color: #666;
}

.audio-status.cached {
    color: #4caf50;
}

.player {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Lyrics container styles */
.lyrics-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.lyrics-paragraph {
    margin-bottom: 16px;
}

.lyrics-sentence {
    margin-bottom: 8px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.align-text {
    display: inline;
    padding: 2px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.align-text:hover {
    background-color: #e3f2fd;
    border-radius: 3px;
}

.align-text.highlighted {
    background-color: #bbdefb;
    border-radius: 3px;
    padding: 2px 4px;
    font-weight: 500;
}

.no-lyrics {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.player-info {
    margin-bottom: 20px;
}

.player-info h3 {
    margin-bottom: 8px;
    color: #333;
}

.cache-indicator {
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.cache-indicator.cached {
    background: #e8f5e8;
    color: #2e7d32;
}

.cache-indicator.downloading {
    background: #fff3e0;
    color: #f57c00;
}

.cache-indicator.not-cached {
    background: #ffebee;
    color: #c62828;
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.delete-btn {
    color: #dc3545;
  }

#play-pause-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    min-width: 50px;
    height: 50px;
}

#play-pause-btn:hover:not(:disabled) {
    background: #1976d2;
    transform: scale(1.05);
}

#play-pause-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.progress-container {
    flex: 1;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: #2196F3;
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #666;
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#volume-slider {
    width: 80px;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.loading p {
    color: white;
    font-size: 1.1rem;
}

/* Toggle sidebar button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: #181c25;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Advanced Controls Accordion */
.advanced-controls-accordion {
    margin-top: 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.advanced-controls-header {
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #495057;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #e9ecef;
}

.advanced-controls-header:hover {
    background: #e9ecef;
}

.advanced-controls-accordion.expanded .advanced-controls-header {
    background: #e3f2fd;
    color: #1976d2;
}

.advanced-controls-toggle {
    font-size: 0.8rem;
    color: #666;
    transition: transform 0.2s ease;
}

.advanced-controls-accordion.expanded .advanced-controls-toggle {
    transform: rotate(180deg);
}

.advanced-controls {
    display: none;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: white;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.advanced-controls-accordion.expanded .advanced-controls {
    max-height: 200px;
    display: flex;
}

.speed-control, .loop-controls, .mode-controls, .script-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-control label, .mode-controls label, .script-controls label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    min-width: 50px;
}

#speed-slider {
    width: 80px;
}

#speed-display {
    min-width: 45px;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.loop-controls {
    gap: 4px;
}

.loop-controls .btn {
    font-size: 0.8rem;
    padding: 4px 8px;
    min-width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-select-sm {
    font-size: 0.85rem;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
}

/* Enhanced Lyrics Styles */
.lyrics-paragraph {
    margin-bottom: 16px;
    padding: 12px;
    border-left: 4px solid #e9ecef;
    background: rgba(248, 249, 250, 0.5);
    border-radius: 0 6px 6px 0;
}

.lyrics-sentence {
    margin-bottom: 8px;
    line-height: 1.7;
    flex-wrap: wrap;
    display: flex;
}

.align-text {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline;
}

.align-text:hover {
    background-color: #e3f2fd;
    transform: translateY(-1px);
}

.align-text.highlighted {
    background-color: #bbdefb;
    border: 1px solid #2196F3;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(33, 150, 243, 0.3);
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }

    .player-info {
        justify-content: right;
        display: flex;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .audio-list {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 70%;
        z-index: 90;
        transition: left 0.3s ease;
        overflow-y: auto;
        height: 100vh;
    }
    
    .audio-list.show {
        left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 80;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .volume-container {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    #volume-slider {
        width: 200px;
    }
    
    .nav-item {
        padding: 12px;
    }
    
    .nav-item-content h4 {
        font-size: 1rem;
    }
    
    /* Mobile Advanced Controls */
    .advanced-controls {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .advanced-controls-accordion.expanded .advanced-controls {
        max-height: 300px;
    }
    
    .speed-control, .loop-controls, .mode-controls, .script-controls {
        /* justify-content: space-between; */
        width: 100%;
    }
    
    .speed-control label, .mode-controls label, .script-controls label {
        min-width: auto;
    }
    
    .loop-controls {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    #speed-slider {
        width: 120px;
    }
}
