/* MCA Safety — styles. Brand palette + mobile-first shell carried over from the
   MCA Follow-Up Assistant (navy/gold), tuned for a field safety app. */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --navy:       #1B2451;
  --navy-dark:  #141b3e;
  --gold:       #C49A38;
  --gold-light: #fdf3d6;
  --ink:        #0F172A;
  --body:       #334155;
  --muted:      #64748B;
  --subtle:     #94A3B8;
  --line:       #E2E8F0;
  --line-soft:  #F1F5F9;
  --bg:         #F8FAFC;
  --surface:    #FFFFFF;
  --ok:         #15803D;
  --ok-bg:      #DCFCE7;
  --warn:       #92400E;
  --warn-bg:    #FEF3C7;
  --fail:       #B91C1C;
  --fail-bg:    #FEE2E2;
  --info:       #1E40AF;
  --info-bg:    #EFF6FF;
  --focus:      rgba(27,36,81,.13);
  --toast-bg:   #0F172A;
  /* Primary button: solid navy + white text (gold stays an accent, never a fill) */
  --btn-bg:        #1B2451;
  --btn-bg-hover:  #141b3e;
  --btn-fg:        #FFFFFF;
  --ring:          rgba(196,154,56,.55);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sh-xs: 0 1px 2px rgba(0,0,0,.05);
  --sh-sm: 0 1px 2px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.06);
  --sh:    0 1px 3px rgba(0,0,0,.06), 0 4px 8px -2px rgba(0,0,0,.08);
  --sh-lg: 0 12px 28px -5px rgba(0,0,0,.12), 0 4px 10px -4px rgba(0,0,0,.07);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--body);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  background: var(--navy);
  padding: env(safe-area-inset-top) 16px 0;
  position: sticky; top: 0; z-index: 20;
}
.hrow1 {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; }
.brand-name { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-gold { color: var(--gold); }
.who { color: #c9cee6; font-size: 12.5px; padding-bottom: 10px; }
.who a { color: var(--gold-light); }
.live-pill {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 7px; border-radius: 999px; margin-left: 8px;
}
.live-on  { background: var(--ok-bg);   color: var(--ok); }
.live-off { background: var(--warn-bg); color: var(--warn); }

/* ── Tabs ──────────────────────────────────────────────────────── */
nav.tabs {
  display: flex; gap: 4px; overflow-x: auto; background: var(--navy-dark);
  padding: 0 8px; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; background: none; border: none; color: #aab1d6;
  font: inherit; font-weight: 600; font-size: 13.5px; padding: 12px 14px;
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab.active { color: #fff; border-bottom-color: var(--gold); }

main { max-width: 720px; margin: 0 auto; padding: 16px 14px 40px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Cards / lists ─────────────────────────────────────────────── */
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--subtle); margin: 6px 2px 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-sm); padding: 14px 16px; margin-bottom: 10px;
}
.card.tap { cursor: pointer; transition: box-shadow .15s, transform .04s; }
.card.tap:active { transform: scale(.995); }
.card.tap:hover { box-shadow: var(--sh); }
.card h3 { font-size: 15.5px; color: var(--ink); font-weight: 650; }
.card .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.chip {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--line-soft); color: var(--muted);
}
.chip.cor { background: var(--info-bg); color: var(--info); }
.chip.concern { background: var(--fail-bg); color: var(--fail); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }

.empty { color: var(--subtle); text-align: center; padding: 40px 16px; font-size: 14px; }

/* ── Forms ─────────────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 14px; font-weight: 600; color: var(--ink); font-size: 13.5px; }
label.field .opt { color: var(--subtle); font-weight: 500; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); margin-top: 6px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-weight: 400;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--focus);
}
textarea { min-height: 84px; resize: vertical; }

/* Custom checkboxes — replaces the plain browser box everywhere. !important
   defeats the width:100% above and the scattered inline width:auto overrides. */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 20px !important; height: 20px !important; min-width: 20px;
  margin: 0; padding: 0 !important; flex: 0 0 auto; vertical-align: middle;
  border: 1.5px solid var(--line); border-radius: 6px; background: var(--surface);
  cursor: pointer; position: relative;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type="checkbox"]:hover { border-color: var(--gold); }
input[type="checkbox"]:checked { background: var(--gold); border-color: var(--gold); }
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 6px; top: 2px; box-sizing: border-box;
  width: 6px; height: 11px; border: solid #1B2451; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.instruction { background: var(--info-bg); border-left: 3px solid var(--info);
  padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink); font-size: 13.5px; margin-bottom: 14px; }

/* Pass/Fail/NA checklist control */
.pfna { display: flex; gap: 6px; margin-top: 6px; }
.pfna button {
  flex: 1; font: inherit; font-weight: 600; font-size: 13px; padding: 9px 0;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: var(--r-sm); cursor: pointer;
}
.pfna button.sel[data-v="pass"] { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.pfna button.sel[data-v="fail"] { background: var(--fail-bg); color: var(--fail); border-color: var(--fail); }
.pfna button.sel[data-v="na"]   { background: var(--line-soft); color: var(--body); border-color: var(--subtle); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 15px; padding: 13px 20px;
  min-height: 46px; border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; width: 100%; transition: background .18s, border-color .18s, color .18s;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-bg-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); border-color: var(--subtle); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { width: auto; flex: 1; }
.link { color: var(--info); background: none; border: none; font: inherit; cursor: pointer; padding: 0; }
.link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }

/* ── Suggest / typeahead ───────────────────────────────────────── */
.suggest { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--sh); margin-top: 4px; overflow: hidden; }
.suggest div { padding: 10px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line-soft); }
.suggest div:hover { background: var(--info-bg); }

/* ── Toast ─────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--toast-bg); color: #fff;
  padding: 12px 18px; border-radius: var(--r); box-shadow: var(--sh-lg);
  font-size: 14px; font-weight: 600; z-index: 60; max-width: 90vw; text-align: center;
}
#toast.err { background: var(--fail); }
#toast.ok  { background: var(--ok); }

.offline { background: var(--warn-bg); color: var(--warn); text-align: center;
  font-size: 13px; padding: 8px; font-weight: 600; }

/* ── Accordion (expandable reference sections) ─────────────────── */
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 10px; overflow: hidden; box-shadow: var(--sh-sm); }
.acc > summary { list-style: none; cursor: pointer; padding: 15px 16px; font-weight: 650;
  font-size: 15px; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary .acc-label { flex: 1; }
.acc > summary .acc-count { background: var(--line-soft); color: var(--muted); font-size: 12px;
  font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.acc > summary::after { content: '▸'; color: var(--subtle); font-size: 13px; transition: transform .15s; }
.acc[open] > summary::after { transform: rotate(90deg); }
.acc[open] > summary { border-bottom: 1px solid var(--line-soft); }
.acc-body { padding: 12px 14px; }

/* ── "More forms" disclosure on the Forms tab ──────────────────── */
.more-forms { margin-top: 4px; }
.more-forms > summary { list-style: none; cursor: pointer; padding: 12px 4px; font-weight: 650;
  font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.more-forms > summary::-webkit-details-marker { display: none; }
.more-forms > summary::after { content: '▸'; color: var(--subtle); font-size: 13px;
  margin-left: auto; transition: transform .15s; }
.more-forms[open] > summary::after { transform: rotate(90deg); }

/* ── Assigned / "Required" forms pinned to the top of the Forms tab ─────── */
.required-form { border: 1.5px solid var(--gold); box-shadow: var(--sh-sm); }
.required-form.overdue { border-color: var(--fail); }
.chip.req { background: var(--gold); color: #1B2451; font-weight: 700; }

/* ── Inline icons ──────────────────────────────────────────────── */
/* Inherit the surrounding text colour (currentColor) → correct in both themes. */
.icon {
  width: 1.05em; height: 1.05em; flex: 0 0 auto;
  display: inline-block; vertical-align: -0.15em;
  stroke: currentColor; fill: none;
}
.icon-ok { color: var(--ok); }
.icon-fail { color: var(--fail); }

/* Inline auto-save status (Forms editor) */
.save-status { font-size: 12px; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--fail); }

/* ── Photo picker (camera or file) ─────────────────────────────── */
.photo-field { margin-bottom: 14px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-photo {
  display: inline-flex; align-items: center; gap: 6px; font: inherit;
  font-size: 13.5px; font-weight: 600; padding: 10px 15px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-photo:hover { border-color: var(--gold); color: var(--gold); }
.btn-photo:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn-camera { border-color: var(--gold); color: var(--gold); }
.btn-camera:hover { background: var(--gold); color: #1B2451; }
.photo-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-thumb {
  position: relative; width: 84px; height: 84px; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--line); background: var(--line-soft);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; margin: 0; }
.photo-thumb.uploading img { opacity: .45; }
.photo-thumb.uploading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,.55); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-thumb-remove {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0;
  border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-thumb-remove:hover { background: rgba(0,0,0,.82); }

/* ── In-app camera overlay ─────────────────────────────────────── */
.camera-overlay { display: none; position: fixed; inset: 0; background: #000; z-index: 3000; }
.camera-overlay.visible { display: flex; }
.camera-viewfinder, .camera-review { display: flex; flex-direction: column; width: 100%; }
.camera-viewfinder { position: relative; }
.camera-review { display: none; }
.camera-overlay.reviewing .camera-viewfinder { display: none; }
.camera-overlay.reviewing .camera-review { display: flex; }
#cameraVideo, #cameraReviewImg { flex: 1; width: 100%; min-height: 0; object-fit: cover; background: #000; }
.camera-ui {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 28px calc(22px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.72);
}
.btn-shutter {
  width: 66px; height: 66px; padding: 0; border-radius: 50%; background: #fff;
  border: 5px solid rgba(255,255,255,.4); cursor: pointer; flex: 0 0 auto;
  transition: background .1s;
}
.btn-shutter:active { background: #ccc; }
.btn-cam-side {
  min-width: 76px; color: #fff; background: transparent; font: inherit; font-size: 14px;
  border: 1px solid rgba(255,255,255,.4); border-radius: var(--r-sm); padding: 10px 16px;
  cursor: pointer; transition: background .15s;
}
.btn-cam-side:hover { background: rgba(255,255,255,.14); }
.btn-cam-ok { background: var(--gold); border-color: var(--gold); color: #1B2451; font-weight: 700; }
.btn-cam-ok:hover { background: var(--gold-light); color: #1B2451; }
.acc-body .card { box-shadow: none; }
.acc-body .card:last-child { margin-bottom: 0; }
/* Nested sub-group (Hospitals / Clinics inside Hospitals & Clinics) */
.acc .acc-sub { box-shadow: none; border: 1px solid var(--line-soft); margin: 0 0 8px; }
.acc .acc-sub:last-child { margin-bottom: 0; }
.acc .acc-sub > summary { padding: 11px 12px; font-size: 14px; font-weight: 600; }

/* ── Modal / popup ─────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px calc(24px + env(safe-area-inset-bottom));
  z-index: 60; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  width: min(460px, 100%); padding: 20px 18px; margin: auto; }
.modal h3 { color: var(--ink); font-size: 18px; margin-bottom: 14px; }
.modal .btn-row { margin-top: 6px; }

/* ── Header controls / theme toggle ────────────────────────────── */
.hrow1-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14);
  color: #e7ebfb;
}
.icon-btn:active { background: rgba(255,255,255,.18); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
.icon-btn[disabled] { opacity: .6; }
.icon-btn .ic-sun { display: none; }
[data-theme="dark"] .icon-btn .ic-moon { display: none; }
[data-theme="dark"] .icon-btn .ic-sun { display: inline; }

/* ── Dark mode ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --ink:        #F1F5F9;
  --body:       #CBD5E1;
  --muted:      #94A3B8;
  --subtle:     #6B7A93;
  --line:       #2A3454;
  --line-soft:  #1C2440;
  --bg:         #0E1430;
  --surface:    #18203F;
  --ok:         #4ADE80;  --ok-bg:   rgba(21,128,61,.22);
  --warn:       #FBBF24;  --warn-bg: rgba(146,64,14,.28);
  --fail:       #F87171;  --fail-bg: rgba(185,28,28,.26);
  --info:       #93C5FD;  --info-bg: rgba(30,64,175,.26);
  --focus:      rgba(196,154,56,.28);
  --toast-bg:   #020617;
  /* On dark surfaces a #1B2451 button disappears — lift it to a brand indigo. */
  --btn-bg:        #3D4A8F;
  --btn-bg-hover:  #4A58A5;
  --btn-fg:        #FFFFFF;

  --sh-xs: 0 1px 2px rgba(0,0,0,.4);
  --sh-sm: 0 1px 2px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.4);
  --sh:    0 1px 3px rgba(0,0,0,.5), 0 4px 8px -2px rgba(0,0,0,.5);
  --sh-lg: 0 12px 28px -5px rgba(0,0,0,.6), 0 4px 10px -4px rgba(0,0,0,.5);
}
[data-theme="dark"] body { background: var(--bg); }
/* Header stays MCA navy in both themes; nudge it slightly darker in dark mode. */
[data-theme="dark"] header { background: var(--navy-dark); }

/* ── Accessibility: keyboard focus + reduced motion ────────────── */
.tab:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.card.tap:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

