:root {
    --bg-black: #000000;
    --bg-dark: #121212;
    --bg-light: #282828;
    --bg-highlight: #181818;
    --text-white: #ffffff;
    --text-gray: #b3b3b3;
    --brand-green: #1db954;
    --brand-green-hover: #1ed760;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Circular', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-black);
    color: var(--text-white);
    height: 100vh;
    overflow: hidden;
}
body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.app-container {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-black);
    padding: 24px;
    padding-bottom: 110px; /* Space for fixed player bar */
    grid-column: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
    color: var(--text-white);
}

.logo i {
    font-size: 40px;
}

.nav-links {
    list-style: none;
    margin-bottom: 30px;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    color: var(--text-gray);
    cursor: pointer;
    transition: color 0.3s;
    font-weight: bold;
}

.nav-links li:hover, .nav-links li.active {
    color: var(--text-white);
}

.playlist-section {
    flex: 1;
    border-top: 1px solid #282828;
    padding-top: 20px;
    overflow-y: auto;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--text-gray);
    margin-bottom: 15px;
}

.create-playlist-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 14px;
}

.create-playlist-btn:hover {
    color: var(--text-white);
}

.playlist-list {
    list-style: none;
}

.playlist-list li {
    padding: 8px 0;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-list li:hover {
    color: var(--text-white);
}

#currentPlaylistName {
    cursor: pointer;
}

.user-profile-section {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #282828;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.logout-btn {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 12px;
}

.logout-btn:hover {
    color: var(--text-white);
}

/* Main Content */
.main-content {
    background-color: var(--bg-dark);
    grid-column: 2;
    overflow-y: auto;
    position: relative;
    border-radius: 8px 8px 0 0;
    height: 100vh;
    padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); /* Space for fixed player bar + safe area */
}

.top-bar {
    position: sticky;
    top: 0;
    background-color: rgba(18, 18, 18, 0.95);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2000;
    pointer-events: auto;
}

.nav-arrows {
    display: flex;
    gap: 16px;
}

.arrow-btn {
    background-color: rgba(0,0,0,0.7);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
}

.search-container {
    flex: 1;
    margin: 0 12px;
    position: relative;
    max-width: none;
}

.search-container input {
    width: 100%;
    padding: 10px 40px;
    border-radius: 500px;
    border: none;
    background-color: white;
    color: black;
    font-size: 14px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #121212;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upgrade-btn {
    background-color: transparent;
    border: 1px solid #727272;
    color: white;
    padding: 8px 16px;
    border-radius: 500px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.upgrade-btn:hover {
    border-color: white;
    transform: scale(1.04);
}

.profile-btn {
    width: 32px;
    height: 32px;
    background-color: #535353;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.content-area {
    padding: 20px 32px;
    padding-bottom: 100px; /* Space for player bar */
}

h2 {
    font-size: 24px;
    margin-bottom: 20px;
}

/* Updated Home Section Styles */
.home-section {
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-white);
}

.show-all {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-gray);
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: 1px;
}

.show-all:hover {
    text-decoration: underline;
    color: var(--text-white);
}

.card-scroll-container {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    padding-bottom: 20px; /* Space for scrollbar */
    scroll-behavior: smooth;
    /* Hide scrollbar for clean look */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.card-scroll-container::-webkit-scrollbar {
    display: none;
}

.card {
    min-width: 180px; /* Fixed width for scrolling */
    width: 180px;
    background-color: #181818;
    padding: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.card:hover {
    background-color: #282828;
}

.card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.card h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-white);
}

.card p {
    font-size: 14px;
    color: var(--text-gray);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* Artist Card Specifics */
.artist-card img {
    border-radius: 50%; /* Circle */
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.artist-card {
    text-align: center;
}

/* Song List Styles */
.song-list {
    display: flex;
    flex-direction: column;
}

.song-row {
    display: grid;
    grid-template-columns: 50px 4fr 3fr 1fr;
    padding: 10px 16px;
    border-radius: 4px;
    color: var(--text-gray);
    align-items: center;
}

.song-row:hover {
    background-color: rgba(255,255,255,0.1);
    color: var(--text-white);
}

.song-row img {
    width: 40px;
    height: 40px;
    margin-right: 16px;
}

.song-title-col {
    display: flex;
    align-items: center;
}

.song-info-text {
    display: flex;
    flex-direction: column;
}

.song-name {
    color: var(--text-white);
    font-size: 16px;
}

.song-artist {
    font-size: 14px;
}

/* Player Bar */
.player-bar {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    width: 100%;
    height: 100px;
    background-color: #181818;
    border-top: 1px solid #282828;
    display: grid;
    grid-template-columns: 180px 1fr 130px;
    align-items: center;
    column-gap: 8px;
    padding: 6px 8px;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
}

.now-playing {
    display: flex;
    align-items: center;
    min-width: 0;
}

.now-playing-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0; /* Prevent buttons from shrinking */
    margin-left: 10px;
    z-index: 10;
}

.album-art {
    width: 44px !important;
    height: 44px !important;
    margin-right: 6px;
    background-color: #282828;
    object-fit: cover;
    flex-shrink: 0;
}

.track-info {
    display: flex;
    flex-direction: column;
    margin-right: 6px;
    overflow: hidden;
    flex: 1; /* Allow it to take available space */
    min-width: 0; /* Enable truncation in flex item */
}

.track-name {
    color: var(--text-white);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.like-btn, .add-to-playlist-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 14px;
    margin-left: 4px;
    position: relative; /* Enable z-index */
    z-index: 10;
    pointer-events: auto; /* Force clickable */
}

.like-btn:hover, .add-to-playlist-btn:hover {
    color: var(--text-white);
    transform: scale(1.1);
}

.like-btn.active {
    color: var(--brand-green);
}

/* Player Controls */
.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 460px;
    justify-self: center;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.center-stack {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0;
}

.play-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    position: relative; /* Enable z-index */
    z-index: 10;
    pointer-events: auto; /* Force clickable */
    display: inline-flex;
    align-items: center;
}
.control-btn i {
    line-height: 1;
    vertical-align: middle;
}
.control-btn.active {
    color: #fff;
}
#repeatBtn.active::after {
    content: "1";
    position: absolute;
    top: -6px;
    right: -8px;
    background: #fff;
    color: #000;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    color: var(--text-white);
}

.control-btn.active {
    color: var(--brand-green);
}

.play-pause-btn {
    font-size: 32px;
    color: var(--text-white);
    background: radial-gradient(circle at center, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 60%);
    border-radius: 50%;
}

.play-pause-btn:hover {
    transform: scale(1.05);
}

.control-btn.small {
    font-size: 18px;
}

.add-to-playlist-btn {
    background: transparent;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
    position: relative; /* Enable z-index */
    z-index: 201;
    pointer-events: auto; /* Force clickable */
}

.add-to-playlist-btn:hover {
    color: var(--text-white) !important;
    transform: scale(1.1);
}

.playback-bar {
    display: none;
}

.progress-bar-container {
    flex: 1;
    height: 4px;
    background-color: #535353;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--text-white);
    border-radius: 2px;
    width: 0%;
}

.progress-bar-container:hover .progress-bar {
    background-color: var(--brand-green);
}

.volume-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    min-width: 90px;
    justify-self: end;
    padding-right: 8px;
}

.volume-step-btn {
    display: none;
}
.volume-step-btn:hover {
    border-color: white;
}
.volume-step-btn i {
    pointer-events: none;
}

.volume-bar-container {
    width: 40px;
    height: 6px;
    background-color: #333;
    border-radius: 20px;
    margin-left: 6px;
    cursor: pointer;
}

.volume-bar {
    height: 100%;
    width: 70%;
    background-color: var(--brand-green);
    border-radius: 20px;
}

@media (max-width: 420px) {
    .player-bar {
        height: 92px;
        padding: 4px 6px;
        grid-template-columns: 150px 1fr 110px;
    }
    .now-playing {
        min-width: 120px;
    }
    .album-art {
        width: 40px !important;
        height: 40px !important;
        margin-right: 4px;
    }
    .track-name {
        font-size: 13px;
        margin-bottom: 1px;
    }
    .track-artist {
        font-size: 10px;
    }
    .control-buttons {
        gap: 5px;
    }
    .play-pause-btn {
        font-size: 24px;
        background: radial-gradient(circle at center, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 60%);
    }
    .volume-controls {
        min-width: 90px;
        gap: 4px;
    }
    .volume-bar-container {
        width: 45px;
    }
}

.volume-bar-container:hover .volume-bar {
    background-color: var(--brand-green);
}

/* Playlist Header in View */
.playlist-header-view {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 24px;
}

.playlist-cover-large {
    width: 232px;
    height: 232px;
    background: linear-gradient(135deg, #450af5, #c4efd9);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 60px rgba(0,0,0,0.5);
    font-size: 64px;
}

.playlist-details h1 {
    font-size: 80px; /* Big title */
    font-weight: 900;
    margin: 0.1em 0;
    line-height: 1;
}

.playlist-type {
    text-transform: uppercase;
    font-size: 12px;
    font-weight: bold;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 9999999; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.8); 
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #282828;
    margin: auto;
    padding: 20px;
    border: 1px solid #181818;
    width: 80%;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    text-align: center;
}

.modal-content h3 {
    color: white;
    margin-bottom: 20px;
}

#modalPlaylistList {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

#modalPlaylistList li {
    padding: 12px;
    border-bottom: 1px solid #3e3e3e;
    color: var(--text-gray);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
}

#modalPlaylistList li i {
    margin-right: 10px;
    font-size: 1.2rem;
}

#modalPlaylistList li:hover {
    background-color: #3e3e3e;
    color: white;
}

.modal-close-btn {
    background-color: transparent;
    color: white;
    padding: 10px 20px;
    border: 1px solid #727272;
    border-radius: 500px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.modal-close-btn:hover {
    border-color: white;
    transform: scale(1.05);
}

.menu-btn {
    display: none;
    background-color: rgba(0,0,0,0.7);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2001;
    pointer-events: auto;
}

.pip-btn {
    background-color: transparent;
    border: 1px solid #727272;
    color: white;
    padding: 6px 10px;
    border-radius: 500px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
    margin-right: 8px;
    display: none;
}
.pip-btn:hover {
    border-color: white;
    transform: scale(1.04);
}

.yt-mini {
    position: fixed;
    right: 12px;
    bottom: 110px; /* above player bar */
    width: 1px;
    height: 1px;
    opacity: 0.01;
    pointer-events: none;
    background: #000;
    border: 1px solid #282828;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 9999;
    overflow: hidden;
}
.yt-mini.show-video {
    width: 240px;
    height: 135px;
    opacity: 1;
    pointer-events: auto;
    z-index: 9999;
}
.yt-mini iframe {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 1024px) {
    body {
        height: auto;
        overflow: auto;
    }
    .app-container {
        display: block; /* Change from grid to block for better mobile handling */
        height: auto;
        width: 100%;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px; /* Slightly narrower sidebar on mobile */
        max-width: 80vw;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 3000; /* Lebih tinggi dari top-bar agar menimpa saat open */
        box-shadow: 2px 0 20px rgba(0,0,0,0.6);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 2900; /* Tepat di bawah sidebar */
    }
    .sidebar.open + .sidebar-backdrop {
        display: block;
    }
    .main-content {
        grid-column: 1;
        height: auto;
        border-radius: 0;
        padding-bottom: 110px;
    }
    .top-bar {
        padding: 12px 16px;
        gap: 12px;
        z-index: 1000; /* Lebih rendah dari sidebar saat open */
    }
    .nav-arrows {
        display: none;
    }
    .menu-btn {
        display: inline-flex;
        margin-top: 6px; /* Agak ke bawah sesuai permintaan */
    }
    .pip-btn {
    .pip-btn {
        display: none;
    }
    .upgrade-btn {
        display: none;
    }
    .search-container {
        margin: 0;
        max-width: none;
    }
    .search-container input {
        font-size: 16px;
        padding: 12px 15px 12px 40px;
    }
    .content-area {
        padding: 16px;
        padding-bottom: 100px;
    }
    .section-header h2 {
        font-size: 20px;
    }
    .card {
        min-width: 140px;
        width: 140px;
        padding: 12px;
    }
    .card img {
        margin-bottom: 12px;
    }
    .song-row {
        grid-template-columns: 40px 1fr 60px;
        gap: 8px;
        padding: 10px 12px;
    }
    .song-album {
        display: none;
    }
    .song-name {
        font-size: 14px;
    }
    .song-artist {
        font-size: 12px;
    }
    .album-art {
        width: 42px !important;
        height: 42px !important;
        margin-right: 10px;
    }
    .now-playing {
        width: auto;
        flex: 1;
        min-width: 0;
        margin-right: 10px;
    }
    .player-controls {
        width: auto;
        display: block; /* Reset flex */
        padding-top: 14px;
        padding-bottom: 8px;
    }
    .control-buttons {
        margin-bottom: 6px;
        gap: 12px;
    }
    .center-stack {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    #shuffleBtn, #repeatBtn {
        display: inline-flex; /* Tampilkan kembali kontrol shuffle/repeat di mobile */
    }
    .add-to-playlist-btn {
        display: inline-flex;
    }
    /* Progress bar at top edge */
    .playback-bar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0;
        margin: 0;
        gap: 0;
    }
    .progress-bar-container {
        height: 3px;
        background-color: rgba(255,255,255,0.2);
        border-radius: 0;
    }
    .progress-bar {
        border-radius: 0;
        background-color: var(--brand-green);
    }
    #currentTime, #totalTime {
        display: none;
    }
    
    .volume-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .playlist-header-view {
        gap: 16px;
        padding-bottom: 16px;
    }
    .playlist-cover-large {
        width: 120px;
        height: 120px;
        font-size: 32px;
    }
    .playlist-details h1 {
        font-size: 28px;
    }
    .yt-mini.show-video {
        width: 200px;
        height: 113px;
        bottom: 100px;
    }
}
