/* ============================================
   THÁNHCA.NET - Audio Player v1
   Spotify-style mini player
   ============================================ */

/* ============================================================
   MINI PLAYER (Fixed bottom bar)
   ============================================================ */
.audio-player {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w, 200px);
    right: 0;
    z-index: 500;
    background: linear-gradient(180deg, rgba(28,8,56,.97) 0%, rgba(20,4,42,1) 100%);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(200,150,60,.2);
    transform: translateY(100%);
    transition: transform .4s cubic-bezier(.22,.68,.36,1);
    box-shadow: 0 -4px 32px rgba(20,0,60,.5);
}

.audio-player.active {
    transform: translateY(0);
}

.audio-player.minimized {
    transform: translateY(calc(100% - 4px));
}

.audio-player.minimized:hover {
    transform: translateY(calc(100% - 48px));
}

/* Gold accent line at top */
.audio-player::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--gold) 20%, #e8c66a 50%, var(--gold) 80%, transparent 100%);
}

.audio-player-inner {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    height: 72px;
    max-width: 100%;
}

/* ============================================================
   TRACK INFO
   ============================================================ */
.audio-track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.audio-track-art {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(107,70,150,.4);
}

.audio-track-art.playing {
    animation: artPulse 2s ease-in-out infinite;
}

@keyframes artPulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(107,70,150,.4); }
    50% { box-shadow: 0 2px 20px rgba(200,150,60,.5); }
}

.audio-track-art-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 18px;
}

.audio-track-art-bar {
    width: 3px;
    background: var(--gold);
    border-radius: 2px;
    animation: audioBar 1.2s ease-in-out infinite;
}

.audio-track-art-bar:nth-child(1) { height: 8px; animation-delay: 0s; }
.audio-track-art-bar:nth-child(2) { height: 14px; animation-delay: .15s; }
.audio-track-art-bar:nth-child(3) { height: 10px; animation-delay: .3s; }
.audio-track-art-bar:nth-child(4) { height: 16px; animation-delay: .1s; }

@keyframes audioBar {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(.4); }
}

.audio-player:not(.playing) .audio-track-art-bar {
    animation-play-state: paused;
}

.audio-track-text {
    min-width: 0;
    overflow: hidden;
}

.audio-track-title {
    font-size: .88rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.audio-track-artist {
    font-size: .74rem;
    color: rgba(255,255,255,.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-track-fav {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255,255,255,.5);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}

.audio-track-fav:hover { color: #f43f5e; transform: scale(1.15); }
.audio-track-fav.active { color: #f43f5e; }

/* ============================================================
   PLAYER CONTROLS
   ============================================================ */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-ctrl-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.audio-ctrl-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.audio-ctrl-btn.play-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gold), #b87828);
    color: #1a0a2e;
    font-size: 1.1rem;
    box-shadow: 0 2px 12px rgba(200,150,60,.4);
}

.audio-ctrl-btn.play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(200,150,60,.6);
}

.audio-ctrl-btn.active {
    color: var(--gold);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.audio-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.audio-time {
    font-size: .68rem;
    color: rgba(255,255,255,.45);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.audio-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,.12);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    min-width: 80px;
    transition: height .15s ease;
}

.audio-progress-bar:hover {
    height: 6px;
}

.audio-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), #e8c66a);
    border-radius: 2px;
    position: relative;
    width: 0%;
    transition: width .1s linear;
}

.audio-progress-fill::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px rgba(200,150,60,.5);
    transition: transform .15s ease;
}

.audio-progress-bar:hover .audio-progress-fill::after {
    transform: translateY(-50%) scale(1);
}

/* ============================================================
   VOLUME & EXTRA CONTROLS
   ============================================================ */
.audio-extra {
    display: flex;
    align-items: center;
    gap: 6px;
}

.audio-volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.audio-volume-bar {
    width: 80px;
    height: 4px;
    background: rgba(255,255,255,.12);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.audio-volume-fill {
    height: 100%;
    background: rgba(255,255,255,.5);
    border-radius: 2px;
    width: 70%;
}

.audio-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.15);
    background: transparent;
    color: rgba(255,255,255,.5);
    cursor: pointer;
    font-size: .7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    margin-left: 4px;
}

.audio-close-btn:hover {
    background: rgba(239,68,68,.2);
    border-color: rgba(239,68,68,.4);
    color: #f87171;
}

/* ============================================================
   PLAYLIST PANEL (slide up from player)
   ============================================================ */
.audio-playlist-panel {
    position: absolute;
    bottom: 100%;
    right: 0;
    width: 360px;
    max-height: 420px;
    background: rgba(20,4,42,.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(200,150,60,.15);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(20,0,60,.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.audio-playlist-panel.active {
    display: flex;
}

.audio-playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(200,150,60,.1);
}

.audio-playlist-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--gold);
}

.audio-playlist-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.6);
    cursor: pointer;
    font-size: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-playlist-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.audio-playlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background .15s;
    border-left: 3px solid transparent;
}

.audio-playlist-item:hover {
    background: rgba(255,255,255,.05);
}

.audio-playlist-item.active {
    background: rgba(200,150,60,.1);
    border-left-color: var(--gold);
}

.audio-playlist-item.active .audio-pl-title {
    color: var(--gold);
}

.audio-pl-num {
    font-size: .72rem;
    color: rgba(255,255,255,.35);
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.audio-pl-info {
    flex: 1;
    min-width: 0;
}

.audio-pl-title {
    font-size: .82rem;
    font-weight: 600;
    color: rgba(255,255,255,.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-pl-artist {
    font-size: .7rem;
    color: rgba(255,255,255,.4);
}

.audio-pl-cat {
    font-size: .65rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(107,70,150,.3);
    color: rgba(255,255,255,.6);
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================================
   YOUTUBE EMBED (hidden behind mini player)
   ============================================================ */
.audio-yt-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 320px;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    border: 1px solid rgba(200,150,60,.2);
    z-index: 499;
    display: none;
    background: #000;
}

.audio-yt-container.active {
    display: block;
    animation: slideUpFade .3s ease forwards;
}

.audio-yt-container.video-hidden {
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.audio-yt-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.audio-yt-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: .7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .audio-player {
        left: 0;
        bottom: 56px; /* Above mobile bottom nav */
    }

    .audio-player-inner {
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding: 8px 14px;
        height: 60px;
    }

    .audio-progress-wrap,
    .audio-extra {
        display: none;
    }

    .audio-track-art {
        width: 40px;
        height: 40px;
    }

    .audio-playlist-panel {
        width: 100%;
        max-height: 50vh;
        border-radius: 14px 14px 0 0;
    }

    .audio-yt-container {
        bottom: 124px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

@media (min-width: 769px) and (max-width: 1000px) {
    .audio-player {
        left: 60px;
    }
}

/* Adjust main content when player is active */
.audio-player.active ~ .mobile-bottom-nav {
    bottom: 72px;
}

body.audio-active .main-content {
    padding-bottom: 80px;
}

body.audio-active .mobile-bottom-nav {
    bottom: 72px;
}

@media (max-width: 768px) {
    body.audio-active .main-content {
        padding-bottom: 68px;
    }
    body.audio-active .mobile-bottom-nav {
        bottom: 60px;
    }
}
