/* ============================================================
   MudBlazor overrides (HQU-1593)
   --------------------------------------------------------------
   Ported from the AuditTrace portal's hque-overrides.css: the part
   that re-skins MudBlazor itself, which is most of what a TerraStack
   list, drawer and form render. Loaded AFTER MudBlazor.min.css.
   Three jobs:
   1. The two faces — Public Sans for text, Archivo for headings.
   2. Flatten every Mud surface: no shadows, 1px borders, token radii,
      sentence-case buttons. Structure is carried by borders.
   3. Ink, not brand blue, for the primary action.
   Radii and colours come from tokens.css — never hard-code them here.
   ============================================================ */

/* --- Font stack --------------------------------------------- */
/* [class*="mud-typography-"] too: MudBreadcrumbs emits .mud-typography-body1 without the bare
   .mud-typography class, so it otherwise falls back to MudBlazor's Roboto. */
html, body, .mud-typography, [class*="mud-typography-"], .mud-input, .mud-button-root,
.mud-table, .mud-list-item, .mud-menu-item, .mud-tooltip,
.mud-dialog, .mud-tab, .mud-nav-link {
    font-family: var(--font-sans);
}

/* --- Heading scale ------------------------------------------
   Archivo is tighter and squarer than Public Sans, so a heading reads as a
   heading at the same size — which is what lets a dense admin screen stay
   dense. .mud-h1/2/3 are listed because the .mud-typography rule above is a
   class selector and would otherwise out-specify a bare `h1`. */
h1, h2, h3,
.mud-typography.mud-h1, .mud-typography.mud-h2, .mud-typography.mud-h3 {
    font-family: var(--font-display);
    letter-spacing: var(--display-tracking);
}
/* h4–h6 are section labels, not display type; Archivo at 14–16px in a dense
   card reads as shouting. */

/* --- Links -------------------------------------------------- */
a, .mud-link {
    color: var(--accent-fg);
    text-decoration: none;
}
a:hover, .mud-link:hover {
    text-decoration: underline;
}
/* A button that is an <a> (MudButton Href) is a button, not a link. */
a.mud-button-root:hover { text-decoration: none; }

/* --- Focus -------------------------------------------------- */
/* No ring: a field shows focus through its border (below), and a ring around a
   clicked button or a heading reads as a stuck selection. */
*:focus-visible { outline: none; }

/* ============================================================
   Flatten MudBlazor surfaces
   ============================================================ */

.mud-paper, .mud-card, .mud-dialog, .mud-popover, .mud-menu-popover,
.mud-table, .mud-tabs, .mud-appbar, .mud-drawer, .mud-tooltip,
.mud-snackbar, .mud-expansion-panels {
    box-shadow: none !important;
}

.mud-paper, .mud-card {
    background: var(--canvas-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

/* A drawer floats over the page, so it keeps a shadow — the one thing flattened
   above that genuinely sits on top of something. */
.mud-drawer.mud-drawer-temporary {
    box-shadow: var(--shadow-floating) !important;
    border-radius: 0;
}

.mud-popover, .mud-menu-popover {
    background: var(--canvas-overlay);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

/* One scrollbar per dropdown, not two: the border above makes the popover 2px
   shorter than the list's inherited max-height, so the popover would scroll too. */
.mud-popover:has(> .mud-list) {
    overflow: hidden;
}

.mud-popover-provider,
.mud-popover.mud-popover-open {
    z-index: 9999 !important;
}

.mud-dialog {
    background: var(--canvas-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-dialog) !important;
}

/* --- Buttons ------------------------------------------------
   Controls sit on --radius-sm; a button rounded like a card reads soft. */
.mud-button-root {
    text-transform: none !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: none !important;
    transition: background-color 80ms ease, border-color 80ms ease;
}
.mud-icon-button { border-radius: var(--radius-sm) !important; }

/* MudBlazor's small button text is under the 13px floor. */
.mud-button-text-size-small,
.mud-button-outlined-size-small,
.mud-button-filled-size-small {
    font-size: var(--text-sm) !important;
}

/* Outlined buttons are white with a neutral rule, whatever their Color — the
   colour stays in the label and icon. */
.mud-button-outlined {
    background: var(--canvas-default);
    border: 1px solid var(--border-default);
}
.mud-button-outlined.mud-button-outlined-default { color: var(--fg-default); }
.mud-button-outlined:hover {
    background: var(--hover-bg);
    border-color: var(--border-default);
}

/* The primary action is INK, not the brand accent. "This is the main thing to
   do here" is structural, and a filled near-black button is the most legible
   affordance on the paper at any brand hue. */
.mud-button-filled.mud-button-filled-primary {
    background: var(--emphasis-bg);
    color: var(--emphasis-fg);
    border: 1px solid var(--emphasis-bg);
}
.mud-button-filled.mud-button-filled-primary:hover {
    background: var(--emphasis-bg-hover);
    border-color: var(--emphasis-bg-hover);
}

.mud-button-filled, .mud-fab,
.mud-button-filled:hover, .mud-fab:hover {
    box-shadow: none !important;
}

/* --- Inputs (outlined field skin) ---------------------------
   White inside a heavier rule than any divider: a field is where you write. */
.mud-input.mud-input-outlined {
    background: var(--canvas-default) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--fg-default) !important;
}
.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--border-input) !important;
    border-radius: var(--radius-sm) !important;
}
.mud-input.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--fg-subtle) !important;
}
.mud-input-outlined.mud-focused .mud-input-outlined-border,
.mud-input.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: var(--accent-fg) !important;
}
.mud-input.mud-input-outlined input::placeholder,
.mud-input.mud-input-outlined textarea::placeholder {
    color: var(--fg-muted) !important;
    opacity: 0.6 !important;
}
.mud-input input, .mud-input textarea, .mud-input-slot {
    color: var(--fg-default);
}
.mud-input-label {
    color: var(--fg-muted);
}
.mud-input-adornment .mud-icon-button { color: var(--fg-muted) !important; }
.mud-input-adornment-start, .mud-input-adornment-end { color: var(--fg-muted) !important; }
/* MudBlazor sizes helper text at 10.5px; a validation message is no smaller than the form. */
.mud-input-helper-text { font-size: var(--text-sm); }
.mud-input-error .mud-input-outlined-border { border-color: var(--danger-fg) !important; }
.mud-input-helper-text.mud-input-error { color: var(--danger-fg) !important; opacity: 1; }

/* --- Tabs ---------------------------------------------------
   A tab set is one bordered white card: MudBlazor only paints the tab bar, so
   the panels would otherwise sit straight on the paper (HQU-1598). */
.mud-tabs {
    background: var(--canvas-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.mud-tabs .mud-tabs-tabbar {
    border-bottom: 1px solid var(--border-muted);
    border-radius: 0;
}
.mud-tab {
    text-transform: none !important;
    font-weight: 400 !important;
    color: var(--fg-muted) !important;
}
.mud-tab.mud-tab-active {
    color: var(--fg-default) !important;
    font-weight: 600 !important;
}
.mud-tabs-toolbar-content .mud-tab-slider {
    background: var(--fg-default) !important;
    height: 2px !important;
}

/* --- Tables -------------------------------------------------
   A table is a bordered white card on the paper. Header cells are the paper
   tint in muted ink — a label row, not a second body row. */
.mud-table {
    background: var(--canvas-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}
/* A table already inside a card (TerraStack wraps its grid in an outlined
   paper) would otherwise draw a second frame just inside the first. */
.mud-paper .mud-table {
    border: 0;
    border-radius: 0;
}
.mud-table-cell {
    border-color: var(--border-muted);
    color: var(--fg-default);
}
.mud-table-head .mud-table-cell {
    background: var(--canvas-subtle);
    color: var(--fg-muted);
    font-weight: 600;
    font-size: var(--text-xs);
}
/* TerraStack freezes the first column with an inline surface-white background
   so the columns scrolling under it don't show through. Inline beats the rule
   above, which left that one heading white. Still opaque, so it still covers. */
.mud-table-head .mud-table-cell.ts-sticky-col {
    background: var(--canvas-subtle) !important;
}
.mud-table-row:hover {
    background: var(--hover-bg);
}
/* The frozen body cell takes its row's tint from --ts-row-tint (TerraStack.Blazor.UI.css).
   Publish the hover above on every list row, not only MudTable Hover ones; the extra
   .mud-table outranks TerraStack's striped rule so a hovered odd row isn't left striped. */
.ts-sticky-table.mud-table .mud-table-container .mud-table-root .mud-table-body .mud-table-row:hover {
    --ts-row-tint: var(--hover-bg);
}
.mud-table-pagination {
    color: var(--fg-muted);
    border-top: 1px solid var(--border-muted);
}

/* --- Switches / chips --------------------------------------- */
.mud-chip {
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 500;
}
.mud-chip.mud-chip-filled.mud-chip-color-default {
    background: var(--neutral-subtle);
    color: var(--fg-default);
}

/* --- Alerts -------------------------------------------------
   Text alerts take the tone grounds rather than MudBlazor's saturated tints. */
.mud-alert {
    border-radius: var(--radius-md);
    font-size: var(--text-md);
}
.mud-alert-text-info    { background: var(--info-subtle); color: var(--info-fg); }
.mud-alert-text-success { background: var(--success-subtle); color: var(--success-fg); }
.mud-alert-text-warning { background: var(--attention-subtle); color: var(--attention-fg); }
.mud-alert-text-error   { background: var(--danger-subtle); color: var(--danger-fg); }
.mud-alert-filled-success {
    background: var(--success-subtle) !important;
    border: 1px solid var(--tone-success-border);
    color: var(--success-fg) !important;
}

/* --- Dialogs ------------------------------------------------ */
.mud-dialog-title {
    font-family: var(--font-display);
    letter-spacing: var(--display-tracking);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--fg-default);
    border-bottom: 1px solid var(--border-default);
    padding: 16px 20px;
}
.mud-dialog-content {
    padding: 16px 20px;
    color: var(--fg-default);
}
.mud-dialog-actions {
    border-top: 1px solid var(--border-default);
    padding: 12px 20px;
}

/* --- Tooltip ------------------------------------------------ */
.mud-tooltip {
    background: var(--fg-default) !important;
    color: var(--canvas-default) !important;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}

/* --- Lists -------------------------------------------------- */
.mud-list-item.mud-selected-item {
    background: var(--accent-subtle);
    color: var(--accent-fg);
}
.mud-list-item:hover {
    background: var(--hover-bg);
}

/* ============================================================
   Status tones. One .tone-* class carries fg and bg; .status-chip
   reads from it. Same vocabulary as the AuditTrace portal.
   ============================================================ */
.tone-neutral { --tone-fg: var(--tone-neutral-fg); --tone-bg: var(--tone-neutral-bg); }
.tone-info    { --tone-fg: var(--tone-info-fg);    --tone-bg: var(--tone-info-bg); }
.tone-success { --tone-fg: var(--tone-success-fg); --tone-bg: var(--tone-success-bg); }
.tone-warning { --tone-fg: var(--tone-warning-fg); --tone-bg: var(--tone-warning-bg); }
.tone-danger  { --tone-fg: var(--tone-danger-fg);  --tone-bg: var(--tone-danger-bg); }
.tone-done    { --tone-fg: var(--tone-done-fg);    --tone-bg: var(--tone-done-bg); }

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 11px;
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    color: var(--tone-fg);
    background: var(--tone-bg);
}
.status-chip::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
