/*
 * Mentis Validator Admin — the only stylesheet we own.
 *
 * Everything that has a Tabler equivalent (cards, tables, buttons, badges,
 * forms, alerts, toasts, progress bars, avatars, the sidebar shell) is left
 * entirely to ../tabler/tabler.min.css and is NOT restated here. What lives
 * in this file is only the handful of components Tabler has no counterpart
 * for — the pipeline's stage/status vocabulary and the dashboard's GPU and
 * run widgets — plus the brand bridge below.
 *
 * Load order matters: this file must come after tabler.min.css so the
 * :root block below wins over Tabler's own defaults.
 */

/* --- Brand bridge -------------------------------------------------------
 * theme/theme.css (vendored from softteam-admin-theme, still the source of
 * truth for the brand palette and the logo) is no longer <link>ed: its
 * `body { background: var(--brand-bg) }` rule keys off prefers-color-scheme,
 * whereas Tabler's dark mode keys off the data-bs-theme attribute — so a
 * manual light/dark toggle would have moved Tabler's surfaces while leaving
 * the body stuck on the *system* setting, which is exactly the mismatch
 * that rule was written to prevent.
 *
 * Instead the one brand value that actually carries identity, the primary
 * blue, is mapped onto Tabler's own primary. Tabler derives -lt/-darken
 * from --tblr-primary via color-mix, so those follow automatically; only
 * the -rgb pair has to be restated by hand (it feeds rgba() call sites
 * that can't read a hex var). */
:root {
  --tblr-primary: #2563eb;
  --tblr-primary-rgb: 37, 99, 235;
}

/* Poppins is the brand face; Tabler's own stack is the fallback chain so a
 * failed webfont degrades to the same UI font Tabler would have used. */
:root {
  --tblr-font-sans-serif: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* The sidebar logo artwork is a solid dark navy shape — invisible against
 * Tabler's own light-theme white/light navbar without a white card behind
 * it (theme.css's original fix, kept here). But Tabler's OWN dark-mode CSS
 * (tabler.min.css, `[data-bs-theme=dark] .navbar-brand-autodark
 * .navbar-brand-image`) already inverts this same artwork to a solid WHITE
 * shape specifically so it reads against a dark navbar — layering an
 * unconditional white card behind that then hides it again, white-on-white
 * (confirmed live 2026-09-23: real bug, dark theme only, light theme was
 * always fine). The card is scoped to light theme only for exactly that
 * reason — dark theme needs no card at all, Tabler's own invert already
 * did the work. */
.navbar-brand-image {
  height: 2rem;
  width: auto;
}
:root:not([data-bs-theme="dark"]) .navbar-brand-image {
  box-sizing: border-box;
  padding: 3px 6px;
  background: #fff;
  border-radius: var(--tblr-border-radius);
}

/* Sidebar nav icons at 24px. Tabler sizes .nav-link-icon for inline SVG —
 * a 1.25rem box, with the glyph scaled by `svg { height: 100% }`. These are
 * Tabler Icons *webfont* glyphs, i.e. text, so the box alone does nothing:
 * the glyph follows font-size and would stay at the nav link's ~14px inside
 * a bigger box. Hence both, plus line-height 1 and a flex centre so the
 * taller glyph sits on the link's optical centre instead of riding its text
 * baseline.
 *
 * 24px, not the 32px the emoji used to need: a line icon carries its detail
 * in strokes rather than in a filled pictogram, so it reads cleanly at
 * Tabler's own icon size and looks heavy-handed blown up to 32.
 *
 * The box is set by overriding the two variables Tabler's own .nav-link-icon
 * rule reads, rather than by restating width/height at a higher specificity
 * — which also leaves its margin-inline-end alone, and that matters: the
 * folded sidebar centres the icon in the 4rem rail by setting
 * --tblr-nav-link-icon-margin-end to 0, so anything hardcoded here would sit
 * visibly off-centre when collapsed. */
.navbar-vertical .nav-link-icon {
  --tblr-nav-link-icon-width: 24px;
  --tblr-nav-link-icon-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}

/* Nothing here keeps the fold toggle visible, on purpose. Tabler hides that
 * control whenever it sits inside a folded .navbar-vertical:
 *
 *   :where([data-bs-sidebar=folded]) .navbar-vertical.navbar-expand-lg
 *       [data-bs-toggle=sidebar-folded] { display: none }
 *
 * ...plus a :not(:hover) variant, so the only way back is hovering the rail.
 * Every one of its 26 rules for this control requires that .navbar-vertical
 * ancestor, so base.html puts the button in the top header instead, where
 * none of them match. That needs no override at all — preferred over winning
 * the cascade with !important, which leaves the hide rule live and one
 * upgrade away from mattering again.
 *
 * Point the arrow where the click will actually move the sidebar. Driven off
 * aria-pressed, which Tabler's own click handler maintains, so there's no
 * second source of truth for the folded state to drift from — base.html only
 * seeds it once on load. */
.sidebar-fold-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}
[data-bs-toggle="sidebar-folded"][aria-pressed="true"] .sidebar-fold-arrow {
  transform: rotate(180deg);
}

/* --- Status vocabulary --------------------------------------------------
 * One pill per pipeline state. These class names are generated by string
 * concatenation from raw DB values in four places — two Jinja macros
 * (_run_status.html, _stage_icons.html) and their two JS mirrors in
 * dashboard.html — so the *names* are load-bearing and deliberately kept
 * as-is rather than being swapped for literal Tabler `.badge bg-*-lt`
 * classes at each call site: a value that grows a new state renders as an
 * unstyled-but-correct pill instead of silently picking up the wrong color.
 *
 * They are styled as Tabler badges (same geometry, same color-mix tint
 * recipe as .bg-*-lt) rather than importing .badge into the markup,
 * because `.status-{{ value }}` is emitted alone, without a sibling class.
 *
 * Four buckets: done-well (green), broken (red), in-flight or
 * deliberately-not-run (yellow), and inert (neutral grey). "skipped" is
 * yellow rather than grey because an auto-skipped architecture stage is a
 * thing the operator may want to notice, not a non-event. */
.status-pass, .status-completed,
.status-fail, .status-error,
.status-skipped, .status-None, .status-warning,
.status-queued, .status-running, .status-awaiting-start, .status-scheduled, .status-stalled,
.status-canceled, .status-cancelled, .status-norun {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.25em 0.5em;
  font-size: 0.85714285em;
  font-weight: var(--tblr-font-weight-medium);
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-radius: var(--tblr-border-radius);
}
.status-pass, .status-completed {
  color: var(--tblr-success);
  background: color-mix(in srgb, var(--tblr-success) 12%, transparent);
}
.status-fail, .status-error {
  color: var(--tblr-danger);
  background: color-mix(in srgb, var(--tblr-danger) 12%, transparent);
}
.status-skipped, .status-None, .status-warning,
.status-queued, .status-running, .status-awaiting-start, .status-scheduled {
  color: var(--tblr-warning);
  background: color-mix(in srgb, var(--tblr-warning) 14%, transparent);
}
.status-canceled, .status-cancelled, .status-norun {
  color: var(--tblr-secondary);
  background: var(--tblr-bg-surface-secondary);
}
/* A scheduled run that needs a human to press Start is NOT waiting in line —
 * blue, not the queued/running yellow. Stalled (queued, but nothing backs
 * it) is orange: it needs attention. */
.status-awaiting-start {
  color: var(--tblr-info);
  background: color-mix(in srgb, var(--tblr-info) 12%, transparent);
}
.status-stalled {
  color: var(--tblr-orange);
  background: color-mix(in srgb, var(--tblr-orange) 14%, transparent);
}

/* --- Stage spinner ------------------------------------------------------
 * Cycling clock faces for "this stage is running right now". Tabler's own
 * .spinner-border is a generic busy indicator; this stays custom because it
 * has to sit inline among the flat icons the other stage states use
 * (ti-circle-check / ti-thumb-down / ti-player-skip-forward /
 * ti-alert-octagon / ti-minus) and read as one of them, not as a foreign
 * widget.
 *
 * A static ti-minus for an in-progress stage read as "gated out, never
 * going to run" — identical to a genuinely skipped stage — which is what
 * made it confusing. Animating the ::after `content` through the 12 clock
 * faces (a discrete-content keyframe animation, not a transform) reads as
 * "time passing" rather than a spinning icon glued to one face.
 *
 * The faces are Tabler's own ti-clock-hour-1..12 glyphs, addressed by
 * codepoint because `content` can only carry a character, not a class —
 * hence the explicit font-family here, which is what makes those escapes
 * resolve to icons instead of tofu. They used to be clock-face emoji; once
 * every other icon in the UI became a monochrome line icon, a color emoji
 * spinner was the one glyph that no longer matched. Keep these escapes in
 * sync with tabler-icons.min.css when upgrading it — the codepoints are
 * stable across Tabler 3.x, but they are not a public API.
 *
 * The span itself stays empty: the glyphs come entirely from ::after, so a
 * screen reader gets the element's aria-label rather than 12 clock faces
 * read aloud. inline-flex + an explicit 1em square keeps the box tightly
 * centered on the glyph regardless of the surrounding font-size, which is
 * what makes the ring below land concentric instead of visibly offset. */
.stage-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 1em;
  height: 1em;
  vertical-align: middle;
}
.stage-spinner::after {
  font-family: 'tabler-icons';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  content: '\f316';
  animation: stage-clock 1.2s steps(1) infinite;
}
/* Same animation either way — a ring color, not a different glyph, is what
 * separates these, because the run genuinely is still "running" as far as
 * the UI can tell. Red: no real model activity for a while (probably killed
 * mid-pipeline by a restart). Amber: long total duration but still making
 * real progress, e.g. a huge PR still grinding through files. Solid rings,
 * not the softer color-mix tints used elsewhere, so they stay unambiguous
 * at this size. */
.stage-spinner.spinner-slow { border-radius: 50%; box-shadow: 0 0 0 3px var(--tblr-warning); }
.stage-spinner.spinner-stuck { border-radius: 50%; box-shadow: 0 0 0 3px var(--tblr-danger); }
@keyframes stage-clock {
  8.333%  { content: '\f313'; }
  16.666% { content: '\f317'; }
  25%     { content: '\f318'; }
  33.333% { content: '\f319'; }
  41.666% { content: '\f31a'; }
  50%     { content: '\f31b'; }
  58.333% { content: '\f31c'; }
  66.666% { content: '\f31d'; }
  75%     { content: '\f31e'; }
  83.333% { content: '\f314'; }
  91.666% { content: '\f315'; }
}
/* Decorative — the tooltip already says "running" in words. */
@media (prefers-reduced-motion: reduce) {
  .stage-spinner::after { animation: none; }
}

/* --- Run card -----------------------------------------------------------
 * The card body itself is a plain Tabler .card; only the pieces with no
 * Tabler counterpart are here.
 *
 * The leading icon stands in for both job status and outcome at once, so
 * it reuses the .status-* pill macros — reset that pill chrome so it reads
 * as one plain oversized glyph rather than a tiny colored badge floating
 * in a 1.3rem box. */
.run-title-icon { flex: none; font-size: 1.3rem; line-height: 1; }
.run-title-icon > span { background: none; padding: 0; border-radius: 0; font-size: 1.3rem; line-height: 1; }

/* Icon + value with no visible text label — the icon carries the meaning
 * and the full label lives in the title tooltip, rather than spending
 * permanent width on "Duration"/"Tokens"/"Tok/s" on every row. */
.run-metric {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--tblr-secondary);
}
.run-metric strong { color: var(--tblr-body-color); font-weight: 600; }

.run-stages { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
/* Stage chips are Tabler's own solid "badge with icons" (bg-{color} +
 * text-{color}-fg — see _stage_icons.html's stage_chip) rather than the
 * tinted .status-* pills Job/Outcome still use, so unlike those they
 * already contrast fine on the card surface with no override needed here. */
/* The badge's font-weight must not reach the icon: synthetic bold on an icon
 * webfont thickens the strokes unevenly (and used to make the color emoji
 * this once held render blank outright in some browsers). Tabler Icons' own
 * `.ti` rule sets normal weight too, but that is a single-class selector —
 * this one wins where both apply, and keeps working if a glyph ever appears
 * here without the .ti class. */
.run-stage-icon { font-weight: 400; }

/* --- Bar chart ----------------------------------------------------------
 * Single series (one measure per category), so: one hue, no legend, and no
 * gridlines or axis — each row already carries its own label and value, and
 * the value is labelled at the row rather than on every point. The track
 * itself is Tabler's .progress; only the label/value columns are here. */
.barchart { display: flex; flex-direction: column; gap: 0.6rem; }
.barchart__row {
  display: grid;
  grid-template-columns: minmax(6rem, 11rem) 1fr auto;
  align-items: center;
  gap: 0.85rem;
}
.barchart__label {
  font-size: 0.85rem;
  color: var(--tblr-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.barchart__value {
  font-size: 0.85rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
}

/* --- Dashboard density --------------------------------------------------
 * The Containers and GPU cards share the dashboard's top row and are read
 * at a glance, so they run tighter than Tabler's default card rhythm.
 * Scoped to that row so every other card on the site keeps normal spacing. */
.dashboard-row .card-body { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* Tabler's own `.ribbon .icon` sizing rule (1.25rem, via
 * --tblr-ribbon-icon-size) targets its SVG icon class, `.icon` — it never
 * matches our webfont icons, which use `.ti` instead, so a plain
 * `<i class="ti ...">` inside a `.ribbon` falls back to the ribbon's own
 * tiny 0.625rem label font-size and reads as barely-visible noise. Reusing
 * the same variable Tabler defines keeps this at the size their own
 * ribbon+icon combination already uses, rather than picking a new number. */
.ribbon i.ti { font-size: var(--tblr-ribbon-icon-size, 1.25rem); }

/* Utilization meters read as a second measure against memory, so they take
 * a different hue rather than a second bar of the same blue. */
.progress-bar-util { background-color: #4a3aa7; }

/* run_detail.html's model-call log — scrolls internally instead of the
 * whole page growing past the viewport. Height itself is set by that
 * page's own JS (varies with the summary card above it), this only owns
 * the overflow behavior and keeping the header readable while scrolled.
 * --tblr-card-bg is the same variable Tabler's own .card uses, so this
 * follows light/dark theme switching without a media query of its own. */
.call-log-scroll {
  overflow-y: auto;
}
.call-log-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--tblr-card-bg);
  z-index: 1;
}

/* Truncates a long model id to one line instead of wrapping its .run-metric
 * chip row below it out of alignment. */
.text-truncate-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Trigger PR page ----------------------------------------------------
   Two cards side by side: pick the pull request, then decide what to do with
   it. Both lists (.trigger-list) take whatever height is left and scroll on
   their own, so the page is one screen tall however long the file or comment
   list is — the dialog this replaced grew past the viewport. The left card's
   body keeps overflow visible on purpose: its dropdown menus would otherwise
   be clipped at the card edge. */
.trigger-layout {
  display: grid;
  grid-template-columns: minmax(20rem, 27rem) minmax(0, 1fr);
  gap: 1rem;
  height: calc(100vh - 11.75rem);
  min-height: 32rem;
}
.trigger-layout > .card { margin: 0; min-height: 0; display: flex; flex-direction: column; }
.trigger-pick-body, .trigger-work-body {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.75rem;
}
.trigger-work-body { overflow: hidden; }
.trigger-grow { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.trigger-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.trigger-list { flex: 1 1 auto; min-height: 6rem; overflow-y: auto; overflow-x: hidden; }
.trigger-work-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; }
.trigger-work-head .card-title { margin: 0; padding-bottom: 0.3rem; }
/* A row of labelled controls: each field is a small label above its control, bottom-aligned so a
   button group, selects and a checkbox share one baseline. In a narrow container (the Start/Resume
   popup) the fields stack and fill the width. */
.trigger-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; }
.trigger-field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.trigger-field > .form-label { margin: 0; font-size: 0.75rem; font-weight: 500; color: var(--tblr-secondary, #667382); line-height: 1.1; }
.trigger-field > .form-select { width: auto; max-width: 100%; }
.trigger-field > .trigger-select-provider { min-width: 8.5rem; }
.trigger-field > .trigger-select-model { width: 16rem; max-width: 100%; }
.trigger-field > .trigger-select-effort { min-width: 8rem; }
.trigger-field-check { margin: 0; padding-left: 0; min-height: 1.95rem; display: flex; align-items: center; gap: 0.4rem; }
.trigger-field-check .form-check-input { float: none; margin: 0; }
.modal .trigger-fields { flex-direction: column; align-items: stretch; }
.modal .trigger-field > .form-select { width: 100%; max-width: none; }
.trigger-foot { display: flex; align-items: center; gap: 0.5rem; }
.trigger-foot .btn { flex: none; white-space: nowrap; }
/* The chosen PR sits on its own line under the heading so a long title is cut on the right, not the left. */
.trigger-work-head .trigger-chip { order: 3; flex: 1 0 100%; max-width: none !important; text-align: left; justify-content: flex-start; }
.trigger-list .list-group-item { padding-top: 0.45rem; padding-bottom: 0.45rem; }
.trigger-foot-text { flex: 1 1 auto; min-width: 0; }
.trigger-extra summary { cursor: pointer; font-size: 0.85rem; }
.trigger-step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; margin-right: 0.35rem; border-radius: 50%;
  background: var(--tblr-primary); color: var(--tblr-primary-fg, #fff); font-size: 0.8rem; font-weight: 600;
}
@media (max-width: 991.98px) {
  .trigger-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .trigger-list { flex: none; height: 16rem; }
  .trigger-pick-body, .trigger-work-body { overflow: visible; }
  .trigger-foot { flex-wrap: wrap; justify-content: flex-end; }
  .trigger-foot-text { flex-basis: 100%; }
}

/* PR chat reuses .trigger-layout's one-screen grid, with the chat on the wide left and the standing plan panel
   on the right. The transcript and the panel body scroll on their own. */
.prchat-layout { grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr) minmax(20rem, 28rem); }
.prchat-side-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0.75rem; }
.prchat-history { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.prchat-history .list-group-item.active { background: var(--tblr-primary-lt, rgba(32, 107, 196, 0.12)); color: inherit; }
.prchat-msg.prchat-muted { color: var(--tblr-secondary, #667382); font-style: italic; }
.prchat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.prchat-msg { max-width: 90%; padding: 0.45rem 0.75rem; border-radius: 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.prchat-msg.me { align-self: flex-end; background: var(--tblr-primary); color: var(--tblr-primary-fg, #fff); }
.prchat-msg.bot { align-self: flex-start; background: var(--tblr-bg-surface-secondary, rgba(128, 128, 128, 0.12)); }
.prchat-msg.err { align-self: flex-start; background: var(--tblr-danger-lt, rgba(214, 57, 57, 0.15)); color: var(--tblr-danger, #d63939); }
.prchat-choices { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.prchat-data { overflow: auto; max-height: 16rem; }
@media (max-width: 991.98px) {
  .prchat-layout { grid-template-columns: minmax(0, 1fr); }
  .prchat-history { flex: none; max-height: 12rem; }
  .prchat-log { flex: none; max-height: 24rem; }
}
