/* ==========================================================================
   ANENERI PERSISTENT AUDIO PLAYER & QUEUE DRAWER DESIGN SYSTEM
   ========================================================================== */

:root {
    --player-height: 80px;
    --player-bg: rgba(18, 24, 38, 0.92);
    --player-border: rgba(255, 255, 255, 0.12);
    --player-accent: #ef4444;
    --player-accent-hover: #dc2626;
    --player-glow: 0 8px 32px 0 rgba(239, 68, 68, 0.25);
    --drawer-bg: #0f172a;
}

/* ── PJAX Page Navigation Progress Bar ── */
#pjax-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #ec4899);
    z-index: 99999;
    transition: width 0.25s ease, opacity 0.3s ease;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    pointer-events: none;
}

/* ── Persistent Floating Audio Bar ── */
.aneneri-global-player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--player-height);
    background: var(--player-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--player-border);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    color: #ffffff;
    user-select: none;
}

.aneneri-global-player.is-visible {
    transform: translateY(0);
}

/* Floating Scrubber on Top of Bar */
.player-scrubber-wrapper {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: height 0.15s ease;
}

.player-scrubber-wrapper:hover {
    height: 9px;
}

.player-scrubber-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ef4444, #f87171);
    position: relative;
    transition: width 0.1s linear;
}

.player-scrubber-head {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
    transition: transform 0.15s ease;
}

.player-scrubber-wrapper:hover .player-scrubber-head {
    transform: translateY(-50%) scale(1);
}

/* Player Inner Layout */
.player-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: calc(var(--player-height) - 6px);
    gap: 16px;
}

/* ── 1. Left Track Information ── */
.player-track-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 220px;
    max-width: 320px;
    flex: 1 1 0;
}

.player-track-art-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    background: #1e293b;
    cursor: pointer;
}

.player-track-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.player-track-text {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-track-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    line-height: 1.3;
}

.player-track-title:hover {
    color: var(--player-accent);
}

.player-track-artist {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.player-offline-badge-icon {
    margin-left: 6px;
    color: #10b981;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* ── 2. Center Audio Controls ── */
.player-center-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 2 1 0;
}

.player-buttons-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    outline: none;
}

.player-btn:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.player-btn.active {
    color: var(--player-accent);
}

.player-play-btn {
    width: 44px;
    height: 44px;
    background: var(--player-accent);
    color: #ffffff !important;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player-play-btn:hover {
    background: var(--player-accent-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.player-time-display {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    letter-spacing: 0.5px;
    display: flex;
    gap: 4px;
}

/* ── 3. Right Extra Controls & Queue Trigger ── */
.player-right-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    min-width: 220px;
    flex: 1 1 0;
}

.player-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
}

.player-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.queue-toggle-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.queue-toggle-btn:hover, .queue-toggle-btn.is-active {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.queue-badge {
    background: var(--player-accent);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

/* ── Slide-up Queue & Playlist Drawer ── */
.aneneri-queue-drawer {
    position: fixed;
    bottom: var(--player-height);
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - var(--player-height) - 40px);
    background: var(--drawer-bg);
    border: 1px solid var(--player-border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    overflow: hidden;
}

.aneneri-queue-drawer.is-open {
    transform: translateY(0);
    opacity: 1;
}

.drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-tabs {
    display: flex;
    gap: 8px;
}

.drawer-tab-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.drawer-tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.drawer-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s ease;
}

.drawer-close-btn:hover {
    color: #ffffff;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Queue Item Card */
.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.queue-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.queue-item.is-playing {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}

.queue-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.queue-item-art {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.queue-item-meta {
    overflow: hidden;
}

.queue-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item.is-playing .queue-item-title {
    color: #f87171;
}

.queue-item-artist {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.queue-action-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.queue-action-btn:hover {
    color: #ef4444;
}

/* Equalizer Wave Icon for Playing Track */
.playing-equalizer {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    margin-right: 6px;
}

.eq-bar {
    width: 2px;
    background: #ef4444;
    border-radius: 1px;
    animation: eqBounce 1s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { height: 8px; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.eq-bar:nth-child(3) { height: 6px; animation-delay: 0.2s; }

@keyframes eqBounce {
    0% { height: 3px; }
    100% { height: 14px; }
}

/* ── Offline Banner / Toast ── */
.aneneri-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 500px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.aneneri-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── PWA Install Bar ── */
.pwa-install-bar {
    position: fixed;
    bottom: calc(var(--player-height) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(150px);
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9997;
    width: 90%;
    max-width: 460px;
    color: #ffffff;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-install-bar.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-install-btn {
    background: #ef4444;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pwa-install-btn:hover {
    background: #dc2626;
}

/* Quick Action Menu for Song Cards (Play Next / Add to Queue / Save Offline) */
.song-quick-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-subdued);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
}

.song-quick-menu-btn:hover {
    color: var(--primary);
    background: rgba(239, 68, 68, 0.08);
}

/* ── Mobile Responsiveness ── */
@media (max-width: 768px) {
    :root {
        --player-height: 72px;
    }

    .player-inner {
        padding: 0 12px;
    }

    .player-track-info {
        min-width: 140px;
        max-width: 180px;
    }

    .player-volume-wrapper {
        display: none;
    }

    .player-time-display {
        display: none;
    }

    .player-right-controls {
        min-width: auto;
        gap: 8px;
    }

    .queue-toggle-btn span:not(.queue-badge) {
        display: none;
    }

    .queue-toggle-btn {
        padding: 6px 8px;
    }

    .aneneri-queue-drawer {
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
    }
}
