/* ConveySure shared UI components (Phase 7.7). Buttons, cards, status
   badges/tags, notices, tables, form fields, KPI boxes and steps —
   extracted from base.html so every template that links this sheet gets
   the same components. Loaded after tokens.css; consumes its tokens. */

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── Buttons ──
   Primary action uses the warm-brown operational anchor (--app-primary); gold
   (.btn.gold) is retained for prominent call-to-action buttons. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--app-primary);
  color: var(--app-primary-contrast);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--app-primary-hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--app-primary-soft), 0 0 0 4px var(--app-primary); }
.btn.primary { background: var(--app-primary); color: var(--app-primary-contrast); }
.btn.primary:hover { background: var(--app-primary-hover); }
.btn.secondary { background: var(--app-surface); color: var(--app-text-secondary); border: 1px solid var(--app-border-strong); }
.btn.secondary:hover { background: var(--app-surface-subtle); border-color: var(--app-primary); color: var(--app-text); }
/* Retained for public marketing CTAs only — not used on operational surfaces. */
.btn.gold { background: var(--gold); color: #fff; border-color: transparent; }
.btn.gold:hover { background: var(--gold-dark); }
.btn.sm { padding: 5px 10px; font-size: 11px; border-radius: 7px; }
.btn.danger { background: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }

/* ── Typography ── */
.muted { color: var(--muted); font-size: 13px; }
h1, h2, h3, h4 { margin: 0 0 .5em 0; font-weight: 600; }

/* ── Tags ── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: #eef2ff;
  color: #3730a3;
  white-space: nowrap;
}
.tag.good { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef9c3; color: #854d0e; }
.tag.bad  { background: #fee2e2; color: #991b1b; }
.tag.gray { background: #f3f4f6; color: #6b7280; }
.tag.info { background: var(--processing-bg); color: var(--processing-text); }
.tag.ai   { background: var(--ai-bg); color: var(--ai-text); }

/* ── Layout ── */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.col { flex: 1 1 300px; }

/* ── KPI boxes ── */
.kpi { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi .box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 140px;
  flex: 1;
}
.kpi .box .label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .06em; }
.kpi .box .value { font-size: 22px; font-weight: 700; font-family: 'Playfair Display', serif; margin-top: 2px; }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 8px 10px; border-bottom: 2px solid #f0f0f4; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #9ca3af; }
td { text-align: left; padding: 10px; border-bottom: 1px solid #f5f5f8; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaf8; }

/* ── Form elements ── */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}
label { font-size: 12px; font-weight: 500; color: #374151; }

/* ── Notices ── */
.notice { padding: 10px 14px; border-radius: 10px; margin: 10px 0; border: 1px solid #e5e7eb; background: #f3f4f6; font-size: 13px; }
.notice.good { background: #ecfdf5; border-color: #a7f3d0; }
.notice.warn { background: #fffbeb; border-color: #fde68a; }
.notice.bad  { background: #fef2f2; border-color: #fecaca; }

/* ── Steps (kept for compatibility) ── */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.step { border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; background: #fff; }
.step h4 { margin: 0 0 6px 0; font-size: 13px; }
.step .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* ── Misc ── */
.card-lite { background: #f9fafb; border: 1px solid #e5e7eb; padding: 12px; border-radius: 12px; }
.checkgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 640px) { .checkgrid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; }
.check input { width: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   Shared operational components (Funding/Dashboard redesign §14)
   Reusable patterns for the authenticated workspaces — panels, summary cards,
   funding rows, calculation totals, filter chips, activity rows and compact
   empty states. Colours come from the warm --app-* tokens so no workspace
   re-implements its own design system inside a <style> block.
   ────────────────────────────────────────────────────────────────────────── */

/* Workspace panel */
.panel { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; padding: 16px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.panel-title { font-size: 1.0625rem; font-weight: 700; margin: 0; letter-spacing: -.01em; color: var(--app-text); }
.panel-sub { font-size: .75rem; color: var(--app-text-secondary); margin: 0 0 12px; line-height: 1.5; }
.panel-link { font-size: .8125rem; font-weight: 600; color: var(--app-primary); text-decoration: none; white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }

/* Summary cards (operational KPI strip) */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.summary-card { display: block; text-decoration: none; background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: 12px; padding: 14px 16px; transition: border-color .15s, box-shadow .15s; }
.summary-card:hover, .summary-card:focus-visible { border-color: var(--app-primary); box-shadow: var(--shadow-md); outline: none; }
.summary-card .sc-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--app-text-secondary); }
.summary-card .sc-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin: 4px 0 2px; color: var(--app-text); }
.summary-card .sc-detail { font-size: .75rem; color: var(--app-text-muted); line-height: 1.35; }

/* Filter chips — warm-brown selected state on the authenticated shell */
.chip { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; color: var(--app-text);
  border: 1px solid var(--app-border-strong); background: var(--app-surface); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; transition: border-color .15s, background .15s, color .15s; }
.chip:hover, .chip:focus-visible { border-color: var(--app-primary); outline: none; }
.chip.active, .chip[aria-pressed="true"] { background: var(--app-primary); border-color: var(--app-primary); color: var(--app-primary-contrast); }
.chip .count { font-variant-numeric: tabular-nums; opacity: .8; }

/* Funding rows + calculation totals (money, tabular) */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--app-surface-subtle); }
.calc-row:last-child { border-bottom: 0; }
.calc-row .calc-label { font-size: .8125rem; color: var(--app-text-secondary); }
.calc-row .calc-value { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--app-text); white-space: nowrap; }
.calc-total { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 10px 0 2px; margin-top: 4px; border-top: 2px solid var(--app-border-strong); }
.calc-total .calc-label { font-weight: 700; font-size: .875rem; color: var(--app-text); }
.calc-total .calc-value { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--app-text); }
.calc-row.muted .calc-label, .calc-row.muted .calc-value { color: var(--app-text-muted); }

/* Activity rows */
.activity-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--app-surface-subtle); }
.activity-row:last-child { border-bottom: 0; }
.activity-title { font-size: .875rem; font-weight: 600; line-height: 1.4; color: var(--app-text); }
.activity-meta { font-size: .75rem; color: var(--app-text-secondary); line-height: 1.5; }
.activity-when { font-size: .75rem; color: var(--app-text-muted); }

/* Compact empty state — a single line, not a large dashed box (§11.4) */
.empty-line { font-size: .8125rem; color: var(--app-text-secondary); padding: 10px 2px; margin: 0; }
.empty-box { border: 1px dashed var(--app-border-strong); border-radius: 10px; background: var(--app-surface-subtle);
  padding: 18px 16px; text-align: center; }
.empty-box strong { display: block; font-size: .8125rem; margin-bottom: 3px; color: var(--app-text); }
.empty-box p { margin: 0; font-size: .75rem; color: var(--app-text-secondary); }

/* Status pills reused across funding + activity (semantic, never colour-only) */
.status-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--app-border); background: var(--app-surface-subtle); color: var(--app-text-secondary); }
.status-pill.good { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.status-pill.warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.status-pill.bad { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.status-pill.info { background: var(--processing-bg); border-color: var(--processing-border); color: var(--processing-text); }

/* ══════════════════════════════════════════════════════════════════════════
   Shared authenticated-workspace card + layout system (card-spacing pass)
   One reusable card and one set of stack/grid primitives for every operational
   page. The golden rule: the PARENT stack/grid owns the spacing via `gap`;
   cards never carry external margins. This removes the compounded/uneven
   spacing that arises when card margins and parent gaps are combined. Colours
   come from the warm --surface/--border/--muted tokens — no new colour system.
   ────────────────────────────────────────────────────────────────────────── */

/* Card ---------------------------------------------------------------------- */
.workspace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--workspace-card-radius);
  padding: var(--workspace-card-padding);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.workspace-card--large { padding: var(--workspace-card-padding-large); }
/* A card that lives inside a stack/grid must not add its own margin — the
   parent gap is the single source of spacing. */
.workspace-stack > .workspace-card,
.workspace-grid > .workspace-card { margin: 0; }

.workspace-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--workspace-gap-md);
  margin: 0 0 var(--workspace-gap-md);
}
.workspace-card__heading { margin: 0; font-size: var(--font-panel-title); font-weight: 700; color: var(--text); }
.workspace-card__description { margin: var(--workspace-gap-xs) 0 0; color: var(--muted); font-size: var(--font-small); line-height: 1.5; }
.workspace-card__body { min-width: 0; }
.workspace-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--workspace-gap-md);
  margin-top: var(--workspace-gap-lg);
  padding-top: var(--workspace-gap-md);
  border-top: 1px solid var(--border);
}

/* Stacks & grids (parent-controlled spacing) -------------------------------- */
.workspace-stack { display: grid; gap: var(--workspace-grid-gap); }
.workspace-stack--section { gap: var(--workspace-section-gap); }

.workspace-grid { display: grid; gap: var(--workspace-grid-gap); align-items: start; }
.workspace-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.workspace-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workspace-grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.workspace-grid > * { min-width: 0; }

/* Compact empty state — never a large vertical panel for one or two lines. */
.workspace-empty {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.workspace-empty strong { display: block; font-size: var(--font-small); margin-bottom: var(--workspace-gap-xs); color: var(--text); }
.workspace-empty p { margin: 0; font-size: var(--font-micro); color: var(--muted); line-height: 1.5; }
.workspace-empty .workspace-empty__action { margin-top: var(--workspace-gap-md); }

@media (max-width: 1024px) {
  .workspace-grid--2,
  .workspace-grid--3,
  .workspace-grid--sidebar { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .workspace-card { padding: 14px; }
  .workspace-stack { gap: 14px; }
  .workspace-grid { gap: 14px; }
  .workspace-stack--section { gap: 16px; }
}
