/* Ottawa Paramedic Service — RPAS Program
   Shared stylesheet — muted palette, mobile-first. */

:root {
  /* Muted, professional palette */
  --brand:      #3f5468;   /* slate blue-grey (normal pages) */
  --brand-dark: #31424f;
  --brand-soft: #eef2f5;
  --emergency:      #b23b3b;  /* reserved for emergency page + button */
  --emergency-dark: #8f2f2f;
  --emergency-soft: #fbeeee;

  --ink: #22282d;
  --muted: #5f6a73;
  --line: #e3e8ec;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ok: #3f7d5a;
  --warn: #9a6a1c;
  --info: #3a6ea5;
  --field: #ffffff;   /* input/select background */

  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tap: 48px; /* minimum touch target */
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --ink: #e6e9ec;
  --muted: #9aa4ad;
  --line: #333c44;
  --bg: #14181c;
  --card: #1e242a;
  --brand-soft: #273039;
  --field: #232a31;
  --info: #7ab3f0;
  --ok: #5cbf8a;
  --warn: #d6a35a;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 4px 14px rgba(0,0,0,.4);
}
[data-theme="dark"] .callout        { background: #1c2530; }
[data-theme="dark"] .callout.warn   { background: #2a2418; }
[data-theme="dark"] .callout.danger { background: #2b1a1a; }
[data-theme="dark"] .badge.warn  { background: #3a2f1a; color: #e0b070; border-color: #4d3f22; }
[data-theme="dark"] .badge.notop { background: #2a2f34; color: #aeb6bd; border-color: #3a424a; }
[data-theme="dark"] .badge.ok    { background: #193024; color: #6fd39c; border-color: #244a37; }
[data-theme="dark"] .badge.info  { background: #17293b; color: #7ab3f0; border-color: #274157; }
[data-theme="dark"] .btn.secondary { background: #2a323a; color: var(--ink); }
[data-theme="dark"] .btn.secondary:hover { background: #333c45; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  max-width: 1080px; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 15px;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: #fff; color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.brand small { display: block; font-weight: 400; opacity: .85; font-size: 11px; }

.emergency-btn {
  margin-left: auto;
  background: var(--emergency);
  color: #fff; text-decoration: none;
  font-weight: 700; font-size: 14px;
  padding: 0 16px; height: var(--tap);
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 10px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(178,59,59,.35);
}
.emergency-btn:hover { background: var(--emergency-dark); }

.theme-btn {
  margin-left: 8px; flex: 0 0 auto;
  width: var(--tap); height: var(--tap);
  background: rgba(255,255,255,.15); border: 0; color: #fff;
  border-radius: 10px; font-size: 20px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-btn:hover { background: rgba(255,255,255,.25); }

/* nav row — horizontally scrollable on phones */
nav.mainnav {
  display: flex; gap: 4px;
  max-width: 1080px; margin: 0 auto;
  padding: 0 8px 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav.mainnav::-webkit-scrollbar { display: none; }
nav.mainnav a {
  color: #fff; text-decoration: none;
  padding: 9px 14px; border-radius: 8px; font-size: 14px;
  opacity: .9; white-space: nowrap;
}
nav.mainnav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
nav.mainnav a.active { background: rgba(0,0,0,.18); opacity: 1; }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 18px 14px 90px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 6px; font-size: 23px; }
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; font-size: 15px; }

h2 { font-size: 18px; margin: 26px 0 10px; }
h3 { font-size: 16px; margin: 16px 0 8px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 16px; margin-bottom: 14px;
}

/* ---------- Home tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; min-height: var(--tap);
}
.tile:active { background: var(--brand-soft); }
.tile .ico { font-size: 26px; width: 34px; text-align: center; flex: 0 0 auto; }
.tile h3 { margin: 0 0 2px; font-size: 16px; }
.tile p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Checklist hub list ---------- */
.cl-list { display: grid; gap: 10px; }
.cl-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  min-height: var(--tap);
}
.cl-item:active { background: var(--brand-soft); }
.cl-item .ico { font-size: 22px; width: 28px; text-align: center; }
.cl-item h3 { margin: 0; font-size: 16px; }
.cl-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Forms ---------- */
.field-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=datetime-local], input[type=email], textarea, select {
  width: 100%; padding: 12px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 16px; /* 16px avoids iOS zoom */
  background: var(--field); color: var(--ink); min-height: var(--tap);
}
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%235f6a73' stroke-width='2'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
textarea { min-height: 90px; resize: vertical; }
.obs-other { margin-top: 8px; }

/* observer multi-select dropdown */
.msel { position: relative; }
.msel-toggle {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--muted); font: inherit; font-size: 16px;
  cursor: pointer; text-align: left;
}
.msel-toggle.has-val { color: var(--ink); }
.msel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-chev { color: var(--muted); flex: 0 0 auto; transition: transform .15s ease; }
.msel.open .msel-chev { transform: rotate(180deg); }
.msel-panel {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; max-height: 280px; overflow: auto;
}
.msel.open .msel-panel { display: block; }
.msel-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 10px;
  border-radius: 8px; font-size: 15px; cursor: pointer; min-height: 44px;
}
.msel-row:hover { background: var(--brand-soft); }
.msel-row input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--brand); }
.msel-panel .obs-other { margin: 4px 6px 6px; width: calc(100% - 12px); }

/* reference links */
.link-list { display: grid; gap: 8px; }
.link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  text-decoration: none; color: var(--info); font-size: 15px; min-height: 44px;
}
.link-row:active { background: var(--brand-soft); }
.link-row .ext { color: var(--muted); font-size: 14px; }

/* checklist items */
.check-section { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 6px; }
.check-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 4px; border-bottom: 1px dashed var(--line);
  cursor: pointer; min-height: var(--tap);
}
.check-row:last-child { border-bottom: 0; }
.check-row input[type=checkbox] {
  width: 28px; height: 28px; margin: 0; flex: 0 0 auto;
  accent-color: var(--ok); cursor: pointer;
}
.check-row .label { flex: 1; font-size: 15.5px; }
.check-row .label .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.check-row:has(input:checked) .label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

/* sticky action bar */
.progress-wrap {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; z-index: 40;
}
.progress-wrap .row1 { display: flex; align-items: center; gap: 10px; width: 100%; }
.progressbar { flex: 1; height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progressbar > span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s ease; }
.progress-wrap .btns { display: flex; gap: 10px; width: 100%; }
.progress-wrap .btns .btn { flex: 1; }

.btn {
  border: 0; border-radius: 10px; padding: 0 18px; min-height: var(--tap);
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--brand-soft); color: var(--ink); }
.btn.secondary:hover { background: #e2e8ec; }
.btn.danger { background: var(--emergency); }
.btn.danger:hover { background: var(--emergency-dark); }
.btn:disabled { opacity: .5; }

/* ---------- Badges & callouts ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; vertical-align: middle; }
.badge.warn { background: #fdf3e2; color: var(--warn); border: 1px solid #f0dcb4; }
.badge.notop { background: #eef0f3; color: #6b7580; border: 1px solid #dbe0e5; }
.badge.ok { background: #e8f3ec; color: var(--ok); border: 1px solid #c3e2cf; }
.badge.info { background: #eaf1f8; color: var(--info); border: 1px solid #cadcee; }

.callout { border-left: 4px solid var(--info); background: #eef4fa; padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.callout.warn { border-color: var(--warn); background: #fdf6ea; }
.callout.danger { border-color: var(--emergency); background: var(--emergency-soft); }
.callout h4 { margin: 0 0 4px; font-size: 14px; }
.callout p { margin: 0; font-size: 14px; }

/* ---------- Emergency page ---------- */
body.emergency { background: var(--emergency); }
body.emergency .topbar { background: var(--emergency-dark); }
body.emergency .emergency-btn { background: rgba(0,0,0,.22); box-shadow: none; }
body.emergency .page-head h1,
body.emergency .page-head p { color: #fff; }
body.emergency .page-head p { opacity: .92; }

.epick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.epick button {
  border: 0; border-radius: 12px; padding: 16px 12px; min-height: 68px;
  background: rgba(255,255,255,.94); color: var(--emergency-dark);
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: var(--shadow); text-align: center; line-height: 1.2;
}
.epick button .ei { font-size: 22px; }
.epick button.active { background: var(--ink); color: #fff; }
.epick button:active { transform: scale(.98); }

#edetail { scroll-margin-top: 120px; }
.edetail { background: #fff; color: #22282d; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 18px; }
.edetail.hidden { display: none; }
.edetail h3 { color: var(--emergency-dark); margin: 0 0 10px; font-size: 20px; }
.edetail ol { margin: 0; padding-left: 22px; }
.edetail li { margin: 9px 0; font-size: 16px; }
.edetail .hint { color: #5f6a73; font-size: 13px; }
.eplaceholder { background: rgba(255,255,255,.9); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--emergency-dark); font-weight: 600; }

.contacts-card { background: #fff; color: #22282d; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 16px; }
.contacts-card table.data th { background: #eef2f5; color: #5f6a73; }
.contacts-card table.data td { color: #22282d; }
.contacts-card h3 { margin-top: 0; }
.contacts-card a.call, .contacts-card span.call {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--emergency); color: #fff; text-decoration: none;
  padding: 10px 16px; border-radius: 10px; font-weight: 700; margin: 4px 6px 4px 0;
}
.contacts-card span.call.static {
  background: var(--brand-soft); color: var(--ink); cursor: default;
}

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: var(--brand-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13.5px; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* ---------- Login ---------- */
#login-overlay {
  position: fixed; inset: 0; background: linear-gradient(160deg, var(--brand-dark), var(--brand));
  display: grid; place-items: center; z-index: 9999; padding: 20px;
}
.login-box {
  background: var(--card); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 30px 26px 24px; width: 100%; max-width: 360px; text-align: center;
}
.login-box .logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px;
}
.login-box h1 { font-size: 18px; margin: 0 0 2px; }
.login-box p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-box input { margin-bottom: 10px; text-align: center; }
.login-box .err { color: var(--emergency); font-size: 13px; min-height: 18px; margin-top: 4px; }

footer.site {
  max-width: 1080px; margin: 0 auto; padding: 20px 14px 30px;
  color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line);
}
footer.site .logout-link { color: var(--info); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- Compact checklist view (body.compact only) ----------
   Density is driven by --scale. Cards are flattened: no
   border/box/shadow, no per-row dividers — just dense content. */
.compact { --scale: 0.4; }
.compact main { padding: 10px 12px 88px; }
.compact .page-head { margin-bottom: 6px; }
.compact .page-head h1 { font-size: 18px; margin-bottom: 2px; }
.compact .page-head p { font-size: 12.5px; }

/* flatten cards */
.compact .card {
  background: transparent; border: 0; box-shadow: none;
  padding: calc(6px * var(--scale)) 0; margin-bottom: calc(6px * var(--scale));
}
.compact .card > h2 {
  font-size: 13px; margin: 0 0 calc(6px * var(--scale)); color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}
.compact h3 {
  font-size: 12px; margin: calc(9px * var(--scale)) 0 calc(2px * var(--scale));
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
}

/* record-detail fields */
.compact .field-grid { grid-template-columns: 1fr 1fr; gap: calc(7px * var(--scale)) 10px; }
.compact label.fld { font-size: 11px; margin-bottom: 2px; }
.compact input[type=text], .compact input[type=datetime-local],
.compact input[type=email], .compact select,
.compact .msel-toggle { min-height: 38px; padding: 7px 10px; }
.compact textarea { min-height: 48px; padding: 7px 10px; }

/* checklist items — no dividers, scale-driven padding */
.compact .check-section { border-top: 1px solid var(--line); padding-top: calc(4px * var(--scale)); margin-top: calc(4px * var(--scale)); }
.compact .check-row {
  padding: calc(5px * var(--scale)) 2px; min-height: 0; gap: 9px;
  border-bottom: 0;
}
.compact .check-row input[type=checkbox] { width: 20px; height: 20px; }
.compact .check-row .label { font-size: calc(12.5px + 2px * var(--scale)); line-height: 1.3; }
.compact .check-row .label .sub { font-size: calc(10.5px + 1px * var(--scale)); margin-top: 0; }
.compact .link-row { min-height: 38px; padding: 8px 12px; font-size: 13.5px; }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  /* Quick-access tiles stay a single vertical column on all sizes */
  .field-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .progress-wrap { flex-wrap: nowrap; }
  .progress-wrap .row1 { width: auto; flex: 1; }
  .progress-wrap .btns { width: auto; }
  .progress-wrap .btns .btn { flex: 0 0 auto; }
  .epick { grid-template-columns: repeat(3, 1fr); }
  .page-head h1 { font-size: 27px; }
}

@media print {
  .topbar, .progress-wrap, .btn, #login-overlay, .epick, .emergency-btn { display: none !important; }
  body, body.emergency { background: #fff; }
  .card, .tile, .edetail { box-shadow: none; }
  .edetail.hidden { display: block !important; }
}
