/* Floating Player - Modern Glassmorphism Design */

#floating-player {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(200%);
    /* HIDDEN by default - increased from 120% */
    z-index: 1000;
    width: auto;
    max-width: 95vw;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    /* Start invisible */
}

#floating-player.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    /* Fade in when visible */
}

/* Compact State (The Pill) */
.player-compact {
    background: rgba(15, 15, 18, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    min-width: 600px;
    max-width: 900px;
    position: relative;
    height: auto;
    min-height: 108px;
}

@media (max-width: 1024px) {
    .player-compact {
        min-width: unset;
        width: 96%;
        max-width: 100%;
        gap: 8px;
        padding: 10px 12px;
        min-height: auto;
        flex-wrap: wrap;
        align-content: flex-start;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        height: auto;
        padding-bottom: 16px;
    }

    .player-controls-compact {
        gap: 6px !important;
        margin-right: 0;
        flex-shrink: 0;
        order: 2;
    }

    .player-compact-top {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 8px;
    }

    #floating-player {
        bottom: -15px;
    }

    #floating-player.visible {
        width: 100%;
        /* Fade in when visible */
    }

    .player-compact {
        border: 0px !important;
    }

    /* FIX: Ensure expanded player close button is clickable but below modals */
    .expanded-top-actions button {
        z-index: 9005;
        position: relative;
    }

    .player-art-btn {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }

    .player-info-compact {
        min-width: 0;
        flex: 0 0 auto;
        max-width: 180px;
        order: 1;
    }

    .player-info-compact h4 {
        font-size: 12px;
    }

    .player-info-compact p {
        font-size: 10px;
    }



    .player-main-ctrl {
        width: 36px;
        height: 36px;
    }

    .player-controls-compact .player-secondary-ctrl {
        width: 30px !important;
        height: 30px !important;
    }

    /* Force Hide Shuffle and Repeat on Mobile */
    #btn-shuffle,
    #btn-repeat {
        display: none !important;
    }

    .player-actions-compact {
        flex-basis: 100%;
        gap: 12px;
        padding: 0;
        border-left: none;
        justify-content: center;
        order: 3;
    }

    #btn-player-like {
        display: flex !important;
    }

    .player-actions-compact button[onclick*="toggleActionMenu"],
    .player-actions-compact button[onclick*="expandPlayer"],
    .player-actions-compact button[onclick*="closePlayer"] {
        display: flex !important;
        padding: 0;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .player-actions-compact button i {
        width: 20px;
        height: 20px;
    }
}

.player-art-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.player-art-btn:hover {
    transform: scale(1.05);
}

.player-art-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info-compact {
    flex: 1;
    min-width: 120px;
    overflow: hidden;
}

.player-info-compact h4 {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.player-info-compact p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.player-controls-compact {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-main-ctrl {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-main-ctrl:hover {
    transform: scale(1.1);
    background: #f0f0f0;
}

.player-secondary-ctrl {
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s ease;
}

.player-secondary-ctrl:hover {
    color: #fff;
}

.player-actions-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 12px;
}

.btn-share-floating {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-share-floating:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Expanded State */
.player-expanded {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    width: min(1220px, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    box-sizing: border-box;
    background: rgba(20, 20, 23, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
    display: none;
    flex-direction: column;
    z-index: 1001;
}

@media (min-width: 1025px) {
    .details-modal-panel {
        max-width: min(1220px, calc(100vw - 64px));
        width: min(1220px, calc(100vw - 64px));
    }
}

.player-expanded.active {
    display: flex;
    animation: slideUpLarge 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.expanded-playback-controls {
    flex-wrap: wrap;
}

.playback-rate-control {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.playback-rate-control::after {
    content: '';
    position: absolute;
    right: 8px;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

#expanded-playback-rate {
    min-width: 58px;
    height: 30px;
    padding: 0 22px 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    appearance: none;
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

#expanded-playback-rate:hover,
#expanded-playback-rate:focus-visible {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    outline: none;
}

#expanded-playback-rate option {
    background: #18181b;
    color: #fff;
}

.mobile-lyrics-close {
    display: none;
}

@keyframes slideUpLarge {
    from {
        transform: translateX(-50%) translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.expanded-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.expanded-top-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-circular {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-circular:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.expanded-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    height: clamp(420px, 52vh, 540px);
    min-height: 0;
}

@media (max-width: 1024px) {
    .player-expanded {
        position: fixed;
        padding-top: 40px;
        left: 0 !important;
        right: 0;
        bottom: 0;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 95vh !important;
        max-height: 95vh !important;
        transform: translateY(0) !important;
        border-radius: 0;
        padding: 20px 16px;
        z-index: 9000;
        overflow-y: auto;
        overflow-x: hidden;
        background: #0f0f12;
        display: none;
        /* Hidden by default on mobile too */
        flex-direction: column;
    }

    .player-expanded.active {
        display: flex !important;
        /* Force show when active */
    }

    /* FIX: Ensure expanded player close button is clickable but below modals */
    .expanded-top-actions button {
        z-index: 9005;
        position: relative;
    }

    .expanded-header {
        display: flex;
        flex-direction: column-reverse;
        /* Navigation at the very top */
        align-items: center;
        text-align: center;
        gap: 20px;
        margin-bottom: 24px;
        width: 100%;
    }

    .expanded-top-actions {
        width: 100%;
        justify-content: center;
        gap: 12px;
        padding-bottom: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .expanded-top-actions button[onclick*="openShareModal"] {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.1);
        padding: 8px 16px;
        border-radius: 20px;
    }

    .expanded-header .flex.gap-4 {
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 100%;
    }

    #expanded-img {
        width: 240px;
        height: 240px;
        max-width: 80vw;
        aspect-ratio: 1/1;
        object-fit: cover;
        border-radius: 16px;
    }

    #expanded-title {
        font-size: 1.5rem;
        margin-top: 10px;
        white-space: normal;
        overflow: visible;
        width: 100%;
        padding: 0 10px;
        line-height: 1.2;
    }

    #expanded-artist {
        font-size: 0.875rem;
        white-space: normal;
        overflow: visible;
        width: 100%;
        padding: 0 15px;
        margin-bottom: 15px;
        color: rgba(255, 255, 255, 0.5);
    }

    #expanded-waveform {
        width: 100%;
        height: 60px !important;
        margin: 10px 0;
        opacity: 0.8;
    }

    .expanded-playback-controls {
        column-gap: clamp(12px, 4vw, 24px) !important;
        row-gap: 10px !important;
    }

    .expanded-content {
        grid-template-columns: 1fr;
        height: auto;
        gap: 20px;
        padding-top: 10px;
    }

    /* Mobile: comments stay hidden; lyrics open only from the dedicated button. */
    .expanded-content>div:nth-child(1) {
        display: none !important;
    }

    .expanded-content>.expanded-lyrics-panel {
        display: none !important;
    }

    .player-expanded.mobile-lyrics-open {
        overflow: hidden;
    }

    .player-expanded.mobile-lyrics-open .expanded-content>.expanded-lyrics-panel {
        display: flex !important;
        position: absolute;
        inset: 0;
        z-index: 9010;
        width: 100%;
        height: 100%;
        min-height: 100%;
        padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
        overflow: hidden;
        background: radial-gradient(circle at 50% 15%, rgba(55, 25, 45, 0.34), transparent 38%), #111114;
    }

    .player-expanded.mobile-lyrics-open #expanded-genre-analysis {
        display: none !important;
    }

    .expanded-lyrics-header {
        flex-shrink: 0;
        margin-bottom: 16px !important;
    }

    .mobile-lyrics-close {
        display: inline-flex;
        width: 38px;
        height: 38px;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.07);
        color: rgba(255, 255, 255, 0.8);
    }

    .lyrics-text {
        font-size: 18px;
        text-align: center;
    }
}

.expanded-section-title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 20px;
}

.genre-analysis-panel {
    flex-shrink: 0;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.genre-analysis-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.genre-analysis-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.genre-analysis-row {
    display: grid;
    grid-template-columns: minmax(70px, 0.45fr) minmax(90px, 1fr) 44px;
    align-items: center;
    gap: 10px;
    min-height: 18px;
}

.genre-analysis-name,
.genre-analysis-score,
.genre-analysis-empty {
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    line-height: 1.2;
}

.genre-analysis-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: capitalize;
}

.genre-analysis-track {
    display: block;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.genre-analysis-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f43f5e, #f59e0b);
}

.genre-analysis-score {
    color: rgba(255, 255, 255, 0.48);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.genre-analysis-empty {
    color: rgba(255, 255, 255, 0.38);
    font-size: 12px;
}

.details-genre-analysis-panel {
    margin-bottom: 0;
}

@media (max-width: 1024px) {
    .genre-analysis-panel {
        width: 100%;
        margin: 0 0 18px;
    }

    .genre-analysis-row {
        grid-template-columns: minmax(80px, 0.5fr) minmax(90px, 1fr) 42px;
    }
}

.scroll-area {
    overflow-y: auto;
    padding-right: 12px;
}

.scroll-area::-webkit-scrollbar {
    width: 4px;
}

.scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.lyrics-text {
    font-size: 16px;
    line-height: 1.8;
    color: #fff;
    white-space: pre-line;
}

.comment-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 20px;
}

.comment-input-area input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    width: 100%;
}

.comment-input-area input:focus {
    outline: none;
}

/* Context Menu Popover */
.player-context-menu {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 200px;
    background: #1a1a1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1002;
}

.player-context-menu.active {
    display: block;
    animation: fadeInScale 0.2s ease;
}

@keyframes fadeInScale {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.context-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.context-item i {
    width: 16px;
    height: 16px;
}

.context-item.danger {
    color: #ff4d4d;
}

.context-item.danger:hover {
    background: rgba(255, 77, 77, 0.1);
}

/* Progress Overlay on Compact */
.progress-pills-container {
    position: absolute;
    top: -2px;
    left: 24px;
    right: 24px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    z-index: 10;
}

.progress-pills-container:hover {
    height: 5px;
    top: -3px;
}

.progress-pill-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

.player-nav-pill {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.expanded-header .flex-1 {
    min-width: 0;
}

/* Critical Fixes */
.modal-overlay,
.modal-container,
#share-modal,
#copy-modal,
#details-modal,
#video-player-modal,
#move-workspace-modal,
#add-to-playlist-modal,
#message-modal,
#confirm-modal,
#input-modal {
    z-index: 20000 !important;
}

.expanded-content>div {
    min-height: 0;
    overflow: hidden;
}

#expanded-lyrics-content {
    padding-bottom: 50px;
}

#player-expanded-lyrics {
    scroll-behavior: smooth;
}

#expanded-lyrics-content.lyrics-karaoke {
    white-space: normal;
}

.karaoke-section {
    margin-bottom: 1.5rem;
}

.karaoke-section-label {
    margin-bottom: 0.45rem;
    color: rgba(251, 59, 106, 0.62);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.karaoke-line {
    margin-bottom: 0.35rem;
    color: rgba(255, 255, 255, 0.34);
    line-height: 1.8;
    transition: transform 120ms ease;
}

.karaoke-line.is-past {
    color: rgba(255, 255, 255, 0.58);
}

.karaoke-line.is-active {
    color: rgba(255, 255, 255, 0.95);
    transform: translateX(4px);
}

.karaoke-word {
    transition: text-shadow 80ms ease, background-color 80ms ease;
}

.karaoke-word.is-sung {
    color: rgba(255, 255, 255, 0.92);
}

.karaoke-line.is-active .karaoke-word:not(.is-sung):not(.is-active) {
    color: rgba(255, 255, 255, 0.42);
}

.karaoke-word.is-active {
    color: #ff3f72 !important;
    background: rgba(251, 59, 106, 0.16);
    border-radius: 4px;
    font-weight: 900;
    text-shadow: 0 0 14px rgba(251, 59, 106, 0.9);
    box-shadow: 0 0 10px rgba(251, 59, 106, 0.12);
}

.karaoke-line.is-active:not(.has-word-timings) {
    color: #ff3f72 !important;
    font-weight: 800;
    text-shadow: 0 0 14px rgba(251, 59, 106, 0.75);
}

.player-secondary-ctrl {
    display: flex !important;
}

/* Volume Popover & Vertical Slider */
.volume-control-container {
    /*display: flex;*/
    align-items: center;
}

.volume-popover {
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.volume-popover.active {
    display: block !important;
    animation: fadeInScale 0.2s ease;
}

.volume-slider-vertical-container {
    transition: all 0.2s ease;
}

.volume-slider-vertical-container:hover {
    width: 8px;
    background: rgba(255, 255, 255, 0.15);
}

.volume-bar-vertical {
    transition: height 0.1s ease;
}

/* Hover behavior for desktop */
@media (min-width: 1025px) {
    .volume-control-container:hover .volume-popover {
        display: block;
        animation: fadeInScale 0.2s ease;
    }
}
