/* nca.css — NCA workbench add-ons on top of tokens.css + base.css + app.css.
   Add-only: reuses .app-header/.toolbar/.workspace/.sidebar/.content/.tab-bar/
   .input-panel/.metrics-table/.chart-box/.seg/.busy-overlay/.data-import/.di-*
   from app.css; this file only adds NCA-specific bits. */

/* ---- Sidebar dataset summary ---------------------------------------- */
.nca-empty { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin: 0; }

/* Sidebar command buttons (e.g. "Re-map columns") — the .cmd base style is scoped
   to .toolbar in app.css, so a bare .cmd here would fall back to the browser
   default and be illegible in dark mode. Give it a theme-aware secondary style. */
.sidebar .cmd {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: var(--space-2); padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.sidebar .cmd:hover { background: var(--hover); }
.sidebar .cmd .icon { display: block; }
.sidebar .cmd:disabled { opacity: .5; cursor: default; }

.nca-summary {
  display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-3);
}
.nca-summary dt { color: var(--muted); font-size: 0.85rem; }
.nca-summary dd { margin: 0; font-variant-numeric: tabular-nums; }

.nca-warnings {
  margin: 0 0 var(--space-3); padding-left: var(--space-4);
  color: var(--error); font-size: 0.82rem; line-height: 1.4;
}
.nca-warnings li { margin: 0.15rem 0; }

/* ---- Data grid ------------------------------------------------------ */
.nca-table-wrap { overflow-x: auto; }               /* wide grids scroll, page never does */
.nca-grid { width: 100%; }
.nca-grid th:first-child, .nca-grid td:first-child { text-align: left; }

/* NCA table headers: mixed-case (not the app-wide uppercase), centred; the .num
   selector is included so it beats app.css's right-aligned numeric-header rule.
   Body numeric cells stay right-aligned (unaffected). */
.nca-grid thead th,
.nca-grid thead th.num {
  text-transform: none; letter-spacing: 0; text-align: center; vertical-align: bottom;
}
.nca-grid thead th sub { font-size: 0.78em; }

/* Descriptive-stats: subhead + "Group by" control on one row; per-group caption. */
.nca-subhead-row {
  display: flex; align-items: baseline; gap: var(--space-4);
  flex-wrap: wrap; margin: var(--space-5) 0 var(--space-2);
}
.nca-subhead-row .nca-subhead { margin: 0; }
.nca-stats-group-label {
  margin: var(--space-3) 0 var(--space-1); font-size: 0.85rem; font-weight: 600;
  color: var(--fg); font-variant-numeric: tabular-nums;
}

/* ---- Plot toolbar + facet filters ----------------------------------- */
/* One vertically-centered row: scale toggle left, count + filter chips right.
   margin-top clears the tab bar above. */
.nca-plot-bar {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap; justify-content: space-between;
  margin: var(--space-3) 0 var(--space-2);
}
.nca-plot-left { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.nca-plot-right { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* A labelled toggle cluster (caption + segmented control) in the plot bar. */
.nca-plot-ctl { display: flex; align-items: center; gap: 6px; }
.nca-plot-ctl-label {
  color: var(--muted); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}

/* Multi-select "Stratify by" chips: independent on/off toggles. */
.nca-strat-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nca-strat-chip {
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.nca-strat-chip:hover:not(.active) { color: var(--fg); }
.nca-strat-chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.nca-plot-count { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.nca-plot-sep { color: var(--muted); }

.nca-filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* A facet = a <details> "chip" that opens an absolutely-positioned popover of
   value checkboxes (so many values scroll instead of pushing the plot down). */
.nca-facet { position: relative; }
.nca-facet > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font-size: 12px; font-weight: 600;
}
.nca-facet > summary::-webkit-details-marker { display: none; }
.nca-facet > summary::after { content: " ▾"; color: var(--muted); }
.nca-facet[open] > summary { border-color: var(--accent); }
.nca-facet-badge { color: var(--muted); font-weight: 400; }

.nca-facet-list {
  position: absolute; z-index: 30; right: 0; margin-top: 4px;
  min-width: 180px; max-height: 260px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-card);
  padding: var(--space-2);
}
.nca-facet-list label {
  display: flex; align-items: center; gap: 6px; padding: 2px 0;
  font-size: 13px; white-space: nowrap; cursor: pointer;
}
.nca-facet-bulk { display: flex; gap: var(--space-2); margin-bottom: 6px; }
.nca-facet-bulk button {
  font-size: 11px; padding: 2px 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg);
}
.nca-facet-bulk button:hover { background: var(--hover); }

/* ---- Linearity tab -------------------------------------------------- */
/* Two exposure-vs-dose scatter cards; side by side on a wide viewport, stacked
   otherwise. Each card is a .chart-box (card chrome from app.css). */
.nca-linearity-grid {
  display: grid; grid-template-columns: 1fr; gap: var(--space-4);
  margin-top: var(--space-2);
}
@media (min-width: 900px) { .nca-linearity-grid { grid-template-columns: 1fr 1fr; } }
.nca-linearity-cell { min-width: 0; }              /* let the chart shrink in its column */
.nca-linearity-stats {
  margin: var(--space-2) 0 0; color: var(--muted);
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
}
.nca-lin-stat-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.nca-lin-swatch {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 2px;
}

/* ---- Column-mapping dialog ----------------------------------------- */
.nca-map .nca-roles {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4);
}
@media (max-width: 620px) { .nca-map .nca-roles { grid-template-columns: 1fr; } }
.nca-role { display: flex; flex-direction: column; gap: 2px; }
.nca-role select { width: 100%; }
.nca-role-hint { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.nca-roles-disabled { opacity: 0.5; }

/* ---- Setup tab note + results extras -------------------------------- */
.nca-setup-note { max-width: 60ch; line-height: 1.5; }
.nca-setup-note p { margin: 0 0 var(--space-3); }

.nca-subhead {
  margin: var(--space-5) 0 var(--space-2);
  font-size: 0.95rem; font-weight: 600; color: var(--fg);
}
.nca-fail { color: var(--error); font-style: italic; }
.nca-flag-badge {
  color: var(--accent); font-size: 0.78rem; font-weight: 600;
  cursor: help; margin-left: 2px;
}
