/* Everything On The Spectrum — Intake Portal
   Mobile-first, accessible, minimal. No CDN-served assets (CSP-tight). */

:root {
  --teal: #6FAEC0;
  --teal-dark: #4A8294;
  --gold: #F0B847;
  --ink: #1F2933;
  --ink-soft: #3E4C59;
  --muted: #7B8794;
  --bg: #F7FAFC;
  --card: #ffffff;
  --border: #E4E7EB;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --success: #166534;
  --success-bg: #DCFCE7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.05);
  --radius: 10px;
  --max-width: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Make the HTML `hidden` attribute win even when a class also sets `display`.
   Without this, e.g. `.field { display: flex }` overrides `[hidden]`'s
   UA-default `display: none` (author CSS beats UA CSS at equal specificity). */
[hidden] { display: none !important; }

/* Pinned waitlist rows — gold tint + accent on the leftmost cell only.
   `box-shadow inset` instead of `border-left` so the row baseline doesn't
   shift relative to unpinned rows (a border-left adds 3px to that cell's
   width, which throws off column alignment in the rest of the table). */
.waitlist-row-pinned td { background: #FFFBEB; }
.waitlist-row-pinned td:first-child {
  box-shadow: inset 4px 0 0 var(--gold);
  padding-left: 16px;
}
.badge-service { background: #E0F2FE; color: #075985; }

/* Pin column: keep width fixed so the badge cell never sizes wider than
   the unpinned "—" cell. Makes the Days/Child columns stay in alignment
   across rows. */
.waitlist-pin-cell { width: 100px; white-space: nowrap; }
.waitlist-pin-cell .badge {
  font-size: 12px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* Staff: inline "View answers" review on the invite detail page.
   Reuses the .pdf-* class structure that the PDF renderer outputs so
   the same rendered HTML works in both contexts. */
.form-review-row td { background: #FAFBFC; padding: 14px 18px; }
.form-review-container { font-size: 14px; line-height: 1.5; }
.form-review-container fieldset {
  border: 1px solid #d0d7de; border-radius: 6px;
  padding: 10px 14px; margin: 10px 0;
}
.form-review-container legend {
  font-weight: 600; padding: 0 6px; font-size: 14px;
}
.form-review-container .field { display: block; margin: 6px 0; }
.form-review-container .field > span {
  font-weight: 600; color: #444; display: block; margin-bottom: 2px;
  font-size: 13px;
}
.form-review-container .field-row,
.form-review-container .field-row-2 {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.form-review-container .pdf-value {
  display: inline-block; min-width: 200px;
  padding: 2px 8px;
  background: #F0F6FA; border-bottom: 1px solid #4A8294;
  color: #003366;
  font-family: Georgia, "Times New Roman", serif;
}
.form-review-container .pdf-value-multiline {
  display: block; min-height: 40px;
  padding: 6px 8px; margin-top: 2px;
  background: #F0F6FA; border: 1px solid #BCD; border-radius: 3px;
  white-space: pre-wrap;
  color: #003366;
  font-family: Georgia, "Times New Roman", serif;
}
.form-review-container .pdf-checkbox,
.form-review-container .pdf-radio {
  font-size: 18px; color: #003366; margin-right: 6px;
}
.form-review-container .pdf-signed-block {
  margin-top: 14px; padding: 10px 14px;
  background: #F0FDF4; border: 1px solid #86EFAC; border-radius: 6px;
}
.form-review-container .pdf-legal-context {
  background: #F8FAFC; border-left: 3px solid #4A8294;
  padding: 6px 12px; margin: 8px 0 14px 0;
}
.form-review-container .legal-text p { margin: 6px 0; }
/* Hide the same interactive remnants we hide in the PDF. */
.form-review-container .signature-pad-wrap,
.form-review-container .signature-pad-frame,
.form-review-container .signature-pad-actions,
.form-review-container .signature-section .form-actions,
.form-review-container .upload-grid-section,
.form-review-container .upload-trigger,
.form-review-container #form-submit-error,
.form-review-container #autosave-status,
.form-review-container .form-actions,
.form-review-container .form-breadcrumb,
.form-review-container .copy-address-row,
.form-review-container .fill-field-row,
.form-review-container .upload-confirm { display: none !important; }

/* Staff: image lightbox for uploaded insurance/ID photos. */
.upload-list { padding: 0; list-style: none; margin: 12px 0; }
.upload-list-row { padding: 6px 0; }
.upload-list-link { font-weight: 500; cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .85);
  display: flex; flex-direction: column;
  padding: 14px;
}
.lightbox-toolbar {
  display: flex; align-items: center; gap: 12px;
  color: #fff; padding: 4px 8px;
}
.lightbox-label { flex: 1; font-weight: 600; }
.lightbox-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 14px;
}
.lightbox-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  background: #fff; border-radius: 8px; padding: 6px;
  box-shadow: 0 6px 30px rgba(0,0,0,.45);
}

/* "Resume where you left off" pulse — used by resume_form.js to draw the
   parent's eye to the first empty required field when reopening an
   in-progress form. */
.resume-highlight {
  animation: resume-pulse 2.2s ease-out;
}
@keyframes resume-pulse {
  0%   { box-shadow: 0 0 0 4px rgba(240, 184, 71, .65); }
  60%  { box-shadow: 0 0 0 8px rgba(240, 184, 71, .15); }
  100% { box-shadow: 0 0 0 4px rgba(240, 184, 71, 0);  }
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--teal-dark); }
a:hover { text-decoration: underline; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--border);
}
.site-header .logo { height: 36px; width: auto; }
.staff-meta { color: var(--muted); }

.content {
  max-width: var(--max-width);
  margin: 24px auto;
  padding: 0 16px;
}

.site-footer {
  text-align: center; padding: 24px 16px; color: var(--muted);
}

h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 22px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.hero { background: var(--card); padding: 32px 24px; border-radius: var(--radius); box-shadow: var(--shadow); }

.card {
  background: var(--card);
  padding: 24px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.form legend { padding: 0 6px; font-weight: 600; color: var(--ink-soft); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.field > span,
.field > label > span { font-weight: 500; }
.field input, .field select, .field textarea {
  font: inherit; padding: 12px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
  min-height: 44px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--teal); border-color: var(--teal);
}

.actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.btn-primary, .btn-secondary {
  display: inline-block; min-height: 44px; padding: 12px 18px;
  font: inherit; font-weight: 600; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary { background: var(--teal-dark); color: #fff; }
.btn-primary:hover { background: var(--teal); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-small { min-height: 0; padding: 8px 14px; font-size: 14px; }
.btn-small:disabled { opacity: .7; cursor: default; }
.copy-address-row { margin: 8px 0 14px 0; }
.fill-field-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.subsection-heading { font-size: 16px; margin: 14px 0 6px 0; color: var(--ink-soft); }

/* Save signature button states. HTMX adds .htmx-request during the in-flight
   POST (because hx-disabled-elt="this"); we use that to swap to a "Saving…"
   label and dim the button. On success the server emits a signature:saved
   event and signature_pad.js flips the .sig-save-btn--saved class on briefly,
   showing a green checkmark + "Signature saved" so the parent has obvious
   visual confirmation right at the button (not just the alert above the pad). */
.sig-save-btn { transition: background-color .15s, color .15s, border-color .15s; }
.sig-save-btn.htmx-request { opacity: .7; cursor: progress; }
.sig-save-btn.htmx-request .sig-save-label::after { content: "…"; }
.sig-save-btn.htmx-request .sig-save-label { color: var(--muted); }
.sig-save-btn.sig-save-btn--saved {
  background: var(--success-bg);
  color: var(--success);
  border-color: #86EFAC;
}

.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* Staff dashboard */
.staff-content { background: var(--card); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* Staff pages are desktop tools and have wide tables (waitlist queue is
   10 columns). Let the page expand wider than the 720px parent-form cap. */
body.has-staff-content .content,
body:has(.staff-content) .content {
  max-width: 1200px;
}

/* Belt-and-suspenders: if a data table is still wider than its container,
   scroll horizontally inside the card instead of overflowing past it. */
.staff-content .data-table-wrap { overflow-x: auto; }
.staff-content .data-table { min-width: 100%; }
.staff-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.data-table th, .data-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 15px; }
.data-table th { color: var(--muted); font-weight: 600; }

.badge { display: inline-block; font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #EEF2F6; color: var(--ink-soft); }
.badge-sent { background: #E0F2FE; color: #075985; }
.badge-opened { background: #FEF9C3; color: #854D0E; }
.badge-partial { background: #FFEDD5; color: #9A3412; }
.badge-submitted { background: var(--success-bg); color: var(--success); }
.badge-expired, .badge-revoked, .badge-locked { background: var(--danger-bg); color: var(--danger); }

.form-list { padding: 0; list-style: none; margin: 16px 0; }
.form-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0;
  background: #fff;
}
.form-name { font-weight: 500; }
.form-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.form-status.pending {
  background: #F1F5F9;
  color: var(--muted);
  border: 1px solid var(--border);
}
.form-status.partial {
  background: #FEF3C7;       /* warm amber background */
  color: #92400E;            /* deep amber for AA contrast */
  border: 1px solid #FCD34D;
}
.form-status.submitted {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #86EFAC;
}

/* NPP document */
.document { background: var(--card); padding: 28px 26px; border-radius: var(--radius); box-shadow: var(--shadow); }
.document-header { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 18px; }
.document-meta { color: var(--ink-soft); font-size: 15px; }
.callout { background: #F8FAFB; border: 1px solid var(--border); border-left: 4px solid var(--ink-soft); padding: 14px 16px; border-radius: 6px; margin: 16px 0; }
.callout-info { border-left-color: var(--teal); background: #EFF6FC; }

/* ===== Form pages ===== */
.form-page { background: var(--card); padding: 24px 22px; border-radius: var(--radius); box-shadow: var(--shadow); }
.form-breadcrumb { margin-bottom: 12px; font-size: 14px; }
.form-breadcrumb a,
.form-breadcrumb .breadcrumb-link {
  color: var(--muted); text-decoration: none;
  background: none; border: none; padding: 0;
  font: inherit; cursor: pointer;
}
.form-breadcrumb a:hover,
.form-breadcrumb .breadcrumb-link:hover {
  color: var(--teal-dark); text-decoration: underline;
}
.form-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.autosave-status { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #EEF2F6; color: var(--ink-soft); font-size: 13px; }
.autosave-ok { background: var(--success-bg); color: var(--success); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

.field-row { display: grid; grid-template-columns: 1fr 80px 100px; gap: 12px; }
.field-row .field { min-width: 0; }
/* Two equal columns — for first/last name pairs, primary/secondary phone, etc.
   Use this instead of .field-row when you want both inputs the same width. */
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-2 .field { min-width: 0; }
@media (max-width: 540px) {
  .field-row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 540px) { .field-row { grid-template-columns: 1fr; } }

.check-row { flex-direction: row; align-items: center; gap: 8px; }
.check-row input { width: auto; min-height: auto; margin: 0; }

/* ===== Signature pad ===== */
.signature-section { margin-top: 18px; }
.signature-pad-wrap { margin: 12px 0; }
.signature-pad-frame { border: 2px dashed var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.signature-pad-frame canvas { display: block; width: 100%; height: 200px; touch-action: none; }
.signature-pad-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; flex-wrap: wrap; }

/* ===== Upload grid (Form C) ===== */
.upload-grid-section { margin-top: 16px; }
.upload-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 540px) { .upload-grid { grid-template-columns: 1fr; } }
.upload-box { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: #fff; }
.upload-label { font-weight: 500; margin-bottom: 8px; }
.upload-trigger { display: block; cursor: pointer; }
.upload-trigger input[type="file"] { position: absolute; left: -9999px; opacity: 0; }
.upload-cta {
  display: inline-block; padding: 10px 14px; border: 1px solid var(--teal-dark);
  color: var(--teal-dark); border-radius: 8px; font-weight: 600; background: #fff;
}
.upload-trigger:hover .upload-cta { background: var(--teal); color: #fff; border-color: var(--teal); }
.upload-confirm { margin-top: 8px; min-height: 20px; }
.upload-confirmed {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #86EFAC;
  font-weight: 600;
  font-size: 13px;
}
.upload-confirmed::before { content: "✓ "; }
.upload-confirmed-text { margin-right: 8px; }
.upload-pending { color: var(--muted); font-style: italic; }
.upload-error { color: var(--danger); font-weight: 500; }
.upload-remove-btn {
  margin-left: 6px;
  padding: 2px 8px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.upload-remove-btn:hover { background: var(--danger-bg); }
/* Wrapper that toggles the secondary upload boxes — display:contents so the
   wrapper itself is transparent to the grid layout, but [hidden] still
   collapses everything via our universal [hidden]{display:none!important}. */
.upload-secondary-row { display: contents; }

/* Upload-box visual states driven by upload_handler.js */
.upload-box--uploading { border-color: var(--teal); background: #F8FCFD; }
.upload-box--done { border-color: #86EFAC; background: #F0FDF4; }
.upload-box--error { border-color: var(--danger); background: var(--danger-bg); }

/* Magic-link copy display (shown when email fails) */
.magic-link-display { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.magic-link-display input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-family: monospace; font-size: 13px; background: #FAFBFC; }

/* ===== Legal text blocks (forms D-K) ===== */
.legal-text { line-height: 1.6; }
.legal-text h2 { font-size: 18px; margin-top: 18px; }
.legal-text h3 { font-size: 16px; margin-top: 14px; color: var(--ink-soft); }
.legal-text p { margin: 10px 0; }
.legal-text ul, .legal-text ol { padding-left: 22px; }
.legal-text li { margin: 4px 0; }
.legal-text .all-caps { letter-spacing: 0.5px; font-size: 14px; background: #FFF8EA; padding: 12px 14px; border-radius: 6px; border-left: 4px solid #BF8F00; }

.legal-context { background: #F3F8FB; border: 1px solid var(--border); margin-bottom: 14px; padding: 14px 18px; }
.legal-context .field { margin: 0; }
.legal-context .field-row { grid-template-columns: 1fr 1fr; }

/* Key/value table (staff detail page, PDF) */
.kv { width: 100%; border-collapse: collapse; margin-top: 12px; }
.kv th { text-align: left; padding: 8px 10px 8px 0; color: var(--muted); font-weight: 500; width: 35%; vertical-align: top; }
.kv td { padding: 8px 0; vertical-align: top; }

@media (min-width: 720px) {
  body { font-size: 16px; }
  h1 { font-size: 28px; }
  .site-header { padding: 18px 32px; }
  .content { margin: 32px auto; padding: 0 24px; }
}
