/* ============================================================
   Header Audio Player — player.css
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --hap-accent:      #ff6b35;
    --hap-radius:      12px;
    --hap-transition:  0.22s cubic-bezier(.4,0,.2,1);
    --hap-font:        'Segoe UI', system-ui, -apple-system, sans-serif;
    --hap-z:           99999;
    --hap-h:           72px;
    --hap-panel-h:     340px;
}

/* ---------- Dark Theme (default) ---------- */
.hap-theme-dark {
    --hap-bg:           #111318;
    --hap-bg2:          #1a1d24;
    --hap-bg3:          #22262f;
    --hap-border:       rgba(255,255,255,.07);
    --hap-text:         #f0f2f5;
    --hap-text2:        rgba(240,242,245,.55);
    --hap-text3:        rgba(240,242,245,.35);
    --hap-shadow:       0 8px 40px rgba(0,0,0,.55);
}

/* ---------- Light Theme ---------- */
.hap-theme-light {
    --hap-bg:           #ffffff;
    --hap-bg2:          #f5f6f8;
    --hap-bg3:          #ebedf0;
    --hap-border:       rgba(0,0,0,.08);
    --hap-text:         #1a1d24;
    --hap-text2:        rgba(26,29,36,.55);
    --hap-text3:        rgba(26,29,36,.35);
    --hap-shadow:       0 8px 40px rgba(0,0,0,.12);
}

/* ---------- Wrap / Positioning ---------- */
.hap-player-wrap {
    position: relative;
    width: 100%;
    background: var(--hap-bg);
    border-bottom: 1px solid var(--hap-border);
    z-index: var(--hap-z);
    font-family: var(--hap-font);
    box-shadow: var(--hap-shadow);
    transition: box-shadow var(--hap-transition);
}

.hap-pos-sticky-top {
    position: sticky;
    top: 0;
}

.hap-pos-top {
    position: relative;
    top: 0;
}

.hap-pos-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--hap-border);
    border-bottom: none;
}

/* ---------- Player Bar ---------- */
.hap-player {
    display: grid;
    grid-template-columns: 56px 1fr 1fr auto;
    align-items: center;
    gap: 14px;
    height: var(--hap-h);
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ---------- Thumbnail ---------- */
.hap-thumb-wrap { flex-shrink: 0; }

.hap-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--hap-bg3);
    overflow: hidden;
    color: var(--hap-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--hap-transition);
}

.hap-thumb.spinning { animation: hapSpin 3s linear infinite; }

.hap-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.hap-thumb svg { width: 28px; height: 28px; }

@keyframes hapSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ---------- Track Info ---------- */
.hap-track-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hap-track-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--hap-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.hap-track-artist {
    font-size: 12px;
    color: var(--hap-text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Progress ---------- */
.hap-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.hap-time {
    font-size: 11px;
    color: var(--hap-text3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

.hap-progress-bar {
    position: relative;
    flex: 1;
    height: 4px;
    background: var(--hap-bg3);
    border-radius: 4px;
    cursor: pointer;
    transition: height var(--hap-transition);
}

.hap-progress-bar:hover,
.hap-progress-bar:focus {
    height: 6px;
    outline: none;
}

.hap-progress-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--hap-accent);
    width: 0%;
    pointer-events: none;
    transition: width 0.1s linear;
}

.hap-progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--hap-accent);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    transition: transform var(--hap-transition);
}

.hap-progress-bar:hover .hap-progress-thumb,
.hap-progress-bar:focus .hap-progress-thumb {
    transform: translate(-50%, -50%) scale(1);
}

/* ---------- Controls ---------- */
.hap-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.hap-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hap-text2);
    transition: color var(--hap-transition), background var(--hap-transition), transform 0.12s ease;
}

.hap-btn:hover { color: var(--hap-text); background: var(--hap-bg3); }
.hap-btn:active { transform: scale(.9); }
.hap-btn svg { width: 20px; height: 20px; fill: currentColor; }

.hap-btn-play {
    background: var(--hap-accent);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.hap-btn-play svg { width: 22px; height: 22px; }

.hap-btn-play:hover {
    background: var(--hap-accent);
    color: #fff;
    filter: brightness(1.12);
    transform: scale(1.05);
}

.hap-btn-playlist.active,
.hap-btn-playlist:focus { color: var(--hap-accent); }

/* ---------- Volume ---------- */
.hap-volume-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hap-btn-vol svg { width: 18px; height: 18px; }

.hap-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 76px;
    height: 4px;
    border-radius: 4px;
    background: var(--hap-bg3);
    cursor: pointer;
    outline: none;
    transition: height var(--hap-transition);
}

.hap-volume-slider:hover { height: 6px; }

.hap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--hap-accent);
    cursor: pointer;
    transition: transform var(--hap-transition);
}

.hap-volume-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.hap-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--hap-accent);
    border: none;
    cursor: pointer;
}

/* ---------- Playlist Panel ---------- */
.hap-playlist-panel {
    background: var(--hap-bg2);
    border-top: 1px solid var(--hap-border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(.4,0,.2,1);
}

.hap-playlist-panel.open {
    max-height: var(--hap-panel-h);
    overflow-y: auto;
}

/* ---------- Category Bar ---------- */
.hap-category-bar {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--hap-bg2);
    border-bottom: 1px solid var(--hap-border);
    padding: 0 20px;
}

.hap-categories {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px 0;
    max-width: 1400px;
    margin: 0 auto;
}

.hap-categories::-webkit-scrollbar { display: none; }

.hap-cat-btn {
    background: transparent;
    border: 1px solid var(--hap-border);
    color: var(--hap-text2);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--hap-transition);
    font-family: var(--hap-font);
}

.hap-cat-btn:hover {
    color: var(--hap-text);
    border-color: var(--hap-accent);
}

.hap-cat-btn.active {
    background: var(--hap-accent);
    border-color: var(--hap-accent);
    color: #fff;
    font-weight: 600;
}

/* ---------- Playlist Items ---------- */
.hap-playlist {
    padding: 8px 0;
    max-width: 1400px;
    margin: 0 auto;
}

.hap-track-item {
    display: grid;
    grid-template-columns: 32px 40px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 0;
    transition: background var(--hap-transition);
    color: var(--hap-text);
}

.hap-track-item:hover { background: var(--hap-bg3); }

.hap-track-item.active {
    background: rgba(255, 107, 53, .1);
}

.hap-track-num {
    font-size: 12px;
    color: var(--hap-text3);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.hap-track-item.active .hap-track-num { color: var(--hap-accent); }

.hap-item-thumb {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: var(--hap-bg3);
    overflow: hidden;
    flex-shrink: 0;
    color: var(--hap-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hap-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hap-item-thumb svg { width: 18px; height: 18px; fill: currentColor; }

.hap-item-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hap-item-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--hap-text);
}

.hap-track-item.active .hap-item-title { color: var(--hap-accent); }

.hap-item-artist {
    font-size: 11px;
    color: var(--hap-text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hap-item-duration {
    font-size: 11px;
    color: var(--hap-text3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Loading & Empty States */
.hap-loading,
.hap-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--hap-text2);
    font-size: 13px;
}

.hap-loading::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--hap-bg3);
    border-top-color: var(--hap-accent);
    border-radius: 50%;
    animation: hapSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .hap-player {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        height: auto;
        padding: 10px 14px;
        gap: 10px;
    }

    .hap-progress-wrap {
        grid-column: 1 / -1;
        order: 10;
    }

    .hap-controls {
        gap: 4px;
    }

    .hap-volume-wrap { display: none; }

    .hap-btn-playlist { display: flex; }
}

@media (max-width: 560px) {
    .hap-player {
        grid-template-columns: 40px minmax(0, 1fr) auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .hap-thumb { width: 38px; height: 38px; }
    .hap-btn-play { width: 36px; height: 36px; }
    .hap-btn-play svg { width: 18px; height: 18px; }

    .hap-track-item {
        grid-template-columns: 24px 34px 1fr auto;
        gap: 8px;
        padding: 6px 12px;
    }
}

/* ---------- Scrollbar (panel) ---------- */
.hap-playlist-panel { scrollbar-width: thin; scrollbar-color: var(--hap-bg3) transparent; }
.hap-playlist-panel::-webkit-scrollbar { width: 4px; }
.hap-playlist-panel::-webkit-scrollbar-track { background: transparent; }
.hap-playlist-panel::-webkit-scrollbar-thumb { background: var(--hap-bg3); border-radius: 4px; }

/* ---------- Now Playing Animation (bars) ---------- */
.hap-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.hap-bars span {
    display: block;
    width: 3px;
    background: var(--hap-accent);
    border-radius: 2px;
    animation: hapBars 0.8s ease-in-out infinite alternate;
}

.hap-bars span:nth-child(2) { animation-delay: 0.2s; }
.hap-bars span:nth-child(3) { animation-delay: 0.4s; }

@keyframes hapBars {
    from { height: 4px; }
    to   { height: 14px; }
}

.hap-bars.paused span { animation-play-state: paused; }
