/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface2: #2a2a2a;
    --surface3: #333333;
    --green: #1db954;
    --green-dark: #17a349;
    --text: #e0e0e0;
    --text-muted: #888;
    --red: #e74c3c;
    --radius: 10px;
    --nav-bg: #000000;
    --border: #444444;
    --border2: #333333;
    --modal-bg: #1a1a1a;
}

[data-theme="light"] {
    --bg: #f4f4f4;
    --surface: #ffffff;
    --surface2: #f0f0f0;
    --surface3: #e4e4e4;
    --text: #111111;
    --text-muted: #666666;
    --nav-bg: #f8f8f8;
    --border: #d8d8d8;
    --border2: #cccccc;
    --modal-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--nav-bg);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border2);
}
.brand { font-size: 1.1rem; font-weight: 700; color: var(--green); letter-spacing: 1px; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }
/* ── Player ── */
.player-container {
    max-width: 640px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.now-playing {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    background: var(--surface);
    padding: 1.25rem;
    border-radius: var(--radius);
}

.album-art {
    width: 90px;
    height: 90px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface2);
}

.track-info { flex: 1; overflow: hidden; }
.track-name { font-size: 1.05rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artists { color: var(--text-muted); font-size: 0.875rem; margin-top: 3px; }
.album-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.device-label { color: var(--green); font-size: 0.78rem; margin-top: 6px; }

/* Progress */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.progress-bar-bg {
    flex: 1;
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 0.5s linear;
}
.time-label { font-size: 0.75rem; color: var(--text-muted); min-width: 32px; }

/* Controls */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

.btn-control {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: color 0.15s;
}
.btn-control:hover { color: var(--text); }

.btn-play {
    background: var(--green);
    border: none;
    color: #000;
    font-size: 1.2rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.btn-play:hover { background: var(--green-dark); transform: scale(1.05); }
.btn-play:active { transform: scale(0.97); }

/* Volume */
.volume-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.volume-icon { font-size: 1rem; }
.volume-slider {
    flex: 1;
    accent-color: var(--green);
    cursor: pointer;
    height: 4px;
}

/* Device */
.device-section, .playlist-section { display: flex; flex-direction: column; gap: 0.5rem; }
.section-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.device-row { display: flex; gap: 0.5rem; }

.select {
    flex: 1;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
}

/* Playlists list */
.playlist-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.playlist-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.75rem;
    transition: background 0.15s;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}
.playlist-card.clickable { cursor: pointer; }
.playlist-card.clickable:hover { background: var(--surface2); }
.playlist-card.clickable:active { background: #333; }

.playlist-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.playlist-thumb-placeholder {
    width: 52px;
    height: 52px;
    background: var(--surface2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}
.playlist-thumb-emoji { font-size: 1.8rem; }

.playlist-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.playlist-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Admin ── */
.admin-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.admin-header { display: flex; align-items: center; justify-content: space-between; }
.admin-header h1 { font-size: 1.4rem; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.card h2 { font-size: 1rem; font-weight: 600; }

.add-form { display: flex; flex-direction: column; gap: 0.5rem; }
.form-row { display: flex; gap: 0.6rem; }
.hint { color: var(--text-muted); font-size: 0.78rem; }

.input {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    flex: 1;
    outline: none;
}
.input:focus { border-color: var(--green); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border2);
}
.table td { padding: 0.6rem; border-bottom: 1px solid var(--surface2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.table-thumb {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    object-fit: cover;
}
.table-thumb-placeholder {
    width: 44px;
    height: 44px;
    background: var(--surface2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.td-name { font-weight: 500; max-width: 180px; }
.td-desc { color: var(--text-muted); font-size: 0.82rem; max-width: 220px; }
.code-id { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); background: var(--surface2); padding: 2px 5px; border-radius: 3px; }

/* Buttons */
.btn-primary {
    background: var(--green);
    color: #000;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 1.1rem;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-sm {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s;
}
.btn-sm:hover { background: var(--surface3); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
}
.alert-error { background: rgba(231,76,60,0.15); color: #e74c3c; border: 1px solid rgba(231,76,60,0.3); }
.alert-success { background: rgba(29,185,84,0.15); color: var(--green); border: 1px solid rgba(29,185,84,0.3); }

/* Login */
.login-container {
    max-width: 360px;
    margin: 5rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.login-container h1 { text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-form label { font-size: 0.85rem; color: var(--text-muted); }
.back-link { text-align: center; font-size: 0.85rem; }

/* Misc */
.empty-msg { color: var(--text-muted); font-size: 0.9rem; }

/* ── Theme toggle ── */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s;
    color: var(--text-muted);
}
.theme-toggle:hover { background: var(--surface2); }
