/* RESET & VARIABEL DASAR */
:root {
    --bg-base: #000000;
    --bg-main: #000000;
    --bg-elevated: #242424;
    --text-base: #b3b3b3;
    --text-highlight: #ffffff;
    --primary-color: #1db954;
    --gradient-top: #800000;
    --font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-family); background-color: var(--bg-base); color: var(--text-base); overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { background: none; border: none; color: inherit; cursor: pointer; font-family: inherit; }

/* LAYOUT GRID UTAMA (Desktop) */
.app-container {
    display: grid;
    grid-template-columns: 240px 1fr 280px; 
    grid-template-rows: calc(100vh - 90px) 90px; 
    grid-template-areas: 
        "left main right"
        "player player player";
}

/* KUSTOMISASI SCROLLBAR */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #888; }

/* === SIDEBAR KIRI === */
.sidebar-left {
    grid-area: left; background-color: var(--bg-base); padding: 20px 10px;
    display: flex; flex-direction: column; overflow-y: auto;
}
.window-controls { margin-bottom: 25px; padding-left: 10px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
.red { background-color: #ff5f56; } .yellow { background-color: #ffbd2e; } .green { background-color: #27c93f; }

.nav-links { list-style: none; margin-bottom: 20px; }
.nav-links li { padding: 10px; font-size: 14px; font-weight: bold; transition: color 0.2s ease; }
.nav-links li:hover, .nav-links li.active { color: var(--text-highlight); }
.nav-links i { font-size: 20px; margin-right: 15px; width: 24px; text-align: center; }

.action-links .icon-box {
    display: inline-flex; justify-content: center; align-items: center;
    width: 24px; height: 24px; margin-right: 15px; border-radius: 2px;
}
.icon-box.plus { background-color: var(--text-base); color: #000; }
.action-links li:hover .icon-box.plus { background-color: var(--text-highlight); }
.icon-box.heart { background: linear-gradient(135deg, #450af5, #c4efd9); color: var(--text-highlight); }

.divider { height: 1px; background-color: #282828; margin: 10px; }
.playlist-list { flex-grow: 1; padding: 10px; }
.playlist-list ul { list-style: none; }
.playlist-list li {
    padding: 8px 0; font-size: 13px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; cursor: default;
}
.playlist-list li:hover { color: var(--text-highlight); }

/* === KONTEN UTAMA === */
.main-content {
    grid-area: main; background-color: var(--bg-main); overflow-y: auto; position: relative; scroll-behavior: smooth;
    background: linear-gradient(to bottom, var(--gradient-top) 0%, var(--bg-main) 40%);
}
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 32px; position: sticky; top: 0; z-index: 10; background: rgba(0, 0, 0, 0.799); 
}
.nav-arrows button {
    background-color: rgba(0, 0, 0, 0.7); color: white; width: 32px; height: 32px;
    border-radius: 50%; margin-right: 10px; display: inline-flex; justify-content: center; align-items: center;
}
.top-bar-right { display: flex; align-items: center; gap: 15px; }
.upgrade-btn {
    border: 1px solid #fffdfd; border-radius: 500px; padding: 8px 24px;
    color: #fff; font-size: 12px; font-weight: bold; letter-spacing: 1.5px; background: #877a7a;
}
.user-profile {
    display: flex; align-items: center; background-color: rgba(0,0,0,0.7);
    border-radius: 500px; padding: 2px 10px 2px 2px; gap: 8px; color: white;
    font-size: 13px; font-weight: bold; cursor: pointer;
}
.user-profile img { width: 28px; height: 28px; border-radius: 50%; }

.mobile-toggle-btn { display: none; color: white; font-size: 24px; background: none; border: none; cursor: pointer; }
.mobile-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7); z-index: 10001; opacity: 0; transition: opacity 0.3s ease;
}

/* Header Playlist */
.playlist-header { display: flex; padding: 20px 32px 32px; align-items: flex-end; }
.playlist-cover {
    width: 232px; height: 232px; background-color: #282828; margin-right: 24px;
    box-shadow: 0 4px 60px rgba(0,0,0,0.5); position: relative;
}
.blend-cover {
    width: 100%; height: 100%; background-color: #1a1a1a; position: relative;
    overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
}
.blend-cover .red-circle {
    width: 120px; height: 120px; background-color: #f73f32; border-radius: 50%;
    position: absolute; top: 50%; left: 40%; transform: translate(-50%, -50%); mix-blend-mode: hard-light; z-index: 2;
}
.blend-cover img { width: 140px; height: 140px; border-radius: 50%; position: absolute; top: 10px; right: 10px; z-index: 1; }
.blend-text { color: white; font-size: 24px; font-weight: bold; padding: 15px; z-index: 3; }

.playlist-info { color: var(--text-highlight); }
.playlist-type { font-size: 12px; font-weight: 700; }
.playlist-title { font-size: 80px; font-weight: 900; line-height: 1; letter-spacing: -2px; margin: 10px 0; }
.playlist-desc { color: #ffffffb3; font-size: 14px; margin-bottom: 10px; }
.playlist-meta { display: flex; align-items: center; font-size: 14px; gap: 5px; }
.spotify-icon { color: var(--primary-color); font-size: 20px; }
.playlist-meta span { color: #ffffffb3; }

/* Action Bar */
.action-bar { padding: 24px 32px; display: flex; align-items: center; gap: 20px; position: relative; }
.play-btn-large {
    width: 56px; height: 56px; border-radius: 50%; background-color: var(--primary-color);
    color: black; font-size: 24px; display: flex; justify-content: center; align-items: center; transition: transform 0.1s ease;
}
.play-btn-large:hover { transform: scale(1.05); }
.action-bar .icon-btn { font-size: 30px; color: #ffffffb3; }
.action-bar .icon-btn:hover { color: var(--text-highlight); }
.action-right { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.action-right .icon-btn { font-size: 16px; }
.custom-order { font-size: 14px; font-weight: bold; color: #ffffffb3; cursor: pointer; }

/* Tracklist Table */
.tracklist-container { padding: 0 32px; }
.tracklist { width: 100%; border-collapse: collapse; text-align: left; }
.tracklist th {
    color: var(--text-base); font-size: 12px; font-weight: normal; letter-spacing: 1px;
    padding: 5px 15px; border-bottom: 1px solid #282828;
}
.tracklist td { padding: 10px 15px; font-size: 14px; vertical-align: middle; }
.tracklist tbody tr { border-radius: 5px; cursor: pointer; }
.tracklist tbody tr:hover { background-color: rgba(255,255,255,0.1); }
.tracklist tbody tr:hover td { color: var(--text-highlight); }
.title-cell { display: flex; align-items: center; gap: 15px; }
.title-cell img { width: 40px; height: 40px; }
.title-info { display: flex; flex-direction: column; }
.song-name { color: var(--text-highlight); font-size: 16px; }
.artist-name { font-size: 14px; }
.added-by-avatar { width: 24px; height: 24px; border-radius: 50%; }

/* Ad Banner */
.ad-banner { margin: 40px 32px; background-color: #227b2e; border-radius: 8px; padding: 15px; color: white; }
.ad-content { display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 20px; }
.ad-content button { background: transparent; border: 1px solid white; border-radius: 20px; padding: 8px 16px; font-weight: bold; }

/* === SIDEBAR KANAN === */
.sidebar-right {
    grid-area: right; background-color: var(--bg-base); padding: 20px;
    display: flex; flex-direction: column; border-left: 1px solid #282828; overflow-y: auto;
}
.friend-activity-header { display: flex; justify-content: space-between; align-items: center; color: var(--text-highlight); margin-bottom: 20px; }
.friend-activity-header h3 { font-size: 16px; }
.add-friend-btn { color: var(--text-base); font-size: 18px; }
.add-friend-btn:hover { color: white; }
.friend-desc, .friend-settings-desc { font-size: 13px; line-height: 1.5; margin-bottom: 20px; }

/* Skeleton Loading */
.skeleton-item { display: flex; align-items: center; gap: 15px; margin-bottom: 25px; }
.skeleton-avatar {
    width: 48px; height: 48px; border-radius: 50%; background-color: #282828;
    display: flex; justify-content: center; align-items: center; font-size: 20px; position: relative;
}
.status-dot {
    position: absolute; top: 0; right: 0; width: 12px; height: 12px; background-color: #3b82f6; 
    border-radius: 50%; border: 2px solid var(--bg-base);
}
.skeleton-lines .line { height: 8px; background-color: #282828; border-radius: 4px; margin-bottom: 8px; }
.line-1 { width: 100px; } .line-2 { width: 80px; } .line-3 { width: 120px; margin-bottom: 0; }

/* === PLAYER BAR BAWAH === */
.player-bar {
    grid-area: player; background-color: #000000; border-top: 1px solid #282828;
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0 16px; height: 90px; overflow: hidden; position: relative; z-index: 10000;
}
.now-playing { display: flex; flex-direction: row; align-items: center; gap: 15px; width: 30%; min-width: 180px; }
.now-playing img {
    width: 56px !important; height: 56px !important; border-radius: 50%; object-fit: cover; 
    flex-shrink: 0; animation: spin 5s linear infinite; animation-play-state: paused; box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.now-playing img.is-spinning { animation-play-state: running; }

.track-info { display: flex; flex-direction: column; white-space: nowrap; }
.player-controls { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 40%; max-width: 722px; }
.control-buttons { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; }
.control-buttons .icon-btn { font-size: 16px; color: var(--text-base); }
.control-buttons .icon-btn:hover { color: white; }
.play-pause-btn {
    width: 32px; height: 32px; background-color: var(--text-highlight); color: black; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; font-size: 14px;
}
.play-pause-btn:hover { transform: scale(1.05); }

.playback-bar { display: flex; align-items: center; width: 100%; gap: 10px; font-size: 11px; }
.progress-bar { flex-grow: 1; height: 4px; background-color: #535353; border-radius: 2px; position: relative; cursor: pointer; }
.progress { background-color: var(--text-highlight); height: 100%; border-radius: 2px; pointer-events: none; }
.progress-bar:hover .progress { background-color: var(--primary-color); }

.right-controls { display: flex; align-items: center; justify-content: flex-end; width: 30%; gap: 15px; }
.right-controls .icon-btn { color: var(--text-base); font-size: 16px; }
.right-controls .icon-btn:hover { color: white; }
.volume-bar { display: flex; align-items: center; width: 120px; gap: 10px; }
.volume-bar .progress-bar { width: 100px; }

.control-active { color: var(--primary-color) !important; }
.heart-active i { font-weight: 900; color: var(--primary-color); }

/* === MODALS (Gambar, Peta, Video, Search) === */
#favoritesList li:not(.nav-header) { cursor: pointer; }

.image-modal {
    display: none; position: fixed; z-index: 10010; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); justify-content: center; align-items: center; flex-direction: column;
}
.modal-content { max-width: 80%; height: auto; max-height: 70vh; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); animation: zoomIn 0.3s ease; object-fit: contain; }
#modalCaption { margin-top: 20px; color: white; font-size: 24px; font-weight: bold; letter-spacing: 1px; animation: zoomIn 0.3s ease; }

.close-modal, .close-map-modal, .close-video-modal, .close-search-modal {
    position: absolute; top: 30px; right: 40px; color: #b3b3b3; font-size: 50px; font-weight: bold; cursor: pointer; transition: 0.3s; z-index: 10011; 
}
.close-modal:hover, .close-map-modal:hover, .close-video-modal:hover, .close-search-modal:hover { color: #ffffff; }

@keyframes zoomIn { from {transform: scale(0.8); opacity: 0;} to {transform: scale(1); opacity: 1;} }

/* PETA */
#mapContainer { width: 80%; height: 80%; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); animation: zoomIn 0.3s ease; z-index: 10010; }
.leaflet-popup-content-wrapper { background-color: #121212; color: #ffffff; border-radius: 8px; }
.leaflet-popup-tip { background-color: #121212; }
.leaflet-popup-content b { color: var(--primary-color); font-size: 16px; }
.map-popup-content { display: flex; flex-direction: column; gap: 6px; width: 200px; padding: 2px; }
.popup-map-img { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: 4px; }
.leaflet-popup-content p { margin: 2px 0 0 0 !important; color: #b3b3b3; font-size: 12px; line-height: 1.4; }

/* SEARCH MODAL */
.search-container {
    background-color: #242424; padding: 30px; border-radius: 12px; width: 90%; max-width: 500px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.8); animation: zoomIn 0.3s ease; z-index: 10010;
}
.search-container h2 { color: white; margin-bottom: 20px; }
.search-container input { width: 100%; padding: 15px; border-radius: 50px; border: none; outline: none; font-size: 16px; background-color: #ffffff; color: #000000; }

/* TOAST NOTIFICATION */
.toast {
    position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background-color: var(--text-highlight); color: var(--bg-base);
    padding: 12px 24px; border-radius: 50px; font-weight: bold; font-size: 14px; z-index: 10020; opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, bottom 0.3s ease; box-shadow: 0 4px 15px rgba(0,0,0,0.5); pointer-events: none;
}
.toast.show { opacity: 1; visibility: visible; bottom: 120px; }


/* =========================================
   RESPONSIVE DESIGN (KHUSUS HP & TABLET)
   ========================================= */

@media screen and (max-width: 768px) {
    body { overflow-y: auto; }
    .app-container { display: flex; flex-direction: column; height: auto; padding-bottom: 140px; }

    .mobile-toggle-btn { display: block; }
    .nav-arrows { display: none; }
    .top-bar { padding: 15px; }
    .top-bar-right { gap: 5px; }
    
    .user-profile span {
        display: inline-block; font-size: 10px; max-width: 90px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .upgrade-btn { display: inline-block; font-size: 10px; padding: 5px 10px; }

    .mobile-overlay.active { display: block; opacity: 1; }

    .sidebar-left {
        position: fixed; top: 0; left: -300px; width: 260px; height: 100vh;
        z-index: 10005; transition: left 0.3s ease; padding-bottom: 120px;
    }
    .sidebar-left.active { left: 0; }
    .playlist-list { max-height: none; }

    .sidebar-right {
        position: fixed; top: 0; right: -300px; width: 260px; height: 100vh;
        z-index: 10005; transition: right 0.3s ease; padding-bottom: 120px; border-left: none;
    }
    .sidebar-right.active { right: 0; }

    .main-content { width: 100%; overflow-y: visible; }
    .playlist-header { flex-direction: column; align-items: center; text-align: center; padding: 20px 16px; }
    .playlist-cover { margin-right: 0; margin-bottom: 20px; }
    .playlist-title { font-size: 40px; }

    .tracklist th:nth-child(3), .tracklist td:nth-child(3),
    .tracklist th:nth-child(4), .tracklist td:nth-child(4) { display: none; }

    .player-bar {
        position: fixed; bottom: 0; left: 0; width: 100%; height: auto;
        flex-direction: column; padding: 10px 15px; gap: 12px; z-index: 9999;
    }
    .now-playing { width: 100%; justify-content: space-between; }
    .player-controls { width: 100%; }
    .right-controls { display: none; }

    #mapContainer { width: 95%; height: 70%; }
    .modal-content { width: 95%; height: auto; max-height: 70vh; object-fit: contain; }
    .close-map-modal, .close-modal, .close-video-modal, .close-search-modal { top: 10px; right: 15px; font-size: 40px; }
    /* =========================================
       PERBAIKAN ACTION BAR & TOAST DI HP
       ========================================= */
       
    /* 1. Merapikan tombol agar turun ke bawah dan tidak terpotong */
    .action-bar {
        padding: 15px 20px;
        gap: 15px; 
        flex-wrap: wrap; /* Kunci utamanya: mengizinkan elemen turun ke baris baru */
    }
    
    .action-right {
        margin-left: 0;
        width: 100%; /* Memaksa bagian kanan turun ke baris kedua */
        justify-content: space-between;
        margin-top: 10px;
    }

    /* 2. Menaikkan posisi notifikasi agar tidak tertutup pemutar musik HP */
    .toast {
        bottom: 170px !important; 
    }
    .toast.show {
        bottom: 180px !important;
    }
}