/**
 * Course Audio Player Styles
 * Floating player positioned below chatbot widget
 *
 * Author: Médéric (Académie des Étoiles)
 * Date: 2025-11-25
 */

/* ============================================================================
   Main Player Container
   ============================================================================ */

.audio-player {
    position: fixed;
    bottom: 10px;
    left: 300px;  /* Right of sidebar on desktop */
    width: 280px;
    max-height: 650px;
    background: white;
    border-radius: 0;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Responsive: Stack on right side - audio at bottom, chatbot above */
@media (max-width: 1100px) {
    .audio-player {
        left: auto;
        right: 24px;
        bottom: 24px;  /* Audio at bottom */
        width: 64px;
    }

    .audio-player--minimized {
        width: 64px;
        max-height: 54px;
    }

    /* When expanded, take most of screen */
    .audio-player:not(.audio-player--minimized) {
        width: calc(100% - 48px);
        max-width: 500px;
        max-height: 600px;
        right: 24px;
        bottom: 24px;
    }

    /* Hide audio when chatbot is open (mobile only) */
    .chatbot-modal.open ~ .audio-player {
        display: none !important;
    }
}

.audio-player--minimized {
    max-height: 54px;  /* Taller for better button alignment */
    width: 280px;
}

.audio-player--minimized .audio-player__body {
    display: none;
}

.audio-player--minimized .audio-player__mini-controls {
    display: flex !important;
}

/* ============================================================================
   Header (Always Visible)
   ============================================================================ */

.audio-player__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;  /* More compact */
    background: linear-gradient(135deg, #ff631e 0%, #e55a1a 100%);  /* Purple theme matching chatbot */
    border-radius: 0 12px 0 0;
    cursor: pointer;
    user-select: none;
}

.audio-player--minimized .audio-player__header {
    border-radius: 0;
}

.audio-player__header:hover {
    background: linear-gradient(135deg, #e55a1a 0%, #d14e15 100%);
}

.audio-player__toggle {
    background: none;
    border: none;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    flex: 1;
    text-align: left;
}

.audio-player__minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}

.audio-player__minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   Player Body
   ============================================================================ */

.audio-player__body {
    padding: 16px;
    overflow-y: auto;
    max-height: 450px;
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE/Edge */
}

.audio-player__body::-webkit-scrollbar {
    display: none;  /* Chrome/Safari - HIDE completely */
}

.audio-player__lesson-info {
    margin-bottom: 12px;
}

.audio-player__lesson-title {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.audio-player__section-info {
    font-size: 13px;
    color: #666;
}

/* ============================================================================
   Audio Controls
   ============================================================================ */

.audio-player__audio {
    display: none;  /* Hide default HTML5 controls, use custom UI */
}

.audio-player__controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audio-player__btn {
    padding: 10px 16px;
    border: none;
    border-radius: 0;
    background: #ff631e;
    color: white;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.audio-player__btn:hover {
    background: #e55a1a;
}

.audio-player__btn:active {
    transform: scale(0.98);
}

.audio-player__btn--play {
    background: #ff631e;
}

.audio-player__btn--play:hover {
    background: #e55a1a;
}

.audio-player__btn--pause {
    background: #f59e0b;  /* Orange for pause */
}

.audio-player__btn--pause:hover {
    background: #d97706;
}

/* Progress Bar */

.audio-player__progress-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audio-player__progress {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.audio-player__progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff631e;
    cursor: pointer;
    transition: background 0.2s;
}

.audio-player__progress::-webkit-slider-thumb:hover {
    background: #e55a1a;
}

.audio-player__progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff631e;
    cursor: pointer;
    border: none;
}

.audio-player__time {
    font-size: 12px;
    color: #666;
    text-align: center;
    font-variant-numeric: tabular-nums;  /* Monospaced numbers */
}

/* Speed Control */

.audio-player__speed {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.audio-player__speed:hover {
    border-color: #ff631e;
}

.audio-player__speed:focus {
    outline: none;
    border-color: #ff631e;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* ============================================================================
   Playlist
   ============================================================================ */

.audio-player__playlist {
    margin-top: 16px;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.audio-player__playlist-header {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.audio-player__playlist-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.audio-player__empty {
    font-size: 13px;
    color: #999;
    text-align: center;
    padding: 12px;
    margin: 0;
}

/* Playlist Items */

.audio-playlist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.audio-playlist-item:hover {
    background: #f3f4f6;
}

.audio-playlist-item--active {
    background: #ecfdf5;  /* Light green */
    border-left-color: #ff631e;
}

/* Voice-specific styling */
.audio-playlist-item.voice-cedar {
    border-left-color: #ff631e;  /* Green for Cedar */
}

.audio-playlist-item.voice-marin {
    border-left-color: #3b82f6;  /* Blue for Marin */
}

.audio-playlist-item.voice-cedar:hover {
    background: #f0fdf4;  /* Light green hover */
}

.audio-playlist-item.voice-marin:hover {
    background: #eff6ff;  /* Light blue hover */
}

.audio-playlist-item__play {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.audio-playlist-item__name {
    flex: 1;
    font-size: 13px;
    color: #1a1a1a;
    line-height: 1.4;
}

.audio-playlist-item__duration {
    font-size: 12px;
    color: #666;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ============================================================================
   Scrollbar Styling
   ============================================================================ */

.audio-player__playlist-items::-webkit-scrollbar {
    width: 6px;
}

.audio-player__playlist-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.audio-player__playlist-items::-webkit-scrollbar-thumb {
    background: #ff631e;
    border-radius: 3px;
}

.audio-player__playlist-items::-webkit-scrollbar-thumb:hover {
    background: #e55a1a;
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

/* REMOVED: Old conflicting media queries replaced by unified 1100px strategy above */

/* ============================================================================
   Accessibility
   ============================================================================ */

.audio-player__btn:focus,
.audio-player__toggle:focus,
.audio-player__minimize:focus,
.audio-player__progress:focus,
.audio-player__speed:focus {
    outline: 2px solid #ff631e;
    outline-offset: 2px;
}

/* Keyboard navigation for playlist */
.audio-playlist-item:focus {
    outline: 2px solid #ff631e;
    outline-offset: -2px;
}

/* ============================================================================
   Loading State
   ============================================================================ */

.audio-player__loading {
    padding: 12px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.audio-player__loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top-color: #ff631e;
    border-radius: 50%;
    margin-left: 8px;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   Print Styles (Hide Player)
   ============================================================================ */

@media print {
    .audio-player {
        display: none !important;
    }
}

/* ============================================================================
   Mini Controls (Shown when minimized)
   ============================================================================ */

/* Horizontal mini player (collapsed state) */
.audio-player__mini {
    display: none;  /* Hidden when expanded */
    background: linear-gradient(135deg, #ff631e 0%, #e55a1a 100%);
    border-radius: 0;
    padding: 0;
    overflow: hidden;
}

.audio-player--minimized .audio-player__mini {
    display: block;
}

.audio-player--minimized .audio-player__expanded {
    display: none;
}

.audio-player__mini-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.25);  /* More visible */
    position: relative;
}

.audio-player__mini-progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.9);  /* Brighter fill */
    width: 0%;
    transition: width 0.1s linear;
}

.audio-player__mini-controls {
    display: flex;
    align-items: center;
    justify-content: space-evenly;  /* Even distribution */
    padding: 10px 8px;  /* Minimal edge padding */
    gap: 0;
}

/* All buttons same style */
.audio-player__menu-btn,
.audio-player__mini-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: rgba(255, 255, 255, 0.95);
    width: 34px;
    height: 34px;
    border-radius: 50%;  /* Round buttons */
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.audio-player__menu-btn:hover,
.audio-player__mini-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
    color: white;
}

/* Play button slightly larger but same background */
.audio-player__mini-btn--play {
    width: 36px;
    height: 36px;
    font-size: 18px;
}
