/* ==========================================================
   NALAM — Design tokens
   Palette: Navy + Grey (brief), with a teal "signal" accent
   for voice/AI moments, and a muted red reserved only for
   serious-symptom referral states (never decorative).
   Type: Sora (display) / Inter (body) / IBM Plex Mono (utility)
   Signature: the ECG/voice waveform — a single line that reads
   as both a heartbeat and an audio waveform, echoing NALAM's
   "health + voice" premise everywhere the mic appears.
   ========================================================== */

:root {
  --navy-900: #081A33;
  --navy-800: #0E2A4E;
  --navy-700: #163A63;
  --navy-600: #1F4C7C;
  --slate-500: #5C7392;
  --slate-300: #9FB0C7;
  --grey-200: #E6EBF2;
  --grey-100: #F4F6FA;
  --white: #FFFFFF;

  --teal-400: #3FC8B4;
  --teal-500: #29A896;

  --danger-500: #C4453A;
  --danger-100: #FBEAE8;

  --text-primary: #101C31;
  --text-muted: #5C6B84;
  --text-inverse: #F4F6FA;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-card: 0 8px 24px rgba(8, 26, 51, 0.08);
  --shadow-pop: 0 16px 40px rgba(8, 26, 51, 0.22);

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--navy-900);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
h4 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-500);
  margin-top: 18px;
}
p { line-height: 1.5; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-500);
  margin: 0 0 6px;
}

/* ---------- App shell (mobile-first phone frame) ---------- */
.phone {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--grey-100);
  position: relative;
  overflow-x: hidden;
  box-shadow: var(--shadow-pop);
}

.view { min-height: 100vh; }
.view-inner { padding: 28px 24px 40px; }

/* ---------- Splash ---------- */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, var(--navy-700), var(--navy-900) 70%);
  color: var(--text-inverse);
  padding: 32px;
}
.pulse-logo { width: 220px; margin-bottom: 8px; }
.ecg-wave { width: 100%; overflow: visible; }
.ecg-wave path {
  fill: none;
  stroke: var(--teal-400);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(63, 200, 180, 0.6));
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: draw-pulse 2.6s ease-in-out infinite;
}
@keyframes draw-pulse {
  0%   { stroke-dashoffset: 320; }
  45%  { stroke-dashoffset: 0; }
  70%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -320; opacity: 1; }
}
.brand {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 800;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  font-weight: 500;
  color: var(--slate-300);
}
.tagline { color: var(--slate-300); margin-top: 10px; font-size: 0.95rem; }

/* ---------- Language select ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 28px;
}
.lang-card {
  background: var(--white);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  font-family: var(--font-body);
}
.lang-card:hover { transform: translateY(-2px); }
.lang-card.selected {
  border-color: var(--teal-500);
  background: linear-gradient(180deg, #F0FBF9, var(--white));
  box-shadow: var(--shadow-card);
}
.lang-native { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--navy-800); }
.lang-en { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--navy-700); color: var(--white); }
.btn-primary:disabled { background: var(--grey-200); color: var(--text-muted); cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: var(--navy-600); }
.btn-ghost { background: transparent; color: var(--navy-700); margin-top: 4px; }
.btn-danger { background: var(--danger-500); color: var(--white); margin-top: 12px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--navy-800); }
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: 0.98rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--grey-200);
  background: var(--white);
  color: var(--text-primary);
  resize: vertical;
}
.field input:focus, .field textarea:focus, textarea:focus {
  outline: 2px solid var(--teal-500);
  outline-offset: 1px;
  border-color: var(--teal-500);
}
.hint { font-size: 0.8rem; color: var(--text-muted); margin: -8px 0 0; }


/* ---------- Login (same original NALAM visual theme) ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 18%, var(--navy-700), var(--navy-900) 72%);
  color: var(--text-inverse);
  padding: 28px 24px 40px;
}
.login-logo { width: 190px; margin-bottom: 2px; }
.login-screen .tagline { margin-bottom: 22px; }
.login-card {
  width: 100%;
  background: var(--white);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: left;
  box-shadow: var(--shadow-pop);
}
.login-card h2 { margin-bottom: 4px; }
.login-card .muted { margin-top: 0; }

/* ---------- Home menu ---------- */
.home-header-actions { display:flex; align-items:center; gap:8px; }
.menu-btn {
  width:38px; height:38px; border-radius:12px; border:1.5px solid var(--grey-200);
  background:var(--white); color:var(--navy-800); font-size:1.2rem; cursor:pointer;
}
.side-menu[hidden] { display:none !important; }
.side-menu { position:fixed; inset:0; z-index:80; background:rgba(8,26,51,.55); max-width:430px; margin:0 auto; }
.side-menu-panel {
  width:min(88%, 360px); height:100%; background:var(--grey-100); padding:24px 18px;
  box-shadow:var(--shadow-pop); animation:menu-in .2s ease-out; position:relative;
}
@keyframes menu-in { from { transform:translateX(-20px); opacity:.5; } to { transform:translateX(0); opacity:1; } }
.side-menu-close { position:absolute; top:16px; right:16px; border:0; background:var(--grey-200); width:34px; height:34px; border-radius:50%; font-size:1.2rem; cursor:pointer; }
.side-menu-brand { padding:8px 4px 18px; border-bottom:1px solid var(--grey-200); margin-bottom:12px; }
.side-option { width:100%; border:1px solid var(--grey-200); background:var(--white); border-radius:16px; padding:14px; display:flex; align-items:center; gap:12px; text-align:left; margin:10px 0; cursor:pointer; color:var(--navy-800); }
.side-option > span { font-size:1.45rem; width:36px; text-align:center; }
.side-option strong { display:block; font-size:.92rem; }
.side-option small { display:block; margin-top:3px; color:var(--text-muted); }
.side-option:hover { border-color:var(--teal-500); }
.hospital-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }

/* ---------- Home ---------- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.brand-mini { font-size: 1.1rem; font-weight: 800; margin: 2px 0 0; color: var(--navy-800); }
.brand-mini span { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.2em; color: var(--slate-500); margin-left: 4px; }
.lang-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1.5px solid var(--grey-200);
  background: var(--white);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--navy-700);
  font-weight: 600;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

.mic-card { text-align: center; }
.mic-btn {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--navy-800);
  color: var(--text-inverse);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 4px;
  transition: background .2s;
}
.mic-btn[aria-pressed="true"] { background: var(--teal-500); }
.mic-icon { width: 32px; height: 32px; position: relative; z-index: 2; }
.ecg-wave--small {
  position: absolute;
  inset: -14px;
  width: calc(100% + 28px);
  opacity: 0;
  transition: opacity .2s;
}
.mic-btn[aria-pressed="true"] .ecg-wave--small { opacity: 1; }
.mic-btn[aria-pressed="true"] .ecg-wave--small path { stroke: rgba(255,255,255,0.85); animation-duration: 1.1s; }

.mic-status { margin-top: 10px; font-size: 0.9rem; color: var(--text-muted); }

.or-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--slate-300); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  margin: 18px 0 12px;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--grey-200); }

.symptom-form textarea {
  width: 100%;
  font-family: var(--font-body);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

/* ---------- Result card ---------- */
.result-card { border-top: 4px solid var(--teal-500); }
.result-card.is-serious { border-top-color: var(--danger-500); }
.result-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: #EAF9F6;
  color: var(--teal-500);
  margin-bottom: 8px;
}
.result-card.is-serious .result-badge { background: var(--danger-100); color: var(--danger-500); }
.result-card.is-caution { border-top-color: var(--danger-500); animation: nalamAlertBlink 1s ease-in-out infinite; }
.result-card.is-caution .result-badge { background: var(--danger-100); color: var(--danger-500); }
@keyframes nalamAlertBlink { 0%, 100% { box-shadow: 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: 0 0 0 5px rgba(220, 53, 69, 0.18); } }


.check-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.check-list li {
  padding-left: 24px;
  position: relative;
  font-size: 0.92rem;
  color: var(--text-primary);
}
.check-list li::before {
  content: "✓";
  position: absolute; left: 0; top: 0;
  color: var(--teal-500);
  font-weight: 700;
}
.disclaimer { font-size: 0.78rem; color: var(--text-muted); margin-top: 14px; border-top: 1px dashed var(--grey-200); padding-top: 12px; }

.alert-box {
  background: var(--danger-100);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 6px;
}
.alert-box p { color: #7A2A22; font-size: 0.92rem; margin: 0; }

/* ---------- Quick actions ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick-tile {
  background: var(--white);
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-md);
  padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--navy-800);
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
}
.quick-tile:hover { border-color: var(--teal-500); }
.tile-icon { font-size: 1.4rem; }

/* ---------- Modal sheets ---------- */
.modal[hidden] {
  display: none !important;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 26, 51, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 50;
  max-width: 430px;
  margin: 0 auto;
}
.modal-sheet {
  background: var(--grey-100);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 28px 28px 0 0;
  padding: 20px 24px 36px;
  position: relative;
  animation: sheet-up .25s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 18px;
  background: var(--grey-200); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 1.1rem; line-height: 1;
  cursor: pointer; color: var(--navy-800);
}

.list-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.list-item {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.list-item h4 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--text-primary); font-weight: 700; }
.list-item p { margin: 2px 0 0; font-size: 0.8rem; color: var(--text-muted); }
.list-item a.call-btn {
  background: var(--navy-700); color: var(--white); border-radius: 999px;
  padding: 8px 14px; font-size: 0.8rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}

/* Form select styling */
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background-color: var(--white);
  cursor: pointer;
}
select:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(47, 168, 150, 0.1);
}

/* Button variants */
.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-danger {
  background: var(--danger-500);
  color: var(--white);
}
.btn-danger:hover {
  background: #B0342F;
}

/* Updated list item for family contacts with remove button */
.list-item {
  flex-direction: column;
  align-items: flex-start;
}
.list-item > div {
  width: 100%;
}
.list-item > button {
  align-self: flex-end;
}

/* Tablet suggestions styling */
#suggestedTabletsBlock {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--grey-200);
}

@media (prefers-reduced-motion: reduce) {
  .ecg-wave path, .mic-btn, .modal-sheet { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }


.hospital-map-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.family-alert-actions { position: fixed; top: 16px; right: 16px; z-index: 9999; background: #fff; color: #111; padding: 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); max-width: 330px; border: 2px solid #d33; }
.family-alert-actions p { margin: 6px 0 12px; }
.family-alert-actions .btn { display: inline-block; text-decoration: none; }
.family-setup-card { margin-bottom: 16px; }
.family-setup-card h3 { margin-top: 0; }
.hospital-map-link { text-decoration: none; }
