/* ============================================================
   carFuel — App CSS
   Swiss Precision design system (adapted from portfolio-analytics)
   Bootstrap 5.3 + data-bs-theme="light|dark"
   Fonts: Hanken Grotesk (sans) · IBM Plex Mono (numbers/data)
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
    --cf-font-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    --cf-font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    /* Palette — light */
    --cf-bg: #f2f5fa;
    --cf-surface: #ffffff;
    --cf-surface-2: #eaeff7;
    --cf-text: #0a0f1e;
    --cf-text-2: #56637a;
    --cf-accent: #1d4ed8;
    --cf-accent-rgb: 29, 78, 216;
    --cf-positive: #0f6b3d;
    --cf-negative: #b91c1c;
    --cf-warn: #b45309;
    --cf-warn-faint: rgba(180, 83, 9, 0.08);
    --cf-border: #dde3ef;
    --cf-border-2: #c4ccdf;
    --cf-shadow: 0 1px 3px rgba(10, 15, 30, .05), 0 1px 2px rgba(10, 15, 30, .03);
    --cf-shadow-md: 0 4px 16px rgba(10, 15, 30, .08), 0 2px 6px rgba(10, 15, 30, .04);

    /* Chart line colours (legacy carfuel: consumption red, price green) */
    --cf-color-consumption: #dc2626;
    --cf-color-price: #059669;
}

[data-bs-theme="dark"] {
    --cf-bg: #080d17;
    --cf-surface: #111827;
    --cf-surface-2: #0d1525;
    --cf-text: #e2e8f7;
    --cf-text-2: #667799;
    --cf-accent: #3b82f6;
    --cf-accent-rgb: 59, 130, 246;
    --cf-positive: #34d399;
    --cf-negative: #f87171;
    --cf-warn: #fb923c;
    --cf-warn-faint: rgba(251, 146, 60, 0.10);
    --cf-border: #1a2540;
    --cf-border-2: #243052;
    --cf-shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .25);
    --cf-shadow-md: 0 4px 16px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .28);

    --cf-color-consumption: #f87171;
    --cf-color-price: #34d399;
}

/* ── Bootstrap variable overrides ──────────────────────────── */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-body-font-family: var(--cf-font-sans);
    --bs-body-bg: var(--cf-bg);
    --bs-body-color: var(--cf-text);
    --bs-card-bg: var(--cf-surface);
    --bs-border-color: var(--cf-border);
    --bs-secondary-bg: var(--cf-surface-2);
    --bs-secondary-color: var(--cf-text-2);
    --bs-primary: var(--cf-accent);
    --bs-primary-rgb: var(--cf-accent-rgb);
    --bs-font-monospace: var(--cf-font-mono);
    --bs-link-color: var(--cf-accent);
    --bs-success: var(--cf-positive);
    --bs-danger: var(--cf-negative);
    --bs-warning: var(--cf-warn);
}

/* ── Global base ───────────────────────────────────────────── */
body {
    font-family: var(--cf-font-sans);
    background: var(--cf-bg);
    color: var(--cf-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Room for the fixed #utilityStrip */
    padding-bottom: calc(2.75rem + env(safe-area-inset-bottom, 0px) + 1rem);
}

body, .card, .navbar, #utilityStrip, .table, .modal-content,
.form-control, .form-select, .btn, .badge, .nav-link {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.strip-emoji {
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
    vertical-align: -0.1em;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

/* Monospace for all numeric data */
.mono, .metric-value, .table td.num, .table th.num {
    font-family: var(--cf-font-mono);
    font-variant-numeric: tabular-nums;
}
.table td.num, .table th.num { text-align: right; }

/* ── Navbar ────────────────────────────────────────────────── */
#mainNav {
    background: var(--cf-surface) !important;
    border-bottom: 1px solid var(--cf-border) !important;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}
#mainNav .navbar-brand {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--cf-text);
}

/* ── Metric cards ──────────────────────────────────────────── */
.metric-card {
    border: 1px solid var(--cf-border);
    border-left: 2px solid var(--cf-accent);
    border-radius: 8px;
    background: var(--cf-surface);
    box-shadow: var(--cf-shadow);
    animation: cardReveal 0.45s ease both;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}
.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cf-shadow-md);
}
@keyframes cardReveal {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--cf-text);
}
.metric-unit {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--cf-text-2);
}
.metric-label {
    font-family: var(--cf-font-sans);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cf-text-2);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cf-text-2);
    border-bottom: 1px solid var(--cf-border-2);
    white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--cf-border); vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--cf-surface-2); }

/* Baseline row (excluded from stats) is de-emphasised */
tr.baseline-row td {
    opacity: 0.55;
    font-style: italic;
}

/* Drift + implausible odometer markers */
.drift-pos { color: var(--cf-warn); }
.drift-neg { color: var(--cf-text-2); }
.badge-implausible {
    background: var(--cf-warn-faint);
    color: var(--cf-warn);
    border: 1px solid var(--cf-warn);
}

/* ── Chart ─────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 340px; }

/* ── Utility strip (fixed footer toolbar) ──────────────────── */
#utilityStrip {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 2.75rem;
    padding: 0 0.75rem calc(env(safe-area-inset-bottom, 0px)) 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--cf-surface);
    border-top: 1px solid var(--cf-border);
    font-size: 0.75rem;
    z-index: 1030;
}
#utilityStrip .btn { line-height: 1; }
#stripVersion { font-family: var(--cf-font-mono); font-size: 0.7rem; }
#sessionBanner.warn     { color: var(--cf-warn); }
#sessionBanner.critical { color: var(--cf-negative); font-weight: 700; }

/* ── Auto-dismiss alerts ───────────────────────────────────── */
.alert.auto-dismiss { transition: opacity 0.4s ease; }

@media (max-width: 575.98px) {
    .metric-value { font-size: 1.25rem; }
    .chart-wrap { height: 260px; }
}
