/* ============================================================
   AWARE Dashboard — Design System
   ETH Zürich Citizen Science · GNSS Network
   ============================================================ */

/* Google Fonts: Syne (display) + IBM Plex Sans (body) + IBM Plex Mono (data) */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* --- Design Tokens ----------------------------------------- */
:root {
    /* Brand */
    --eth-blue:         #215CAF;
    --eth-blue-dark:    #164380;
    --eth-blue-light:   #3a7bd5;
    --eth-blue-muted:   #d0e2f7;

    /* Dark surfaces (header/footer) */
    --navy:             #0a1628;
    --slate-900:        #0f1f3a;
    --slate-800:        #1a2f4a;

    /* Light surfaces */
    --bg:               #eef2f7;
    --surface:          #ffffff;
    --surface-2:        #f7f9fc;
    --surface-3:        #eef2f7;

    /* Text */
    --text-1:           #0d1b2e;
    --text-2:           #3d5068;
    --text-3:           #6b7e95;
    --text-inv:         #ffffff;
    --text-inv-muted:   rgba(255,255,255,0.60);

    /* Borders */
    --border:           #dde5ef;
    --border-strong:    #b8c8dc;

    /* Status */
    --green:            #16a34a;
    --green-bg:         #dcfce7;
    --yellow:           #d97706;
    --yellow-bg:        #fef9c3;
    --red:              #dc2626;
    --red-bg:           #fee2e2;
    --gray:             #6b7280;
    --gray-bg:          #f3f4f6;

    /* Accent */
    --accent:           #0ea5e9;
    --accent-bg:        #e0f2fe;
    --accent-border:    #bae6fd;

    /* Typography */
    --font-display:     'Syne', sans-serif;
    --font-body:        'IBM Plex Sans', sans-serif;
    --font-mono:        'IBM Plex Mono', monospace;

    /* Radii */
    --r-sm:             4px;
    --r-md:             8px;
    --r-lg:             12px;
    --r-xl:             16px;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(10,22,40,0.07), 0 1px 2px rgba(10,22,40,0.04);
    --shadow-md:        0 4px 12px rgba(10,22,40,0.09), 0 2px 6px rgba(10,22,40,0.05);
    --shadow-lg:        0 12px 32px rgba(10,22,40,0.12), 0 4px 12px rgba(10,22,40,0.07);

    --content-width:    1200px;
    --nav-height:       64px;
}

/* --- Language toggle ---------------------------------------- */
.lang-en { display: none; }
.lang-en-block { display: none; }
body[data-lang="en"] .lang-en { display: inline; }
body[data-lang="en"] .lang-de { display: none; }
body[data-lang="en"] .lang-en-block { display: block; }
body[data-lang="en"] .lang-de-block { display: none; }

.lang-toggle {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all 0.15s;
    line-height: 1.4;
}
.lang-toggle:hover {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    border-color: rgba(255,255,255,0.25);
}

/* --- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-1);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--eth-blue); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--eth-blue-dark); }

/* --- Header ------------------------------------------------- */
.site-header {
    background: var(--navy);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--nav-height);
    background-image:
        radial-gradient(ellipse at 0% 0%, rgba(33,92,175,0.30) 0%, transparent 55%),
        radial-gradient(ellipse at 100% 100%, rgba(14,165,233,0.08) 0%, transparent 50%);
}
.nav-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.brand-wordmark {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.10em;
    line-height: 1;
}
.brand-sub {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-inv-muted);
    letter-spacing: 0.02em;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(255,255,255,0.14);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.nav-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-inv-muted);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.15s;
}
.nav-link:hover { color: #fff; text-decoration: none; }

/* --- InfluxDB status chip ---------------------------------- */
.influx-status {
    font-size: 0.68rem;
    font-weight: 500;
    font-family: var(--font-mono);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

/* --- Main content ------------------------------------------ */
.site-main {
    flex: 1;
    max-width: var(--content-width);
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
}

/* --- Footer ------------------------------------------------- */
.site-footer {
    background: var(--navy);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 1.2rem 2rem;
}
.footer-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.footer-brand {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.10em;
}
.footer-text {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.22);
    font-family: var(--font-body);
}

/* --- Generic card ------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.card-body {
    padding: 1.25rem;
}

/* --- Section labels ---------------------------------------- */
.section-label {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

/* --- Map ---------------------------------------------------- */
#map {
    z-index: 1;
    display: block;
}

/* --- Status dots ------------------------------------------- */
.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    vertical-align: middle;
}
.status-green {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-bg);
    animation: pulse-green 2.8s ease-in-out infinite;
}
.status-yellow {
    background: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-bg);
}
.status-red {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-bg);
}
.status-unknown {
    background: var(--gray);
    box-shadow: 0 0 0 3px var(--gray-bg);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 3px var(--green-bg); }
    50%       { box-shadow: 0 0 0 5px rgba(22,163,74,0.18); }
}

/* --- Stations table ---------------------------------------- */
.stations-table-wrapper { overflow-x: auto; }
.stations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.stations-table th {
    padding: 0.625rem 1.125rem;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.stations-table td {
    padding: 0.8rem 1.125rem;
    border-bottom: 1px solid var(--surface-3);
    vertical-align: middle;
}
.stations-table tr:last-child td { border-bottom: none; }
.stations-table tbody tr { transition: background 0.1s; }
.stations-table tbody tr:hover { background: var(--surface-2); }

.station-name {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-1);
    letter-spacing: 0.03em;
}
.last-seen {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-2);
}

/* --- Sensor badges ----------------------------------------- */
.sensor-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    padding: 2px 8px;
    margin: 1px 2px;
    border-radius: var(--r-sm);
    background: var(--accent-bg);
    color: #0369a1;
    border: 1px solid var(--accent-border);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* --- Details button ---------------------------------------- */
.btn-detail {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: var(--font-body);
    white-space: nowrap;
}
.btn-detail::after { content: '→'; font-size: 0.85rem; }
.btn-detail:hover {
    background: var(--eth-blue);
    border-color: var(--eth-blue);
    color: white;
    text-decoration: none;
}

/* --- Pipeline status --------------------------------------- */
.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--border);
}
.pipeline-stat {
    background: var(--surface);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.pipeline-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
}
.pipeline-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-1);
}
.pipeline-value-sm {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-1);
}
.pipeline-unit {
    font-size: 0.72rem;
    color: var(--text-3);
    margin-left: 2px;
}
.pipeline-errors { margin-top: 1rem; }
.pipeline-errors summary {
    font-size: 0.78rem;
    color: var(--red);
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    font-family: var(--font-body);
}
.pipeline-errors ul {
    margin-top: 0.5rem;
    padding-left: 1.25rem;
    list-style: disc;
}
.pipeline-errors li {
    font-size: 0.72rem;
    color: var(--text-2);
    font-family: var(--font-mono);
    padding: 2px 0;
}

/* --- Station hero ------------------------------------------ */
.station-hero {
    background: var(--navy);
    background-image:
        radial-gradient(ellipse at 8% 60%, rgba(33,92,175,0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 92% 20%, rgba(14,165,233,0.12) 0%, transparent 50%);
    border-radius: var(--r-lg);
    padding: 1.75rem 2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}
.station-hero-left {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.station-breadcrumb {
    font-size: 0.75rem;
    color: var(--text-inv-muted);
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.station-breadcrumb a {
    color: var(--text-inv-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.station-breadcrumb a:hover { color: white; text-decoration: none; }
.station-breadcrumb-sep { opacity: 0.35; }
.station-hero-name {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 500;
    color: white;
    letter-spacing: 0.06em;
    line-height: 1;
}
.station-hero-coords {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-inv-muted);
    letter-spacing: 0.03em;
}

/* --- Sensor cards ------------------------------------------ */
.sensor-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}
.sensor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}
.sensor-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.sensor-card-header {
    padding: 0.7rem 1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sensor-card-name {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--eth-blue);
    letter-spacing: 0.03em;
}
.sensor-card-body {
    padding: 0.75rem 1rem;
    flex: 1;
}
.value-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 5px 0;
    border-bottom: 1px solid var(--surface-3);
}
.value-row:last-child { border-bottom: none; }
.value-label {
    font-size: 0.78rem;
    color: var(--text-3);
}
.value-number {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
}
.value-unit {
    font-size: 0.68rem;
    color: var(--text-3);
    margin-left: 2px;
}
.sensor-card-footer {
    padding: 0.45rem 1rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.sensor-card-ts {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-3);
}

/* --- Time selector ----------------------------------------- */
.time-selector {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.time-btn {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
}
.time-btn:hover {
    background: var(--eth-blue-muted);
    border-color: var(--eth-blue);
    color: var(--eth-blue-dark);
}
.time-btn.active {
    background: var(--eth-blue);
    border-color: var(--eth-blue);
    color: white;
}

/* --- Chart cards ------------------------------------------- */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}
.chart-card-header {
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.chart-card-title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--eth-blue);
    letter-spacing: 0.03em;
}
.chart-card-body {
    padding: 1rem 1.25rem 1.25rem;
}
.chart-card-body canvas {
    max-height: 280px;
}

/* --- Spacing helpers --------------------------------------- */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
    :root { --nav-height: 56px; }
    .site-main { padding: 1.25rem 1rem 2rem; }
    .brand-sub { display: none; }
    .pipeline-grid { grid-template-columns: 1fr; }
    .station-hero { padding: 1.25rem 1.25rem; }
    .station-hero-name { font-size: 1.6rem; }
    .sensor-cards-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .sensor-cards-grid { grid-template-columns: 1fr; }
    .time-selector { flex-wrap: wrap; }
    .station-hero { flex-direction: column; }
}
