:root {
    --bg-black: #000000;
    --bg-dark-grey: #121212;
    --bg-light-grey: #242424;
    --bg-hover-grey: #2a2a2a;
    --primary-green: #1ed760;
    --primary-green-hover: #1fdf64;
    --text-white: #ffffff;
    --text-grey: #b3b3b3;
    --sidebar-width: 300px;
    /* Reduced slightly for better proportions */
    --playbar-height: 90px;
}

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

body {
    font-family: 'Inter', sans-serif;
    /* Modern font */
    background-color: var(--bg-black);
    color: var(--text-white);
    height: 100vh;
    overflow: hidden;
}

.invert {
    filter: invert(1);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    padding: 8px;
    /* Small gap around the app like modern web apps */
    padding-bottom: 0;
    gap: 8px;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-black);
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: calc(100vh - var(--playbar-height) - 16px);
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header,
.nav-links,
.library-section {
    background-color: var(--bg-dark-grey);
    border-radius: 8px;
    padding: 16px 24px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
}

.logo {
    width: 80px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: none;
    /* Hidden on desktop */
}

.nav-links ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-grey);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: 0.2s;
}

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

.nav-links img {
    width: 24px;
}

.library-section {
    flex: 1;
    /* Takes remaining height */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.library-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    color: var(--text-grey);
    margin-bottom: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.library-header:hover {
    color: var(--text-white);
}

.library-header img {
    width: 24px;
}

.library-content {
    background-color: var(--bg-light-grey);
    padding: 16px;
    border-radius: 8px;
    margin-top: 10px;
}

.hint-text {
    font-weight: 600;
    margin-bottom: 10px;
}

.small-btn {
    background-color: var(--text-white);
    color: var(--bg-black);
    border: none;
    padding: 8px 16px;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    transform: scale(1);
    transition: transform 0.1s;
}

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

.sidebar-footer {
    padding: 0 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: auto;
    margin-bottom: 20px;
}

.sidebar-footer a {
    color: var(--text-grey);
    text-decoration: none;
    font-size: 11px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    background: linear-gradient(180deg, #222222 0%, var(--bg-dark-grey) 40%);
    background-color: var(--bg-dark-grey);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    height: calc(100vh - var(--playbar-height) - 16px);
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: 64px;
    background-color: rgba(0, 0, 0, 0.5);
    /* Glass-ish */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-controls {
    display: flex;
    gap: 8px;
}

.circle-btn {
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--text-grey);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sidebar-toggle {
    display: none;
    /* Hidden on desktop */
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-grey);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
}

.btn-text:hover {
    color: var(--text-white);
    transform: scale(1.05);
}

.btn-white {
    background-color: var(--text-white);
    color: var(--bg-black);
    border: none;
    padding: 12px 32px;
    border-radius: 24px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.1s;
}

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

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 40px;
}

/* Scrollbar Customization */
.content-scroll::-webkit-scrollbar,
.library-section::-webkit-scrollbar {
    width: 12px;
}

.content-scroll::-webkit-scrollbar-thumb,
.library-section::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Playlist Grid */
.playlist-grid-section h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

.card {
    background-color: #181818;
    padding: 16px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover {
    background-color: var(--bg-hover-grey);
}

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

.card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.play-icon-hover {
    position: absolute;
    right: 20px;
    bottom: 110px;
    /* Adjusted based on padding+text height */
    background-color: var(--primary-green);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 8px rgba(0, 0, 0, 0.3);
}

.card:hover .play-icon-hover {
    opacity: 1;
    transform: translateY(0);
}

/* Song List View (Hidden by default) */
.hidden {
    display: none;
}

.playlist-hero {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    padding-bottom: 24px;
}

.hero-image img {
    width: 230px;
    height: 230px;
    box-shadow: 0 4px 60px rgba(0, 0, 0, 0.5);
}

.hero-info span {
    font-size: 14px;
    font-weight: 700;
}

.hero-info h1 {
    font-size: 80px;
    /* Big title like Spotify */
    margin: 10px 0;
    font-weight: 900;
}

.play-btn-large {
    background-color: var(--primary-green);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 30px;
}

.play-btn-large:hover {
    transform: scale(1.05);
    background-color: var(--primary-green-hover);
}

.song-header-row {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    color: var(--text-grey);
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.song-item {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    padding: 10px 16px;
    align-items: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.song-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.song-item .play-indicator {
    display: none;
}

.song-item:hover .number {
    display: none;
}

.song-item:hover .play-indicator {
    display: block;
    filter: invert(1);
    width: 12px;
}

/* --- Playbar --- */
.playbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--playbar-height);
    background-color: black;
    border-top: 1px solid #282828;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 200;
}

.now-playing {
    width: 30%;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.track-art {
    width: 56px;
    height: 56px;
    border-radius: 4px;
}

.track-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.track-name {
    color: var(--text-white);
    font-weight: 500;
    font-size: 14px;
}

.track-artist {
    color: var(--text-grey);
    font-size: 12px;
}

.player-controls {
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
}

.control-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: 0.2s;
}

.control-btn:hover {
    opacity: 1;
}

.play-pause-btn {
    background-color: var(--text-white);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.play-pause-btn img {
    filter: invert(0) !important;
    /* It's black on white */
    width: 16px;
}

.playback-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-grey);
    font-size: 12px;
}

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

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

.progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    /* Dynamic */
    width: 12px;
    height: 12px;
    background-color: var(--text-white);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    /* Show on hover */
    pointer-events: none;
}

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

.progress-container:hover .progress-thumb {
    opacity: 1;
}

.volume-controls {
    width: 30%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

input[type=range] {
    height: 4px;
    border-radius: 2px;
    cursor: pointer;
}

/* --- Media Queries --- */

@media (max-width: 1200px) {
    /* Tablet adjustments if needed */
}

@media (max-width: 900px) {

    /* Mobile/Small Tablet */
    .app-container {
        padding: 0;
        gap: 0;
    }

    .sidebar {
        position: absolute;
        left: -100%;
        /* Hide offscreen */
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 999;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    #close-sidebar {
        display: block;
        /* Show close button on mobile sidebar */
    }

    .main-content {
        height: 100vh;
        border-radius: 0;
        padding-bottom: var(--playbar-height);
    }

    .content-scroll {
        padding-bottom: 200px;
        /* Ensure last song is visible above playbar */
    }

    .nav-controls #sidebar-toggle {
        display: flex;
    }

    .nav-controls button:not(#sidebar-toggle):not(#back-btn) {
        display: none;
        /* Hide forward arrow on mobile, keep back & hamburger */
    }

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

    .hero-info h1 {
        font-size: 32px;
    }

    .hero-image img {
        width: 150px;
        height: 150px;
    }

    .playlist-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .playbar {
        padding: 8px;
        flex-direction: row;
    }

    .now-playing {
        width: 100px;
    }

    .volume-controls {
        display: none;
        /* Hide volume on super small screens or move to popup */
    }

    .player-controls {
        width: auto;
        flex: 1;
    }

    .playback-bar {
        display: none;
        /* Hide seek bar on footer for minimal view? Or keep it. Let's keep buttons. */
    }

    /* Let's keep the play/pause prominent */
    .control-buttons {
        gap: 16px;
    }
}
