/* app.css — Two-Tablet System, styled to match the Wald Neuropsychology System (WNS).
   Design tokens lifted from WNS V8: teal #2a7a8c, Segoe UI, teal-gradient bg,
   16px white cards with soft shadow, teal titles/buttons. */

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

:root {
  --teal: #2a7a8c;
  --teal-dark: #226476;
  --ink: #1f2937;
  --muted: #6b7280;
  --muted2: #4b5563;
  --line: #e5e7eb;
  --line2: #dddddd;
  --green: #27ae60;
  --green-dark: #219150;
  --red: #e74c3c;
  --red-dark: #c0392b;
  --amber: #d68910;
  --bg-grad: linear-gradient(135deg, #e8f4f8 0%, #f0f7f4 100%);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  --card-radius: 16px;
  --ctrl-radius: 8px;
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header (WNS look: teal title on the gradient, no dark bar) ── */
.topbar {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 24px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.topbar .role { display: flex; flex-direction: column; }
.topbar .role .sys { font-size: 20px; font-weight: 700; color: var(--teal); line-height: 1.1; }
.topbar .role .sub { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.topbar .status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted2); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(39,174,96,.2); }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(214,137,16,.2); }

.wrap { max-width: 900px; width: 100%; margin: 0 auto; padding: 10px 24px 28px; flex: 1 1 auto; }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 26px 28px;
  margin-bottom: 22px;
}
.card h2 { color: var(--teal); margin: 0 0 16px; font-size: 1.2rem; }
.card .blurb { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.5; }

/* ── Buttons ── */
button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--ctrl-radius);
  padding: 14px 24px;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
  transition: background .2s, transform .1s, filter .15s;
}
button:hover { background: var(--teal-dark); }
button:active { transform: translateY(1px); }
button.ghost { background: #fff; color: var(--teal); border: 1px solid var(--line2); }
button.ghost:hover { background: #f3f9fb; border-color: var(--teal); }
button.big { width: 100%; font-size: 1.05rem; padding: 18px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.danger { background: #fff; color: var(--red); border: 1px solid #eab5ad; }
button.danger:hover { background: #fdecea; }
.row { display: flex; gap: 12px; flex-wrap: wrap; } .row > button { flex: 1; }

/* ── Forms (intake / join) ── */
label.field { display: block; font-size: .9rem; font-weight: 600; color: var(--muted2); margin: 0 0 6px; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 12px 16px; border: 1px solid var(--line2);
  border-radius: var(--ctrl-radius); font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--teal); }
.field-group { margin-bottom: 16px; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.demo-note { font-size: .82rem; color: var(--muted); font-weight: 400; }
.code-big { font-size: 2.6rem; font-weight: 800; letter-spacing: 6px; color: var(--teal); text-align: center; font-family: 'Consolas', monospace; }

/* ── Patient banner ── */
.patient-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: #eafaf1; border: 1px solid #bfe6cf; border-radius: 12px; padding: 12px 18px; margin-bottom: 20px; }
.patient-banner .who { font-size: 15px; color: var(--ink); }
.patient-banner .who b { color: var(--teal); }
.patient-banner .code-chip { font-size: 14px; color: var(--muted2); }
.patient-banner .code-chip b { font-family: 'Consolas', monospace; letter-spacing: 2px; color: var(--teal); font-size: 17px; }

/* ── Test picker ── */
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin: 18px 2px 8px; }
.cat-chip { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; margin-left: 8px; vertical-align: middle; }
.cat-A { background: #e7f2f5; color: #1c5e6e; } .cat-B { background: #e8f7ee; color: #1c7a43; } .cat-C { background: #efeaf6; color: #5b4a86; }
.test-list button { display: block; width: 100%; text-align: left; background: #fff; color: var(--ink); border: 1px solid var(--line); margin-bottom: 8px; padding: 15px 18px; font-weight: 400; }
.test-list button:hover { border-color: var(--teal); background: #f7fbfc; }
.test-list .t-name { font-weight: 600; color: var(--ink); font-size: 16px; }

/* ── Lock bar ── */
.lock-bar { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 0; background: linear-gradient(180deg, rgba(240,247,244,0) 0%, #eef6f2 40%); }
.lock-btn { flex: 2; font-weight: 700; }
.lock-btn.locked { background: var(--red); } .lock-btn.locked:hover { background: var(--red-dark); }
.lock-btn.unlocked { background: var(--green); } .lock-btn.unlocked:hover { background: var(--green-dark); }
.mode-note { flex: 2; text-align: center; align-self: center; color: var(--muted2); font-size: 15px; }

/* ── Live peek ── */
.peek { background: #f2f9fb; border: 1px dashed var(--teal); }
.peek .label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--teal); font-weight: 700; }
.peek .empty { color: var(--muted); font-style: italic; font-size: 15px; }
.peek-headline { font-size: 17px; font-weight: 700; color: var(--ink); margin: 6px 0 8px; }

/* ── Examinee ── */
.ex-stage { position: relative; flex: 1 1 auto; display: flex; margin: 0 auto; max-width: 100%; width: 100%; }
.ex-frame { border: 0; width: 100%; height: 100%; min-height: 78vh; background: #fff; }
.ex-blank { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; text-align: center; color: var(--muted); padding: 30px; }
.ex-blank .big { font-size: 30px; max-width: 20ch; color: var(--teal); font-weight: 700; }
.ex-blank .sub { font-size: 18px; max-width: 26ch; }

.lock-overlay { position: absolute; inset: 0; z-index: 30; display: none; align-items: flex-end; justify-content: center; }
.lock-overlay.active { display: flex; }
.lock-overlay.tint { background: rgba(42,122,140,.06); }
.lock-chip { margin-bottom: 26px; background: var(--teal); color: #fff; padding: 12px 22px; border-radius: 30px; font-size: 18px; font-weight: 600; box-shadow: 0 4px 14px rgba(42,122,140,.3); }
.done-overlay { position: absolute; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; background: rgba(255,255,255,.95); text-align: center; color: var(--teal); }
.done-overlay.active { display: flex; } .done-overlay .ico { font-size: 60px; } .done-overlay .msg { font-size: 26px; }

.stim-viewer { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 24px; background: #fff; }
.stim-wait { font-size: 26px; color: var(--muted); max-width: 22ch; text-align: center; }
.stim-img { max-width: 94%; max-height: 86vh; object-fit: contain; border-radius: 10px; }
.stim-word { font-size: 12vh; font-weight: 700; font-family: 'Times New Roman', serif; letter-spacing: 3px; color: #1f2937; }

.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 14px; }

/* ── Results screen ── */
.results-open { background: #fff; color: var(--teal); border: 1px solid var(--teal); font-weight: 600; }
.results-topline { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.results-topline #back { flex: 0 0 auto; padding: 10px 16px; }
.results-title { color: var(--teal); font-size: 22px; margin: 0; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.results-actions button { flex: 1; min-width: 120px; font-size: 15px; padding: 12px 14px; }
.result-card { padding: 18px 22px; }
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.r-name { font-size: 18px; font-weight: 700; color: var(--teal); }
.r-headline { font-size: 15px; font-weight: 700; color: var(--green); text-align: right; }
.score-table { width: 100%; border-collapse: collapse; }
.score-table td { padding: 6px 4px; font-size: 14px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
.score-table td.k { color: var(--muted); width: 46%; }
.score-table td.v { color: var(--ink); font-weight: 600; }
.drawing { margin-top: 10px; } .drawing img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; }
.r-details { margin-top: 10px; }
.r-details summary { cursor: pointer; color: var(--teal); font-size: 14px; font-weight: 600; }
.r-details pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 8px; }
.score-draw { font-size: 14px; padding: 10px 16px; }
.score-draw.unscored { background: var(--amber); color: #fff; border: none; font-weight: 700; }
.score-draw.unscored:hover { filter: brightness(1.05); background: var(--amber); }

/* ── Battery ── */
.battery-list { display: flex; flex-direction: column; gap: 8px; }
.batt-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 400; padding: 13px 16px; }
.batt-item:hover { border-color: var(--teal); }
.batt-item .bi-status { font-size: 18px; width: 22px; text-align: center; color: var(--muted); }
.batt-item .bi-name { flex: 1; font-weight: 600; }
.batt-item.is-done { background: #f4faf6; } .batt-item.is-done .bi-status { color: var(--green); }
.batt-item.is-current { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(42,122,140,.15); } .batt-item.is-current .bi-status { color: var(--teal); }
.batt-progress { color: var(--teal); font-weight: 700; }
.batt-check { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid #eef1f4; cursor: pointer; }
.batt-check input { width: 20px; height: 20px; accent-color: var(--teal); }
.batt-check .t-name { flex: 1; font-weight: 600; }
.all-tests { margin-top: 6px; } .all-tests > summary { cursor: pointer; color: var(--teal); font-weight: 600; padding: 8px 2px; }

/* ── Modals (capture prompt, summary sheet) ── */
.modal-back { position: fixed; inset: 0; z-index: 300; background: rgba(31,58,95,.45); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); padding: 24px 26px; max-width: 520px; width: 100%; max-height: 92vh; overflow: auto; }
.modal-card.wide { max-width: 760px; }
.modal-card h2 { color: var(--teal); margin: 0 0 10px; font-size: 1.2rem; }
.capture-img { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sheet-pre { white-space: pre; overflow-x: auto; font-family: 'Consolas', 'Courier New', monospace; font-size: 12.5px; line-height: 1.5; background: #f7f9fb; border: 1px solid var(--line); border-radius: 10px; padding: 16px; color: var(--ink); }
@media print { .modal-back { position: static; background: none; } .modal-card { box-shadow: none; max-width: none; } .sheet-pre { border: none; background: none; } .modal-card .row { display: none; } }

/* ── Picture-in-picture: live examinee screen ── */
.pip { position: fixed; right: 16px; bottom: 16px; z-index: 200; width: 440px; max-width: 92vw; background: #fff; border: 2px solid var(--teal); border-radius: 12px; box-shadow: 0 10px 34px rgba(0,0,0,.3); overflow: hidden; display: flex; flex-direction: column; }
.pip-bar { display: flex; align-items: center; justify-content: space-between; background: var(--teal); color: #fff; padding: 10px 14px; font-size: 14px; font-weight: 600; }
.pip-bar button { background: transparent; color: #fff; padding: 0 4px; font-size: 18px; }
.pip-bar button:hover { background: transparent; opacity: .8; }
.pip-body { position: relative; background: #eef3f5; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.pip-body img { width: 100%; display: none; }
.pip-wait { color: var(--muted); font-size: 14px; padding: 40px 16px; text-align: center; }
@media (max-width: 560px) { .pip { width: 88vw; right: 6px; bottom: 6px; } }

@media (max-width: 560px) { .demo-grid { grid-template-columns: 1fr; } }
@media print {
  .topbar, .results-topline #back, .results-actions { display: none !important; }
  body { background: #fff; }
  .card, .result-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

/* ── Corsi live board (semantic mirror, examiner side) ───────────────────── */
/* Geometry comes from the examinee's actual board, so this is a true replica  */
/* rather than a screenshot — every tap appears the moment it happens.         */
.cl-ctx { font-size: 14px; color: var(--muted); margin: 4px 0 10px; }
.corsi-live-board { position: relative; width: 100%; max-width: 360px; height: 260px; margin: 0 auto;
  background: #f8fafc; border: 1px solid var(--line2); border-radius: 10px; }
.cl-block { position: absolute; width: 38px; height: 38px; border-radius: 6px; background: #cbd5e1;
  transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff; transition: background .12s; }
.cl-block.is-tapped { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.cl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 15px; }
.cl-status { color: var(--teal); font-weight: 600; }
.cl-seq { margin-top: 6px; font-size: 15px; color: var(--ink); font-family: 'Consolas', monospace; }

/* ── Bells Test live board (semantic mirror, examiner side) ───────────────── */
/* Dots mark where each target was cancelled, numbered in order. The vertical   */
/* midline + left/right counts make a neglect pattern visible as it builds.     */
.bells-live-board { position: relative; width: 100%; max-width: 460px; height: 300px; margin: 0 auto;
  background: #f8fafc; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.bl-midline { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #cbd5e1; }
.bl-mark { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #10b981; color: #fff;
  transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; box-shadow: 0 0 0 2px rgba(16,185,129,.25); }
.bl-skew { color: var(--red); font-weight: 700; }
