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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --accent: #3b82f6;
    --accent-dim: #1d4ed8;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

nav .logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent);
    text-decoration: none;
    margin-right: 1rem;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
}

nav a:hover { color: var(--text); }

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

h1 { margin-bottom: 1.5rem; font-size: 1.8rem; }
h2 { margin-bottom: 1rem; font-size: 1.3rem; color: var(--text-dim); }

section { margin-bottom: 2.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
}

thead { background: var(--border); }
th, td { padding: 0.75rem 1rem; text-align: left; }
th { font-size: 0.8rem; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
td { border-top: 1px solid var(--border); font-size: 0.9rem; }

.track-uri {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-dim { color: var(--text-dim); }

.stream-art { width: 40px; padding: 0.4rem; }
.stream-art img { border-radius: 4px; display: block; }

.empty {
    color: var(--text-dim);
    font-style: italic;
    padding: 2rem;
    text-align: center;
    background: var(--surface);
    border-radius: 8px;
}

#roads-map {
    border-radius: 8px;
    border: 1px solid var(--border);
    height: 450px;
}

/* Drives page */
.drives-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    height: 500px;
}

.drive-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.drive-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.15s;
}

.drive-card:hover { border-color: var(--accent); }
.drive-card.active { border-color: var(--accent); background: var(--accent-dim); }

.drive-card { position: relative; }
.drive-device {
    font-size: 0.7rem;
    color: var(--text-dim);
    background: var(--border);
    padding: 0 0.4rem;
    border-radius: 3px;
    display: inline-block;
    margin-right: 0.4rem;
}
.device-filter {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.device-filter select {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}
.drive-delete-form {
    position: absolute;
    top: 4px;
    right: 4px;
    margin: 0;
}
.drive-delete-form .btn-small {
    padding: 0 0.5rem;
    line-height: 1.4;
    opacity: 0.4;
}
.drive-card:hover .drive-delete-form .btn-small { opacity: 1; }

.drive-date { font-size: 0.9rem; font-weight: 500; }
.drive-duration { font-size: 0.8rem; color: var(--text-dim); }
.drive-points { font-size: 0.75rem; color: var(--text-dim); }

#map {
    border-radius: 8px;
    border: 1px solid var(--border);
    min-height: 400px;
}

.drives-layout.heatmap-mode {
    grid-template-columns: 1fr;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    z-index: 1000;
    gap: 0;
    border-radius: 0;
}

.drives-layout.heatmap-mode #map {
    border-radius: 0;
    border: none;
    min-height: unset;
    height: 100%;
}

.heatmap-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 14px;
    gap: 12px;
    align-items: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.heatmap-exit {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.tab-btn:hover { color: var(--text); border-color: var(--text-dim); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.heatmap-controls {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.heatmap-controls input { margin-right: 0.3rem; }

/* Admin */
.admin-form { max-width: 400px; }
.admin-form label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.25rem; margin-top: 0.75rem; }
.admin-form input, .admin-form select {
    width: 100%; padding: 0.5rem 0.75rem;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg); color: var(--text); font-size: 0.9rem;
}
.admin-form input:focus, .admin-form select:focus { outline: none; border-color: var(--accent); }

.btn, .btn-small { border: none; border-radius: 4px; cursor: pointer; font-weight: 600; }
.btn { padding: 0.6rem 1.2rem; background: var(--accent); color: #fff; font-size: 0.9rem; margin-top: 1rem; display: inline-block; }
.btn:hover { background: var(--accent-dim); }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.btn-small:hover { border-color: var(--text-dim); color: var(--text); }
.btn-danger { color: #fca5a5; }
.btn-danger:hover { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
.btn-approve { color: #86efac; }
.btn-approve:hover { background: #14532d; color: #86efac; border-color: #166534; }

.badge { padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.75rem; font-weight: 600; }
.badge-approved { background: #14532d; color: #86efac; }
.badge-pending { background: #78350f; color: #fde68a; }
.badge-revoked { background: #7f1d1d; color: #fca5a5; }

.nav-logout { margin-left: auto; }

/* Changelog entries on /apks page */
.changelog-entry {
    margin-bottom: 1.25rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}
.changelog-entry h4 {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 0.4rem;
    font-weight: 600;
}
.changelog-entry ul {
    padding-left: 1.25rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}
.changelog-entry li { margin-bottom: 0.2rem; }
.changelog-entry code {
    background: var(--surface);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* ========================================
   Player — Android App Style (always)
   ======================================== */

body:has(#player-app) {
    --bg: #0E1013;
    --surface: #0E1013;
    --surface-variant: #43474E;
    --primary: #90CAF9;
    --on-bg: #E2E2E6;
    --on-surface-variant: #C3C6CF;
    --border: #43474E;
    --accent: #90CAF9;
    --text: #E2E2E6;
    --text-dim: #C3C6CF;
    font-family: 'Oswald', system-ui, sans-serif;
    background: var(--bg);
    color: var(--on-bg);
}

body:has(#player-app) main {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* --- App layout: 65/35 side-by-side --- */
#player-app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 53px); /* subtract nav height */
    max-width: none;
}

.app-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.app-left {
    flex: 0 0 65%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
}

.app-right {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
}

/* --- Toolbar overlay (sort + fullscreen buttons) --- */
.app-toolbar {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 200;
    display: flex;
    gap: 4px;
}

.toolbar-btn {
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s;
    padding: 0;
}

.toolbar-btn:hover { background: rgba(255,255,255,0.1); }
.toolbar-btn .material-symbols-outlined { font-size: 28px; }

/* --- CoverFlow --- */
.coverflow-container {
    width: 100%;
    height: 100%;
    perspective: 800px;
    overflow: hidden;
    position: relative;
    background: none;
    cursor: default;
}

.coverflow-track {
    position: relative;
    height: 100%;
    transform-style: preserve-3d;
}

.coverflow-item {
    position: absolute;
    width: 200px;
    height: 200px;
    top: 50%;
    margin-top: -100px;
    border-radius: 8px;
    transition: transform 0.35s ease, opacity 0.35s ease;
    cursor: pointer;
    transform-style: preserve-3d;
    overflow: hidden;
    background: var(--surface);
    border: 2px solid transparent;
}

.coverflow-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
}

.coverflow-item.no-art {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
}

.coverflow-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    border-radius: 6px;
    transition: opacity 0.35s ease;
}

.coverflow-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 8px;
    font-size: 12px;
    font-family: 'Oswald', system-ui, sans-serif;
    color: #fff;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.3s;
}

.coverflow-item.center .coverflow-label { opacity: 1; }
.coverflow-item.playing { border-color: var(--primary); }

/* --- Track list (right panel) --- */
.album-header {
    font-family: 'Oswald', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--primary);
    padding: 8px 16px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: none;
    padding-bottom: 8px;
}

.track-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.track-row:hover { background: rgba(255,255,255,0.05); }
.track-row.playing { color: var(--primary); background: rgba(144,202,249,0.08); }

.track-num {
    width: 1.5rem;
    text-align: right;
    font-size: 14px;
    color: var(--on-surface-variant);
    flex-shrink: 0;
}

.track-row.playing .track-num { color: var(--primary); }

.track-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Oswald', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 400;
}

.track-dur {
    font-size: 14px;
    color: var(--on-surface-variant);
    flex-shrink: 0;
}

.track-empty {
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

/* --- Now Playing Bar (Android style: slider on top) --- */
.now-playing-bar {
    position: relative;
    flex-shrink: 0;
    background: var(--surface-variant);
    border-top: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    gap: 0;
    z-index: 1000;
}

.np-slider {
    width: 100%;
    height: 16px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    outline: none;
    cursor: pointer;
    margin: 0;
    display: block;
}

.np-slider::-webkit-slider-runnable-track { height: 4px; background: var(--border); }
.np-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); cursor: pointer; margin-top: -6px;
}
.np-slider::-moz-range-track { height: 4px; background: var(--border); border: none; }
.np-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary); border: none; cursor: pointer;
}

.np-content {
    display: flex;
    align-items: center;
    padding: 2px 16px 4px;
    gap: 4px;
}

.np-info {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.np-title {
    font-family: 'Oswald', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 500;
    color: var(--on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.np-artist {
    font-family: 'Oswald', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--on-surface-variant);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-time {
    font-family: 'Oswald', system-ui, sans-serif;
    font-size: 14px;
    color: var(--on-surface-variant);
    opacity: 0.7;
    min-width: 80px;
    text-align: right;
}

.np-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    transition: background 0.15s;
}

.ctrl-btn:hover { background: rgba(255,255,255,0.1); }

.ctrl-mode { width: 48px; height: 48px; }
.ctrl-mode .material-symbols-outlined { font-size: 24px; }
.ctrl-med { width: 54px; height: 54px; }
.ctrl-med .material-symbols-outlined { font-size: 32px; }
.ctrl-large { width: 62px; height: 62px; }
.ctrl-large .material-symbols-outlined { font-size: 40px; }

/* CoverFlow fade transition for sort */
.coverflow-container.sorting { opacity: 0; transition: opacity 150ms ease; }
.coverflow-container.sorting-in { opacity: 1; transition: opacity 350ms ease; }

/* --- Fullscreen mode: hide nav, fill viewport --- */
body.player-fullscreen nav { display: none; }
body.player-fullscreen #player-app { height: 100vh; }
body.player-fullscreen { overflow: hidden; }

/* Car Thing portrait (480x800) */
@media (max-width: 520px) and (min-height: 700px) {
    .app-main { flex-direction: column; }
    .app-left { flex: 0 0 55%; }
    .app-right { flex: 0 0 45%; border-left: none; border-top: 1px solid var(--border); }
    .ctrl-med { width: 44px; height: 44px; }
    .ctrl-large { width: 52px; height: 52px; }
}
