/* ─────────────────────────────────────────────────────────────────────────────
   Canonical MudBlazor → Infinity.UI (AIR) theme bridge.

   ROOT CAUSE this fixes: MudBlazor ships its own design system — a purple primary,
   purple-grey dark surfaces and the Roboto type stack — rendered into
   --mud-palette-* / --mud-typography-* CSS variables. The Infinity.UI.MudBlazor
   `IAirMudThemeBridge.MudTheme` returns those Mud DEFAULTS (verified by reflection), so every
   MudBlazor component (dashboard cards, buttons, icons, chips, tables) renders as a second,
   un-canonical theme next to the AIR shell.

   This file makes MudBlazor consume the single canonical AIR token authority: it maps each
   --mud-palette-* / --mud-typography-* variable onto the equivalent --air-* token. Because the
   AIR tokens are regenerated per active theme by AirThemeProvider, MudBlazor now flips correctly
   with light/dark automatically. `!important` guarantees the mapping wins over MudThemeProvider's
   runtime-generated <style>. This is a token bridge, NOT a second palette — no colors are
   hand-picked here except the accent's RGB triplet (the value of --air-color-blue-500), which
   MudBlazor needs as "R,G,B" for its opacity math.
   ───────────────────────────────────────────────────────────────────────────── */

:root,
.mud-theme-provider {
    /* ── Resolvable AIR surface aliases ───────────────────────────────────────────────────────────
       AIR ships its tokens in two layers, and only ONE of them exists at runtime in this application:

         SEMANTIC layer  (--air-surface, --air-bg, --air-text, --air-hover, …) — regenerated per active
                         theme by AirThemeProvider into a <style> block scoped to `:root`.
         COMPONENT layer (--air-card-bg, --air-bg-muted, --air-accent-text, …) — declared ONLY inside
                         the static `[data-air-theme="light"]` block of air-design-tokens.css.

       InfinityNMS never sets `data-air-theme` on any element, so the component layer never applies and
       those names are undefined here. A `var()` that cannot resolve makes the WHOLE declaration invalid
       at computed-value time, so `--mud-palette-surface` computed to the guaranteed-invalid value — and
       MudBlazor's `.mud-paper { background-color: var(--mud-palette-surface) }` carries no fallback, so
       it fell back to the property's initial value: `transparent`. Every portal-rendered floating
       surface (dialog, popover, select, menu, autocomplete, date picker) was therefore see-through,
       while the modal scrim kept dimming correctly because it uses MudBlazor's own
       --mud-palette-overlay-dark and touches no AIR token. That asymmetry IS the reported defect.

       These aliases keep the component token as the PREFERRED value (so the bridge stays correct if a
       future Infinity.UI emits it at runtime) and terminate every chain in a token AirThemeProvider
       really emits. No colour is hand-picked: each fallback reproduces AIR's own definition of that
       component token, so a palette change still flows through.
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --nms-air-surface:       var(--air-card-bg, var(--air-surface));
    --nms-air-surface-muted: var(--air-bg-muted, color-mix(in srgb, var(--air-text) 4%, var(--air-bg)));
    --nms-air-on-accent:     var(--air-accent-text, var(--air-color-white, #ffffff));

    /* Accent / primary — AIR accent is blue (--air-color-blue-500 #3b6cf6), not Mud purple. */
    --mud-palette-primary: var(--air-accent) !important;
    --mud-palette-primary-rgb: 59, 108, 246 !important; /* #3b6cf6 = --air-color-blue-500 */
    --mud-palette-primary-text: var(--nms-air-on-accent) !important;
    --mud-palette-secondary: var(--air-accent) !important;
    --mud-palette-secondary-rgb: 59, 108, 246 !important;
    --mud-palette-secondary-text: var(--nms-air-on-accent) !important;
    --mud-palette-tertiary: var(--air-accent) !important;
    --mud-palette-tertiary-text: var(--nms-air-on-accent) !important;

    /* Surfaces / backgrounds — neutral AIR dark tone hierarchy (not Mud's purple-grey). */
    --mud-palette-background: var(--air-bg) !important;
    --mud-palette-background-gray: var(--nms-air-surface-muted) !important;
    --mud-palette-surface: var(--nms-air-surface) !important;
    --mud-palette-appbar-background: var(--nms-air-surface-muted) !important;
    --mud-palette-appbar-text: var(--air-text) !important;
    --mud-palette-drawer-background: var(--nms-air-surface-muted) !important;
    --mud-palette-drawer-text: var(--air-text) !important;
    --mud-palette-drawer-icon: var(--air-text-muted) !important;

    /* Text / actions. */
    --mud-palette-text-primary: var(--air-text) !important;
    --mud-palette-text-secondary: var(--air-text-muted) !important;
    --mud-palette-text-disabled: var(--air-text-subtle) !important;
    --mud-palette-action-default: var(--air-text-muted) !important;
    --mud-palette-action-disabled: var(--air-text-subtle) !important;

    /* Lines / borders / dividers. */
    --mud-palette-lines-default: var(--air-border) !important;
    --mud-palette-lines-inputs: var(--air-border) !important;
    --mud-palette-table-lines: var(--air-border) !important;
    --mud-palette-divider: var(--air-border) !important;
    --mud-palette-divider-light: var(--air-border-soft) !important;

    /* Status colors from AIR. */
    --mud-palette-error: var(--air-danger) !important;
    --mud-palette-warning: var(--air-warning) !important;
    --mud-palette-success: var(--air-success) !important;
    --mud-palette-info: var(--air-info) !important;

    /* Interactive/utility tints. The Infinity.AppShell theme host renders MudThemeProvider WITHOUT
       binding IsDarkMode, so MudBlazor emits its LIGHT palette base and the bridge alone must drive
       every surface from the AIR tokens (which AirThemeProvider regenerates per active theme). These
       map the remaining vars that would otherwise leak a Mud light default into the dark reference:
       hover/striped rows, disabled surfaces, the "Dark" named color, and the skeleton shimmer. */
    --mud-palette-action-default-hover: var(--air-hover) !important;
    --mud-palette-table-hover: var(--air-hover) !important;
    --mud-palette-table-striped: var(--nms-air-surface-muted) !important;
    --mud-palette-action-disabled-background: var(--nms-air-surface-muted) !important;
    --mud-palette-skeleton: var(--nms-air-surface-muted) !important;
    --mud-palette-dark: var(--nms-air-surface-muted) !important;
    --mud-palette-dark-text: var(--air-text) !important;

    /* Geometry. */
    --mud-default-borderradius: var(--air-radius-md) !important;

    /* Typography — single base font stack shared with the AIR shell (kills the Roboto/Arial
       fallback that made NMS text look larger & looser than the InfinityAI Segoe-UI baseline). */
    --mud-typography-default-family: var(--nms-font) !important;
    --mud-typography-body1-family: var(--nms-font) !important;
    --mud-typography-body2-family: var(--nms-font) !important;
    --mud-typography-button-family: var(--nms-font) !important;
    --mud-typography-caption-family: var(--nms-font) !important;
    --mud-typography-subtitle1-family: var(--nms-font) !important;
    --mud-typography-subtitle2-family: var(--nms-font) !important;
    --mud-typography-overline-family: var(--nms-font) !important;
    --mud-typography-h1-family: var(--nms-font) !important;
    --mud-typography-h2-family: var(--nms-font) !important;
    --mud-typography-h3-family: var(--nms-font) !important;
    --mud-typography-h4-family: var(--nms-font) !important;
    --mud-typography-h5-family: var(--nms-font) !important;
    --mud-typography-h6-family: var(--nms-font) !important;
}
