/* =========================================================
   TIMA Radar v3 — Modern Minimal Theme
   Light, clean, map-first.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Mono:wght@400;500&display=swap');

:root {
    --bg: #FAFAF8;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F5F5F3;
    --border: #E5E5E0;
    --border-hover: #D0D0C8;

    --text-primary: #1A1A18;
    --text-secondary: #6B6B65;
    --text-dim: #9B9B95;

    --brand-blue: #3566D8;
    --brand-blue-light: rgba(53, 102, 216, 0.08);

    --tor-red: #DC2626;
    --tor-red-bg: rgba(220, 38, 38, 0.08);
    --svr-orange: #EA580C;
    --svr-orange-bg: rgba(234, 88, 12, 0.08);
    --ffw-blue: #2563EB;
    --green: #16A34A;

    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'DM Mono', 'SF Mono', monospace;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Top Nav ─────────────────────────────────────────────── */
#topnav {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-primary);
}

.nav-brand svg {
    width: 22px;
    height: 22px;
    fill: var(--text-primary);
}

.nav-brand .brand-radar {
    color: var(--brand-blue);
}

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

.nav-links a {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.nav-links a.active {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-signin {
    padding: 7px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-decoration: none;
}

.btn-signin:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

/* Mode switcher for logged in users */
.mode-switch {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--bg-card-hover);
    border-radius: 8px;
}

.mode-btn {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.mode-btn:hover {
    color: var(--text-secondary);
}

.mode-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

/* ── Map Container ───────────────────────────────────────── */
#map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Hide MapLibre controls */
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
    display: none;
}

/* ── Search Bar ──────────────────────────────────────────── */
#search-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 420px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
}

#search-bar svg {
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
}

#search-input::placeholder {
    color: var(--text-dim);
}

#search-bar .shortcut {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
}

/* ── Floating Cards ──────────────────────────────────────── */
.float-card {
    position: absolute;
    z-index: 15;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 16px;
}

/* Alerts — top left */
#alerts-card {
    top: 12px;
    left: 12px;
    width: 260px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.card-count {
    font-size: 11px;
    color: var(--text-dim);
}

.alert-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.alert-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-family: var(--font-mono);
}

.alert-badge.tor {
    color: var(--tor-red);
    background: var(--tor-red-bg);
}

.alert-badge.svr {
    color: var(--svr-orange);
    background: var(--svr-orange-bg);
}

.alert-text {
    flex: 1;
    margin-left: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.alert-time {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

/* Layers — top right */
#layers-card {
    top: 12px;
    right: 12px;
    width: 200px;
}

.layer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.layer-row .layer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.layer-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

/* Toggle switch */
.toggle {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--border);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.toggle.on {
    background: var(--brand-blue);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}

.toggle.on::after {
    transform: translateX(16px);
}

/* Selected Radar — bottom left */
#radar-card {
    bottom: 60px;
    left: 12px;
    width: 300px;
}

.radar-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.radar-card-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    font-weight: 600;
}

.radar-card-id {
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--brand-blue);
}

.radar-card-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 2px;
}

.radar-card-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.radar-stats {
    display: flex;
    gap: 16px;
}

.radar-stat .stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    font-weight: 600;
}

.radar-stat .stat-val {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.radar-stat .stat-val .stat-unit {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Bottom Bar ──────────────────────────────────────────── */
#bottombar {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
    gap: 16px;
}

/* Loop timeline */
.loop-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.play-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
}

.play-btn:hover {
    border-color: var(--border-hover);
}

.play-btn svg {
    width: 14px;
    height: 14px;
    fill: var(--text-primary);
}

.loop-track {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
}

.loop-fill {
    width: 100%;
    height: 100%;
    background: var(--text-dim);
    border-radius: 2px;
}

.loop-label {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    white-space: nowrap;
}

.loop-label .live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 4px;
    vertical-align: middle;
}

/* Speed buttons */
.speed-btns {
    display: flex;
    gap: 2px;
}

.speed-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.speed-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-hover);
}

.speed-btn.active {
    color: var(--text-primary);
    border-color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ── Station Pill (on map) ───────────────────────────────── */
.m-station-pill {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    cursor: pointer;
}

.m-station-pill.has-data {
    background: var(--brand-blue);
}

.m-station-pill.active {
    background: var(--brand-blue);
    width: 14px;
    height: 14px;
    border-width: 3px;
    box-shadow: 0 0 0 4px rgba(53, 102, 216, 0.2), 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Station pills (matching Pro view) */
.station-pill {
    display: flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 10px; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer; white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.station-pill .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-blue); }
.station-pill.no-data .dot { background: var(--text-dim); }
.station-pill:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.station-pill.active { color: white; background: var(--brand-blue); border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(53,102,216,0.2), var(--shadow-sm); }
.station-pill.active .dot { background: white; }
