:root {
    --playlist-theme: #6b46c1;
    --playlist-accent: #d6bcfa;
    --playlist-bg: #0a0a0c;
    --playlist-text: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
}

body {
    background: var(--playlist-bg);
    color: var(--playlist-text);
    font-family: 'Inter', sans-serif;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ambient Background */
.ambient-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at center, var(--playlist-theme) -50%, var(--playlist-bg) 100%);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--playlist-theme);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--playlist-accent);
    bottom: -150px;
    right: -150px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--playlist-theme);
    top: 50%;
    left: 70%;
    opacity: 0.1;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 50px) scale(1.1); }
}

/* Layout */
.playlist-container {
    max-width: 1200px;
    margin: 120px auto 40px;
    padding: 0 20px;
    transition: margin-left 0.3s ease;
}

body.sidebar-open .playlist-container {
    margin-left: 320px;
}

/* Sidebar */
.playlist-sidebar {
    position: fixed;
    top: 100px;
    left: -300px;
    width: 280px;
    height: calc(100vh - 140px);
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    margin-left: 20px;
}

body.sidebar-open .playlist-sidebar {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--playlist-accent);
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: none; /* Only show on mobile if needed */
    width: 32px;
    height: 32px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-radius: 12px;
    text-decoration: none;
    color: #94a3b8;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.sidebar-item.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--playlist-accent);
    color: var(--playlist-accent);
}

.sidebar-icon {
    font-size: 1.2rem;
}

.sidebar-icon img {
    width: 1.2rem;
    height: 1.2rem;
    object-fit: contain;
    vertical-align: middle;
}

.sidebar-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle Button */
.toggle-sidebar-btn {
    position: fixed;
    top: 110px;
    left: 15px;
    z-index: 101;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
}

.toggle-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

body.sidebar-open .toggle-sidebar-btn {
    left: 310px;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px;
    margin-bottom: 30px;
    gap: 30px;
    flex-wrap: wrap;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 30px;
}

.playlist-icon {
    font-size: 4rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.playlist-icon img {
    width: 1em;
    height: 1em;
    object-fit: contain;
    display: block;
}

/* Styled specifically when using an image icon to act as an album/playlist cover */
.playlist-icon.playlist-icon-image {
    width: 180px;
    height: 180px;
    padding: 0;
    overflow: hidden;
    border-radius: 24px;
}

.playlist-icon.playlist-icon-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Adjust size on mobile devices */
@media (max-width: 768px) {
    .playlist-icon.playlist-icon-image {
        width: 150px;
        height: 150px;
    }
}

.header-text h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, var(--playlist-text) 0%, var(--playlist-accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    max-width: 600px;
}

/* Controls */
.controls-section {
    display: flex;
    gap: 20px;
    padding: 20px;
    margin-bottom: 40px;
    align-items: center;
}

.search-wrapper {
    flex: 1;
    position: relative;
}

.search-wrapper input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--playlist-accent);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(214, 188, 250, 0.1);
}

.filter-wrapper {
    position: relative;
}

select {
    appearance: none;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 40px 12px 20px;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Grid & Cards */
.song-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.song-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.song-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.song-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.song-card:hover .song-thumbnail img {
    transform: scale(1.05);
}

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

.song-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--playlist-accent);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.card-icon {
    font-size: 1.5rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.song-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.song-artist {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 0 0 20px 0;
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    border-radius: 16px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--playlist-theme);
    color: white;
}

.btn-primary:hover {
    background: var(--playlist-accent);
    color: #1a1a2e;
    transform: scale(1.05);
}

/* Responsive */
.unavailable-notice {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .playlist-header {
        padding: 30px;
        text-align: center;
        justify-content: center;
    }
    .header-content {
        flex-direction: column;
    }
    .playlist-container {
        margin-top: 80px;
    }
    .controls-section {
        flex-direction: column;
    }
    .search-wrapper, .filter-wrapper, select {
        width: 100%;
    }

    /* Prevent UI squashing by hiding content when sidebar is open on mobile */
    body.sidebar-open .playlist-container,
    body.sidebar-open .playlist-footer {
        display: none;
    }

    body.sidebar-open .playlist-sidebar {
        width: calc(100% - 40px);
        left: 0;
        margin: 20px;
        top: 20px;
        height: calc(100vh - 40px);
    }

    .close-btn {
        display: flex;
    }

    body.sidebar-open .toggle-sidebar-btn {
        display: none;
    }
}


.error-container {
    text-align: center;
    padding: 100px 20px;
}
