/* PrimaryCare FAST — Components */

/* ---------- Icon defaults (prevent SVGs ballooning in flex layouts) ---------- */
svg { flex-shrink: 0; }
.btn svg              { width: 18px; height: 18px; }
.btn-sm svg           { width: 16px; height: 16px; }
.btn-lg svg           { width: 22px; height: 22px; }
.btn-icon svg         { width: 22px; height: 22px; }
.fab svg              { width: 26px; height: 26px; }
.list-item > svg      { width: 22px; height: 22px; }
.list-item .chev      { width: 20px; height: 20px; color: var(--color-text-muted); }
.list-item .icon-wrap svg { width: 20px; height: 20px; }
.action-card .icon-wrap svg { width: 22px; height: 22px; }
.event-btn svg        { width: 22px; height: 22px; }
.tab-bar a svg        { width: 22px; height: 22px; }
.search-bar svg       { width: 18px; height: 18px; }
.disclaimer svg       { width: 18px; height: 18px; }
.chip svg             { width: 14px; height: 14px; }
.badge svg            { width: 14px; height: 14px; }
.workflow-step svg    { width: 14px; height: 14px; }
.empty svg            { width: 56px; height: 56px; }
.app-header .back-btn svg,
.app-header .header-action svg { width: 22px; height: 22px; }

/* ---------- Header ---------- */
.app-header .back-btn,
.app-header .header-action {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--color-text);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.app-header {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.app-header .back-btn:hover,
.app-header .header-action:hover { background: var(--color-surface-2); }
.app-header .header-title {
  flex: 1;
  font-size: var(--fs-h3);
  font-weight: 600;
  margin: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-header .header-actions { display: inline-flex; gap: 4px; }

/* ---------- Tab bar ---------- */
.tab-bar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 4px;
  min-height: 44px;
}
.tab-bar a svg { width: 22px; height: 22px; }
.tab-bar a[aria-current="page"] { color: var(--color-primary); }
.tab-bar a:hover { text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--color-surface-2);
  color: var(--color-text);
  height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-lg { height: 60px; font-size: 18px; }

/* SJA primary CTA = yellow on black-type */
.btn-primary {
  background: var(--brand-cta-bg);
  color: var(--brand-cta-fg);
  border-color: transparent;
}
.btn-primary:hover {
  background: var(--brand-cta-hover);
}

/* Secondary = NHS/SJA disciplined green flood */
.btn-secondary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: transparent;
}
.btn-secondary:hover {
  background: var(--color-primary-700);
  color: var(--color-on-primary);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
}
.btn-ghost:hover { background: var(--color-surface-2); }

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Floating action button */
.fab {
  position: fixed;
  right: var(--sp-md);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-md));
  width: 60px; height: 60px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-float);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  cursor: pointer;
}
.fab:active { transform: scale(0.96); }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-md) var(--sp-md);
}
.card + .card { margin-top: var(--sp-md); }
.card-title { font-size: var(--fs-h3); font-weight: 600; margin-bottom: var(--sp-sm); }
.card-subtitle { font-size: var(--fs-secondary); color: var(--color-text-secondary); margin-bottom: var(--sp-md); }
.card-row { display: flex; align-items: center; gap: var(--sp-md); justify-content: space-between; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { text-decoration: none; }

.hero-card {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-700));
  color: #fff;
  border: none;
  padding: var(--sp-lg);
}
.hero-card .greeting { font-size: 14px; opacity: 0.9; }
.hero-card .title { font-size: 24px; font-weight: 700; margin-top: 4px; }
.hero-card .row { margin-top: var(--sp-md); display: flex; align-items: center; gap: var(--sp-sm); flex-wrap: wrap; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--color-border);
}
.chip svg { width: 14px; height: 14px; }
.chip-primary { background: var(--score-blue-bg); color: var(--score-blue-fg); border-color: transparent; }
.chip-success { background: var(--score-green-bg); color: var(--score-green-fg); border-color: transparent; }
.chip-warning { background: var(--score-amber-bg); color: var(--score-amber-fg); border-color: transparent; }
.chip-danger { background: var(--score-red-bg); color: var(--score-red-fg); border-color: transparent; }

/* ---------- Score badge ---------- */
.score-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  padding: var(--sp-md) var(--sp-lg);
  min-width: 120px;
  background: var(--score-blue-bg);
  color: var(--score-blue-fg);
}
.score-badge[data-band="green"] { background: var(--score-green-bg); color: var(--score-green-fg); }
.score-badge[data-band="amber"] { background: var(--score-amber-bg); color: var(--score-amber-fg); }
.score-badge[data-band="red"] { background: var(--score-red-bg); color: var(--score-red-fg); }
.score-badge .num { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score-badge .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }

/* ---------- Stat tile ---------- */
.stat-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-tile .stat-label { font-size: 12px; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-tile .stat-sub { font-size: 12px; color: var(--color-text-secondary); }

/* ---------- Timeline row ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.timeline-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--sp-sm);
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px var(--sp-md);
}
.timeline-row .t {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.timeline-row .label { font-weight: 600; }
.timeline-row .meta { font-size: 12px; color: var(--color-text-secondary); }
.timeline-row .actions { display: inline-flex; gap: 4px; }
.timeline-row[data-kind="critical"] .label { color: var(--color-danger); }
.timeline-row[data-kind="success"] .label { color: var(--color-success); }

/* ---------- Field ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-md);
}
.field label { font-size: 14px; font-weight: 600; color: var(--color-text); }
.field .helper { font-size: 12px; color: var(--color-text-secondary); }
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="datetime-local"],
.field input[type="search"],
.field select,
.field textarea {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
  min-height: 44px;
  transition: border-color var(--t-fast) var(--ease);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--shadow-focus);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-sm); }
.field-inline { display: flex; align-items: center; gap: var(--sp-sm); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle .track {
  width: 48px; height: 28px;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  position: relative;
  transition: background var(--t-fast) var(--ease);
  border: 1px solid var(--color-border);
}
.toggle .thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--t-fast) var(--ease);
}
.toggle input:checked + .track { background: var(--color-primary); border-color: var(--color-primary); }
.toggle input:checked + .track .thumb { transform: translateX(20px); }

.segmented {
  display: inline-flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--color-border);
  gap: 2px;
  width: 100%;
}
.segmented button {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--color-text);
  height: 36px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.segmented button[aria-pressed="true"] {
  background: var(--color-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  color: var(--color-primary);
}

/* ---------- Quick action grid ---------- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
}
@media (min-width: 480px) {
  .action-grid { grid-template-columns: repeat(3, 1fr); }
}
.action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-sm);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  min-height: 100px;
  transition: transform var(--t-fast) var(--ease);
}
.action-card:active { transform: scale(0.98); }
.action-card .icon-wrap {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--sja-light-green);
  color: var(--sja-dark-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.action-card .icon-wrap svg { width: 22px; height: 22px; }
.action-card .label { font-weight: 600; font-size: 15px; }
.action-card .sub { font-size: 12px; color: var(--color-text-secondary); }

/* Color variants for action cards */
.action-card[data-color="green"] .icon-wrap { background: var(--score-green-bg); color: var(--score-green-fg); }
.action-card[data-color="amber"] .icon-wrap { background: var(--score-amber-bg); color: var(--score-amber-fg); }
.action-card[data-color="red"] .icon-wrap { background: var(--score-red-bg); color: var(--score-red-fg); }

/* Event grid (arrest logger) */
.event-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
}
@media (min-width: 480px) {
  .event-grid { grid-template-columns: repeat(4, 1fr); }
}
.event-btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-lg);
  padding: var(--sp-md) 8px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-height: 80px;
  transition: transform var(--t-fast) var(--ease);
}
.event-btn:active { transform: scale(0.97); }
.event-btn svg { width: 22px; height: 22px; }
.event-btn[data-tone="primary"] { background: var(--color-primary); color: #fff; border-color: transparent; }
.event-btn[data-tone="danger"] { background: var(--color-danger); color: #fff; border-color: transparent; }
.event-btn[data-tone="success"] { background: var(--color-success); color: #fff; border-color: transparent; }
.event-btn[data-tone="warning"] { background: var(--color-warning); color: #fff; border-color: transparent; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--color-surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) + var(--safe-bottom));
  max-height: 85dvh;
  overflow: auto;
  box-shadow: var(--shadow-float);
}
.modal-title { font-size: var(--fs-h2); margin-bottom: var(--sp-sm); }
.modal-actions { display: flex; gap: var(--sp-sm); margin-top: var(--sp-md); }
.modal-actions .btn { flex: 1; }

/* ---------- Toasts ---------- */
.toast {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in var(--t-base) var(--ease);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
}
.toast[data-tone="success"] { background: var(--color-success); color: #fff; }
.toast[data-tone="danger"] { background: var(--color-danger); color: #fff; }
.toast[data-tone="warning"] { background: var(--color-warning); color: #0F172A; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Search bar ---------- */
.search-bar {
  position: relative;
  margin-bottom: var(--sp-md);
}
.search-bar input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 16px;
}
.search-bar svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--color-text-secondary);
  pointer-events: none;
}

/* ---------- Disclaimer banner ---------- */
.disclaimer {
  background: var(--score-amber-bg);
  color: var(--score-amber-fg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: var(--sp-md);
}
.disclaimer svg { flex: 0 0 auto; width: 18px; height: 18px; }

/* ---------- Offline / privacy badges ---------- */
.badge-row { display: flex; gap: var(--sp-sm); flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.18);
  color: inherit;
}
.badge svg { width: 14px; height: 14px; }
.badge-success { background: var(--score-green-bg); color: var(--score-green-fg); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: var(--sp-xl) var(--sp-md);
  color: var(--color-text-secondary);
}
.empty svg { width: 56px; height: 56px; opacity: 0.4; margin-bottom: var(--sp-md); }
.empty h3 { color: var(--color-text); margin-bottom: 4px; }

/* ---------- Progress bar ---------- */
.progress {
  width: 100%;
  height: 8px;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--t-base) var(--ease);
}
.progress[data-band="green"] > span { background: var(--color-success); }
.progress[data-band="amber"] > span { background: var(--color-warning); }
.progress[data-band="red"] > span { background: var(--color-danger); }

/* ---------- Section header ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-sm);
  margin-top: var(--sp-md);
}
.section-head h2, .section-head h3 { margin: 0; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: var(--sp-sm); }
.list-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.list-item:hover { background: var(--color-surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow .title { font-weight: 600; }
.list-item .grow .meta { font-size: 12px; color: var(--color-text-secondary); }
.list-item .chev { color: var(--color-text-muted); }
