/* =========================================================
   TIMA Radar v3 — Pro Meteorologist Theme
   Dark, technical, NWS-vibes.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ── Tokens ──────────────────────────────────────────────── */
:root {
    /* Brand */
    --tima-blue: #3566D8;
    --tima-red: #8F282A;
    --tima-orange: #F7750F;
    --tima-purple: #7905FC;

    /* UI */
    --bg-primary: #060A10;
    --bg-secondary: #0C1117;
    --bg-panel: #0E1319;
    --bg-card: #121820;
    --border: #1A2230;
    --border-hover: #243040;

    /* Accent */
    --cyan: #00E5FF;
    --cyan-dim: rgba(0, 229, 255, 0.15);
    --cyan-glow: rgba(0, 229, 255, 0.3);
    --green: #00FF88;
    --green-dim: rgba(0, 255, 136, 0.15);
    --red: #FF3D3D;
    --red-dim: rgba(255, 61, 61, 0.15);
    --yellow: #FFB300;
    --yellow-dim: rgba(255, 179, 0, 0.15);

    /* Text */
    --text-primary: #E8ECF0;
    --text-secondary: #8A95A5;
    --text-dim: #4A5568;

    /* Fonts */
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-sans: 'Inter', -apple-system, sans-serif;
}

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

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

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

/* ── Top Bar ─────────────────────────────────────────────── */
#topbar {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    letter-spacing: 0.05em;
    z-index: 100;
    flex-shrink: 0;
}

#topbar .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
}

#topbar .brand .tima {
    color: var(--text-primary);
}

#topbar .brand .radar {
    color: var(--tima-blue);
}

#topbar .brand svg {
    width: 18px;
    height: 18px;
    fill: var(--text-primary);
}

#topbar .nav {
    display: flex;
    gap: 20px;
}

#topbar .nav a {
    color: var(--text-secondary);
    text-decoration: none;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.12em;
    font-weight: 500;
    transition: color 0.2s;
}

#topbar .nav a:hover,
#topbar .nav a.active {
    color: var(--cyan);
}

#topbar .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

#topbar .live-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--green);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.1em;
}

#topbar .live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(0, 255, 136, 0); }
}

/* ── Main Content ────────────────────────────────────────── */
#main {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ── Map Container ───────────────────────────────────────── */
#map {
    flex: 1;
    position: relative;
}

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

.maplibregl-ctrl-top-right {
    top: 8px;
    right: 8px;
}

.maplibregl-ctrl-group {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
}

.maplibregl-ctrl-group button {
    border-color: var(--border) !important;
}

.maplibregl-ctrl-group button + button {
    border-top: 1px solid var(--border) !important;
}

/* ── Info Bar (above map) ────────────────────────────────── */
#infobar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 14px;
    background: rgba(6, 10, 16, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-transform: uppercase;
    white-space: nowrap;
}

#infobar .coord {
    color: var(--cyan);
    font-weight: 500;
    padding: 2px 8px;
    background: var(--cyan-dim);
    border-radius: 4px;
}

/* ── Station Pill Markers ────────────────────────────────── */
.station-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(6, 10, 16, 0.8);
    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;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.station-pill:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(0, 229, 255, 0.08);
}

.station-pill.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.station-pill .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
}

.station-pill.no-data .dot {
    background: var(--text-dim);
}

/* ── Right Panel — Station Info ──────────────────────────── */
#station-panel {
    width: 280px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 10;
}

#station-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#station-panel .panel-header .label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
}

#station-panel .operational {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--green);
    font-weight: 600;
}

#station-panel .operational::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
}

#station-panel .station-id {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

#station-panel .station-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

#station-panel .station-meta {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.6;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-box {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.stat-box .stat-label {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.stat-box .stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.stat-box .stat-unit {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-secondary);
}

/* ── Product Buttons ─────────────────────────────────────── */
.products-section .section-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.product-btn {
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    letter-spacing: 0.04em;
}

.product-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.product-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

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

/* Legend */
#legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

#legend .legend-label {
    text-transform: uppercase;
    font-weight: 600;
    min-width: 28px;
}

#legend-bar {
    width: 280px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid var(--border);
}

#legend .legend-range {
    display: flex;
    gap: 12px;
    font-size: 9px;
    color: var(--text-secondary);
}

/* Bottom product quick-switch */
.bottom-products {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.bottom-product-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.06em;
}

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

.bottom-product-btn.active {
    color: var(--cyan);
    border-color: var(--cyan);
    background: var(--cyan-dim);
}

/* Freshness */
#freshness {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
}

#freshness .fresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

#freshness.stale .fresh-dot {
    background: var(--yellow);
}

#freshness.offline .fresh-dot {
    background: var(--red);
}

/* ── Scan line decoration ────────────────────────────────── */
#scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--cyan) 50%,
        transparent 100%
    );
    opacity: 0.4;
    z-index: 200;
    animation: scanline-sweep 8s linear infinite;
    pointer-events: none;
}

@keyframes scanline-sweep {
    0% { top: 0; opacity: 0; }
    5% { opacity: 0.4; }
    95% { opacity: 0.4; }
    100% { top: 100%; opacity: 0; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
