/* =====================================================================
   APP.CSS
   Consolidated stylesheet for rules that used to live inline or in
   per-page <style> blocks under 06_Pages. Organized by the page/area
   each group of classes belongs to. Page-scoped selectors are prefixed
   by a class added to that page's <body> tag (e.g. .auth-page,
   .live-page, .public-page) so that two pages can reuse the same
   element class name (e.g. "topbar", "popup-title") without their
   rules colliding.
   ===================================================================== */

* {
    box-sizing: border-box;
}

:root {
    /* Chrome (sidebar) */
    --color-ink: #14161a;
    --color-ink-soft: #20232b;
    --color-ink-text: #d7d9dd;
    --color-ink-text-muted: #8a8f98;
    /* Workspace */
    --color-paper: #f6f5f2;
    --color-surface: #ffffff;
    --color-border: #e5e2da;
    --color-text: #1b1d22;
    --color-text-muted: #6b6f76;
    /* Brand accent */
    --color-accent: #f5a623;
    --color-accent-ink: #1b1d22;
    /* Status colors */
    --color-live: #1faa59;
    --color-live-bg: #e8f7ee;
    --color-stop: #e1432d;
    --color-stop-bg: #fcecea;
    --color-warn: #b9860a;
    --color-warn-bg: #fdf3e0;
    --color-info: #2f6fed;
    --color-info-bg: #e9f0fe;
    --color-neutral: #8a8f98;
    --color-neutral-bg: #eeeef0;
    --color-purple: #9b59b6;
    --color-purple-bg: #f2e9f7;
    /* Type */
    --font-display: "Barlow Condensed", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
    --radius: 8px;
    --radius-pill: 999px;
}


/* =====================================================================
   ADMIN SHELL (Shared/_Layout.cshtml)
   ===================================================================== */
.sidebar-logo {
    width: 100%;
    max-width: 180px;
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    color: var(--color-ink-text-muted);
}

.sidebar-user-role {
    opacity: 0.6;
}


/* =====================================================================
   ADMIN TABLE PAGES — shared utility classes
   (CheckIn, EventRiders, Events, Riders, Trackers, Users, Status, TrackExport)
   ===================================================================== */

/* Event filter dropdown at the top of CheckIn / EventRiders */
.event-select {
    max-width: 400px;
}

/* Single-button forms rendered inline next to other controls in a table cell */
.inline-form {
    display: inline;
}

/* Table action cells that shouldn't wrap (Edit / Delete buttons) */
.nowrap-cell {
    white-space: nowrap;
}

/* Status/health badges that are informational only, not clickable */
.static-badge {
    cursor: default;
}

/* Inline <select> that should size to its content instead of filling the cell (Events status select) */
.inline-select {
    width: auto;
    display: inline-block;
}

/* Row pairing a route/file badge with its remove button (Events GPX route) */
.route-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

/* "None" route badge sits alone, so it needs the spacing .route-row normally provides */
.route-badge-none {
    margin-bottom: 6px;
    display: inline-block;
}

.gpx-file-input {
    width: 160px;
    display: inline-block;
}

/* Descriptive helper text under a page heading */
.page-note {
    color: var(--color-text-muted);
    max-width: 600px;
}

.page-note-plain {
    color: var(--color-text-muted);
}

/* CheckIn: "by <name> at <time>" caption under the pass/fail badge */
.checkin-subtext {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* CheckIn: tracker-swap form, hidden until "Swap" is clicked */
.swap-form {
    display: none;
    gap: 6px;
    margin-top: 8px;
    align-items: center;
}

.swap-form.swap-form-visible {
    display: flex;
}

.swap-select {
    width: auto;
}

.swap-reason-input {
    width: 200px;
}

/* Status page: big banner showing whether trackers are currently reporting */
.status-banner {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-banner-live {
    background: var(--color-live-bg);
    color: var(--color-live);
}

.status-banner-stop {
    background: var(--color-stop-bg);
    color: var(--color-stop);
}

.status-banner-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-banner-dot-pulse {
    animation: status-pulse 1s infinite;
}

.status-banner-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-banner-subtitle {
    font-size: 13px;
    opacity: 0.85;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}


/* =====================================================================
   ADMIN "ADD/EDIT" MODALS (Events, Riders, Trackers, Users)
   ===================================================================== */
.modal-content {
    border-radius: var(--radius);
    border-color: var(--color-border);
}

.modal-header, .modal-footer {
    border-color: var(--color-border);
}

.modal-title {
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text);
}


/* =====================================================================
   AUTH PAGES (Login.cshtml, Setup.cshtml) — standalone, no _Layout
   Add class="auth-page login-page" / "auth-page setup-page" to <body>
   ===================================================================== */
.auth-page {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: #14161a;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-page .card {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

.login-page .card {
    width: 340px;
}

.setup-page .card {
    width: 360px;
}

.auth-page .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.auth-page .brand-stripe {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background-image: linear-gradient(45deg, #14161a 25%, transparent 25%, transparent 75%, #14161a 75%), linear-gradient(45deg, #14161a 25%, transparent 25%, transparent 75%, #14161a 75%);
    background-size: 7px 7px;
    background-position: 0 0, 3.5px 3.5px;
    background-color: #eee;
}

.auth-page .brand-name {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.setup-page h1 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 22px;
    margin: 0 0 4px;
    border-left: 4px solid #f5a623;
    padding-left: 10px;
}

.setup-page p.sub {
    color: #6b6f76;
    font-size: 13px;
    margin: 0 0 20px;
    padding-left: 14px;
}

.auth-page label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b6f76;
    display: block;
    margin-bottom: 4px;
}

.auth-page input {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid #e5e2da;
    font-size: 14px;
    margin-bottom: 16px;
}

.auth-page input:focus {
    outline: none;
    border-color: #f5a623;
    box-shadow: 0 0 0 3px rgba(245,166,35,0.2);
}

.auth-page button {
    width: 100%;
    padding: 10px;
    border-radius: 999px;
    border: none;
    background: #f5a623;
    color: #1b1d22;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.auth-page .error {
    background: #fcecea;
    color: #e1432d;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.setup-page .done {
    text-align: center;
    color: #1b1d22;
}

.setup-page .done a {
    color: #2f6fed;
}


/* =====================================================================
   TRACKING PAGES (Live.cshtml, Public.cshtml) — standalone, no _Layout
   Add class="tracking-page live-page" / "tracking-page public-page" to <body>
   ===================================================================== */
.tracking-page {
    margin: 0;
    font-family: var(--font-body);
}

/* Leaflet map canvas -- id="map" is kept for L.map('map'), class added for styling */
.map-canvas {
    flex: 1;
    height: 100%;
    min-width: 0;
}

/* Legend swatches -- shared between Live and Public, colors match 1:1 */
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-moving { background: #1FAA59; }
.dot-stopped-yellow { background: #F1C40F; }
.dot-stopped-red { background: #E1432D; }
.dot-lost { background: #2F6FED; }
.dot-abandoned { background: #E67E22; }
.dot-support { background: #9b59b6; }
.dot-medical { background: #fff; border: 2px solid #E1432D; }

@keyframes flash-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.marker-flash {
    animation: flash-pulse 0.7s infinite;
}

/* ---- Live.cshtml ---- */
.live-page .topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 20px; background: var(--color-ink); color: #fff; flex-wrap: wrap;
}
.live-page .topbar select { padding: 6px 10px; border-radius: 6px; border: none; }
.live-page .topbar .legend { display: flex; gap: 14px; margin-left: auto; font-size: 12px; flex-wrap: wrap; }
.live-page .topbar .legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.live-brand { font-family: 'Barlow Condensed'; text-transform: uppercase; letter-spacing: 0.05em; }

.live-page .live-body { display: flex; height: calc(100vh - 52px); position: relative; }

@keyframes sos-pulse {
    0% { box-shadow: 0 0 0 0 rgba(225,67,45,0.65); }
    70% { box-shadow: 0 0 0 12px rgba(225,67,45,0); }
    100% { box-shadow: 0 0 0 0 rgba(225,67,45,0); }
}
.sos-ring {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%; border: 3px solid #E1432D; animation: sos-pulse 1s infinite;
}

.sos-banner {
    position: absolute; top: 0; left: 0; right: 260px; z-index: 1000;
}
.sos-alert-row {
    display: flex; align-items: center; gap: 14px; padding: 10px 20px;
    background: #E1432D; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.25);
}
.sos-alert-row .sos-icon { font-size: 18px; }
.sos-alert-row .sos-info { flex: 1; }
.sos-alert-row .sos-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: 0.02em; }
.sos-alert-row .sos-time { font-size: 12px; opacity: 0.85; font-family: var(--font-mono); }
.sos-alert-row button {
    background: #fff; color: #E1432D; border: none; border-radius: 999px;
    padding: 7px 16px; font-weight: 700; font-size: 12px; cursor: pointer; white-space: nowrap;
}

.live-page .participants-sidebar {
    width: 260px; flex-shrink: 0; background: var(--color-surface);
    border-left: 1px solid var(--color-border); height: 100%; overflow-y: auto;
}
.live-page .sidebar-section { border-bottom: 6px solid var(--color-paper); }
.live-page .sidebar-section.collapsed .section-list { display: none; }
.live-page .participants-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-family: var(--font-display); font-weight: 700; font-size: 20px; text-transform: uppercase;
    letter-spacing: 0.02em; padding: 14px 16px; border-bottom: 1px solid var(--color-border);
    position: sticky; top: 0; background: var(--color-surface); white-space: nowrap; cursor: pointer;
}
.live-page .participants-toggle {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; border: none;
    background: none; color: var(--color-text); line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.live-page .participants-toggle:hover { color: var(--color-text-muted); }
.live-page .participants-toggle svg { transition: transform 0.15s ease; }
.live-page .sidebar-section.collapsed .participants-toggle svg { transform: rotate(180deg); }
.live-page .participant-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    border-bottom: 1px solid var(--color-border); cursor: pointer; transition: background-color 0.1s ease;
}
.live-page .participant-row:hover { background: var(--color-paper); }
.live-page .participant-dot {
    width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.live-page .participant-label { font-size: 14px; font-weight: 500; }
.live-page .participant-label .num { font-family: var(--font-mono); color: var(--color-text-muted); margin-right: 4px; }

.live-page .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 0;
}
.live-page .leaflet-popup-content { margin: 0; width: 260px !important; }
.live-page .leaflet-popup-tip { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }

.live-page .trail-point-tooltip {
    font-size: 14px;
    line-height: 1.4;
    padding: 6px 10px;
    font-family: var(--font-body);
}

.popup-card { font-family: var(--font-body); color: var(--color-text); }
.popup-header {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 14px; border-bottom: 1px solid var(--color-border);
}
.live-page .popup-title {
    font-family: var(--font-display); font-weight: 600; font-size: 17px;
    text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.1;
}
.popup-pill {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.popup-stats { display: flex; padding: 12px 14px; gap: 16px; }
.popup-stat { flex: 1; }
.popup-stat-label {
    display: block; font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 3px;
}
.popup-stat-value { font-family: var(--font-mono); font-size: 18px; font-weight: 500; }
.popup-stat-value small { font-family: var(--font-body); font-size: 11px; color: var(--color-text-muted); }

.battery-bar {
    margin-top: 5px; width: 100%; height: 5px; border-radius: 3px;
    background: var(--color-neutral-bg); overflow: hidden;
}
.battery-fill { height: 100%; border-radius: 3px; }

.popup-updated {
    padding: 0 14px 12px; font-size: 11px; color: var(--color-text-muted); font-family: var(--font-mono);
    cursor: help; width: fit-content; border-bottom: 1px dotted var(--color-text-muted);
}
.popup-divider { height: 1px; background: var(--color-border); margin: 0 14px; }

.popup-actions { display: flex; gap: 6px; padding: 12px 14px 0; }
.popup-actions-row3 { padding-bottom: 14px; }
.popup-actions a, .popup-actions button {
    flex: 1; text-align: center; font-size: 12px; font-weight: 600; padding: 7px 10px;
    border-radius: 999px; border: none; cursor: pointer; text-decoration: none;
}
.btn-directions { background: var(--color-info-bg); color: var(--color-info); }
.btn-gearth { background: var(--color-info-bg); color: var(--color-info); }
.btn-abandon { background: var(--color-warn-bg); color: var(--color-warn); }
.btn-unabandon { background: var(--color-neutral-bg); color: var(--color-neutral); }
.btn-dnf { background: #fcecea; color: #E1432D; }
.btn-ack-sos { background: #fcecea; color: #E1432D; }
.btn-monitor-off { background: var(--color-neutral-bg); color: var(--color-neutral); }
.btn-monitor-on { background: var(--color-purple-bg); color: var(--color-purple); }

.popup-trail { display: flex; align-items: center; gap: 8px; padding: 0 14px 14px; }
.popup-trail label {
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-text-muted); white-space: nowrap;
}
.popup-trail select {
    flex: 1; font-size: 12px; padding: 5px 8px; border-radius: 8px;
    border: 1px solid var(--color-border); background: var(--color-paper); color: var(--color-text);
}

.date-range-dialog {
    position: fixed; inset: 0; background: rgba(27, 29, 34, 0.45);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.date-range-dialog.hidden { display: none; }
.date-range-dialog-box {
    background: var(--color-surface); border-radius: 10px; padding: 20px 22px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); width: 240px; font-family: var(--font-body);
}
.date-range-dialog-box h4 { margin: 0 0 14px; font-size: 15px; color: var(--color-text); }
.date-range-dialog-box label {
    display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 4px;
}
.date-range-dialog-box input[type="date"] {
    width: 100%; box-sizing: border-box; padding: 6px 8px; margin-bottom: 14px;
    border-radius: 8px; border: 1px solid var(--color-border); background: var(--color-paper);
    color: var(--color-text); font-size: 13px;
}
.date-range-dialog-actions { display: flex; gap: 8px; }
.date-range-dialog-actions button {
    flex: 1; text-align: center; font-size: 12px; font-weight: 600; padding: 8px 10px;
    border-radius: 999px; border: none; cursor: pointer;
}
.btn-date-cancel { background: var(--color-neutral-bg); color: var(--color-neutral); }
.btn-date-confirm { background: var(--color-info-bg); color: var(--color-info); }

/* ---- Public.cshtml ---- */
.public-page .topbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 20px; background: #14161a; color: #fff;
}
.public-page .topbar select { padding: 6px 10px; border-radius: 6px; border: none; }
.public-page .brand { font-family: 'Barlow Condensed'; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.delay-note { margin-left: auto; font-size: 12px; opacity: 0.8; }

.public-page .legend {
    display: flex; gap: 14px; padding: 8px 20px; background: #fff;
    border-bottom: 1px solid #e5e2da; font-size: 12px; flex-wrap: wrap;
}
.public-page .legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }

.public-page .body-row { display: flex; height: calc(100vh - 92px); }

.public-page .participants-sidebar {
    width: 240px; flex-shrink: 0; background: #fff;
    border-left: 1px solid #e5e2da; height: 100%; overflow-y: auto;
}
.public-page .participants-header {
    font-family: 'Barlow Condensed'; font-weight: 700; font-size: 18px; text-transform: uppercase;
    letter-spacing: 0.02em; padding: 12px 16px; border-bottom: 1px solid #e5e2da;
    position: sticky; top: 0; background: #fff;
}
.public-page .participant-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 16px;
    border-bottom: 1px solid #e5e2da; cursor: pointer;
}
.public-page .participant-row:hover { background: #f6f5f2; }
.public-page .participant-dot {
    width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.public-page .participant-label { font-size: 13px; font-weight: 500; }
.public-page .participant-label .num { font-family: 'JetBrains Mono'; color: #6b6f76; margin-right: 4px; }

.public-page .leaflet-popup-content-wrapper { border-radius: 10px; }
.public-page .popup-title { font-family: 'Barlow Condensed'; font-weight: 700; font-size: 15px; text-transform: uppercase; }
