/* ============================================================
   Telavexa design tokens — FleetWeb
   Source of truth: Telavexa UI Design Skill + the "Telavexa Portal
   Design Component" reference artifact. Dark theme is the default
   and primary theme for this data-heavy fleet-ops dashboard.
   ============================================================ */

:root {
    /* Brand */
    --tvx-yellow: #F0DC00;
    --tvx-yellow-hover: #FFF07A;
    --tvx-carbon: #0A0A0C;
    --tvx-white: #FEF1F1;
    /* Yellow-as-text/border variant — see the light-theme override below for why this
       needs to differ from --tvx-yellow at all. Same value here since #F0DC00 already
       has good contrast as text/outline against dark surfaces. */
    --tvx-yellow-fg: var(--tvx-yellow);
    /* Same idea, for --tvx-warn specifically (SOC % text, low-battery numerals) — kept
       separate from --tvx-yellow-fg so badge/bg-warning use of --tvx-warn as a BACKGROUND
       (fine in both themes — it's paired with dark text) is untouched. */
    --tvx-warn-fg: var(--tvx-warn);

    /* Surfaces (dark theme) — "Telavexa Technical Background" direction: solid near-black
       page bg + an ambient wash reserved for the main content area only (see main.content
       in telavexa.css). Deliberately darker than the earlier flat #14141A so the grid/
       telemetry-line texture (below) reads as ambient background detail rather than
       competing with cards, the map, and text for attention. */
    --tvx-bg: #0B0D12;
    /* Four layers, listed topmost-first (each painted over the one after it):
         1. telemetry waveform — five distinct curved traces evenly spaced across the
            *whole viewport* (a 640x900 tile, lines at y = 150/300/450/600/750 — i.e. every
            1/6th of the tile), not clustered in one band or cropped to a fraction of the
            width. Getting that "spread over/fill the full screen" look needs two things
            together, not just one: viewport-locking the layer (no-repeat + background-size:
            100vw 100vh + background-attachment: fixed on html/body) AND
            preserveAspectRatio="none" on the <svg> root itself — without that second part,
            the SVG ignores the CSS background-size entirely and falls back to its own
            default xMidYMid-meet "contain" behavior, rendering at its native 640x900 size
            centered in the box instead of actually stretching to fill it (verified: this is
            what was cropping the waves to a narrow centered strip regardless of the CSS
            sizing). An earlier version also tiled a 300px-tall strip with repeat-x, which
            only ever occupied one 300px band no matter how evenly the 5 lines were spaced
            *inside* that strip.
         2/3. technical grid — hairlines every 64px, tinted brand yellow, opacity ~0.03-0.035.
         4. radial glow — School Bus Yellow, dimmed a bit further (each stop ~10% darker
            again on top of the previous pass) while keeping the same shape/position,
            fading out to --tvx-bg at the edge. Still viewport-locked rather than
            content-box-locked (see the background-size on main.content) or its falloff
            balloons across the whole scrollable page instead of vignetting one screen. */
    --tvx-main-glow:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='900' viewBox='0 0 640 900' preserveAspectRatio='none'%3E%3Cpath d='M0,150 C80,110 160,190 240,150 C320,110 400,190 480,150 C560,110 640,190 640,150' stroke='%23F0DC00' stroke-width='1' fill='none' opacity='0.15'/%3E%3Cpath d='M0,300 C80,340 160,260 240,300 C320,340 400,260 480,300 C560,340 640,260 640,300' stroke='%23F0DC00' stroke-width='1' fill='none' opacity='0.11'/%3E%3Cpath d='M0,450 C80,410 160,490 240,450 C320,410 400,490 480,450 C560,410 640,490 640,450' stroke='%23F0DC00' stroke-width='1' fill='none' opacity='0.14'/%3E%3Cpath d='M0,600 C80,640 160,560 240,600 C320,640 400,560 480,600 C560,640 640,560 640,600' stroke='%23F0DC00' stroke-width='1' fill='none' opacity='0.10'/%3E%3Cpath d='M0,750 C80,710 160,790 240,750 C320,710 400,790 480,750 C560,710 640,790 640,750' stroke='%23F0DC00' stroke-width='1' fill='none' opacity='0.13'/%3E%3C/svg%3E"),
        repeating-linear-gradient(0deg, rgba(240, 220, 0, 0.035) 0 1px, rgba(0, 0, 0, 0) 1px 64px),
        repeating-linear-gradient(90deg, rgba(240, 220, 0, 0.03) 0 1px, rgba(0, 0, 0, 0) 1px 64px),
        radial-gradient(120% 90% at 52% 78%, #BEAE00 0%, #8C7700 20%, #5E4D0D 42%, #2C2718 68%, #0B0D12 100%);
    --tvx-graphite: #15171D;
    --tvx-iron: #2C2C30;
    --tvx-smoke: #5A5A60;
    --tvx-sunken: #17171D;
    --tvx-rail: #0D0F14;
    --tvx-rail-hover: #1A1D24;
    --tvx-hover: rgba(255, 255, 255, 0.04);
    --tvx-chip: #2F2F37;

    /* Text */
    --tvx-fg: #FEF1F1;
    --tvx-fg2: #B7BAC0;
    --tvx-fg3: #8B8B95;

    /* Status — the artifact's dark theme brightens these past the flat brand hues (used
       as-is on light backgrounds/badges) specifically for legibility as text/lines directly
       on a dark surface; keep in sync with wwwroot/js/fleetmap.js statusColor/batteryColor. */
    --tvx-ok: #34C46E;
    --tvx-warn: #F0DC00;
    --tvx-err: #FF6A3D;
    --tvx-info: #4E96F0;
    --tvx-ok-bg: #0d3d1f;
    --tvx-warn-bg: #3d3400;
    --tvx-err-bg: #3d1008;
    --tvx-info-bg: #0a2040;

    /* Borders / shadow — the artifact uses solid hex borders (not a translucent white
       overlay), which stay a consistent, predictable contrast regardless of what's showing
       through the translucent panel behind them. */
    --tvx-border: #35353E;
    --tvx-border-strong: #6C6C76;
    --tvx-shadow-card: 0 8px 28px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);

    /* Type */
    --tvx-font-display: 'Orbitron', system-ui, sans-serif;
    --tvx-font-body: 'Inter', 'Gellix', system-ui, -apple-system, sans-serif;
    --tvx-font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Sharp corners everywhere — the reference artifact uses square panels, badges,
       buttons and inputs throughout (the only rounded shapes are the map marker card
       and the logo mark, both styled directly rather than through these tokens). */
    --tvx-radius: 0;
    --tvx-radius-card: 0;
    --tvx-radius-pill: 0;
}

/* ---- Retheme Bootstrap so existing markup (badges, buttons, cards, tables,
   accordions, forms) picks up Telavexa colors without rewriting every page. ---- */
:root,
[data-bs-theme="dark"] {
    --bs-body-bg: transparent;
    --bs-body-color: var(--tvx-fg);
    --bs-body-font-family: var(--tvx-font-body);
    --bs-border-color: var(--tvx-border);
    --bs-border-radius: var(--tvx-radius);
    --bs-border-radius-sm: var(--tvx-radius);
    --bs-border-radius-lg: var(--tvx-radius-card);

    --bs-primary: var(--tvx-info);
    --bs-primary-rgb: 78, 150, 240;
    --bs-success: var(--tvx-ok);
    --bs-success-rgb: 52, 196, 110;
    --bs-warning: var(--tvx-warn);
    --bs-warning-rgb: 240, 220, 0;
    --bs-danger: var(--tvx-err);
    --bs-danger-rgb: 255, 106, 61;
    --bs-info: var(--tvx-info);
    --bs-info-rgb: 78, 150, 240;
    --bs-secondary: var(--tvx-smoke);
    --bs-secondary-rgb: 90, 90, 96;
    --bs-secondary-color: var(--tvx-fg2);
    /* Bootstrap pairs "bg-light" with "text-dark" throughout the app (e.g. muted/inactive
       badges) — bg-light must stay an actual light color for that combination to stay
       legible, so it's left as Bootstrap's default rather than remapped into the dark
       palette like the other theme colors above. */
    --bs-dark: var(--tvx-carbon);

    /* Cards are translucent --tvx-graphite (#15171D) so the main-glow texture shows through
       at the edges. (The earlier full-opacity pass was working around two real bugs — a
       missing --bs-tertiary-bg-rgb var and .shadow-sm's !important stomping the card
       shadow — both fixed below now, which was the actual cause of low contrast, not the
       translucency itself.) Overlays (modals/dropdowns/offcanvas) stay fully opaque. */
    --bs-card-bg: rgba(21, 23, 29, 0.4);
    --bs-card-border-color: var(--tvx-border);
    --bs-card-cap-bg: rgba(18, 20, 25, 0.46);
    /* .bg-body-tertiary (Signal Chart's chart frame + marker-readout header) reads
       --bs-tertiary-bg-*rgb*, not the plain hex var — without the -rgb variant the
       rgba() call is invalid and the background falls through to transparent,
       exposing the page's warm glow underneath instead of a proper dark panel. */
    --bs-tertiary-bg: var(--tvx-sunken);
    --bs-tertiary-bg-rgb: 23, 23, 29;
    --bs-emphasis-color: var(--tvx-fg);
    --bs-link-color: var(--tvx-yellow);
    --bs-link-hover-color: var(--tvx-yellow-hover);

    /* `.shadow-sm` (used alongside `.card` throughout — vehicle info, datalogger info,
       RouteMapCard, LiveMapCard, ...) applies its box-shadow with !important, which was
       silently overriding .card's own shadow with Bootstrap's near-invisible default.
       Point it at the same token so every card gets a consistent, visible shadow. */
    --bs-box-shadow-sm: var(--tvx-shadow-card);

    --bs-modal-bg: var(--tvx-graphite);
    --bs-modal-color: var(--tvx-fg);
    --bs-modal-border-color: var(--tvx-border);
    --bs-modal-header-border-color: var(--tvx-border);
    --bs-modal-footer-border-color: var(--tvx-border);
    --bs-dropdown-bg: var(--tvx-graphite);
    --bs-dropdown-color: var(--tvx-fg);
    --bs-dropdown-border-color: var(--tvx-border);
    --bs-dropdown-link-color: var(--tvx-fg);
    --bs-dropdown-link-hover-bg: var(--tvx-hover);
    --bs-offcanvas-bg: var(--tvx-rail);
    --bs-offcanvas-color: var(--tvx-fg);
}

/* Trip category — dedicated blue (info) chip/button, kept separate from .btn-primary /
   .bg-primary so the app's real primary-action buttons (Save, Create, Apply, Link, ...)
   stay the brand yellow CTA color; only Home's event-category toggle needs blue here. */
.badge-tvx-info {
    background-color: var(--tvx-info);
    color: #fff;
}

.btn-tvx-info {
    background-color: var(--tvx-info);
    border-color: var(--tvx-info);
    color: #fff;
}

.btn-tvx-info:hover, .btn-tvx-info:focus {
    background-color: #4E96F0;
    border-color: #4E96F0;
    color: #fff;
}

/* ============================================================
   Light theme — activated via [data-theme="light"] on <html>
   (set by FleetWeb.theme, see js/fleetweb.js + the inline snippet
   in index.html). Everything else in this file/telavexa.css reads
   these same --tvx-* custom properties, so redefining them here is
   enough to reflow the whole app — no need to duplicate every rule.

   This is a straight light/dark inversion of the dark theme above
   (near-black surfaces -> near-white, near-white text -> near-black),
   not the flatter white-page version from the brand skill: Telavexa
   Yellow keeps doing background/glow duty here too, just dialed back
   so it stays a wash rather than overpowering a light page. Status
   and brand hues (yellow/green/orange/blue) are unchanged — only
   their background tints move from dark fills to light tints.
   ============================================================ */
[data-theme="light"] {
    --tvx-bg: #F6F5F0;
    /* Dialed WAY back from a first pass that used solid hex stops the same way the dark
       theme does — on a near-white page that read as a heavy yellow wash burying every
       card/table underneath it, instead of the faint texture it's supposed to be. Every
       stop here is a low-alpha rgba() over transparent (not over --tvx-bg), so it's a
       subtle tint on top of whatever's already there rather than its own opaque block. */
    --tvx-main-glow:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='900' viewBox='0 0 640 900' preserveAspectRatio='none'%3E%3Cpath d='M0,150 C80,110 160,190 240,150 C320,110 400,190 480,150 C560,110 640,190 640,150' stroke='%23C4A800' stroke-width='1' fill='none' opacity='0.08'/%3E%3Cpath d='M0,300 C80,340 160,260 240,300 C320,340 400,260 480,300 C560,340 640,260 640,300' stroke='%23C4A800' stroke-width='1' fill='none' opacity='0.06'/%3E%3Cpath d='M0,450 C80,410 160,490 240,450 C320,410 400,490 480,450 C560,410 640,490 640,450' stroke='%23C4A800' stroke-width='1' fill='none' opacity='0.07'/%3E%3Cpath d='M0,600 C80,640 160,560 240,600 C320,640 400,560 480,600 C560,640 640,560 640,600' stroke='%23C4A800' stroke-width='1' fill='none' opacity='0.05'/%3E%3Cpath d='M0,750 C80,710 160,790 240,750 C320,710 400,790 480,750 C560,710 640,790 640,750' stroke='%23C4A800' stroke-width='1' fill='none' opacity='0.06'/%3E%3C/svg%3E"),
        repeating-linear-gradient(0deg, rgba(196, 168, 0, 0.035) 0 1px, rgba(0, 0, 0, 0) 1px 64px),
        repeating-linear-gradient(90deg, rgba(196, 168, 0, 0.03) 0 1px, rgba(0, 0, 0, 0) 1px 64px),
        radial-gradient(120% 90% at 52% 78%, rgba(255, 222, 120, 0.30) 0%, rgba(255, 222, 120, 0.14) 25%, rgba(240, 220, 150, 0.05) 50%, rgba(240, 220, 150, 0) 75%);

    --tvx-graphite: #FFFFFF;
    --tvx-iron: #E2E1DA;
    --tvx-smoke: #6B6B72;
    --tvx-sunken: #F0EFE8;
    --tvx-rail: #FFFFFF;
    --tvx-rail-hover: #EFEEE6;
    --tvx-hover: rgba(10, 10, 12, 0.045);
    --tvx-chip: #EAE9E1;

    /* Text */
    --tvx-fg: #15151A;
    --tvx-fg2: #45454D;
    --tvx-fg3: #6C6C74;

    /* Status backgrounds — light tints instead of dark fills; the foreground status
       hues (--tvx-ok/warn/err/info above) stay the same in both themes. */
    --tvx-ok-bg: #DDF3E5;
    --tvx-warn-bg: #FFF3B0;
    --tvx-err-bg: #FDE2DA;
    --tvx-info-bg: #DDEAFC;

    --tvx-border: #DFDED6;
    --tvx-border-strong: #B7B6AC;
    --tvx-shadow-card: 0 2px 10px rgba(20, 18, 10, 0.08), 0 1px 2px rgba(20, 18, 10, 0.06);

    /* School Bus Yellow (#F0DC00) used AS TEXT/border (outline buttons, hover accents) —
       not as a button's own solid background — fails contrast on a light page (~2:1
       against white). --tvx-yellow itself is untouched (still used for solid CTA fills,
       where the pairing is dark text on bright yellow, unaffected by theme); this
       darkened variant is for spots that render yellow as the foreground color instead.
       #8A7300 measures ~4.6:1 against white, clearing AA for normal text. */
    --tvx-yellow-fg: #8A7300;
    --tvx-warn-fg: #8A7300;
}

/* Bootstrap variables that read a literal color rather than a --tvx-* var (so they
   don't already follow the token overrides above) — see the matching dark-theme
   comments on the base :root block and on .card in telavexa.css for why these two
   in particular have to stay literal instead of using var(). */
[data-theme="light"] {
    --bs-tertiary-bg-rgb: 240, 239, 232; /* matches --tvx-sunken above */
    /* Root-level, not just scoped to .card below — .tvx-stat-tile/.tvx-metric-tile (Home,
       Vehicle Detail) read var(--bs-card-bg) directly without being a .card themselves,
       so they need this to inherit; the .card-scoped rule beneath still exists because
       .card redeclares --bs-card-bg literally on itself (see telavexa.css) and would
       otherwise win over inheriting this one. */
    --bs-card-bg: rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .card,
[data-theme="light"] .accordion-item,
[data-theme="light"] .list-group {
    --bs-card-bg: rgba(255, 255, 255, 0.72);
}
