/* admin-components.css — shared components. One component = one class family.
 * Zero literals: every value comes from admin-tokens.css. ISC-85 layer 3,
 * ISC-87 (chips/buttons/tables share these classes), ISC-88 (new reusable
 * pieces land here, never scoped to a view). */

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn,
button:not(.unstyled):not(.nav-tab):not(.account-button):not(.icon):not(.help-button) {
  min-height: var(--control-h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 500;
}
.btn:hover { background: var(--surface-2); }

.btn-primary, button[type="submit"]:not(.secondary) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
  font-weight: 600;
}
.btn-accent {
  min-height: 44px;
  padding: 0 var(--sp-5);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--accent);
  color: var(--white);
  font-size: var(--fs-body);
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent-deep); }
.btn-danger {
  background: var(--danger-ink);
  border-color: var(--danger-ink);
  color: var(--white);
  font-weight: 600;
}
.secondary, .btn-secondary {
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--ink);
}
.btn-ghost {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-2);
}
button.icon, .icon {
  width: 36px; height: 36px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
button.icon:hover { background: var(--tint); }

/* ── Chips ───────────────────────────────────────────────────────────────── */
/* .chip = TYPE/status pill (radius 6, tinted pair). Tones via .chip-{tone}.  */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--state-neutral-bg);
  color: var(--state-neutral-ink);
}
.chip-accent    { background: var(--accent-bg);  color: var(--accent-deep); }
.chip-danger    { background: var(--danger-bg);  color: var(--danger-ink); }
.chip-warn      { background: var(--warn-bg);    color: var(--warn-ink); }
.chip-ok        { background: var(--ok-bg);      color: var(--ok-ink); }
.chip-neutral   { background: var(--state-neutral-bg); color: var(--state-neutral-ink); }

.chip-dashed {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--ink-2);
  font-weight: 500;
}
.chip-action {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: 3px 9px;
  font-size: var(--fs-label);
}
.chip-action:hover { background: var(--tint); }

/* Meta tag pill (UCR detail header, keyword tags): radius pill, tint fill */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--tint-3);
  color: var(--ink-2);
  font-size: var(--fs-small);
}
.tag-sm { padding: 4px 10px; font-size: 12.5px; background: var(--tint); }
.tag-accent { background: var(--accent-bg); color: var(--accent-deep); font-weight: 600; }

/* Filter chips in toolbars (40px pill; active = dark) */
.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-small);
}
.chip-filter .dot { width: 8px; height: 8px; border-radius: var(--r-xs); }
.chip-filter[aria-pressed="true"], .chip-filter.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
  font-weight: 600;
}
.chip-filter.add {
  border-style: dashed;
  border-color: var(--border-strong);
  background: transparent;
  color: var(--ink-2);
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-xs); background: var(--ink-faint); }
.dot-danger { background: var(--danger-ink); }
.dot-warn { background: var(--warn); }
.dot-accent { background: var(--accent); }
.dot-muted { background: var(--ink-faint); }
.dot-ok { background: var(--ok-ink); }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.card-sm { border-radius: var(--r-xl); padding: var(--sp-4) 18px; gap: 6px; }
.card-title { font-size: var(--fs-h3); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
}

/* KPI / stat tile */
.stat {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-4) 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.stat-value {
  font: 700 32px var(--font-display);
}
.stat-value.danger { color: var(--danger-ink); }
.stat-value.warn { color: var(--warn-ink); }
.stat-note { font-size: var(--fs-label); color: var(--ink-muted); }

.stat-tile {
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--surface-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-tile b { font: 700 24px var(--font-display); }
.stat-tile span { font-size: var(--fs-label); color: var(--ink-muted); }

/* ── Tables / list cards ─────────────────────────────────────────────────── */

.table-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  overflow: hidden;
}
.table-card table { width: 100%; border-collapse: collapse; }
.table-card th {
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--tint-2);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-align: left;
}
.table-card td {
  padding: 14px var(--sp-5);
  border-bottom: 1px solid var(--tint);
  font-size: var(--fs-small);
}
.table-card tr:last-child td { border-bottom: 0; }
.table-card tr.row-failed td, .row-failed { background: var(--row-failed); }
.table-card tr.row-outlier td, .row-outlier { background: var(--row-outlier); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-2); }

th .th-sort { display: inline-flex; align-items: center; gap: 4px; }

/* ── Inputs ──────────────────────────────────────────────────────────────── */

.input,
input[type="text"], input[type="search"], input[type="email"],
input[type="password"], input[type="number"], input[type="url"],
select, textarea {
  min-height: var(--control-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-body);
}
textarea { padding: var(--sp-3); line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

.input-icon {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink-muted);
}
.input-icon input {
  flex-grow: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  padding: 0; min-height: 0;
  font-size: var(--fs-body);
  color: var(--ink);
}

/* ── Toolbar (filter row) ────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar .spacer, .toolbar .sp { flex-grow: 1; }
.toolbar .sort-label {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-small);
  color: var(--ink-2);
}

/* ── Segmented controls ──────────────────────────────────────────────────── */
/* .seg = big status segmented (Pipeline, mockup 04). .seg-window = small pill
   group (24 h / 7 d / 30 d in Monitor). */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.seg button {
  padding: 14px 16px;
  border: 0;
  border-right: 1px solid var(--tint-2);
  background: transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-body);
  color: var(--ink);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--white);
}
.seg .seg-count {
  font: 700 26px var(--font-display);
}
.seg .seg-label {
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--ink-muted);
}
.seg button[aria-selected="true"] .seg-label { color: var(--white); }
.seg .seg-count.is-empty { color: var(--ink-faint); }
.seg button.seg-danger { background: var(--row-failed); }
.seg button.seg-danger .seg-count, .seg button.seg-danger .seg-label { color: var(--danger-ink); }
.seg .seg-count.warn { color: var(--warn-ink); }

.seg-window {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--tint-3);
}
.seg-window button {
  height: var(--control-h-xs);
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--fs-small);
  color: var(--ink-2);
}
.seg-window button[aria-pressed="true"] {
  background: var(--paper);
  font-weight: 600;
  color: var(--ink);
}

/* ── States: empty / loading / error ─────────────────────────────────────── */

.empty, .loading {
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  color: var(--ink-muted);
  font-size: var(--fs-body);
}
.empty .empty-title { font-weight: 600; color: var(--ink-2); margin-bottom: var(--sp-1); }
.empty .empty-hint { font-size: var(--fs-small); }

.error-box {
  padding: var(--sp-3) 14px;
  border-radius: var(--r-lg);
  background: var(--danger-bg);
  color: var(--danger-ink-2);
  font-size: var(--fs-small);
  line-height: 1.45;
}

/* Inline callouts (heartbeat mismatch, integrity warnings, banners) */
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: var(--sp-3) 14px;
  border-radius: var(--r-lg);
  font-size: var(--fs-small);
  line-height: 1.45;
}
.callout svg { flex-shrink: 0; margin-top: 1px; }
.callout-danger { background: var(--danger-bg); color: var(--danger-ink-2); }
.callout-warn { background: var(--warn-bg); color: var(--warn-ink); }
.callout-info { background: var(--accent-bg); color: var(--accent-deep); }
.callout-neutral { background: var(--tint); color: var(--ink-2); }

.banner {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: 14px 18px;
  border: 1px solid var(--warn);
  border-radius: var(--r-xl);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: var(--fs-body);
  line-height: 1.5;
}

/* ── Bulk action bar (dark, floating) ────────────────────────────────────── */

.bulkbar {
  position: sticky;
  bottom: var(--sp-5);
  align-self: center;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 10px var(--sp-3) 10px var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-body);
  z-index: 20;
}
.bulkbar button {
  height: 38px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 0;
  background: var(--white);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 600;
}
.bulkbar button.secondary {
  background: transparent;
  border: 1px solid var(--ink-2);
  color: var(--white);
}
.bulkbar button.icon {
  width: 38px; height: 38px;
  color: var(--white);
  font-size: 18px;
}

/* ── Drawer ──────────────────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: var(--ink-alpha-18);
  z-index: 40;
}
.drawer, .pipeline-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 92vw);
  background: var(--paper);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
  border-bottom: 1px solid var(--tint-2);
}
.drawer-tabs {
  display: flex;
  gap: 2px;
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--tint-2);
}
.drawer-tab {
  padding: 10px var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: var(--fs-small);
  color: var(--ink-2);
}
.drawer-tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}
.drawer-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-6);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--white);
  font-size: var(--fs-small);
  box-shadow: var(--shadow-pop);
  z-index: 60;
}

/* ── Dialogs ─────────────────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  background: var(--paper);
  color: var(--ink);
  padding: var(--sp-6);
  max-width: min(560px, 92vw);
  box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: var(--ink-alpha-18); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}
.danger-button {
  background: var(--danger-ink);
  border-color: var(--danger-ink);
  color: var(--white);
  font-weight: 600;
}

/* ── Bars (check segments, distributions) ────────────────────────────────── */

.bar-checks {
  display: flex;
  gap: 3px;
}
.bar-checks i {
  width: 14px; height: 8px;
  border-radius: var(--r-xs);
  background: var(--tint-2);
}
.bar-checks i.pass { background: var(--ok-ink); }
.bar-checks i.fail { background: var(--danger-ink); }

.bar-stack {
  display: flex;
  height: 14px;
  border-radius: var(--r-xs);
  overflow: hidden;
  gap: 2px;
}
.bar-stack i { display: block; height: 100%; }
.bar-stack .fill-accent { background: var(--accent-strong); }
.bar-stack .fill-muted { background: var(--border-soft); }
.bar-stack .fill-danger { background: var(--danger-soft); }
.bar-stack .fill-warn { background: var(--warn); }
.bar-stack .fill-ok { background: var(--ok-ink); }

/* ── Check rows (QA / integrity) ─────────────────────────────────────────── */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--tint);
  font-size: var(--fs-small);
}
.check-row .check-mark {
  width: 20px; height: 20px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.check-row .check-mark.fail { background: var(--danger-bg); color: var(--danger-ink); }
.check-row .check-mark.pass { background: var(--ok-bg); color: var(--ok-ink); }
.check-row .check-mark.warn { background: var(--warn-bg); color: var(--warn-ink); }
.check-row .check-evidence {
  font: var(--fs-label) var(--font-mono);
  color: var(--ink-muted);
}

/* ── Breadcrumb / meta lines ─────────────────────────────────────────────── */

.breadcrumb {
  font-size: var(--fs-small);
  color: var(--ink-muted);
}
.breadcrumb a { color: var(--accent); }
.meta-mono {
  font: var(--fs-label) var(--font-mono);
  color: var(--ink-muted);
}

/* ── Assistant (docked panel) ────────────────────────────────────────────── */

.ask-dock {
  width: 460px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
}
.ask-msg-user {
  align-self: flex-end;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--r-xl) var(--r-xl) var(--r-xs) var(--r-xl);
  background: var(--ink);
  color: var(--white);
  font-size: var(--fs-body);
  line-height: 1.45;
}
.ask-msg-bot {
  align-self: flex-start;
  max-width: 90%;
  font-size: var(--fs-body);
  line-height: 1.55;
}

/* ── Selection left-bar (QA queue selection) ─────────────────────────────── */

.selbar { box-shadow: inset 3px 0 0 var(--accent); }

/* ── Skeleton placeholders ───────────────────────────────────────────────── */

.skeleton {
  border-radius: var(--r-sm);
  background: var(--tint);
  min-height: 1em;
}

/* ── Migrated from legacy admin.css (ISC-84..89) ─────────────────────────── */

/* Toolbar field sizing */
.toolbar > input { flex: 1; min-width: 250px; }
.toolbar > select { width: 190px; }

/* Status badge pill (orders/payments) */
.badge {
  display: inline-flex;
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--tint-2);
  color: var(--ink-2);
}
.badge.paid { background: var(--ok-bg); color: var(--ok-ink); }
.badge.failed, .badge.setup_failed { background: var(--danger-bg); color: var(--danger-ink); }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); }

/* Secondary hover affordance */
.secondary:hover, .btn-secondary:hover { background: var(--surface-2); }

/* Inline busy spinner inside buttons */
.button-spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--r-pill);
  animation: button-spin 0.7s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .button-spinner { animation-duration: 1.4s; }
}

/* Confirm dialog (destructive / approve flows) */
.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  padding: var(--sp-6);
}
.confirm-dialog::backdrop {
  background: var(--ink-alpha-58);
  backdrop-filter: blur(3px);
}
.confirm-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 22px;
  font-weight: 800;
}
.confirm-icon.approve { background: var(--accent-bg); color: var(--accent); }
.confirm-dialog h2 { margin: 7px 0 10px; }
.confirm-dialog p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.confirm-note {
  margin-top: var(--sp-4);
  padding: var(--sp-3) 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-small);
  line-height: 1.45;
}
.dialog-copy { margin: 6px 0 0; color: var(--ink-muted); }

/* Table-card collapses to stacked cards on narrow screens */
@media (max-width: 800px) {
  .toolbar > input { width: 100%; min-width: 0; }
  .toolbar > select { width: 100%; }
}
@media (max-width: 640px) {
  .table-card { overflow: visible; border: 0; box-shadow: none; background: transparent; }
  .table-card table { min-width: 0; }
  .table-card thead { display: none; }
  .table-card tbody { display: block; }
  .table-card tr {
    display: block;
    margin-bottom: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--paper);
    overflow: hidden;
  }
  .table-card td { display: block; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--tint); }
  .table-card td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: var(--sp-1);
    font-weight: 700;
    color: var(--ink-muted);
    font-size: var(--fs-eyebrow);
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }
  .table-card td[colspan] { display: block; text-align: left; }
  .table-card td[colspan]::before { display: none; }
}
