/* Camp Med Portal — styles. Big tap targets, high contrast, works on iPad + laptop. */
:root {
  --blue: #0f4c81;
  --blue-dark: #0c3a63;
  --ink: #1c2733;
  --muted: #5a6b7b;
  --line: #d9e1e8;
  --bg: #eef2f6;
  --card: #ffffff;
  --good: #1b7f4b;
  --warn: #b5870a;
  --bad: #b3261e;
  --hold: #6b4ea0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 42, 67, .12), 0 1px 2px rgba(16, 42, 67, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); min-height: 1.2em; margin: .4rem 0 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: linear-gradient(160deg, var(--blue), var(--blue-dark));
}
.login-card {
  background: var(--card); width: 100%; max-width: 380px; padding: 2rem;
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: .5rem;
}
.login-card h1 { margin: 0; font-size: 1.4rem; color: var(--blue); }
.login-card label { display: flex; flex-direction: column; gap: .3rem; margin-top: .6rem; font-weight: 600; font-size: .9rem; }
.login-card input { font-size: 1.05rem; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--blue); color: #fff; padding: .6rem 1rem; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
}
#brand-logo { height: 38px; width: auto; display: block; flex-shrink: 0; }
.brand { display: flex; flex-direction: column; line-height: 1.1; font-weight: 700; }
.brand .muted { color: #cfe0ef; font-weight: 400; }
.tabs { display: flex; gap: .4rem; margin-left: auto; }
.tab {
  background: rgba(255,255,255,.12); color: #fff; border: 0; padding: .55rem 1rem;
  border-radius: 999px; font-size: .95rem; cursor: pointer;
}
.tab.active { background: #fff; color: var(--blue); font-weight: 700; }
.who { display: flex; align-items: center; gap: .6rem; }
#who-name { font-weight: 600; }

/* ---------- Layout ---------- */
.main { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.page-head { display: flex; align-items: center; gap: 1rem; margin: .3rem 0 1rem; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 1.3rem; }
.grow { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  font-size: 1rem; padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.5); color: #fff; }
.btn.block { width: 100%; margin-top: .8rem; padding: .8rem; font-size: 1.05rem; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Inputs ---------- */
input, select, textarea {
  font-family: inherit; font-size: 1rem; padding: .6rem; border: 1px solid var(--line);
  border-radius: 10px; width: 100%; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field label { font-weight: 600; font-size: .88rem; }
.field-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 140px; }
.search { max-width: 320px; }

/* ---------- Cards / lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; }
.patient-card { display: flex; gap: 1rem; align-items: center; cursor: pointer; }
.patient-card:hover { outline: 2px solid var(--blue); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: #cdd8e2;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex-shrink: 0;
}
.avatar.lg { width: 90px; height: 90px; font-size: 1.6rem; }
.pc-main { flex: 1; min-width: 0; }
.pc-name { font-weight: 700; font-size: 1.05rem; }
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill.alert { background: #fdeceb; color: var(--bad); }
.pill.meds { background: #e8f0f8; color: var(--blue); }
.badge { font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 6px; }
.badge.given { background: #e4f3ea; color: var(--good); }
.badge.refused { background: #fdeceb; color: var(--bad); }
.badge.held { background: #efeaf7; color: var(--hold); }
.badge.missed { background: #fbf2da; color: var(--warn); }

/* ---------- Patient sub-tabs (Medications / Observations) ---------- */
.subtabs { display: flex; gap: .4rem; margin: 1.2rem 0 .2rem; border-bottom: 2px solid var(--line); }
.subtab {
  background: transparent; border: 0; border-bottom: 3px solid transparent;
  padding: .6rem 1.1rem; font-weight: 700; color: var(--muted); cursor: pointer;
  font-size: 1rem; margin-bottom: -2px;
}
.subtab.active { color: var(--blue); border-bottom-color: var(--blue); }
.pill.obs { background: #e8f0f8; color: var(--blue); }
.obs-card { cursor: pointer; }
.obs-card:hover { outline: 2px solid var(--blue); }

.pill.sched { background: #e4f3ea; color: var(--good); }
.pill.prn { background: #eef0f3; color: var(--muted); }
.radio { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.radio input { width: auto; transform: scale(1.3); }

/* ---------- Planner ---------- */
.time-group { margin-bottom: 1.2rem; }
.time-head {
  position: sticky; top: 56px; z-index: 5;
  font-weight: 800; font-size: 1.05rem; color: var(--blue);
  background: var(--bg); padding: .4rem .2rem; border-bottom: 2px solid var(--line); margin-bottom: .5rem;
}
.slot { border-left: 6px solid var(--line); }
.slot.done { border-left-color: var(--good); opacity: .7; }
.slot.due { border-left-color: var(--blue); }
.slot.upcoming { border-left-color: var(--line); }
.slot.overdue { border-left-color: var(--bad); background: #fdf4f3; }

.meta { color: var(--muted); font-size: .85rem; }
.divider { height: 1px; background: var(--line); margin: .8rem 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

/* ---------- Photo picker / camera ---------- */
.cam-wrap { background: #000; border-radius: 12px; overflow: hidden; }
.cam-wrap video { width: 100%; max-height: 60vh; display: block; object-fit: contain; background: #000; }
.photo-preview { margin-top: .6rem; display: flex; align-items: center; gap: .6rem; }
.photo-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,33,51,.55); display: flex;
  align-items: flex-start; justify-content: center; padding: 1.5rem; z-index: 50; overflow: auto;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px; padding: 1.3rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); margin: auto;
}
.modal h3 { margin: 0 0 .8rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* ---------- 5 rights checklist ---------- */
.rights { list-style: none; padding: 0; margin: .4rem 0; }
.rights li { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
.rights input { width: auto; margin-top: .2rem; transform: scale(1.4); }
.rights .r-label { font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 80; font-weight: 600;
}

@media (max-width: 560px) {
  .topbar { gap: .5rem; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
}

/* ---------- Paper MAR (print) ---------- */
#print-root { display: none; }
.pt-head { text-align: center; margin-bottom: .6rem; }
.pt-head h1 { font-size: 18px; margin: 0; }
.pt-sub { font-size: 13px; margin: .2rem 0; }
.pt-staff { font-size: 12px; margin-top: .5rem; text-align: left; }
.pt-time { margin: .9rem 0 .2rem; font-size: 14px; border-bottom: 2px solid #000; }
.pt-prnhead { margin-top: 1rem; }
.pt-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pt-table th, .pt-table td { border: 1px solid #000; padding: 4px 5px; text-align: left; vertical-align: top; }
.pt-table th { background: #eee; }
.pt-table td:nth-child(n+4) { height: 26px; } /* roomy write-in cells */
.pt-foot { margin-top: .8rem; font-size: 10px; color: #333; }

/* ---------- End-of-camp report ---------- */
.rpt-student { page-break-before: always; }
.rpt-student:first-of-type { page-break-before: avoid; }
.rpt-shead { display: flex; gap: 12px; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 6px; margin-top: 10px; }
.rpt-photo { width: 72px; height: 72px; object-fit: cover; border: 1px solid #000; flex-shrink: 0; }
.rpt-student h2 { margin: 0; font-size: 16px; }
.rpt-student h3 { margin: 10px 0 3px; font-size: 12px; background: #e8e8e8; padding: 2px 5px; border: 1px solid #999; }
.rpt-meta { font-size: 11px; }
.rpt-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.rpt-table th, .rpt-table td { border: 1px solid #000; padding: 3px 4px; text-align: left; vertical-align: top; }
.rpt-table th { background: #e8e8e8; }
.rpt-obs { border: 1px solid #999; padding: 5px 6px; margin-bottom: 5px; font-size: 11px; page-break-inside: avoid; }
.rpt-note { white-space: pre-wrap; margin: 3px 0; }
.rpt-obsphoto { max-width: 300px; max-height: 300px; margin-top: 4px; border: 1px solid #000; }
.rpt-empty { font-size: 11px; color: #555; font-style: italic; }

@media print {
  @page { margin: 12mm; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.printing > #app-view,
  body.printing > #login-view,
  body.printing > #modal-root,
  body.printing > #toast { display: none !important; }
  body.printing > #print-root { display: block !important; }
  #print-root h1, #print-root h2, #print-root h3 { color: #000 !important; }
  .pt-table tr { page-break-inside: avoid; }
  .pt-time { page-break-after: avoid; }
}
