﻿/* ============================================================
   Telavexa shell — header, sidebar, page background, typography.
   Design tokens live in css/tokens.css (loaded before this file).
   ============================================================ */

/* "Telavexa Technical Background" lives directly on html/body, not on a separate
   positioned div. That div (z-index:-1, sibling of #app) was a bad idea: z-index only
   ranks elements *within the same stacking context*, and whether header/sidebar/cards end
   up in that same context (and therefore actually respect -1) depends on browser specifics
   that turned out not to hold here — z-index:-1 hid the background behind body's own paint
   entirely, and z-index:0 made it paint OVER the header and cards instead of behind them.
   body's background has no such ambiguity: the CSS spec special-cases it as the page's
   "canvas" background, always painted at the absolute bottom of everything regardless of
   z-index, stacking contexts, or DOM position — no positioning trick needed at all.
   #sidebar and #fleetweb-header still mask it out over their own area exactly as before,
   because they simply paint their own opaque backgrounds on top as normal DOM children. */
html, body {
    background-color: var(--tvx-bg);
    background-image: var(--tvx-main-glow);
    background-repeat: no-repeat, repeat, repeat, no-repeat;
    background-position: 0 0, 0 0, 0 0, 0 0;
    background-size: 100vw 100vh, auto, auto, 100vw 100vh;
    background-attachment: fixed, fixed, fixed, fixed;
    color: var(--tvx-fg);
}

h1, h2, h3, h4, h5, h6,
.navbar-brand, .card-header, .accordion-button {
    font-family: var(--tvx-font-display);
    letter-spacing: 0.02em;
}

.tvx-label {
    font-family: var(--tvx-font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--tvx-fg3);
    text-transform: uppercase;
}

.tvx-mono {
    font-family: var(--tvx-font-mono);
}

/* Focus-visible ring — accessibility: keyboard nav must be clearly visible on a dark UI */
a:focus-visible, button:focus-visible, .btn:focus-visible,
.nav-link:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--tvx-yellow);
    outline-offset: 2px;
}

#boot-overlay {
    position: fixed;
    inset: 0;
    background: var(--tvx-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s ease;
}

#boot-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#boot-overlay video {
    width: min(95vw, 1200px);
    display: block;
}

/* These mp4s aren't transparent — each has its own baked-in dark/light background — so the
   file has to match the page background it's sitting on, not the ink-color convention the
   static logo PNGs use. Both videos sit in the DOM (see index.html); only one is ever
   visible, picked from html[data-theme] which is set synchronously before this markup
   paints, so there's no flash of the wrong one. */
#boot-overlay .tvx-boot-logo-dark { display: block; }
#boot-overlay .tvx-boot-logo-light { display: none; }

[data-theme="light"] #boot-overlay .tvx-boot-logo-dark { display: none; }
[data-theme="light"] #boot-overlay .tvx-boot-logo-light { display: block; }

/* In-page loading indicator (TvxSpinner.razor): the Telavexa mark, looping, standing in for
   Bootstrap's spinner-border. Same dark/light-pick-by-theme pattern as #boot-overlay above,
   scoped to a class since a page can have several of these at once. */
.tvx-spinner {
    display: inline-block;
    width: 24rem;
    height: 24rem;
    vertical-align: -0.5em;
}

.tvx-spinner.tvx-spinner-sm {
    width: 4rem;
    height: 4rem;
}

.tvx-spinner.tvx-spinner-lg {
    width: 14rem;
    height: 14rem;
}

.tvx-spinner video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.tvx-spinner .tvx-spinner-dark { display: block; }
.tvx-spinner .tvx-spinner-light { display: none; }
[data-theme="light"] .tvx-spinner .tvx-spinner-dark { display: none; }
[data-theme="light"] .tvx-spinner .tvx-spinner-light { display: block; }

/* Opt-out for spinners sitting over a fixed dark scrim regardless of page theme (e.g. the
   VehicleDetail refresh overlay) — always show the mark whose baked-in background is dark,
   never the theme pick. */
.tvx-spinner.tvx-spinner-force-dark .tvx-spinner-dark { display: block !important; }
.tvx-spinner.tvx-spinner-force-dark .tvx-spinner-light { display: none !important; }

/* !important on background/height: Bootstrap's own responsive .offcanvas-lg rule sets
   background-color: transparent !important and height: auto !important (same trick
   #fleetweb-header below already needed for its own background). Without matching
   !important here, Bootstrap's rule wins regardless of #sidebar's higher ID specificity —
   important always beats specificity — which is what let the page's background glow show
   through the sidebar (transparent bg) and past its lower half (collapsed to content
   height instead of the full column). */
#sidebar {
    background: var(--tvx-rail) !important;
    color: var(--tvx-fg);
    border-right: 1px solid var(--tvx-border);
}

#fleetweb-header {
    background: var(--tvx-graphite) !important;
    border-bottom: 1px solid var(--tvx-border) !important;
}

/* Mobile hamburger icon — Bootstrap's default .navbar-toggler-icon is a dark stroke,
   right for light theme's white header. Re-apply Bootstrap's own .navbar-dark variant
   (light stroke) for dark theme, where the header is dark instead. */
[data-theme="dark"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

[data-theme="dark"] .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Sidebar brand strip — matches the reference artifact's layout: the Telavexa mark lives
   at the top of the nav rail, not in the top header bar. */
.tvx-sidebar-brand {
    height: 60px;
    flex: 0 0 60px;
    padding: 0 16px;
}

.tvx-sidebar-brand .offcanvas-title {
    display: flex;
    align-items: center;
}

/* Nav rail links — left accent bar on hover/active, matches design reference */
#sidebar .nav-link {
    position: relative;
    /* Explicit instead of relying on inherited body color: Bootstrap's own --bs-nav-link-color
       resolves to --bs-link-color (School Bus Yellow, see the retheme block in tokens.css),
       which would make every nav item look "active" instead of just the hover/active state
       below. */
    color: var(--tvx-fg2);
    border-radius: 0 !important;
    border-left: 3px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
}

/* Sidebar brand mark — two logo variants (light-on-dark / dark-on-light) swapped purely by
   [data-theme] so the mark stays visible against the sidebar's own background in both
   themes (see NavMenu.razor). */
.tvx-logo-dark {
    display: none;
}

[data-theme="light"] .tvx-logo-light {
    display: none;
}

[data-theme="light"] .tvx-logo-dark {
    display: inline-block;
}

/* Sidebar close button (mobile offcanvas) — Bootstrap's own .btn-close-white filter,
   applied only for dark theme; the plain .btn-close (dark X) already reads fine on
   light theme's white sidebar. */
[data-theme="dark"] #sidebar .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* LoginDisplay (bottom of sidebar) — same reasoning as #sidebar .nav-link above: without
   an explicit color, the "Hello, <user>" text and the settings/logout icon buttons
   (Bootstrap .btn-link) would inherit School Bus Yellow from --bs-link-color. */
.tvx-sidebar-link-icon {
    color: var(--tvx-fg2) !important;
}

.tvx-sidebar-link-icon:hover {
    color: var(--tvx-yellow-fg) !important;
}

#sidebar .nav-link:hover {
    background-color: var(--tvx-rail-hover) !important;
    border-left-color: var(--tvx-yellow-fg);
}

#sidebar .nav-link.active {
    background-color: var(--tvx-rail-hover) !important;
    border-left-color: var(--tvx-yellow-fg);
    color: var(--tvx-fg) !important;
}

/* Cards / panels — sharp corners, translucent Graphite surface, subtle shadow (no
   decorative gradients on components — the gradient is reserved for the page bg).
   Bootstrap's own .card rule declares --bs-card-bg: var(--bs-body-bg) directly on
   .card itself, which — because it's set on the element, not just inherited from
   :root — beats tokens.css's :root-level --bs-card-bg every time, resolving to
   transparent and letting the page's warm glow show through with no dark overlay
   at all. Redeclaring it here (loaded after bootstrap.min.css) on the same .card
   selector is what actually wins. */
.card, .accordion-item, .list-group {
    --bs-card-bg: rgba(21, 23, 29, 0.4);
    background: var(--bs-card-bg);
    border: 1px solid var(--tvx-border);
    border-radius: 0 !important;
    box-shadow: var(--tvx-shadow-card);
}

/* A card nested inside another card (e.g. OwaConfigs' per-CAN-bus tiles) needs a border
   that actually reads against the outer card's own translucent surface. */
.card .card {
    border-color: var(--tvx-border-strong);
}

/* Overlays — must stay fully opaque (unlike the translucent dashboard panels above) or
   their text becomes unreadable against whatever page content sits behind them. */
.modal-content, .dropdown-menu, .offcanvas {
    background: var(--tvx-graphite);
    border-radius: 0 !important;
    box-shadow: var(--tvx-shadow-card);
}

.card-header, .accordion-button, .list-group-item, .accordion-body {
    background: transparent;
    color: var(--tvx-fg);
}

.accordion-button:not(.collapsed) {
    background: var(--tvx-hover);
    color: var(--tvx-fg);
    box-shadow: inset 0 -1px 0 var(--tvx-border);
}

.accordion-button::after {
    filter: invert(1) grayscale(1) brightness(1.6);
}

.list-group-item {
    border-color: var(--tvx-border) !important;
}

.list-group-item-action:hover {
    background: var(--tvx-hover) !important;
}

.nav-tabs {
    border-bottom-color: var(--tvx-border);
}

.nav-tabs .nav-link {
    color: var(--tvx-fg2);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-link:hover {
    color: var(--tvx-fg);
    background: transparent;
    border-bottom-color: var(--tvx-yellow);
}

.btn {
    border-radius: var(--tvx-radius) !important;
}

/* Positive/"do something" action buttons (Create, Add, Configure, Apply, Save...) all read
   as the same brand yellow — Bootstrap's semantic color classes (primary/success) don't map
   to distinct meanings in this app's actual usage, they're just whichever class each button
   happened to be given. .btn-danger (Delete/Unlink) is deliberately left alone — that's the
   one place a different color (red) is actually load-bearing, marking a destructive action
   apart from every other button.
   The --bs-btn-disabled-* custom properties are redeclared alongside the plain background/
   border/color, not left to fall back on Bootstrap's own — Bootstrap's compiled .btn-primary
   rule bakes its own literal --bs-btn-disabled-bg: #0d6efd (etc.) directly on that same
   .btn-primary selector, and .btn:disabled (a *higher-specificity* class+pseudo-class
   selector, 0,2,0 vs our plain class's 0,1,0) is what actually reads --bs-btn-disabled-bg to
   paint a disabled button — so a disabled "Add" button was falling back to Bootstrap's blue
   regardless of our override, since we'd only ever repainted the *enabled* state. Redeclaring
   the variables here (not the background-color property directly, which .btn:disabled would
   still out-specificity) is what actually reaches that rule: same selector + later file beats
   Bootstrap's own value for the variable itself. */
.btn-primary, .btn-success {
    background: var(--tvx-yellow);
    border-color: var(--tvx-yellow);
    color: var(--tvx-carbon);
    font-weight: 600;
    --bs-btn-disabled-bg: var(--tvx-yellow);
    --bs-btn-disabled-border-color: var(--tvx-yellow);
    --bs-btn-disabled-color: var(--tvx-carbon);
}

.btn-primary:hover, .btn-primary:focus,
.btn-success:hover, .btn-success:focus {
    background: var(--tvx-yellow-hover);
    border-color: var(--tvx-yellow-hover);
    color: var(--tvx-carbon);
}

.btn-outline-success {
    color: var(--tvx-yellow-fg);
    background: rgba(240, 220, 0, 0.12);
    border-color: var(--tvx-yellow-fg);
    --bs-btn-disabled-bg: rgba(240, 220, 0, 0.12);
    --bs-btn-disabled-border-color: var(--tvx-yellow-fg);
    --bs-btn-disabled-color: var(--tvx-yellow-fg);
}

.btn-outline-success:hover, .btn-outline-success:focus {
    background: var(--tvx-yellow);
    border-color: var(--tvx-yellow);
    color: var(--tvx-carbon);
}

/* Outline buttons get a faint tinted fill rather than pure transparent — against a busy
   translucent-card-over-glow background a purely-outlined button (e.g. the per-format
   download buttons on Datalogger Detail) all but disappears. */
.btn-outline-secondary {
    color: var(--tvx-fg2);
    background: var(--tvx-chip);
    border-color: var(--tvx-border-strong);
}

.btn-outline-secondary:hover {
    background: var(--tvx-hover);
    border-color: var(--tvx-yellow-fg);
    color: var(--tvx-fg);
}

.btn-outline-primary {
    color: var(--tvx-yellow-fg);
    background: rgba(240, 220, 0, 0.12);
    border-color: var(--tvx-yellow-fg);
    /* see the comment above .btn-primary — same reason this needs redeclaring, not just
       the plain color/background/border-color, for the disabled state to actually pick it up */
    --bs-btn-disabled-bg: rgba(240, 220, 0, 0.12);
    --bs-btn-disabled-border-color: var(--tvx-yellow-fg);
    --bs-btn-disabled-color: var(--tvx-yellow-fg);
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--tvx-yellow);
    border-color: var(--tvx-yellow);
    color: var(--tvx-carbon);
}

.badge {
    border-radius: 0 !important;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* No circles or rounded corners anywhere in the product — squares throughout, including
   Bootstrap's own rounding utilities (.rounded-3, .rounded-circle, .rounded-pill, ...) and
   the little color-swatch dots used as legend/signal-list markers. Spinners are exempt
   (a spinning circle is inherent to the loading-indicator convention, not decoration). */
.rounded, .rounded-0, .rounded-1, .rounded-2, .rounded-3, .rounded-4, .rounded-5,
.rounded-circle, .rounded-pill,
.rounded-top, .rounded-bottom, .rounded-start, .rounded-end {
    border-radius: 0 !important;
}

.form-select, .form-control {
    background-color: var(--tvx-chip);
    border-color: var(--tvx-border);
    color: var(--tvx-fg);
    border-radius: var(--tvx-radius) !important;
}

.form-select:focus, .form-control:focus {
    background-color: var(--tvx-chip);
    color: var(--tvx-fg);
    border-color: var(--tvx-yellow);
    box-shadow: 0 0 0 1px var(--tvx-yellow);
}

/* Native date/time inputs render their own browser-supplied text + calendar/clock icon,
   which default to a light color scheme regardless of our own dark styling — invisible
   dark-on-dark text otherwise. color-scheme flips the browser's own picker UI to dark too. */
input[type="date"], input[type="time"], input[type="datetime-local"] {
    color-scheme: dark;
}

/* Checkboxes only — .rounded-circle above already squares off any decorative dot, and
   radio buttons keep their native circle (that's a UI convention, not decoration). */
.form-check-input[type="checkbox"] {
    border-radius: 0 !important;
}

/* Checkboxes, radios, and toggle switches (.form-check-input[type=checkbox/radio],
   role="switch") all default to Bootstrap blue when checked — brand them yellow
   instead, with Carbon Black checkmarks/dots so they stay legible on the yellow fill. */
.form-check-input {
    border-color: var(--tvx-border-strong);
}

.form-check-input:checked {
    background-color: var(--tvx-yellow);
    border-color: var(--tvx-yellow);
}

.form-check-input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%230A0A0C'%3e%3cpath d='M0 11l2-2 5 5L18 3l2 2L7 18z'/%3e%3c/svg%3e");
}

.form-check-input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%230A0A0C'/%3e%3c/svg%3e");
}

.form-switch .form-check-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%235A5A60'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%230A0A0C'/%3e%3c/svg%3e");
}

.form-check-input:focus {
    border-color: var(--tvx-yellow);
    box-shadow: 0 0 0 1px var(--tvx-yellow);
}

.table {
    color: var(--tvx-fg);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-bg: var(--tvx-hover);
    border-color: var(--tvx-border);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--tvx-border);
}

/* Table headers were relying on the (near-invisible) page background for contrast —
   give every table header row a solid bar and brighter, higher-contrast label text.
   --tvx-chip rather than the near-black --tvx-sunken, which read as too harsh/stark
   next to the rest of the (translucent, softer) card surfaces. */
.table thead, .table > :not(caption) > thead {
    background: var(--tvx-chip);
}

.table thead th {
    color: var(--tvx-fg2);
    font-weight: 600;
    border-bottom: 1px solid var(--tvx-border-strong) !important;
}

/* Solid (non-translucent) sunken panel — used where a translucent card would otherwise
   let the page's warm glow bleed through and wreck contrast (chart frame, signal-chart
   readout table, other data-dense panels that need to stay legible above all else). */
.tvx-panel-sunken {
    background: var(--tvx-sunken) !important;
    border-color: var(--tvx-border) !important;
}

.tvx-table-head-bar {
    background: var(--tvx-graphite) !important;
    border-color: var(--tvx-border) !important;
}

.tvx-table-head th {
    color: var(--tvx-fg2) !important;
    font-weight: 600;
}

hr {
    border-color: var(--tvx-border);
    opacity: 1;
}

.text-muted {
    color: var(--tvx-fg3) !important;
}

/* ============================================================
   Home dashboard — stat tiles, vehicle status rows, event stream.
   ============================================================ */

.tvx-stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.tvx-stat-tile {
    background: var(--bs-card-bg);
    box-shadow: var(--tvx-shadow-card);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tvx-stat-value {
    font-family: var(--tvx-font-display);
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--tvx-fg);
}

.tvx-stat-sub {
    font-family: var(--tvx-font-body);
    font-size: 12px;
    font-weight: 400;
    color: var(--tvx-fg3);
}

/* Vehicle status rows (Online/Recent/Offline lists) */
.tvx-veh-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tvx-veh-alias {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--tvx-fg);
}

.tvx-veh-alias:hover {
    color: var(--tvx-yellow-fg);
}

.tvx-soc-bar {
    width: 56px;
    flex: 0 0 56px;
    height: 6px;
    background: var(--tvx-sunken);
    border: 1px solid var(--tvx-border);
}

.tvx-soc-bar > div {
    height: 100%;
}

.tvx-veh-soc {
    flex: 0 0 auto;
    width: 38px;
    text-align: right;
    font-size: 11.5px;
    font-weight: 500;
}

.tvx-veh-last {
    flex: 0 0 auto;
    width: 56px;
    text-align: right;
    font-size: 11px;
}

/* ============================================================
   Home dashboard — KPI tiles as filter buttons, and the vehicle
   table that replaced the Online/Recent/Offline accordion.
   ============================================================ */

/* A .tvx-stat-tile that's also a <button>: same look, plus a pointer cursor,
   left-aligned text (buttons center by default) and a selected/active state. */
.tvx-stat-btn {
    cursor: pointer;
    text-align: left;
    border: 1px solid var(--tvx-border);
    font: inherit;
    width: 100%;
}

.tvx-stat-btn:hover {
    border-color: var(--tvx-border-strong);
}

.tvx-stat-btn.active {
    border-color: var(--tvx-yellow-fg);
    background: rgba(240, 220, 0, 0.08);
}

.tvx-veh-table-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.tvx-veh-table-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--tvx-border);
    flex: 0 0 auto;
}

.tvx-veh-table-head span {
    font-family: var(--tvx-font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--tvx-fg3);
    text-transform: uppercase;
}

.tvx-veh-table-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.tvx-veh-table-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--tvx-border);
    text-decoration: none;
}

.tvx-veh-table-row:last-child {
    border-bottom: none;
}

.tvx-veh-table-row:hover .tvx-veh-alias {
    color: var(--tvx-yellow-fg);
}

.tvx-veh-dot {
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    border-radius: 50%;
}

/* SOC fill bar in the vehicle table — hidden by default (a plain % reads fine at
   table density on anything up to a small laptop), shown again on large desktop
   monitors (~19" and up) where there's width to spare. See RenderVehicleTableRow,
   which always renders this markup; only its visibility is breakpoint-driven. */
.tvx-veh-table-bar {
    display: none;
}

@media (min-width: 1600px) {
    .tvx-veh-table-bar {
        display: block;
    }
}

/* Phones (<576px): KPI tiles 3-per-row instead of one-per-row, with tighter type
   so five+ tiles fit without feeling cramped. */
@media (max-width: 575.98px) {
    .tvx-stat-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .tvx-stat-tile {
        padding: 8px;
        gap: 4px;
    }

    .tvx-stat-tile .tvx-label {
        font-size: 8px;
    }

    .tvx-stat-value {
        font-size: 18px;
        gap: 4px;
    }

    .tvx-stat-sub {
        font-size: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Stacked layout (container narrower than the side-by-side breakpoint below): cap
   visible rows and scroll — 3 on a phone-width viewport, 5 otherwise. */
@media (max-width: 575.98px) {
    .tvx-veh-table-body {
        max-height: 132px; /* ~3 rows */
    }
}

@media (min-width: 576px) {
    .tvx-veh-table-body {
        max-height: 220px; /* ~5 rows */
    }
}

/* Vehicle table + map: side-by-side, table height matched to the map, once the
   actual content column has room — a CONTAINER query, not a viewport one, since
   the same viewport width can leave very different content width depending on
   whether the real sidebar is pinned open or collapsed to a hamburger drawer.
   Gated separately for mouse vs touch: a touch tablet in PORTRAIT (e.g. iPad Pro
   13, ~984px of content once its sidebar collapses to a hamburger) has almost the
   exact same content width as a mouse-driven small laptop with its sidebar PINNED
   (~992px) — width alone can't tell those two apart, even though they're meant to
   lay out differently, so touch devices go by orientation instead of width. */
.tvx-veh-map-row {
    container-type: inline-size;
    container-name: tvx-veh-map;
}

@media (pointer: fine) {
    @container tvx-veh-map (min-width: 760px) {
        .tvx-veh-map-row .row {
            display: grid;
            /* Vehicle card = 1/3, map = 2/3 of the row — minmax(300px, 1fr) keeps the
               vehicle column from being crushed narrower than 300px on the smaller
               end of this range, at the cost of the 1/3 ratio there. */
            grid-template-columns: minmax(300px, 1fr) 2fr;
            align-items: stretch;
        }

        .tvx-veh-map-row .tvx-veh-col,
        .tvx-veh-map-row .tvx-map-col {
            max-width: 100%;
            min-width: 0;
        }

        .tvx-veh-map-row .tvx-veh-table-card,
        .tvx-veh-map-row #fleet-map-card {
            height: 100%;
        }

        .tvx-veh-map-row .tvx-veh-table-body {
            max-height: none;
        }
    }
}

@media (pointer: coarse) and (orientation: landscape) {
    @container tvx-veh-map (min-width: 760px) {
        .tvx-veh-map-row .row {
            display: grid;
            grid-template-columns: minmax(300px, 1fr) 2fr;
            align-items: stretch;
        }

        .tvx-veh-map-row .tvx-veh-col,
        .tvx-veh-map-row .tvx-map-col {
            max-width: 100%;
            min-width: 0;
        }

        .tvx-veh-map-row .tvx-veh-table-card,
        .tvx-veh-map-row #fleet-map-card {
            height: 100%;
        }

        .tvx-veh-map-row .tvx-veh-table-body {
            max-height: none;
        }
    }
}

/* Mobile (and any stacked layout — touch tablets in portrait too): the map fills
   whatever vertical space is left below the KPI row and vehicle table, instead of
   a fixed height. Flex-grow has to be threaded through every level of the actual
   Bootstrap .row/.col nesting for this to reach the map — flex-grow on a
   grandchild does nothing if its own direct parent isn't itself a growing flex
   item in a COLUMN direction. */
@media (max-width: 575.98px), (pointer: coarse) and (orientation: portrait) {
    .tvx-home-page {
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - var(--header-h) - 2rem);
    }

    .tvx-home-page .tvx-veh-map-row {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .tvx-home-page .tvx-veh-map-row .row {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .tvx-home-page .tvx-veh-col {
        flex: 0 0 auto;
    }

    .tvx-home-page .tvx-map-col {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .tvx-home-page #fleet-map-card {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .tvx-home-page #fleet-map {
        flex: 1 1 auto;
        min-height: 160px;
        height: auto !important;
    }
}

/* "There's more below" chevron — shown while the event stream card is scrolled
   out of view, hidden once it scrolls into view (see FleetWeb.watchScrollHint
   in fleetweb.js, wired up from Home.razor). */
@keyframes tvx-bounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 6px); }
}

.tvx-scroll-hint {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 0);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(21, 23, 29, 0.85);
    border: 1px solid var(--tvx-border);
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 40;
    animation: tvx-bounce 1.6s ease-in-out infinite;
}

.tvx-scroll-hint.visible {
    display: flex;
}

/* Event stream — flat rows, not individually boxed cards */
.tvx-event-list {
    display: flex;
    flex-direction: column;
}

.tvx-event-row {
    display: grid;
    grid-template-columns: 52px auto minmax(120px, 220px) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--tvx-border);
    border-left: 2px solid transparent;
    cursor: pointer;
}

.tvx-event-row:hover {
    background: var(--tvx-hover);
}

.tvx-event-time {
    font-size: 11px;
    color: var(--tvx-fg3);
}

.tvx-event-badge {
    justify-self: start;
}

.tvx-event-vehicle {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tvx-fg);
}

@media (max-width: 640px) {
    .tvx-event-row {
        grid-template-columns: 44px auto 1fr;
    }
    .tvx-event-vehicle {
        grid-column: 1 / -1;
    }
}

/* ============================================================
   Vehicle Detail — metric tiles (SOC / Speed / Odometer / Aux battery).
   ============================================================ */

.tvx-metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.tvx-metric-tile {
    background: var(--bs-card-bg);
    box-shadow: var(--tvx-shadow-card);
    padding: 13px 15px;
}

.tvx-metric-value {
    font-family: var(--tvx-font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--tvx-fg);
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-top: 8px;
}

.tvx-metric-unit {
    font-family: var(--tvx-font-body);
    font-size: 13px;
    font-weight: 400;
    color: var(--tvx-fg3);
}

.tvx-metric-tile .tvx-soc-bar {
    width: 100%;
    height: 5px;
    margin-top: 9px;
}

/* Map legend overlay — solid (not translucent) so it's always readable regardless of
   what's on the map tile underneath it, matching the artifact's floating legend box. */
/* A normal header bar above the map (not overlaid on top of the tiles) — same treatment
   as any other card header. */
.tvx-map-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--tvx-border);
}

.tvx-map-controls .form-check-label {
    color: var(--tvx-fg2);
    font-size: 13px;
}

.tvx-map-legend {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 500; /* above Leaflet's panes (max ~400) */
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    background: var(--tvx-graphite);
    border: 1px solid var(--tvx-border);
    padding: 6px 10px;
    font-size: 12px;
    color: var(--tvx-fg2);
}

.tvx-speed-bars {
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 26px;
    margin-top: 10px;
}

.tvx-speed-bars > div {
    flex: 1 1 auto;
    min-height: 1px;
    background: var(--tvx-info);
    opacity: 0.7;
}

.veh-container {
    position: relative;
    /* While loading, the only in-flow content is the hidden (display:none) page body,
       so this container's auto height collapses to 0 — which makes .veh-loader's
       absolute inset:0 resolve against a 0-height box instead of the viewport, and it
       ends up mispositioned near the top instead of centered. A min-height guarantees
       there's always room to center the spinner in, loading or not. */
    min-height: 60vh;
}

.veh-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 12, .55);
    backdrop-filter: blur(2px);
    z-index: 1050;
    pointer-events: all;
}

[data-theme="light"] .veh-loader {
    background: rgba(246, 245, 240, .7);
}

/* Vehicle photo (top row, next to the vehicle/datalogger cards). On lg+ the three columns
   sit in one Bootstrap flex row with the default align-items:stretch, so they're already
   forced to equal height — but a plain <img style="height:100%"> can't resolve that
   percentage (the column's own height depends on the image, circularly), so browsers fall
   back to the image's intrinsic aspect ratio and the photo ends up far taller than the
   text cards next to it. Taking the image out of flow (position:absolute inside a
   position:relative wrapper) removes it from that height calculation entirely, so the
   wrapper's stretched height comes purely from its siblings (the vehicle/datalogger cards)
   and the image just fills whatever that turns out to be. Below lg the columns stack
   (one per row) and stretch no longer applies, so give it an explicit height there instead. */
.veh-photo {
    position: relative;
    height: 220px;
    overflow: hidden;
    border: 1px solid var(--tvx-border);
    box-shadow: var(--tvx-shadow-card);
}

.veh-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (min-width: 992px) {
    .veh-photo {
        height: 100%;
    }
}

/* === Fleet map basemap === */
/* fleetmap.js loads plain OSM tiles (light, keyless) for both themes — this filter is
   what turns them dark for dark theme. Scoped to .leaflet-tile-pane specifically (not
   .leaflet-container) so it only touches the raster tile images themselves; markers,
   popups, the zoom control, and the attribution strip live in their own Leaflet panes
   and are untouched, keeping their real brand colors instead of getting inverted along
   with the map. Gated to [data-theme="dark"] so light theme shows the same OSM tiles
   unfiltered ("standard leaflet tiles," as-is) instead of also inverting them. */
[data-theme="dark"] .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.6);
}

/* === Fleet map markers === */
/* Leaflet divIcon wrapper — resets Leaflet defaults so our card is fully in control */
.fleet-marker-leaflet-icon {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
}

/* Outer wrapper — positions the white card + pointer as a unit */
.fleet-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.45));
}

/* Card that holds the icon (and optional battery badge) — a faint School Bus Yellow tint
   (not the full-strength #F0DC00, which reads as too loud/saturated at marker size)
   instead of plain white. */
.fleet-marker__card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 6px;
    background: #fdf6cc;
    border: 1.5px solid rgba(10,10,12,.4);
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,.55);
}

/* Downward triangle pointer under the card */
.fleet-marker__card::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 8px solid #fdf6cc;
}

/* Cluster bubbles (leaflet.markercluster) — retheme from its default green to School Bus
   Yellow so grouped vehicles read as one family with the pin cards above. */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(240, 220, 0, 0.35);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: var(--tvx-yellow, #F0DC00);
    color: var(--tvx-carbon, #0A0A0C);
    font-weight: 700;
}

.fleet-marker__icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* Vertical battery badge — colour only, no percentage text */
.fleet-battery {
    width: 9px;
    height: 18px;
    flex-shrink: 0;
    border: 1.5px solid rgba(0,0,0,.35);
    border-radius: 2px;
    position: relative;
}

/* Battery nub at the top */
.fleet-battery::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 3px;
    background: rgba(0,0,0,.35);
    border-radius: 1px 1px 0 0;
}
/* DbcSignalSearchSelect — searchable combobox for Analytics Signal Mapping's DBC signal
   picker (Inventory.razor), used instead of a flat <select> since a DBC can carry ~30k
   signals. Matches the dark theme + gold focus ring used across the rest of the app. */
.dbc-signal-search-select {
    position: relative;
}

.dbc-signal-search-select input.form-control:focus {
    outline: 2px solid var(--tvx-yellow);
    outline-offset: 1px;
}

.dbc-signal-search-select-clear {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 6px;
    color: var(--tvx-fg2);
    text-decoration: none;
    line-height: 1;
}

.dbc-signal-search-select-clear:hover {
    color: var(--tvx-yellow-fg);
}

.dbc-signal-search-select-menu {
    position: absolute;
    z-index: 1080;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--tvx-graphite);
    border: 1px solid var(--tvx-border);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.dbc-signal-search-select-item {
    padding: 4px 10px;
    font-size: .8125rem;
    color: var(--tvx-fg);
    cursor: pointer;
    white-space: nowrap;
}

.dbc-signal-search-select-item:hover {
    background: var(--tvx-rail-hover);
}

.dbc-signal-search-select-item.active {
    background: var(--tvx-rail-hover);
    color: var(--tvx-yellow-fg);
}

.dbc-signal-search-select-empty {
    color: var(--tvx-fg2);
    cursor: default;
    white-space: normal;
}

.dbc-signal-search-select-empty:hover {
    background: none;
}

/* ── LTE link indicator (Components/LteIndicator.razor) ─────────────────────
   Green = good, red = poor; bars = 1–5 quality. Uses --tvx-ok / --tvx-err so it
   follows the light/dark tokens like the other status colors. */
.tvx-lte {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    font-size: 14px;
    cursor: default;
    white-space: nowrap;
}
.tvx-lte-good { color: var(--tvx-ok); }
.tvx-lte-bad  { color: var(--tvx-err); }
.tvx-lte-label { font-size: 12px; font-weight: 600; }

/* Tables with long device messages (S3 URLs, upload ids): fixed column widths so the message
   column can't push the others off-screen; text breaks anywhere and is clamped until expanded. */
.tvx-table-fixed { table-layout: fixed; width: 100%; }
.tvx-text-wrap { overflow-wrap: anywhere; word-break: break-word; }
.tvx-nowrap { white-space: nowrap; }
.tvx-clamp-3,
.tvx-clamp-2 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tvx-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.tvx-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }

/* Maintenance mode: green wrench next to the LTE indicator, only while active. */
.tvx-maint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    font-size: 14px;
    cursor: default;
    white-space: nowrap;
    color: var(--tvx-ok);
}
.tvx-maint-label { font-size: 12px; font-weight: 600; }

/* Support "Actions" column: compact icon buttons; a red dot marks a failed last request. */
.tvx-action-btn {
    position: relative;
    width: 32px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tvx-action-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tvx-err);
}

/* Home vehicle table: fixed last column so rows stay aligned with or without a logger
   (room for the LTE bars plus the maintenance wrench). */
.tvx-veh-lte {
    flex: 0 0 38px;
    display: inline-flex;
    justify-content: flex-end;
    gap: 4px;
}

/* Log Files card (Datalogger Detail, Cloud and Device tabs): the dates column sits beside the
   file list with a divider on wide screens, and stacks above it on narrow ones. */
@media (min-width: 992px) {
    .tvx-files-dates {
        border-right: 0.5px solid var(--tvx-border);
    }
}
.tvx-files-dates-list {
    max-height: 60vh;
    overflow-y: auto;
}

/* Leave room above the list when a page change scrolls it into view, so the toolbar isn't
   hidden under the 56px sticky header (#fleetweb-header). */
.tvx-files-list {
    scroll-margin-top: calc(56px + 1rem);
}
