/* =========================================================
   LIGHTS OFF: MILO's dark theme
   Switched by the Lights button in the top bar, which sets
   data-bs-theme="dark" on <html> (Bootstrap's own components follow
   it). This file: the dark values of MILO's colour tokens, and fixes
   by hand. milo-dark-auto.css (generated, loaded before this) covers
   the colours written straight into the stylesheets.

   Same rules as in the light: the sidebar stays deep green, colour only
   where it means something (green on track, amber look, red critical),
   a little brighter so it reads on the dark.
   ========================================================= */

html[data-bs-theme="dark"] {
    color-scheme: dark;

    --milo-ink: #e7ece8;
    --bs-link-color: #e7ece8;
    --bs-link-color-rgb: 231, 236, 232;
    --bs-link-hover-color: #ffffff;
    --bs-link-hover-color-rgb: 255, 255, 255;
    --bs-focus-ring-color: rgba(231, 236, 232, 0.25);

    --milo-cocoa-green: #8cc3a3;
    --milo-sage: #2f4a3b;
    --milo-sage-soft: #16241d;

    /* Page, cards, panels: deep green-black, a step lighter each */
    --milo-off-white: #0d1311;
    --milo-surface: #151c19;
    --milo-surface-soft: #1b2420;
    --milo-glass: rgba(21, 28, 25, 0.72);

    --milo-sand: #3b3528;
    --milo-silver: #5b6064;

    --milo-charcoal: #d0d7d2;
    --milo-gray-700: #a3ada6;
    --milo-gray: #77817a;
    --milo-border: #29332e;

    --milo-danger: #f08072;
    --milo-warning: #e9a748;
    --milo-info: #8bbad4;
    --milo-sky: #83c7ef;
    --milo-green-600: #4cc782;

    --milo-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    --milo-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
    --milo-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);

    --milo-btn-raised:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35),
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 3px 8px rgba(0, 0, 0, 0.35);

    --milo-btn-pressed:
        inset 0 1px 2px rgba(0, 0, 0, 0.5),
        inset 0 -1px 0 rgba(255, 255, 255, 0.08),
        0 1px 1px rgba(0, 0, 0, 0.3);

    --milo-btn-raised-light:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4),
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 3px 8px rgba(0, 0, 0, 0.3);

    --milo-btn-face-light:
        linear-gradient(180deg, #212b27 0%, #1d2622 40%, #18201c 100%);

    /* Bootstrap's own, on MILO's dark */
    --bs-body-bg: #0d1311;
    --bs-body-bg-rgb: 13, 19, 17;
    --bs-body-color: #e7ece8;
    --bs-body-color-rgb: 231, 236, 232;
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: rgba(231, 236, 232, 0.7);
    --bs-secondary-bg: #1b2420;
    --bs-tertiary-bg: #161e1b;
    --bs-border-color: #29332e;
    --bs-heading-color: #f2f5f3;
}

/* A bad colour in the face gradient above can't fall back to light */
html[data-bs-theme="dark"] {
    --milo-btn-face-light: linear-gradient(180deg, #212b27 0%, #1d2622 40%, #18201c 100%);
}


/* The sign-in page's green panel looks the same in both: what sits on
   it (the white "Today at a glance" card) keeps the light colours */
html[data-bs-theme="dark"] .milo-auth-brand {
    --milo-ink: #161616;
    --milo-charcoal: #2e2e2e;
    --milo-gray-700: #59605b;
    --milo-gray: #8a8f8a;
    --milo-border: #e1e5e1;
    --milo-surface: #ffffff;
    --milo-surface-soft: #f5f6f3;
    --milo-sage-soft: #edf4ec;
    --milo-green-600: #17854a;
}


/* ---------- Bootstrap pieces the views use ---------- */

html[data-bs-theme="dark"] .card {
    --bs-card-bg: var(--milo-surface);
    --bs-card-cap-bg: var(--milo-surface-soft);
    --bs-card-border-color: var(--milo-border);
    --bs-card-color: var(--milo-ink);
}

html[data-bs-theme="dark"] .dropdown-menu {
    --bs-dropdown-bg: var(--milo-surface);
    --bs-dropdown-border-color: var(--milo-border);
    --bs-dropdown-link-color: var(--milo-ink);
    --bs-dropdown-link-hover-bg: var(--milo-surface-soft);
    --bs-dropdown-link-hover-color: #ffffff;
    --bs-dropdown-divider-bg: var(--milo-border);
}

html[data-bs-theme="dark"] .modal {
    --bs-modal-bg: var(--milo-surface);
    --bs-modal-border-color: var(--milo-border);
}

html[data-bs-theme="dark"] .list-group {
    --bs-list-group-bg: var(--milo-surface);
    --bs-list-group-border-color: var(--milo-border);
    --bs-list-group-color: var(--milo-ink);
}

html[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--milo-ink);
    --bs-table-border-color: var(--milo-border);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    --bs-table-hover-color: var(--milo-ink);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.025);
}

html[data-bs-theme="dark"] .table-light {
    --bs-table-bg: var(--milo-surface-soft);
    --bs-table-color: var(--milo-ink);
    --bs-table-border-color: var(--milo-border);
}

html[data-bs-theme="dark"] .bg-white { background-color: var(--milo-surface) !important; }
html[data-bs-theme="dark"] .bg-light { background-color: var(--milo-surface-soft) !important; }
html[data-bs-theme="dark"] .text-dark,
html[data-bs-theme="dark"] .text-black { color: var(--milo-ink) !important; }
html[data-bs-theme="dark"] .text-muted { color: var(--milo-gray-700) !important; }
html[data-bs-theme="dark"] .border { border-color: var(--milo-border) !important; }

html[data-bs-theme="dark"] .btn-light {
    --bs-btn-bg: var(--milo-surface-soft);
    --bs-btn-color: var(--milo-ink);
    --bs-btn-border-color: var(--milo-border);
    --bs-btn-hover-bg: #232d29;
    --bs-btn-hover-color: #ffffff;
}

html[data-bs-theme="dark"] .btn-outline-dark {
    --bs-btn-color: var(--milo-ink);
    --bs-btn-border-color: var(--milo-border);
    --bs-btn-hover-bg: var(--milo-ink);
    --bs-btn-hover-color: #101512;
}


/* ---------- Ink-filled pieces: ink turns light, so their words turn dark ---------- */

html[data-bs-theme="dark"] [data-milo-tooltip]::after,
html[data-bs-theme="dark"] .milo-user-avatar,
html[data-bs-theme="dark"] .milo-hx-today,
html[data-bs-theme="dark"] .milo-hx-chip.is-on,
html[data-bs-theme="dark"] .milo-hx-area input:checked + span,
html[data-bs-theme="dark"] .milo-report-modes a.active,
html[data-bs-theme="dark"] .milo-row-go:hover,
html[data-bs-theme="dark"] .milo-pillar-letter {
    color: #101512;
}

/* The bell's flowing colours, and the same on a Requests tab or a page
   guide: the chart palette's amber for the dark */
html[data-bs-theme="dark"] .milo-bell {
    --milo-bell-amber: #e9a748;
}

html[data-bs-theme="dark"] .milo-segmented a.milo-tab-waiting,
html[data-bs-theme="dark"] .milo-guide {
    --milo-tab-amber: #e9a748;
    --milo-guide-amber: #e9a748;
}

/* The guide's step numbers: light sage on the dark */
html[data-bs-theme="dark"] .milo-guide-steps li:not(.is-tip)::before {
    color: #9dd5ae;
    background: rgba(157, 213, 174, 0.16);
}

html[data-bs-theme="dark"] .milo-guide-steps li.is-tip::before {
    color: #e9a748;
}

/* Light-green fills keep dark words (ink turns light in the dark) */
html[data-bs-theme="dark"] .btn-primary,
html[data-bs-theme="dark"] .btn-primary:disabled,
html[data-bs-theme="dark"] .milo-page-header-icon-back:hover,
html[data-bs-theme="dark"] .milo-page-header-icon-back:focus-visible,
html[data-bs-theme="dark"] .milo-calendar .fc-day-today .fc-daygrid-day-number {
    color: #0d1311;
}

html[data-bs-theme="dark"] .btn-primary:hover,
html[data-bs-theme="dark"] .btn-primary:focus,
html[data-bs-theme="dark"] .btn-primary:active,
html[data-bs-theme="dark"] .btn-primary.active,
html[data-bs-theme="dark"] .milo-choice-buttons > .btn-check:checked + .btn {
    color: #0d1311 !important;
}

/* Words in deep green would vanish on the dark: the light green instead */
html[data-bs-theme="dark"] .milo-att-position h2,
html[data-bs-theme="dark"] .milo-att-today h2 > span:first-child,
html[data-bs-theme="dark"] .milo-att-first > span,
html[data-bs-theme="dark"] .milo-att-subhead,
html[data-bs-theme="dark"] .milo-action-note,
html[data-bs-theme="dark"] .milo-profile-role {
    color: var(--milo-sage-200);
}

html[data-bs-theme="dark"] .milo-status-success,
html[data-bs-theme="dark"] .milo-variance-ok {
    color: var(--milo-green-600);
}

/* The schedule calendar: today a faint green wash, not a pale block;
   the chosen view's button keeps dark words on its light green */
html[data-bs-theme="dark"] .milo-calendar {
    --fc-today-bg-color: rgba(157, 213, 174, 0.1);
}

html[data-bs-theme="dark"] .milo-calendar .fc-button-primary:not(:disabled).fc-button-active,
html[data-bs-theme="dark"] .milo-calendar .fc-button-primary:not(:disabled):active {
    color: #0d1311;
}

html[data-bs-theme="dark"] .btn {
    --bs-btn-disabled-border-color: var(--milo-border);
}

/* The selected option sits a step lighter than its track */
html[data-bs-theme="dark"] .milo-segmented a.active,
html[data-bs-theme="dark"] .milo-segmented button.active {
    background: #2a3530;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}


/* ---------- The Lights button and the logo ---------- */

.milo-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;

    color: var(--milo-ink);
    background: var(--milo-btn-face-light);
    border: 1px solid var(--milo-border);
    border-radius: 50%;
    box-shadow: var(--milo-btn-raised-light);

    font-size: 1.05rem;
    transition: transform 0.15s ease;
}

.milo-theme-toggle:hover { transform: translateY(-1px); }
.milo-theme-toggle:active { box-shadow: var(--milo-btn-pressed); transform: none; }

.milo-theme-toggle:focus-visible {
    outline: 2px solid var(--milo-ink);
    outline-offset: 3px;
}

/* Moon while the lights are on (switch them off), sun while off */
.milo-theme-toggle .is-sun,
html[data-bs-theme="dark"] .milo-theme-toggle .is-moon { display: none; }
html[data-bs-theme="dark"] .milo-theme-toggle .is-sun { display: inline; color: #f3c969; }

/* The sidebar logo: the sage coin with the lights on, the black coin off */
.milo-rail-mark .is-off,
html[data-bs-theme="dark"] .milo-rail-mark .is-on { display: none; }
html[data-bs-theme="dark"] .milo-rail-mark .is-off { display: block; }


/* ---------- The searchable lists (Tom Select) ---------- */

html[data-bs-theme="dark"] .ts-control,
html[data-bs-theme="dark"] .ts-wrapper.single .ts-control,
html[data-bs-theme="dark"] .ts-dropdown {
    color: var(--milo-ink);
    background: var(--milo-surface);
    border-color: var(--milo-border);
}

/* The open list is glass, like the light one (GLASS in milo.css) */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html[data-bs-theme="dark"] .ts-dropdown {
        background: var(--milo-glass);
    }
}

@media (prefers-reduced-transparency: reduce) {
    html[data-bs-theme="dark"] .ts-dropdown {
        background: var(--milo-surface);
    }
}

html[data-bs-theme="dark"] .ts-control input {
    color: var(--milo-ink);
}

html[data-bs-theme="dark"] .ts-dropdown .option {
    color: var(--milo-ink);
}

html[data-bs-theme="dark"] .ts-dropdown .active {
    color: #ffffff;
    background: var(--milo-surface-soft);
}

html[data-bs-theme="dark"] .ts-wrapper.form-select.focus {
    border-color: var(--milo-gray-700);
    box-shadow: 0 0 0 0.2rem rgba(231, 236, 232, 0.12);
}

/* Calm motion's landing band: the dark sage-soft is too close to the
   cards to see, so a sage tint with a sage edge, as in the preview */
html[data-bs-theme="dark"][data-milo-calm] {
    --milo-landed-bg: rgba(157, 213, 174, 0.22);
    --milo-landed-edge: #9dd5ae;
}

/* The menu's amber bubbles: the bright amber needs dark figures */
html[data-bs-theme="dark"] .milo-flyout .milo-bubble-warning {
    color: #2b1c05;
}

/* Fleet now (Intelligence menu) and the fleet bars: Maintenance's dark
   red follows Lights as the Vehicles chart's does (MILO_THEME deepRed),
   so it doesn't vanish on the dark */
html[data-bs-theme="dark"] :is(.milo-fleet-dot-maintenance, .milo-fleet-bar-maintenance) {
    background: #c0504a;
}

/* The compact "More insights +2" button's pill: deep green words would
   vanish on the dark, so light green on a faint green; on hover the
   light green fill takes dark figures, like the main button */
html[data-bs-theme="dark"] .milo-more-count {
    color: var(--milo-sage-200);
    background: rgba(157, 213, 174, 0.16);
}

html[data-bs-theme="dark"] :is(.milo-more-button:hover, .milo-more-button:focus-visible) .milo-more-count {
    color: #0d1311;
    background: var(--milo-sage-200);
}

/* The Vehicle Cost form's lines between the kinds: the generated dark
   grey hardly shows on the dark strip, so a touch lighter */
html[data-bs-theme="dark"] .milo-segmented-option + .milo-segmented-option::before {
    background: #3e4943;
}
