/* =========================================================================
   TrackNow EMS & RTLS — theme
   Palette taken from the trackNOW / msbtrack reference site
   (https://www.tracknow.in/tracknow-products/msbtrack-pro/):
     amber/gold  #FAB800  — primary brand color (logo, active states, CTAs)
     charcoal    #222222  — dark chrome, headings, secondary buttons
     slate gray  #6E757A  — body copy / muted text
     light gray  #F4F6F8  — section backgrounds
   Bootstrap grid/components are left as-is; only colors, the brand mark
   and a few surface details (radius, borders) are restyled.
   ========================================================================= */

:root {
    --tn-amber: #fab800;
    --tn-amber-dark: #e0a400;
    --tn-amber-darker: #c98f00;
    --tn-amber-light: #fff4d6;
    --tn-amber-soft: #fdf0cf;

    --tn-dark: #202428;
    --tn-dark-2: #2b3036;
    --tn-charcoal: #333333;

    --tn-text: #24282c;
    --tn-text-muted: #6e757a;

    --tn-bg: #f4f6f8;
    --tn-card-radius: 10px;
    --tn-border: #e5e7ea;

    /* kept for status/priority semantics (not brand chrome) */
    --tn-red: #dc2626;
    --tn-green: #61a229;
    --tn-blue: #2563eb;
}

* { box-sizing: border-box; }

body.app-body {
    background: var(--tn-bg);
    font-family: "Work Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--tn-text);
    margin: 0;
}

body.auth-body {
    margin: 0;
    background:
        radial-gradient(circle at 15% 10%, rgba(250,184,0,0.16) 0%, rgba(250,184,0,0) 45%),
        linear-gradient(160deg, #1b1e21 0%, var(--tn-dark) 45%, #101214 100%);
    min-height: 100vh;
}

/* ---------- Shell layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--tn-dark) 0%, #121416 100%);
    color: #c9cdd2;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 3px solid var(--tn-amber);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* trackNOW-style wordmark: "track" in white + "NOW" in amber, with a
   location-pin accent, mirroring the reference site's logo. */
.brand-mark {
    width: 40px; height: 40px;
    background: var(--tn-amber);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #1a1a1a; letter-spacing: 0.5px;
    flex-shrink: 0;
}

.brand-wordmark {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1;
    white-space: nowrap;
}
.brand-wordmark .brand-track { color: #fff; }
.brand-wordmark .brand-now { color: var(--tn-amber); }
.brand-wordmark .brand-pin { color: var(--tn-amber); font-size: 0.9rem; margin-left: 3px; }

.brand-title { font-weight: 700; font-size: 1rem; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 0.72rem; color: #9aa0a6; letter-spacing: 0.02em; }

.sidebar-nav { padding: 10px 10px 24px; flex: 1; }

.nav-group-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: #7c8288;
    margin: 18px 12px 6px;
    font-weight: 600;
}

.nav-group-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #c9cdd2;
    text-decoration: none;
    font-size: 0.88rem;
    margin: 2px 4px;
    transition: background 0.15s, color 0.15s;
}

.nav-group-link i { font-size: 1rem; width: 18px; text-align: center; }

.nav-group-link:hover { background: rgba(250,184,0,0.12); color: #fff; }

.nav-group-link.active {
    background: linear-gradient(90deg, rgba(250,184,0,0.28), rgba(250,184,0,0.06));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--tn-amber);
}

/* ---------- Topbar ---------- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 26px;
    min-height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--tn-border);
    border-top: 3px solid var(--tn-amber);
    position: sticky; top: 0; z-index: 20;
    box-sizing: border-box;
}

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1.15rem; font-weight: 700; margin: 0; color: #1a1a1a; }
.topbar-subtitle { font-size: 0.8rem; color: var(--tn-text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 14px; }

/* ---------- Language switcher ---------- */
.lang-switch {
    display: flex; align-items: center; gap: 4px;
    font-size: 0.8rem; font-weight: 600;
}
.lang-switch a {
    color: var(--tn-text-muted);
    text-decoration: none;
    padding: 3px 6px;
    border-radius: 4px;
}
.lang-switch a.active { color: #1a1a1a; background: var(--tn-amber-light); }
.lang-switch a:hover { color: var(--tn-amber-darker); }
.lang-switch .lang-sep { color: var(--tn-border); }
.lang-switch-auth { position: fixed; top: 18px; right: 18px; z-index: 30; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 999px; padding: 4px 10px; }
.lang-switch-auth a { color: #cfd3d8; }
.lang-switch-auth a.active { color: #1a1a1a; background: var(--tn-amber); }
:root[dir="rtl"] .lang-switch-auth,
body.rtl .lang-switch-auth { right: auto; left: 18px; }

.org-pill {
    background: var(--tn-amber-light); color: #7a5900;
    padding: 5px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}

.user-chip {
    display: flex; align-items: center; gap: 8px;
    background: #f5f6f8; border: 1px solid var(--tn-border);
    border-radius: 999px; padding: 4px 12px 4px 4px;
}

.user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--tn-amber); color: #1a1a1a;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}

.user-name { font-size: 0.85rem; font-weight: 600; color: var(--tn-text); }

.app-content { padding: 24px 26px 60px; }

.btn-icon { border: none; background: transparent; font-size: 1.3rem; }

/* ---------- Buttons ---------- */
.btn { border-radius: 5px; letter-spacing: 0.01em; }

.btn-primary {
    background-color: var(--tn-amber);
    border-color: var(--tn-amber);
    color: #1a1a1a;
    font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--tn-amber-dark) !important;
    border-color: var(--tn-amber-dark) !important;
    color: #1a1a1a !important;
}
.btn-check:checked + .btn-primary,
.btn-primary:not(:disabled):not(.disabled):active {
    background-color: var(--tn-amber-darker) !important;
    border-color: var(--tn-amber-darker) !important;
    color: #1a1a1a !important;
}

.btn-dark {
    background-color: var(--tn-dark);
    border-color: var(--tn-dark);
    font-weight: 600;
}
.btn-dark:hover, .btn-dark:focus { background-color: #101214; border-color: #101214; }

.btn-outline-primary {
    color: var(--tn-amber-darker);
    border-color: var(--tn-amber);
}
.btn-outline-primary:hover {
    background-color: var(--tn-amber);
    border-color: var(--tn-amber);
    color: #1a1a1a;
}

a { color: var(--tn-amber-darker); }
a:hover { color: var(--tn-amber-dark); }

.form-control:focus, .form-select:focus {
    border-color: var(--tn-amber);
    box-shadow: 0 0 0 0.2rem rgba(250,184,0,0.25);
}

.nav-tabs .nav-link.active { color: var(--tn-amber-darker); border-bottom: 2px solid var(--tn-amber); }
.form-check-input:checked { background-color: var(--tn-amber); border-color: var(--tn-amber); }

/* ---------- Cards / KPI tiles ---------- */
.tn-card {
    background: #fff;
    border-radius: var(--tn-card-radius);
    border: 1px solid var(--tn-border);
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
    transition: box-shadow 0.15s;
}
.tn-card:hover { box-shadow: 0 4px 16px rgba(16,24,40,0.07); }

/* Small uppercase label grouping a row of related cards - used to organize a
   content-rich dashboard into readable sections instead of a flat wall of cards. */
.section-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tn-text-muted);
    margin: 4px 2px 10px;
    display: flex; align-items: center; gap: 8px;
}
.section-eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--tn-border); }

.tn-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--tn-border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700;
    font-size: 0.94rem;
    color: #1a1a1a;
}
.tn-card-header i { color: var(--tn-amber-darker); }

.tn-card-body { padding: 20px; }

.kpi-tile {
    background: #fff;
    border-radius: var(--tn-card-radius);
    border: 1px solid var(--tn-border);
    border-left: 4px solid var(--tn-tile-accent, var(--tn-border));
    padding: 18px 20px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
    transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-tile:hover { box-shadow: 0 4px 14px rgba(16,24,40,0.08); transform: translateY(-1px); }
:root[dir="rtl"] .kpi-tile, body.rtl .kpi-tile { border-left: 1px solid var(--tn-border); border-right: 4px solid var(--tn-tile-accent, var(--tn-border)); }

.kpi-icon {
    width: 46px; height: 46px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: #fff; flex-shrink: 0;
}

.kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1; color: #1a1a1a; }
.kpi-label { font-size: 0.78rem; color: var(--tn-text-muted); margin-top: 2px; }

.bg-icon-red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.bg-icon-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.bg-icon-amber { background: linear-gradient(135deg, var(--tn-amber), var(--tn-amber-darker)); }
.bg-icon-green { background: linear-gradient(135deg, #7ec850, var(--tn-green)); }
.bg-icon-purple { background: linear-gradient(135deg, var(--tn-dark-2), var(--tn-dark)); }

/* Utility for a slightly smaller-than-.fs-6 inline label (Bootstrap only
   ships fs-1..fs-6); used next to a stat value for a "min"/unit suffix. */
.fs-7 { font-size: 0.72rem; }

/* Small non-chart scorecard tile - used for a short fixed list (e.g. the
   3 dispatch priorities) where a chart would be overkill; gives the
   dashboard a genuinely different visual rhythm from its charts/cards. */
.priority-score-tile {
    background: #fbfbfc;
    border: 1px solid var(--tn-border);
    border-left: 3px solid var(--tn-tile-accent, var(--tn-border));
    border-radius: 8px;
    padding: 10px 14px;
}
:root[dir="rtl"] .priority-score-tile, body.rtl .priority-score-tile { border-left: 1px solid var(--tn-border); border-right: 3px solid var(--tn-tile-accent, var(--tn-border)); }
.priority-score-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.priority-score-value { font-size: 1.05rem; font-weight: 800; color: #1a1a1a; }

/* ---------- Status badges ---------- */
.status-badge { padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
.status-new, .status-available { background: #e4f3d7; color: #3d6b1b; }
.status-dispatched, .status-assigned { background: #dbeafe; color: #1e40af; }
.status-enroute { background: var(--tn-amber-light); color: #8a6400; }
.status-onscene, .status-atscene { background: #fee2e2; color: #991b1b; }
.status-transporting { background: #ede9fe; color: #5b21b6; }
.status-athospital { background: #e0f2fe; color: #075985; }
.status-closed, .status-completed, .status-outofservice { background: #e5e7eb; color: #374151; }
.status-cancelled { background: #fecaca; color: #7f1d1d; }

.priority-p1 { background: #dc2626; color: #fff; }
.priority-p2 { background: var(--tn-amber); color: #1a1a1a; }
.priority-p3 { background: #6b7280; color: #fff; }

/* ---------- Map ---------- */
.tn-map { width: 100%; border-radius: var(--tn-card-radius); overflow: hidden; border: 1px solid var(--tn-border); }
.map-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 12px 18px; background: #f8f9fa; border-top: 1px solid var(--tn-border); font-size: 0.8rem; }
.map-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ---------- Live vehicle markers ----------
   Rendered as plain google.maps.Marker image icons (a data: URI SVG built in
   fleet-map.js), not custom DOM overlays - this is the same well-supported
   Marker API the map already used before, just with a richer icon image, so
   there's no custom positioning/lifecycle code that can silently fail to
   render. No marker-specific CSS is needed for that reason. */

/* ---------- Full-bleed Live Fleet Map page ---------- */
.tn-fullmap-page {
    position: relative;
    margin: -24px -26px -60px;
    background: #eef1f4;
}
.tn-map-full {
    height: calc(100vh - 70px);
    min-height: 420px;
    border-radius: 0;
    border: none;
    width: 100%;
}
.tn-map-toolbar {
    position: absolute; top: 16px; left: 16px; z-index: 6;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16,24,40,0.16);
    padding: 14px 16px;
    max-width: min(360px, calc(100% - 32px));
    border: 1px solid rgba(16,24,40,0.06);
}
.tn-map-toolbar .toolbar-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; color: #1a1a1a; }
.tn-map-legend-float {
    position: absolute; bottom: 16px; left: 16px; z-index: 6;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: 0 8px 24px rgba(16,24,40,0.16);
    display: flex; flex-wrap: wrap; gap: 8px 18px;
    font-size: 0.8rem;
    max-width: calc(100% - 32px);
}
.tn-map-alert-float {
    position: absolute; top: 16px; right: 16px; z-index: 6;
    max-width: min(340px, calc(100% - 32px));
    box-shadow: 0 8px 24px rgba(16,24,40,0.16);
}
:root[dir="rtl"] .tn-map-toolbar, body.rtl .tn-map-toolbar,
:root[dir="rtl"] .tn-map-legend-float, body.rtl .tn-map-legend-float { left: auto; right: 16px; }
:root[dir="rtl"] .tn-map-alert-float, body.rtl .tn-map-alert-float { right: auto; left: 16px; }

@media (max-width: 767.98px) {
    .tn-fullmap-page { margin: -24px -26px -60px; }
    .tn-map-toolbar, .tn-map-legend-float, .tn-map-alert-float {
        position: static; max-width: none; border-radius: 0;
        box-shadow: none; border-bottom: 1px solid var(--tn-border);
    }
    .tn-map-full { height: calc(100vh - 260px); }
}

/* ---------- Hospital bed capacity widget ---------- */
.hospital-capacity-tile {
    background: #fafbfc;
    border: 1px solid var(--tn-border);
    border-radius: 8px;
    padding: 12px 14px;
    height: 100%;
}
.hospital-capacity-tile .progress { background: #e9ecf0; border-radius: 999px; overflow: hidden; }
.hospital-capacity-tile .progress-bar { border-radius: 999px; }

/* ---------- Auth page ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: rgba(255,255,255,0.06); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 36px 32px; color: #fff; border-top: 3px solid var(--tn-amber); }
.auth-card .form-control { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); color: #fff; }
.auth-card .form-control::placeholder { color: #b7bcc2; }
.auth-card .form-control:focus { background: rgba(255,255,255,0.12); border-color: var(--tn-amber); box-shadow: 0 0 0 0.2rem rgba(250,184,0,0.25); color: #fff; }
.auth-card label { color: #dfe2e6; font-size: 0.85rem; }
.auth-card a { color: var(--tn-amber); }

table.table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tn-text-muted); border-bottom-width: 1px; }
table.table td { vertical-align: middle; font-size: 0.88rem; }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: -280px; z-index: 1050; transition: left 0.2s ease; box-shadow: 4px 0 20px rgba(0,0,0,0.25); }
    .app-sidebar.open { left: 0; }
}

/* =========================================================================
   Workforce / Fleet Ops / Billing additions
   ========================================================================= */
.roster-table td, .roster-table th { vertical-align: top; padding: 6px; }
.roster-today { background: var(--tn-amber-light) !important; }
.roster-chip {
    font-size: 0.72rem; line-height: 1.25;
    background: #fff; border: 1px solid var(--tn-border);
    border-left: 3px solid var(--chip, #6b7280);
    border-radius: 6px; padding: 4px 6px; margin-bottom: 4px;
}
:root[dir="rtl"] .roster-chip, body.rtl .roster-chip { border-left: 1px solid var(--tn-border); border-right: 3px solid var(--chip, #6b7280); }
.roster-x { font-size: 0.9rem; line-height: 1; }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill-totals td { padding: 4px 8px; }
.bill-totals tr.grand td { font-size: 1.05rem; font-weight: 800; border-top: 2px solid var(--tn-dark); }
.line-type-badge { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em; background: #f1f3f5; color: #495057; border-radius: 4px; padding: 1px 6px; }
.alert-row-expired { border-left: 3px solid #dc2626; }
.alert-row-duesoon { border-left: 3px solid #d97706; }
:root[dir="rtl"] .alert-row-expired, body.rtl .alert-row-expired { border-left: none; border-right: 3px solid #dc2626; }
:root[dir="rtl"] .alert-row-duesoon, body.rtl .alert-row-duesoon { border-left: none; border-right: 3px solid #d97706; }
.stat-mini { font-size: 1.25rem; font-weight: 800; color: #1a1a1a; line-height: 1.1; }

/* ---------- Printable invoice / receipt ---------- */
.invoice-sheet { background: #fff; max-width: 900px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--tn-border); border-radius: var(--tn-card-radius); }
.invoice-sheet h2 { font-weight: 800; letter-spacing: 0.02em; }
.invoice-sheet table th { font-size: 0.72rem; text-transform: uppercase; color: var(--tn-text-muted); }
@media print {
    .app-sidebar, .app-topbar, .no-print, .alert { display: none !important; }
    .app-content { padding: 0 !important; }
    body.app-body { background: #fff !important; }
    .invoice-sheet { border: none; padding: 0; max-width: none; }
}


/* Hide scrollbar but keep scrolling enabled */
html,
body,
.app-sidebar,
.app-content,
.app-main {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

    html::-webkit-scrollbar,
    body::-webkit-scrollbar,
    .app-sidebar::-webkit-scrollbar,
    .app-content::-webkit-scrollbar,
    .app-main::-webkit-scrollbar {
        display: none;
    }

/* ---------- Incident tracking map (grid popup + incident details) ---------- */
.tn-track-map { width: 100%; height: 400px; background: #eef1f4; }
.tn-track-modal .tn-track-map { height: 62vh; min-height: 360px; }
.tn-track-summary { font-size: 0.82rem; background: #fafbfc; }
.tn-track-summary:empty { display: none; }
.tn-track-row + .tn-track-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--tn-border); }
.tn-track-swatch { display: inline-block; width: 16px; height: 4px; border-radius: 2px; vertical-align: middle; }
.tn-track-timeline { color: #6b7688; font-size: 0.76rem; display: flex; flex-wrap: wrap; row-gap: 2px; }
.tn-track-timeline span + span::before { content: "\203A"; margin: 0 6px; color: #b6bcc6; }
.tn-live-badge { display: inline-flex; align-items: center; gap: 6px; color: #16a34a; font-weight: 600; font-size: 0.78rem; }
.tn-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; animation: tnLivePulse 1.6s ease-out infinite; }
.tn-route-badge { color: #475569; font-weight: 600; font-size: 0.78rem; }
@keyframes tnLivePulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
@media (prefers-reduced-motion: reduce) { .tn-live-dot { animation: none; } }

/* ---------- New Incident: location search ---------- */
.tn-loc-suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 300px; overflow-y: auto; border-radius: 8px; }
.tn-loc-suggest .list-group-item { border-left: 0; border-right: 0; text-align: start; }
.tn-loc-suggest .list-group-item.active i { color: #fff; }
