/* Operations Centre (/operations-centre) — see AI.Client/Pages/OperationsCentre/OperationsCentre.razor.
   Global stylesheet per house convention: *.razor.css is inert in this project, and Blazor's ::deep
   combinator only exists for scoped CSS, so it can never match here — every selector below is a plain
   descendant selector.
   The header time-range control (.ops-controls / .range-seg) renders inside <PageHeader>, which is a
   sibling of the .operations-centre body div, NOT a descendant — those rules are intentionally NOT
   prefixed with .operations-centre. */

/* Every token below resolves from the house --mud-palette-* / --status-* variables rather than a literal
   hex, so this page holds correctly in light, dark AND the red tenant-operator theme without a
   `.mud-theme-dark` fork — the web host never stamps that marker class (MudThemeProvider only swaps
   the palette variables), so a class-scoped dark override here would silently never fire. Severity
   tones (success/warning/error/info) intentionally use --status-*-hue rather than --mud-palette-error
   etc., matching utilities.css: severity means the same thing in every theme and does NOT follow the
   tenant-red repaint, only genuinely actionable/selection colour does (--mud-palette-primary). */
.operations-centre {
    padding: 0 16px 32px;
    --ops-fg-1: var(--mud-palette-text-primary);
    --ops-fg-2: var(--mud-palette-text-secondary);
    --ops-fg-3: var(--mud-palette-text-secondary);
    --ops-surface: var(--mud-palette-surface);
    --ops-border: var(--mud-palette-table-lines);
    --ops-table-lines: var(--mud-palette-table-lines);
    --ops-gray-light: var(--mud-palette-background-gray);
    --ops-radius: 10px;
    --ops-radius-sm: 6px;
    --ops-radius-pill: 999px;
    --ops-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
}

.ops-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* .range-seg / .ops-controls render inside <PageHeader>, a SIBLING of .operations-centre in the DOM,
   not a descendant — the --ops-* custom properties declared on .operations-centre are out of scope
   here (CSS custom properties inherit through the DOM tree, not through selector matching), so these
   rules reference the global --mud-palette-* / --status-* tokens directly rather than the local aliases. */
.range-seg {
    display: inline-flex;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-table-lines);
    border-radius: 10px;
    overflow: hidden;
}

.range-seg button {
    background: transparent;
    border: 0;
    padding: 6px 12px;
    font: 500 12px var(--mud-typography-default-family, inherit);
    letter-spacing: .03em;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
    border-right: 1px solid var(--mud-palette-table-lines);
}

.range-seg button:last-child {
    border-right: 0;
}

.range-seg button:hover {
    background: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-primary);
}

.range-seg button.is-active {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.range-seg button:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

/* Attention banner */
.operations-centre .attention-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--status-warning-bg);
    border: 1px solid var(--status-warning-border);
    border-radius: var(--ops-radius);
    color: var(--status-warning-fg);
    font-size: 13px;
    margin-bottom: 16px;
}

.operations-centre .attention-banner .b-strong {
    font-weight: 600;
}

/* Needs Attention — promoted to a full-width lead card, above the KPI summary row. */
.operations-centre .needs-attention-card {
    margin-bottom: 16px;
}

/* KPI summary — one ruled row of compact stats, not eight cards fighting Needs Attention for
   the loudest thing on the page. Values read at body-strong weight, not display size. */
.operations-centre .kpi-summary-row {
    display: flex;
    flex-wrap: wrap;
    row-gap: 4px;
    padding: 4px 20px;
    margin-bottom: 16px;
}

/* No border-right divider here: with flex-wrap, a border tied to :last-child leaves a dangling rule
   at the end of every wrapped row except the true last item — there's no CSS-only way to detect "last
   in this particular wrapped row". Spacing alone (gap + padding) carries the separation instead. */
.operations-centre .kpi-summary-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    flex: 1 1 200px;
    min-width: 0;
}

.operations-centre .kpi-summary-icon {
    width: 26px;
    height: 26px;
    border-radius: var(--ops-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* tone-neutral carries no hue at all — a healthy count metric spends no colour, per
   the house Colour-Means-Something Rule. Only warning/error are earned by real state
   (see GetMetricToneClass); tone-success is unused by design, kept only so a future
   metric with a genuine "actively good" signal (not just "not broken") has somewhere to go. */
.operations-centre .kpi-summary-icon.tone-neutral { background: var(--ops-gray-light); color: var(--ops-fg-3); }
.operations-centre .kpi-summary-icon.tone-success { background: var(--status-success-bg); color: var(--status-success-hue); }
.operations-centre .kpi-summary-icon.tone-warning { background: var(--status-warning-bg); color: var(--status-warning-hue); }
.operations-centre .kpi-summary-icon.tone-error { background: var(--status-error-bg); color: var(--status-error-hue); }
.operations-centre .kpi-summary-icon.tone-info { background: var(--status-info-bg); color: var(--status-info-hue); }

.operations-centre .kpi-summary-text {
    min-width: 0;
    flex: 1;
}

.operations-centre .kpi-summary-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.operations-centre .kpi-summary-label {
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ops-fg-3);
    font-weight: 600;
    white-space: nowrap;
}

.operations-centre .kpi-summary-value {
    font: 600 15px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
}

.operations-centre .kpi-summary-trend {
    display: block;
    font-size: 11.5px;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.operations-centre .kpi-summary-trend.warn { color: var(--status-warning-hue); }
.operations-centre .kpi-summary-trend.bad { color: var(--status-error-hue); }
.operations-centre .kpi-summary-trend.flat { color: var(--ops-fg-3); }

/* Integrations & Devices — three collapsible subsections replacing three separate cards. */
.operations-centre .ops-subsection {
    border-top: 1px solid var(--ops-table-lines);
    margin-top: 14px;
    padding-top: 12px;
}

.operations-centre .ops-subsection-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}

.operations-centre .ops-subsection-summary::-webkit-details-marker {
    display: none;
}

.operations-centre .ops-subsection-summary::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid var(--ops-fg-3);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-right: 2px;
    transition: transform .15s ease;
    flex-shrink: 0;
}

.operations-centre .ops-subsection[open] > .ops-subsection-summary::before {
    transform: rotate(90deg);
}

.operations-centre .ops-subsection-title {
    margin: 0;
    font: 600 13px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
    flex: 1;
}

/* Two-column main */
.operations-centre .ops-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.operations-centre .ops-grid > .ops-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* Card */
.operations-centre .ops-card {
    background: var(--ops-surface);
    border-radius: var(--ops-radius);
    box-shadow: var(--ops-shadow-1);
    border: 1px solid var(--ops-border);
}

.operations-centre .ops-card.flush > .section-head {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--ops-table-lines);
}

.operations-centre .ops-card.padded {
    padding: 18px 20px;
}

.operations-centre .throughput-card {
    margin-bottom: 16px;
}

.operations-centre .throughput-card .section-head {
    margin-bottom: 8px;
}

.operations-centre .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.operations-centre .section-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.operations-centre .section-title {
    margin: 0;
    font: 600 14px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
}

.operations-centre .section-count {
    background: var(--ops-gray-light);
    color: var(--ops-fg-2);
    font: 600 11px var(--mud-typography-default-family, inherit);
    padding: 2px 8px;
    border-radius: var(--ops-radius-pill);
}

.operations-centre .section-count.has-error { background: var(--status-error-bg); color: var(--status-error-hue); }

.operations-centre .section-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* Filter pill */
.operations-centre .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--ops-radius-pill);
    font: 600 11.5px var(--mud-typography-default-family, inherit);
    background: var(--ops-gray-light);
    color: var(--ops-fg-2);
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.operations-centre .filter-chip:hover { background: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--ops-gray-light)); }

.operations-centre .filter-chip:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
}

/* A filter chip's active state is a selection, not a severity — Signal Blue per the One Blue
   Rule, and it must resolve from the palette variable (not a frozen hex) so it turns red for a
   platform operator inside a customer tenant, same as every other actionable control on the page. */
.operations-centre .filter-chip.is-active {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-color: var(--mud-palette-primary);
}

/* Triage list */
.operations-centre .triage-list {
    display: flex;
    flex-direction: column;
}

.operations-centre .triage-row {
    display: grid;
    grid-template-columns: 32px 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ops-table-lines);
    transition: background-color .15s ease;
}

.operations-centre .triage-row:last-child { border-bottom: 0; }
.operations-centre .triage-row:hover { background: var(--ops-gray-light); }

.operations-centre .triage-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--ops-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.operations-centre .triage-icon.sev-error { background: var(--status-error-bg); color: var(--status-error-hue); }
.operations-centre .triage-icon.sev-warning { background: var(--status-warning-bg); color: var(--status-warning-hue); }
.operations-centre .triage-icon.sev-info { background: var(--status-info-bg); color: var(--status-info-hue); }
.operations-centre .triage-icon.sev-resolved { background: var(--status-success-bg); color: var(--status-success-hue); }

.operations-centre .triage-body { min-width: 0; }
.operations-centre .triage-title {
    font: 600 13.5px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
}

.operations-centre .triage-sub {
    font-size: 12px;
    color: var(--ops-fg-3);
    margin-top: 2px;
}

.operations-centre .triage-when {
    font-size: 11.5px;
    color: var(--ops-fg-3);
    white-space: nowrap;
}

.operations-centre .triage-actions {
    display: flex;
    gap: 4px;
}

/* Activity feed */
.operations-centre .feed {
    display: flex;
    flex-direction: column;
}

.operations-centre .feed-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px dashed var(--ops-table-lines);
    font-size: 13px;
}

.operations-centre .feed-row:last-child { border-bottom: 0; }

.operations-centre .feed-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.operations-centre .feed-icon.t-neutral { background: var(--ops-gray-light); color: var(--ops-fg-3); }
.operations-centre .feed-icon.t-error { background: var(--status-error-bg); color: var(--status-error-hue); }
.operations-centre .feed-icon.t-warn { background: var(--status-warning-bg); color: var(--status-warning-hue); }

.operations-centre .feed-title { color: var(--ops-fg-1); font-weight: 500; }
.operations-centre .feed-meta { font-size: 11.5px; color: var(--ops-fg-3); margin-top: 2px; }
.operations-centre .feed-when { font-size: 11.5px; color: var(--ops-fg-3); white-space: nowrap; }

.operations-centre .feed-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--ops-fg-3);
    font-size: 13px;
}

/* System health */
.operations-centre .health-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0 14px;
}

.operations-centre .health-stat {
    background: var(--ops-gray-light);
    border-radius: var(--ops-radius);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.operations-centre .health-stat-label {
    font-size: 11px;
    color: var(--ops-fg-3);
    letter-spacing: .03em;
    text-transform: uppercase;
    font-weight: 600;
}

.operations-centre .health-stat-value {
    font: 600 14px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
    margin-left: auto;
}

.operations-centre .health-section-label {
    font-size: 11px;
    color: var(--ops-fg-3);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    margin: 4px 0 4px;
}

.operations-centre .health-checks {
    display: flex;
    flex-direction: column;
}

.operations-centre .health-row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--ops-table-lines);
    font-size: 13px;
}

.operations-centre .health-row:last-child { border-bottom: 0; }

.operations-centre .health-status {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.operations-centre .health-status.ok { background: var(--status-success-bg); color: var(--status-success-hue); }
.operations-centre .health-status.warn { background: var(--status-warning-bg); color: var(--status-warning-hue); }
.operations-centre .health-status.err { background: var(--status-error-bg); color: var(--status-error-hue); }

.operations-centre .health-label {
    font-weight: 600;
    color: var(--ops-fg-1);
}

.operations-centre .health-detail {
    font-size: 11.5px;
    color: var(--ops-fg-3);
    margin-top: 1px;
}

.operations-centre .health-value {
    font-size: 12px;
    color: var(--ops-fg-3);
    text-align: right;
}

/* Schedule list */
.operations-centre .sched-list {
    display: flex;
    flex-direction: column;
}

.operations-centre .sched-row {
    display: grid;
    grid-template-columns: 36px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ops-table-lines);
}

.operations-centre .sched-row:last-child { border-bottom: 0; }

.operations-centre .sched-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--ops-radius);
    background: var(--ops-gray-light);
    color: var(--ops-fg-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.operations-centre .sched-name {
    font: 600 13px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
}

.operations-centre .sched-next {
    font-size: 11.5px;
    color: var(--ops-fg-3);
    margin-top: 2px;
}

.operations-centre .sched-cadence {
    font: 600 12px var(--mud-typography-default-family, inherit);
    padding: 3px 8px;
    border-radius: var(--ops-radius-sm);
    background: var(--ops-gray-light);
    color: var(--ops-fg-3);
}

/* Job table */
.operations-centre .jobs-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ops-table-lines);
    flex-wrap: wrap;
}

.operations-centre .jobs-search {
    flex: 1;
    max-width: 320px;
    min-width: 200px;
    position: relative;
}

.operations-centre .jobs-search input {
    width: 100%;
    background: var(--ops-gray-light);
    border: 1px solid var(--ops-border);
    border-radius: var(--ops-radius);
    padding: 7px 12px 7px 32px;
    font: 400 13px var(--mud-typography-default-family, inherit);
    color: var(--ops-fg-1);
}

.operations-centre .jobs-search input:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
    border-color: var(--mud-palette-primary);
    background: var(--ops-surface);
}

.operations-centre .jobs-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ops-fg-3);
    pointer-events: none;
}

.operations-centre .jobs-table .mud-table-toolbar { display: none; }

.operations-centre .jobs-table .mud-table-head .mud-table-cell {
    font: 600 11px var(--mud-typography-default-family, inherit);
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ops-fg-3);
    background: var(--ops-surface);
    border-bottom: 1px solid var(--ops-table-lines);
}

.operations-centre .jobs-table .mud-table-cell {
    color: var(--ops-fg-1);
    border-bottom: 1px solid var(--ops-table-lines);
}

.operations-centre .jobs-table tr.is-failed .mud-table-cell:first-child {
    box-shadow: inset 3px 0 0 var(--status-error-hue);
}

.operations-centre .task-name { font-weight: 600; }
.operations-centre .task-meta { font-size: 11.5px; color: var(--ops-fg-3); margin-top: 2px; }
.operations-centre .dur-cell {
    color: var(--ops-fg-2);
    font-family: var(--mud-typography-monospace, monospace);
    font-size: 12px;
}

/* Responsive */
@media (max-width: 1280px) {
    .operations-centre .ops-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .operations-centre .triage-row { grid-template-columns: 32px 1fr; }
    .operations-centre .triage-when, .operations-centre .triage-actions { grid-column: 2; }
}
