/* ============================================================
   Astrata Ops Portal - brand layer
   Astrata Visual Identity Guidelines, Edition 1.0 (2026).
   Tokens mirror the website's shared/tokens.css; the MudBlazor
   theme (Theme/AstrataTheme.cs) carries the same values.
   ============================================================ */

:root {
    /* Brand (s.04) */
    --signal-green: #00C389;
    --core-blue: #1F4DFF;
    --ink: #0F172A;
    --cloud: #F4F6FA;
    --paper: #FFFFFF;

    /* Slate scale */
    --slate-50: #F8FAFC;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-300: #CBD5E1;
    --slate-400: #94A3B8;
    --slate-500: #64748B;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1E293B;

    /* Semantic: reserved for state, always paired with an icon or label */
    --success: var(--signal-green);
    --success-bg: #E6F9F2;
    --success-fg: #047857;
    --info: var(--core-blue);
    --info-bg: #E8EEFF;
    --warning: #FFB020;
    --warning-bg: #FFF4DC;
    --warning-fg: #92400E;
    --critical: #E5484D;
    --critical-bg: #FCE4E5;
    --critical-fg: #B42318;

    /* Spacing (base 4px), radius and elevation (s.10) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 999px;
    --elevation-1: 0 1px 2px rgba(15,23,42,0.04);
    --elevation-2: 0 4px 8px rgba(15,23,42,0.08);
    --elevation-3: 0 12px 32px rgba(15,23,42,0.12);
    --shadow-focus: 0 0 0 3px rgba(31,77,255,0.24);

    /* Type (s.05) */
    --font-sans: 'Inter', 'Inter Variable', 'Aptos', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Motion (s.08): never above 600ms */
    --dur-micro: 120ms;
    --dur-small: 200ms;
    --dur-medium: 320ms;
    --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html, body {
    font-family: var(--font-sans);
    background: var(--cloud);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--core-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1:focus { outline: none; }

/* ---------- Focus: Core Blue ring, never removed ---------- */
:focus-visible {
    outline: 2px solid var(--core-blue);
    outline-offset: 2px;
}
.mud-input-control:focus-within .mud-input-outlined-border { border-color: var(--core-blue) !important; }

/* ---------- Numbers and identifiers ---------- */
/* Tabular figures on every data surface (s.05). */
.mud-table, .mud-data-grid, .aos-tnum, .aos-tile-value {
    font-feature-settings: 'tnum' 1, 'cv11' 1;
    font-variant-numeric: tabular-nums;
}
/* Asset IDs, serials, job numbers and plates use JetBrains Mono (s.05). */
.aos-mono, td.aos-mono {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0;
    font-feature-settings: 'tnum' 1;
}

/* ---------- App chrome ---------- */
.aos-appbar {
    border-bottom: 1px solid var(--slate-200);
    box-shadow: none !important;
}

.aos-appbar-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--slate-500);
}

.aos-drawer {
    border-right: 0;
}

.aos-drawer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-4) var(--space-4);   /* clear space around the mark */
}
.aos-drawer-brand img { display: block; }
.aos-drawer-brand--mini { padding: var(--space-4) 0; }

/* Loading spinner. Only `transform` is animated, so the browser runs it on the compositor
   thread (GPU): it stays at the display's refresh rate even while the main thread is busy.
   `linear` keeps the speed constant; `will-change` promotes the layer ahead of time. */
.aos-spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50vh;   /* centre in the page body, not hugging the top edge */
}
.aos-spinner {
    display: block;
    height: auto;
    transform-origin: 50% 50%;
    will-change: transform;
    animation: aos-spin 1.2s linear infinite;
}
@keyframes aos-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .aos-spinner { animation-duration: 4s; }
}

.aos-nav-heading {
    display: block;
    padding: var(--space-4) var(--space-4) var(--space-1);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--slate-400);
}

.aos-drawer .mud-nav-link {
    margin: 2px var(--space-2);
    border-radius: var(--radius-md);
    color: var(--slate-300);
    transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.aos-drawer .mud-nav-link:hover { background: var(--slate-800); color: var(--cloud); }
/* Active page: Signal Green on the dark drawer (strong contrast; green is never used for text on light surfaces). */
.aos-drawer.mud-drawer .mud-navmenu.mud-navmenu-default .mud-nav-link.active:not(.mud-nav-link-disabled) {   /* out-ranks MudBlazor's active rule */
    background: var(--slate-800);
    color: var(--signal-green);
    box-shadow: inset 3px 0 0 var(--signal-green);
}
.aos-drawer .mud-nav-link .mud-nav-link-icon { color: var(--slate-400); }
.aos-drawer .mud-nav-link.active .mud-nav-link-icon { color: var(--signal-green); }
.aos-drawer .mud-nav-link.active .mud-nav-link-text { font-weight: 600; }
.aos-drawer .mud-nav-link-text { font-size: 14px; font-weight: 500; }

.aos-drawer-footer {
    margin-top: auto;
    padding: var(--space-4);
    font-size: 12px;
    line-height: 16px;
    color: var(--slate-400);
}

.mud-drawer--closed .aos-nav-heading,
.mud-drawer-mini:not(.mud-drawer--open) .aos-nav-heading,
.mud-drawer-mini:not(.mud-drawer--open) .aos-drawer-footer { display: none; }

.aos-content { padding-top: var(--space-6); padding-bottom: var(--space-8); }

/* ---------- Page header ---------- */
.aos-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.aos-page-title { margin: 0; }                          /* sentence case, set by Typo.h4 */
.aos-page-subtitle { margin: var(--space-1) 0 0; max-width: 72ch; color: var(--slate-600); }
.aos-page-actions { display: flex; gap: var(--space-2); align-items: center; }

/* ---------- Panels, tables ---------- */
.mud-paper { border-radius: var(--radius-md); }
.mud-paper.mud-paper-outlined { border-color: var(--slate-200); }

.mud-table, .mud-data-grid {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.mud-table-head .mud-table-cell, .mud-data-grid .mud-table-head .mud-table-cell {
    background: var(--slate-50);
    color: var(--slate-600);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 1px solid var(--slate-200);
}
.mud-table-body .mud-table-row:hover { background: var(--slate-50); }
.mud-table-cell { border-bottom-color: var(--slate-200); font-size: 14px; }

.mud-input-control .mud-input-outlined .mud-input-outlined-border { border-radius: var(--radius-sm); }
.mud-button-root { border-radius: var(--radius-md); white-space: nowrap; }
.mud-dialog { border-radius: var(--radius-lg); box-shadow: var(--elevation-3); }
.mud-dialog .mud-dialog-title { font-weight: 600; }

/* ---------- Form rows: inputs share a row when there is room, wrap when there is not ---------- */
.aos-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-2) var(--space-4);
    align-items: end;
}

.aos-warn-text { color: var(--warning-fg) !important; }

/* ---------- Billable toggle pill: a compact chip-like checkbox next to the equipment actions ---------- */
.aos-toggle-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--slate-100);
    padding: 0 var(--space-2) 0 0;
    margin-right: var(--space-1);
    transition: background-color .15s ease, color .15s ease;
}
.aos-toggle-pill--on { background: var(--success-bg); color: var(--success-fg); }
.aos-toggle-pill .mud-typography-body1 { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }

/* ---------- Checklist rows: a card per step that highlights green once checked off ---------- */
.aos-checklist-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-1) var(--space-3);
    margin-bottom: var(--space-2);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--slate-50);
    transition: background-color .15s ease, border-color .15s ease;
}
.aos-checklist-row--done {
    background: var(--success-bg);
    border-color: var(--success);
}
/* MudBlazor gives a boolean MudInputControl width:0 and lets its label overflow visually - fine when
   nothing sits to its right, but here it would overlap the remarks field. Give it a real reserved width
   (wide enough for "Location Correct", the longest step name) so every remarks field lines up and is
   the same width regardless of step name length. */
.aos-checklist-check { flex: 0 0 170px; width: 170px; }
.aos-checklist-check .mud-checkbox { width: 100%; }
.aos-checklist-check .mud-typography-body1 { font-weight: 500; white-space: nowrap; }
.aos-checklist-remarks { flex: 0 0 auto; width: 220px; }

/* Outlined text fields default to the primary (blue) color on focus; the checklist remarks use a
   neutral gray instead so the whole row stays within the green/slate palette used here. */
.aos-checklist-remarks .mud-input-outlined:focus-within > .mud-input-outlined-border,
.aos-checklist-remarks .mud-input-outlined:focus-within .mud-shrink > .mud-input-outlined-border {
    border-color: var(--slate-400) !important;
}

/* ---------- Device model picker activator: looks like a text field, opens a MudMenu on click ---------- */
.aos-device-model-activator {
    width: 100%;
    cursor: pointer;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .42);
}
.aos-device-model-activator-label { display: block; color: rgba(0, 0, 0, .6); }

/* ---------- Blacklisted-client badge: a small warning bubble pinned to a button's corner ---------- */
/* Size.Small MudIconButton renders at 26x26px, so this is exactly half that. MudBadge's own CSS sets a
   fixed width/height, so these need !important to win. */
.aos-blacklist-badge.mud-badge {
    width: 13px !important;
    height: 13px !important;
    min-width: 13px !important;
    padding: 0 !important;
}
.aos-blacklist-badge.mud-badge .mud-icon-root {
    font-size: 9px !important;
    width: 9px !important;
    height: 9px !important;
}

/* ---------- Alerts: dark text on a tinted fill (state colour on its own is too light for text) ---------- */
.mud-alert-text-error   { background: var(--critical-bg); color: var(--critical-fg); }
.mud-alert-text-warning { background: var(--warning-bg);  color: var(--warning-fg); }
.mud-alert-text-success { background: var(--success-bg);  color: var(--success-fg); }
.mud-alert-text-info    { background: var(--info-bg);     color: #1639C4; }
.mud-alert .mud-link { font-weight: 600; text-decoration: underline; }

/* ---------- Status chip: tinted fill + icon + label (colour is never the only signal) ---------- */
.aos-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    white-space: nowrap;
}
.aos-chip .mud-icon-root { width: 14px; height: 14px; }
.aos-chip--neutral  { background: var(--slate-100); color: var(--slate-700); }
.aos-chip--info     { background: var(--info-bg); color: #1639C4; }
.aos-chip--success  { background: var(--success-bg); color: var(--success-fg); }
.aos-chip--warning  { background: var(--warning-bg); color: var(--warning-fg); }
.aos-chip--critical { background: var(--critical-bg); color: var(--critical-fg); }

/* ---------- Stat tiles ("data with a job": each number links to the queue it counts) ---------- */
.aos-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}
.aos-tile {
    display: block;
    padding: var(--space-4) var(--space-6);
    background: var(--paper);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    box-shadow: var(--elevation-1);
    color: var(--ink);
    transition: border-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-small) var(--ease-out);
}
.aos-tile:hover { text-decoration: none; border-color: var(--slate-300); box-shadow: var(--elevation-2); }
.aos-tile-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.02em; color: var(--slate-600); }
.aos-tile-value { margin-top: var(--space-2); font-size: 36px; line-height: 44px; font-weight: 600; letter-spacing: -0.01em; }
.aos-tile-hint { margin-top: var(--space-1); font-size: 14px; line-height: 20px; color: var(--slate-600); }
.aos-tile--critical { border-left: 3px solid var(--critical); }
.aos-tile--critical .aos-tile-value { color: var(--critical-fg); }
.aos-tile--warning { border-left: 3px solid var(--warning); }

/* ---------- Validation / errors ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--signal-green); }
.invalid { outline: 1px solid var(--critical); }
.validation-message { color: var(--critical-fg); }

.blazor-error-boundary {
    background: var(--critical);
    padding: 1rem 1rem 1rem 1rem;
    color: #fff;
    border-radius: var(--radius-md);
}
.blazor-error-boundary::after { content: "Something went wrong on this page." }

#blazor-error-ui {
    color-scheme: light only;
    background: var(--critical-bg);
    color: var(--critical-fg);
    border-top: 2px solid var(--critical);
    bottom: 0;
    box-shadow: var(--elevation-3);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ---------- Reduced motion is non-negotiable (s.08) ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
        animation-delay: 0ms !important;
        scroll-behavior: auto !important;
    }
}

/* Spinner shown inside a data grid's body while it loads: shorter than the full-page one. */
.aos-spinner-wrap.aos-spinner-wrap--grid { min-height: 260px; }
