/* ============================================================
   VARIABLES & RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-base:      #090912;
    --bg-surface:   #111120;
    --bg-elevated:  #1a1a2e;
    --bg-hover:     #22223a;
    --bg-card:      #161628;
    --accent:       #1565ff;
    --accent-light: #4d8fff;
    --accent-glow:  rgba(21,101,255,0.30);
    --text-primary: #ffffff;
    --text-muted:   #9090b0;
    --border:       #252540;
    --player-h:     88px;
    --sidebar-w:    240px;
    --radius:       8px;
    --radius-lg:    12px;
}

html, body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    overflow: hidden;
}

button { cursor: pointer; border: none; background: none; color: inherit; }
input  { outline: none; border: none; }
a      { text-decoration: none; color: inherit; }
img    { display: block; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: calc(100vh - var(--player-h));
    overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    background: #07070f;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    text-decoration: none;
    transition: opacity 0.15s;
}

.sidebar-logo:hover { opacity: 0.85; }

.sidebar-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-spoti { color: #ffffff; }
.logo-tube  { color: var(--accent-light); }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover, .nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active { color: white; }
.nav-item i { width: 20px; text-align: center; font-size: 16px; }

.sidebar-section {
    padding: 20px 14px 12px;
    flex: 1;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding: 0 4px;
}

.queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.queue-item:hover { background: var(--bg-hover); }
.queue-item.playing { color: var(--accent-light); }

.queue-item img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.queue-item-info { overflow: hidden; }
.queue-item-title {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.queue-item-artist {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    overflow-y: auto;
    background: linear-gradient(180deg, #0d1433 0%, var(--bg-base) 300px);
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================================
   SEARCH HEADER
   ============================================================ */
.content-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 20px 32px 16px;
    background: linear-gradient(180deg, rgba(13,20,51,0.98) 80%, transparent);
    backdrop-filter: blur(8px);
}

.search-bar-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 0 18px;
    gap: 12px;
    max-width: 640px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon { color: var(--text-muted); font-size: 15px; flex-shrink: 0; }

.search-input {
    flex: 1;
    background: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 14px 0;
}

.search-input::placeholder { color: var(--text-muted); }

.clear-btn {
    color: var(--text-muted);
    font-size: 14px;
    padding: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.clear-btn.visible { opacity: 1; pointer-events: auto; }
.clear-btn:hover { color: white; }

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */
.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 32px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i, .loading-state i {
    font-size: 56px;
    color: var(--accent);
    opacity: 0.4;
}

.empty-state h2 { font-size: 22px; color: var(--text-primary); }
.empty-state p  { font-size: 14px; }

.hidden { display: none !important; }

/* ============================================================
   RESULTS GRID
   ============================================================ */
.results-section, #resultsSection { padding: 0 32px 100px; }

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-top: 8px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

/* ============================================================
   SONG CARD
   ============================================================ */
.song-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    position: relative;
}

.song-card:hover { background: var(--bg-hover); transform: translateY(-2px); }
.song-card.active { background: var(--bg-hover); outline: 2px solid var(--accent); }

.song-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--bg-elevated);
}

.song-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.song-card:hover .song-thumb img { transform: scale(1.04); }

.thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.song-card:hover .thumb-overlay,
.song-card.active .thumb-overlay { opacity: 1; }

.play-hover-icon {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(30,111,255,0.5);
    transition: transform 0.15s;
}

.play-hover-icon i {
    font-size: 16px;
    margin-left: 2px;
}

.song-card:hover .play-hover-icon { transform: scale(1.08); }

.song-meta { overflow: hidden; }

.song-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    color: var(--text-primary);
}

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

/* ============================================================
   NOW PLAYING
   ============================================================ */
.now-playing-wrap {
    padding: 16px 32px 100px;
}

/* Mobile full-screen controls — hidden on desktop */
.np-player-mobile { display: none; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    margin-bottom: 32px;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
}
.back-btn:hover { color: var(--text-primary); }

.now-playing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    max-width: 360px;
    margin: 0 auto;
    text-align: center;
}

.np-thumb {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.np-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-light);
    margin-bottom: 8px;
}

.np-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.np-artist {
    font-size: 15px;
    color: var(--text-muted);
}

/* ============================================================
   PLAYER BAR
   ============================================================ */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--player-h);
    background: #0b0b1a;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr 200px;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 100;
}

/* Info lagu */
.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.player-thumb {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-elevated);
}

.player-meta { min-width: 0; }

.player-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-artist {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Kontrol tengah */
.player-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

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

.ctrl-btn {
    color: var(--text-muted);
    font-size: 16px;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover { color: white; }

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

.btn-play {
    width: 42px;
    height: 42px;
    background: white;
    color: #000;
    font-size: 16px;
    border-radius: 50%;
    box-shadow: 0 2px 12px rgba(30,111,255,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-play:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 20px rgba(30,111,255,0.5);
    color: #000;
}

/* Progress bar */
.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 560px;
}

.time-label {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.progress-bar, .volume-bar {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-hover);
    cursor: pointer;
    transition: height 0.1s;
}

.progress-bar { flex: 1; }
.volume-bar   { width: 90px; }

.progress-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.progress-bar:hover, .volume-bar:hover { height: 5px; }

.progress-bar:hover::-webkit-slider-thumb,
.volume-bar:hover::-webkit-slider-thumb,
.progress-bar:focus::-webkit-slider-thumb,
.volume-bar:focus::-webkit-slider-thumb { opacity: 1; }

/* Volume */
.player-right {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

/* ============================================================
   HAMBURGER (hidden on desktop)
   ============================================================ */
.hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 300;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 15px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    :root { --sidebar-w: 200px; }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .player-bar {
        grid-template-columns: 180px 1fr 160px;
    }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    :root {
        --player-h: 120px;
    }

    /* Hamburger visible */
    .hamburger { display: flex; }

    /* Sidebar jadi overlay */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 200;
        transition: left 0.25s ease;
        width: 260px;
    }
    .sidebar.open { left: 0; }

    /* Layout tanpa sidebar */
    .app-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - var(--player-h));
    }

    /* Header search dengan padding untuk hamburger */
    .content-header {
        padding: 14px 16px 12px 60px;
    }

    /* Results grid 3 kolom kecil */
    .results-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    #resultsSection { padding: 0 12px 120px; }

    .section-title { font-size: 15px; margin-bottom: 12px; padding-top: 4px; }

    .song-card {
        padding: 7px;
        border-radius: 8px;
        min-width: 0;
    }

    .song-thumb { margin-bottom: 5px; }

    .song-title  { font-size: 10px; margin-bottom: 2px; }
    .song-artist { font-size: 9px; }

    .play-hover-icon { width: 28px; height: 28px; }
    .play-hover-icon i { font-size: 10px; margin-left: 1px; }

    #resultsSection,
    .now-playing-wrap {
        padding-left: 16px;
        padding-right: 16px;
    }

    .section-title { font-size: 18px; }

    /* Player bar mobile: stack info + kontrol + progress */
    .player-bar {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 16px;
        height: var(--player-h);
    }

    .player-info {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .player-thumb {
        width: 36px;
        height: 36px;
    }

    .player-title { font-size: 12px; }
    .player-artist { font-size: 11px; }

    .player-center { width: 100%; }

    .player-controls { gap: 8px; }

    /* Sembunyikan shuffle & repeat di mobile */
    #btnShuffle, #btnRepeat { display: none; }

    .progress-row { max-width: 100%; }

    /* Sembunyikan volume di mobile */
    .player-right { display: none; }

    /* Now playing mobile — full screen */
    #nowPlayingSection {
        position: fixed;
        inset: 0;
        z-index: 150;
        background: var(--bg-base);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    #nowPlayingSection.hidden { display: none; }

    .now-playing-wrap {
        padding: 16px 24px 0;
        flex: 1;
    }

    .back-btn { margin-bottom: 20px; }

    .now-playing-card {
        max-width: 100%;
        gap: 16px;
    }

    .np-thumb {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
        box-shadow: 0 12px 40px rgba(0,0,0,0.7);
    }

    .np-title  { font-size: 20px; }
    .np-artist { font-size: 14px; }

    /* Mobile player controls */
    .np-player-mobile {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px 24px 32px;
    }

    .np-progress-row {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .np-time {
        font-size: 11px;
        color: var(--text-muted);
        min-width: 32px;
        text-align: center;
        font-variant-numeric: tabular-nums;
    }

    .np-progress-bar {
        flex: 1;
        -webkit-appearance: none;
        appearance: none;
        height: 4px;
        border-radius: 2px;
        background: var(--bg-hover);
        cursor: pointer;
    }

    .np-progress-bar::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: white;
        cursor: pointer;
    }

    .np-controls-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 16px;
    }

    .np-ctrl {
        color: var(--text-muted);
        font-size: 20px;
        padding: 8px;
        border-radius: 50%;
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        transition: color 0.15s;
    }

    .np-ctrl:hover { color: white; }
    .np-ctrl.active { color: var(--accent-light); }

    .np-btn-play {
        width: 56px;
        height: 56px;
        background: white;
        color: #000;
        font-size: 20px;
        border-radius: 50%;
        box-shadow: 0 4px 20px rgba(21,101,255,0.4);
    }

    /* Sembunyikan player bar saat now playing tampil di mobile */
    body.np-open .player-bar { display: none; }
    body.np-open .hamburger  { display: none; }
}
