/**
 * Global Plyr Player Styles
 * Compact single-line audio player with light theme
 * Navigation controls (prev/play/next) integrated
 * Drag & Drop + Resize support
 *
 * Layout:
 * - Track title: fixed width (content-based), no resize
 * - Progress bar: flexible, min-width = 150px
 * - Volume slider: fixed width 100px
 * - Close button: fixed
 *
 * @version 2.7.1
 */

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

.plyr-floating-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 600px;
    max-width: calc(100vw - 40px);
    /* Min width = all elements at their minimum sizes:
       buttons (36+42+36) + title (~180) + progress (150) + volume (100) + close (36) + gaps + padding */
    min-width: 600px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    transition: box-shadow 0.2s ease;
    cursor: grab;
}

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

.plyr-floating-container.dragging {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(59, 130, 246, 0.5);
    cursor: grabbing !important;
}

.plyr-floating-container.resizing {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* ==================== DRAG HANDLE (HIDDEN - entire player is draggable) ==================== */

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

/* ==================== RESIZE HANDLES ==================== */

.plyr-resize-handle {
    position: absolute;
    z-index: 10;
}

/* Edge handles */
.plyr-resize-n {
    top: -4px;
    left: 20px;
    right: 20px;
    height: 8px;
    cursor: ns-resize;
}

.plyr-resize-s {
    bottom: -4px;
    left: 20px;
    right: 20px;
    height: 8px;
    cursor: ns-resize;
}

.plyr-resize-e {
    right: -4px;
    top: 20px;
    bottom: 20px;
    width: 8px;
    cursor: ew-resize;
}

.plyr-resize-w {
    left: -4px;
    top: 20px;
    bottom: 20px;
    width: 8px;
    cursor: ew-resize;
}

/* Corner handles */
.plyr-resize-ne {
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    cursor: nesw-resize;
}

.plyr-resize-nw {
    top: -4px;
    left: -4px;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.plyr-resize-se {
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.plyr-resize-sw {
    bottom: -4px;
    left: -4px;
    width: 16px;
    height: 16px;
    cursor: nesw-resize;
}

/* No visual indicator - only cursor change */

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

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

/* ==================== 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 {
    /* Fixed width - does not change when resizing */
    flex: 0 0 auto;
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    padding: 0 8px;
    user-select: none;
    overflow: hidden;
}

.plyr-track-title {
    display: block;
    font-size: 13px;
    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;
}

/* ==================== 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 {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        min-width: 480px;
        max-width: none;
    }

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

    .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 - smaller fixed width on tablet */
    .plyr-track-info {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
    }

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

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

@media (max-width: 480px) {
    .plyr-floating-container {
        min-width: 320px;
    }

    .plyr-compact-player {
        flex-wrap: nowrap;
    }

    /* Hide track info on mobile */
    .plyr-track-info {
        display: none;
    }

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

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