/**
 * Global Plyr Player Styles
 * Compact single-line audio player with light theme
 * Navigation controls (prev/play/next) integrated
 * Fixed at bottom, full width with side padding
 *
 * Layout:
 * - Track title: fixed width 320px (expanded)
 * - Progress bar: flexible, min-width = 150px
 * - Volume slider: fixed width 100px
 * - Close button: fixed
 * - Full width at bottom with left/right padding (like hero blocks)
 * - Body padding when player is visible to prevent content overlap
 * - On detail pages, syncs with embedded player
 *
 * @version 2.14.0
 */

/* ==================== FLOATING CONTAINER ==================== */

.plyr-floating-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    background: #ffffff;
    border-radius: 0;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: box-shadow 0.2s ease;
    cursor: default;
    /* Padding like hero blocks */
    padding: 0 1rem;
    box-sizing: border-box;
}

/* Add bottom padding to body when player is visible to allow scrolling past player */
body.plyr-player-active {
    padding-bottom: 70px;
}

.plyr-floating-container.hidden {
    display: none;
}

.plyr-floating-container.dragging,
.plyr-floating-container.resizing {
    /* No visual change - player is fixed */
}

/* ==================== DRAG & RESIZE HANDLES (HIDDEN - player is fixed) ==================== */

.plyr-drag-handle,
.plyr-resize-handle {
    display: none;
}

/* ==================== COMPACT PLAYER LAYOUT ==================== */

.plyr-compact-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
}

/* ==================== CONTROL BUTTONS ==================== */

.plyr-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}

.plyr-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

.plyr-btn:active {
    transform: scale(0.95);
}

.plyr-btn i {
    font-size: 16px;
}

/* Play/Pause button - primary style */
.plyr-play-pause-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: #3b82f6;
    color: #ffffff;
}

.plyr-play-pause-btn:hover {
    background: #2563eb;
    color: #ffffff;
}

.plyr-play-pause-btn i {
    font-size: 18px;
}

.plyr-play-pause-btn.playing {
    background: #10b981;
}

.plyr-play-pause-btn.playing:hover {
    background: #059669;
}

/* Close button */
.plyr-btn-close {
    background: transparent;
    color: #9ca3af;
}

.plyr-btn-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ==================== TRACK INFO ==================== */

.plyr-track-info {
    /* Expanded fixed width for track title */
    flex: 0 0 auto;
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    padding: 0 12px;
    user-select: none;
    overflow: hidden;
}

.plyr-track-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== PROGRESS WRAPPER ==================== */

.plyr-progress-wrapper {
    /* Flexible - grows and shrinks with player resize */
    flex: 1 1 auto;
    min-width: 150px;
    position: relative;
}

#plyr-floating-player {
    width: 100%;
}

/* ==================== PLYR OVERRIDES FOR COMPACT MODE ==================== */

/* Hide all video elements */
.plyr-floating-container .plyr__video-wrapper,
.plyr-floating-container .plyr__poster,
.plyr-floating-container .plyr__control--overlaid,
.plyr-floating-container video {
    display: none !important;
}

/* YouTube embed - keep functional but hidden */
.plyr-floating-container .plyr__video-embed {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    opacity: 0.01;
    pointer-events: none;
}

.plyr-floating-container .plyr__video-embed iframe {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
}

/* Plyr container - ensure full width */
.plyr-floating-container .plyr {
    --plyr-color-main: #3b82f6;
    width: 100% !important;
    min-height: auto;
    height: auto !important;
    background: transparent !important;
}

.plyr-floating-container .plyr--video,
.plyr-floating-container .plyr--youtube,
.plyr-floating-container .plyr--audio {
    width: 100% !important;
    min-height: auto;
    height: auto !important;
    background: transparent !important;
}

/* Controls - inline style, full width */
.plyr-floating-container .plyr__controls {
    position: relative !important;
    width: 100% !important;
    background: transparent !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    gap: 8px;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Hide Plyr's play button - we have our own */
.plyr-floating-container .plyr__control[data-plyr="play"] {
    display: none !important;
}

/* Progress bar - flexible, takes available space */
.plyr-floating-container .plyr__progress {
    flex: 1 1 auto !important;
    min-width: 0;
    margin: 0;
}

/* Progress container inside plyr__progress */
.plyr-floating-container .plyr__progress__container {
    flex: 1 1 auto !important;
    min-width: 0;
}

.plyr-floating-container .plyr__progress input[type=range] {
    color: #3b82f6;
    width: 100%;
}

.plyr-floating-container .plyr__progress__buffer {
    background: #e5e7eb;
}

/* Time */
.plyr-floating-container .plyr__time {
    color: #6b7280;
    font-size: 12px;
    padding: 0 4px;
}

/* Volume - fixed width, does not change when resizing */
.plyr-floating-container .plyr__volume {
    flex: 0 0 auto;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

.plyr-floating-container .plyr__volume input[type=range] {
    color: #3b82f6;
}

/* Hide unnecessary controls */
.plyr-floating-container .plyr__control[data-plyr="mute"] {
    color: #6b7280;
    padding: 0 4px;
}

.plyr-floating-container .plyr__control[data-plyr="settings"],
.plyr-floating-container .plyr__control[data-plyr="fullscreen"],
.plyr-floating-container .plyr__control[data-plyr="pip"],
.plyr-floating-container .plyr__control[data-plyr="captions"],
.plyr-floating-container .plyr__menu,
.plyr-floating-container .plyr__captions {
    display: none !important;
}

/* ==================== DETAIL PAGE MODE ==================== */

/* On detail pages, compact player shows track info and progress, syncs with embedded player */

/* Adjust layout for detail page mode */
.plyr-floating-container.detail-page-mode .plyr-compact-player {
    justify-content: center;
}

/* Track info can be wider on detail pages */
.plyr-floating-container.detail-page-mode .plyr-track-info {
    flex: 0 0 auto;
    width: auto;
    min-width: 200px;
    max-width: 400px;
}

/* ==================== CUSTOM PROGRESS BAR (for detail pages) ==================== */

.plyr-custom-progress {
    display: none; /* Hidden by default, shown via JS on detail pages */
    align-items: center;
    gap: 8px;
    width: 100%;
}

.plyr-custom-time {
    font-size: 12px;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: center;
    user-select: none;
}

.plyr-custom-progress-bar {
    flex: 1 1 auto;
    position: relative;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.plyr-custom-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #3b82f6;
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s linear;
}

.plyr-custom-progress-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.plyr-custom-progress-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.plyr-custom-progress-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Responsive for custom progress */
@media (max-width: 480px) {
    .plyr-custom-time {
        font-size: 11px;
        min-width: 35px;
    }

    .plyr-custom-progress {
        gap: 4px;
    }
}

/* ==================== PLAY BUTTON STATES ON PAGE ==================== */

.audio-play-btn,
.play-btn,
[data-play-media] {
    transition: all 0.2s ease;
}

.audio-play-btn.playing,
.play-btn.playing,
[data-play-media].playing {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.audio-play-btn.playing i,
.play-btn.playing i,
[data-play-media].playing i {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 768px) {
    .plyr-floating-container {
        padding: 0 0.75rem;
    }

    body.plyr-player-active {
        padding-bottom: 60px;
    }

    .plyr-compact-player {
        gap: 6px;
        padding: 8px 18px;
    }

    .plyr-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .plyr-btn i {
        font-size: 14px;
    }

    .plyr-play-pause-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    /* Track info - reduced width on tablet */
    .plyr-track-info {
        width: 200px;
        min-width: 200px;
        max-width: 200px;
    }

    .plyr-track-title {
        font-size: 13px;
    }

    /* Hide volume on tablet */
    .plyr-floating-container .plyr__volume {
        display: none;
    }
}

@media (max-width: 480px) {
    .plyr-floating-container {
        padding: 0 0.5rem;
    }

    body.plyr-player-active {
        padding-bottom: 56px;
    }

    .plyr-compact-player {
        gap: 4px;
        padding: 8px 16px;
    }

    /* Smaller track info on mobile */
    .plyr-track-info {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
    }

    .plyr-track-title {
        font-size: 12px;
    }

    .plyr-progress-wrapper {
        min-width: 60px;
    }

    .plyr-floating-container .plyr__time {
        display: none;
    }
}
