/* Shared components. Page-specific styles go in css/pages/<area>.css; move a pattern here
   once a second page needs it. Matching Jinja macros live in templates/redesign/_macros.html. */

/* ---------- Page header & breadcrumb ---------- */
.breadcrumb { font-size: var(--fs-md); color: var(--text-subtle); }
.breadcrumb a, .breadcrumb .link-button { color: var(--text-subtle); }
.breadcrumb__sep { margin: 0 4px; }

.page-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-header__text { flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; }
.page-header__sub { color: var(--text-muted); }
.page-header__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.eyebrow { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.eyebrow--info { color: var(--info-fg); }
.eyebrow--success { color: var(--success-fg); }

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-md); }
.xsmall { font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); }
.strong { font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--sm { gap: 6px; }
.stack--lg { gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--baseline { align-items: baseline; }
.grow { flex-grow: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 14px;
}
.card--accent { border-top: 3px solid var(--brand); }
.card--flush { padding: 0; gap: 0; overflow: hidden; }
.card--compact { padding: 14px 18px; gap: 8px; }
.card__header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card__header > h2, .card__header > h3 { flex-grow: 1; }
.card--flush > .card__header { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card__footer { padding: 12px 20px; font-size: var(--fs-md); color: var(--text-muted); }
.card__footer--bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); }

.note { padding: 10px 12px; background: var(--surface-sunken); border-radius: var(--radius); font-size: var(--fs-md); color: var(--text-2); }

/* ---------- Stats ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.stat { padding: 14px 20px; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-left: 1px solid var(--divider); }
.stat__label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat__value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat__value--md { font-size: 22px; }
.stat__value--sm { font-size: var(--fs-lg); }
.stat__sub { font-size: var(--fs-sm); color: var(--text-muted); }
.stat__value--warn { color: var(--warn-fg); }
.stat__value--success { color: var(--success-fg); }
.stat__value--danger { color: var(--danger-fg); }
.stat__value--zero { color: var(--text-disabled); }

/* ---------- Pills, badges, on-time chips ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.pill--warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill--info { background: var(--info-bg); color: var(--info-fg); }
.pill--success { background: var(--success-bg); color: var(--success-fg); }
.pill--danger { background: var(--danger-bg); color: var(--danger-fg); }
.pill--muted { background: var(--neutral-bg); color: var(--text-muted); }
.pill--lg { padding: 5px 12px; font-size: var(--fs-md); }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--brand); color: var(--on-brand); font-size: var(--fs-xs); font-weight: 700;
}

.pct { display: inline-block; padding: 1px 6px; border-radius: var(--radius-sm); font-weight: 600; }
.pct--good { background: var(--success-bg); color: var(--success-fg); }
.pct--watch { background: var(--caution-bg); color: var(--caution-fg); }
.pct--bad { background: var(--danger-bg); color: var(--danger-fg); }
.pct--none { color: var(--text-muted); }

.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--success-fg); }
.status-dot--off::before { background: var(--text-disabled); }

.num-circle {
  flex-shrink: 0; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--neutral-bg); font-size: var(--fs-md); font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-strong); color: var(--on-brand); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--control-border); }
.btn--secondary:hover { background: var(--surface-sunken); color: var(--text); }
.btn--success { background: var(--success-fg); color: var(--on-brand); }
.btn--danger { background: var(--danger-fg); color: var(--on-brand); }
.btn--detail { background: var(--detail); color: var(--on-brand); }
.btn--quiet { background: transparent; color: var(--text-muted); }
.btn--danger-outline { background: var(--surface); color: var(--danger-fg); border-color: var(--control-border); font-weight: 500; }
.btn--sm { height: 36px; padding: 0 14px; }
.btn--lg { height: 48px; padding: 0 20px; border-radius: var(--radius-lg); }
.btn--xl { height: 52px; padding: 0 20px; border-radius: var(--radius-lg); font-size: 15px; }
.btn--block { width: 100%; }

.link-button {
  padding: 0; background: transparent; border: 0;
  color: var(--brand-strong); font-weight: 600; text-decoration: underline; cursor: pointer;
}
.link-button--plain { text-decoration: none; }
.inline-form { display: inline; margin: 0; }

/* ---------- Form controls ---------- */
.input, .select, .textarea {
  min-height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius);
}
.textarea { padding: 10px; border-radius: var(--radius-lg); resize: vertical; min-height: 0; }
.select--lg, .input--lg { min-height: 44px; border-radius: var(--radius-lg); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 500; }
.checkbox { display: inline-flex; align-items: flex-start; gap: 10px; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; }

/* ---------- Choice buttons (single choice, styled as cards) ---------- */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  min-height: 56px; padding: 10px 14px; display: flex; align-items: center; gap: 12px;
  text-align: left; border-radius: var(--radius-lg); border: 1px solid var(--control-border);
  background: var(--surface); color: var(--text);
}
.choice:hover { border-color: var(--text-muted); }
.choice[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.choice__text { display: flex; flex-direction: column; }
.choice__label { font-weight: 600; }
.choice__sub { font-size: var(--fs-sm); color: var(--text-muted); }
.choice__icon {
  width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--bg); font-weight: 700;
}

/* ---------- Chips: single-choice filter links (aria-current="true" marks the active one) ---------- */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 34px; display: inline-flex; align-items: center; padding: 6px 12px;
  border: 1px solid var(--control-border); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text); font-size: var(--fs-md); text-decoration: none;
}
.chip:hover { background: var(--surface-sunken); color: var(--text); }
.chip[aria-current="true"], .chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--on-brand); }
button.chip { font-weight: 500; }
/* Suggestion chips (e.g. common questions to the agent): lighter selected state */
.chip--suggest[aria-current="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  height: 42px; display: flex; align-items: center; gap: 6px; padding: 0 14px;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  color: var(--text-muted); text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { border-bottom-color: var(--brand); color: var(--text); font-weight: 600; }

/* ---------- Alerts & toasts ---------- */
.alert {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.alert--warn { border-color: var(--warn-line); }
.alert--info { background: var(--info-bg); border-color: var(--info-bg); color: var(--info-fg); }
.alert--danger { border-color: var(--danger-line); align-items: flex-start; }
.alert__body { flex-grow: 1; }
.alert__title { font-weight: 600; font-size: var(--fs-lg); }
.toast { padding: 6px 6px 6px 18px; }
/* .alert's display: flex would otherwise override the hidden attribute (toasts are alerts too). */
.alert[hidden] { display: none; }

/* ---------- Data tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px; background: var(--surface-sunken); border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); text-align: left; white-space: nowrap;
}
/* Sortable header (app.js data-sortable): the whole header is the button; the arrow shows the order. */
.th-sort {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; cursor: pointer;
}
.th-sort:hover { color: var(--text); }
.th-sort__icon::after { content: '↕'; opacity: .45; }
th[aria-sort] .th-sort { color: var(--text); }
th[aria-sort="ascending"] .th-sort__icon::after { content: '↑'; opacity: 1; }
th[aria-sort="descending"] .th-sort__icon::after { content: '↓'; opacity: 1; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num, .data-table .actions { text-align: right; }
.data-table--compact td { padding: 8px 12px; font-size: var(--fs-md); }
.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.cell-stack__sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 4px; }
.pager__btn {
  height: 34px; min-width: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--control-border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none;
}
.pager__btn:hover { background: var(--surface-sunken); color: var(--text); }
.pager__btn[aria-current="page"] { background: var(--text); border-color: var(--text); color: var(--on-brand); font-weight: 600; }
.pager__btn--disabled { opacity: .45; }
.pager__gap { padding: 0 4px; color: var(--text-muted); }

/* ---------- Stepper (case progress) ---------- */
.stepper {
  display: flex; padding: 14px 20px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  list-style: none; margin: 0;
}
.stepper__step { flex-grow: 1; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--fs-md); white-space: nowrap; }
.stepper__step::after { content: ""; flex-grow: 1; min-width: 12px; height: 1px; margin: 0 8px; background: var(--border); }
.stepper__step:last-child::after { display: none; }
.stepper__dot {
  width: 22px; height: 22px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--neutral-bg); font-size: var(--fs-xs); font-weight: 600;
}
.stepper__step--done { color: var(--text); }
.stepper__step--done .stepper__dot { background: var(--text); color: var(--on-brand); }
.stepper__step--current { color: var(--brand-strong); font-weight: 600; }
.stepper__step--current .stepper__dot { background: var(--surface); color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

/* ---------- Timeline (activity) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline__item { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; }
.timeline__rail { display: flex; flex-direction: column; align-items: center; }
.timeline__rail::after { content: ""; flex-grow: 1; width: 1px; background: var(--border); }
.timeline__dot { width: 10px; height: 10px; margin-top: 5px; border-radius: var(--radius-pill); background: var(--timeline-dot); }
.timeline__dot--info { background: var(--info-fg); }
.timeline__dot--success { background: var(--success-fg); }
.timeline__dot--danger { background: var(--danger-fg); }
.timeline__dot--detail { background: var(--detail); }
.timeline__dot--neutral { background: var(--text-muted); }
.timeline__body { padding-bottom: 14px; }
.timeline__text { font-size: var(--fs-md); }
.timeline__time { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Layout helpers ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--divider); }
  .card { padding: 16px; }
}
