/* ===== MUSIC PLAYER WIDGET — BOTTOM BAR ===== */
.music-player-widget {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #12121a; /* was hardcoded #181818 — now matches --bg-secondary token */
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -2px 20px rgba(0,0,0,0.6);
    /* Safe area for iOS notch / home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    -webkit-transform: translateY(100%);
}
.music-player-widget.show {
    transform: translateY(0) !important;
    -webkit-transform: translateY(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
}
body.player-active {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

.player-bar-inner {
    position: relative;
}

/* ---- Main row ---- */
.player-bar-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    height: 64px;
}

/* ---- Left: Artwork + Info + Version ---- */
.player-bar-track {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
    max-width: 280px;
}
.player-artwork {
    width: 42px;
    height: 42px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.3);
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}
.player-artwork.has-image {
    background: #000;
}
.player-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.player-bar-info {
    min-width: 0;
    flex-shrink: 1;
}
.music-player-widget .current-track-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    margin: 0;
}
.music-player-widget .current-track-artist {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin: 0;
}

/* Version badge */
.player-version-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}
.player-version-badge:hover {
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}

/* ---- Center: Transport ---- */
.player-bar-transport {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.transport-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s;
}
.transport-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}
.transport-btn.transport-play {
    width: 38px;
    height: 38px;
    font-size: 22px;
    color: #fff;
}
.transport-btn.transport-play:hover {
    transform: scale(1.05);
}
.transport-btn.playing {
    color: #fff;
}

/* ---- Waveform area ---- */
.player-bar-waveform-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.player-time {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    flex-shrink: 0;
    letter-spacing: 0.3px;
    min-width: 36px;
    text-align: center;
}

/* ---- Waveform ---- */
.waveform-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 40px;
    background: transparent;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}
.waveform-canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.waveform-canvas.loaded {
    opacity: 1;
}

/* Progress overlay — hidden, canvas handles coloring */
.waveform-progress {
    display: none;
}

/* Playhead — orange/red vertical line */
.waveform-playhead {
    position: absolute;
    top: 0;
    left: 0%;
    width: 2px;
    height: 100%;
    background: #e8480c;
    pointer-events: none;
    transition: left 0.15s linear;
    box-shadow: 0 0 6px rgba(232,72,12,0.6);
    z-index: 2;
}

/* Hover cursor */
.waveform-cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: rgba(255,255,255,0.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 1;
}
.waveform-wrapper:hover .waveform-cursor {
    opacity: 1;
}

/* Hover time tooltip */
.waveform-wrapper::after {
    content: attr(data-hover-time);
    position: absolute;
    top: -26px;
    left: var(--hover-x, 50%);
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 3;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.waveform-wrapper:hover::after {
    opacity: 1;
}

/* Loading overlay */
.waveform-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.waveform-loading.active {
    opacity: 1;
}
.waveform-loading-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 15, 0.55);
    backdrop-filter: blur(1px);
    z-index: 1;
}
.waveform-loading-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #dc2828;
    border-radius: 50%;
    animation: waveformSpin 0.8s linear infinite;
    z-index: 2;
    margin-right: 8px;
}
@keyframes waveformSpin {
    to { transform: rotate(360deg); }
}
.waveform-loading-text {
    position: relative;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    z-index: 2;
    animation: pulseText 1.5s infinite;
}
@keyframes pulseText {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ---- Volume ---- */
.player-bar-volume {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.player-bar-volume .transport-btn {
    width: 30px;
    height: 30px;
    font-size: 15px;
    color: rgba(255,255,255,0.5);
}
.player-bar-volume .transport-btn:hover {
    color: #fff;
    background: none;
}
.volume-slider {
    width: 70px;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}
.volume-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
}

/* ---- Right actions ---- */
.player-bar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.action-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.45);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}
.action-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}
.action-btn.is-fav {
    color: #ff6b6b;
}
.action-btn.is-fav:hover {
    color: #ff4444;
}
.action-btn-collapse {
    color: rgba(255,255,255,0.35);
}
.action-btn-collapse:hover {
    color: #fff;
}

/* ---- Player Dropdown Menu ---- */
.player-more-wrapper {
    position: relative;
}
.player-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 6px 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.18s ease;
    z-index: 1000;
}
.player-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.player-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.12s;
    text-align: left;
    white-space: nowrap;
}
.player-dropdown-item:hover {
    background: rgba(108,92,231,0.15);
    color: #fff;
}
.player-dropdown-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: rgba(108,92,231,0.85);
    flex-shrink: 0;
}
.player-dropdown-item:hover i {
    color: #6c5ce7;
}

@keyframes waveformShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Bottom bar responsive ===== */
@media (max-width: 768px) {
    .player-bar-controls {
        gap: 8px;
        padding: 0 10px;
        height: 56px;
    }
    .player-bar-track {
        max-width: 160px;
    }
    .player-artwork {
        width: 36px;
        height: 36px;
    }
    .music-player-widget .current-track-title {
        font-size: 0.75rem;
    }
    .music-player-widget .current-track-artist {
        font-size: 0.62rem;
    }
    .player-version-badge {
        display: none;
    }
    .player-bar-waveform-area {
        display: none !important;
    }
    .player-bar-volume {
        display: none !important;
    }
    #playerDownloadBtn,
    #playerFavBtn {
        display: flex !important;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .transport-btn {
        width: 28px;
        height: 28px;
        font-size: 15px;
    }
    .transport-btn.transport-play {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    .volume-slider {
        display: none;
    }
    .player-time {
        font-size: 0.62rem;
        min-width: 28px;
    }
    .music-player-widget {
        z-index: 1100 !important;
    }
    .music-player-widget.show {
        display: block !important;
        transform: translateY(0) !important;
        -webkit-transform: translateY(0) !important;
    }
    body.player-active {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
}
@media (max-width: 575px) {
    .player-bar-track {
        max-width: 120px;
    }
    .player-bar-transport {
        gap: 0;
    }
    .player-bar-waveform-area {
        gap: 6px;
    }
    .player-bar-actions > .action-btn {
        display: none;
    }
    #playerDownloadBtn,
    #playerFavBtn {
        display: flex !important;
    }
    .player-more-wrapper,
    .action-btn-collapse {
        display: flex !important;
    }
}

