/* Theme Variables */
:root[data-theme="dark"] {
    --bg-dark: #09090b;
    --panel-bg: rgba(24, 24, 27, 0.6);
    --primary-green: #1DB954;
    --primary-hover: #1ed760;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --border-color: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(255, 255, 255, 0.05);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --error-color: #ef4444;
}

:root[data-theme="light"] {
    --bg-dark: #f4f4f5;
    --panel-bg: rgba(255, 255, 255, 0.8);
    --primary-green: #1DB954;
    --primary-hover: #1ed760;
    --text-main: #18181b;
    --text-muted: #52525b;
    --border-color: rgba(0, 0, 0, 0.1);
    --input-bg: rgba(0, 0, 0, 0.03);
    --hover-bg: rgba(0, 0, 0, 0.05);
    --error-color: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Animation */
.background-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(90px);
    border-radius: 50%;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

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

.blob-2 {
    width: 500px;
    height: 500px;
    background: #115e59;
    bottom: -150px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(8px);
    font-size: 20px;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    transform: scale(1.1);
}

.app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    padding: 40px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
}

/* LOGIN VIEW */
#login-view {
    padding: 60px;
    max-width: 500px;
    width: 100%;
}

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

.header { margin-bottom: 30px; }
.spotify-icon { font-size: 56px; color: var(--primary-green); margin-bottom: 16px; filter: drop-shadow(0 0 12px rgba(29,185,84,0.4));}
.mixora-title { font-size: 36px; font-weight: 700; margin-bottom: 8px;}
.header p { color: var(--text-muted); font-size: 16px;}

.login-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.divider {
    position: relative;
    text-align: center;
    margin: 10px 0;
}
.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
    z-index: 0;
}
.divider span {
    background: var(--bg-dark); /* not ideal on glass, better to use panel-bg or pure color */
    padding: 0 10px;
    position: relative;
    z-index: 1;
    color: var(--text-muted);
    font-size: 14px;
}

/* DASHBOARD LAYOUT */
.dashboard-layout {
    display: flex;
    width: 100%;
    height: 100%;
    max-height: 850px;
    gap: 24px;
}

.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.mixora-logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 30px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: 12px;
    text-align: left;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.nav-item.active {
    background: var(--hover-bg);
    color: var(--primary-green);
    font-weight: 600;
}

.history-section {
    margin-top: auto;
    margin-bottom: 24px;
    max-height: 200px;
    overflow-y: auto;
}

.history-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.history-list {
    list-style: none;
}
.history-item {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}
.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.user-profile span {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}
#logout-btn:hover { color: var(--error-color); }

/* Main Content Area */
.content-area {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tab-pane {
    animation: fadeIn 0.4s ease forwards;
}

.mt-4 { margin-top: 32px; }

/* FORMS & INPUTS */
.input-group {
    position: relative;
    margin-bottom: 16px;
    width: 100%;
}
.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
input[type="url"], select, input[type="range"], textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}
input[type="url"] { padding: 16px 16px 16px 44px; }
select, textarea { padding: 16px; cursor: pointer;}
input[type="url"]:focus, select:focus, textarea:focus {
    border-color: var(--primary-green);
    background: var(--hover-bg);
}
select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.form-row {
    display: flex;
    gap: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

/* BUTTONS */
.btn-primary {
    background: var(--primary-green);
    color: #000;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-primary:hover { background: var(--primary-hover); transform: scale(1.02); }
.sm-btn { padding: 10px 16px; font-size: 14px; }

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}
.btn-secondary:hover { background: var(--hover-bg); }

/* RESULT HEADER & ACTIONS */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.export-actions { display: flex; gap: 8px; }
.action-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}
.action-btn:hover { background: var(--primary-green); color: #000; border-color: var(--primary-green); }

/* TABLE */
.table-container, .table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
}
.tracks-table, .result-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.tracks-table th, .result-table th {
    padding: 16px;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.tracks-table td, .result-table td {
    padding: 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}
.tracks-table tr:last-child td, .result-table tr:last-child td { border-bottom: none; }
.tracks-table tr:hover, .result-table tr:hover { background: var(--hover-bg); }

/* PLAYLIST GRID */
.playlists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.playlist-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.playlist-card:hover { transform: translateY(-4px); background: var(--hover-bg); border-color: var(--primary-green); }
.playlist-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    margin-bottom: 12px;
    object-fit: cover;
}
.playlist-card h4 { font-size: 16px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-card p { font-size: 13px; color: var(--text-muted); }


/* UTILS */
.hidden { display: none !important; }
.active-view { display: flex !important; }

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
}
.loader-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}
.loader-centered .loader {
    position: relative;
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-green);
    width: 40px; height: 40px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* RESPONSIVE */
@media (max-width: 768px) {
    .dashboard-layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 20px; }
    .content-area { padding: 20px; }
}
