/* Medical Assistant — Professional UI */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #0062CC;
  --primary-dark:  #004A99;
  --primary-light: #EBF3FF;
  --primary-text:  #003A7A;
  --bg:            #FFFFFF;
  --bg2:           #F4F7FB;
  --bg3:           #E8EEF6;
  --text:          #0F1923;
  --text2:         #4A5568;
  --text3:         #8A9BB0;
  --border:        rgba(15,25,35,0.08);
  --border2:       rgba(15,25,35,0.14);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.09), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.07);
  --green-bg:      #DCFCE7;
  --green-text:    #15803D;
  --green-border:  #86EFAC;
  --red-bg:        #FEE2E2;
  --red-text:      #B91C1C;
  --red-border:    #FCA5A5;
  --radius:        14px;
  --radius-sm:     9px;
  --radius-xs:     6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary:       #3B8FE8;
    --primary-dark:  #2C7DD4;
    --primary-light: #0A2240;
    --primary-text:  #93C5FD;
    --bg:            #111827;
    --bg2:           #1F2937;
    --bg3:           #2D3748;
    --text:          #F1F5F9;
    --text2:         #94A3B8;
    --text3:         #64748B;
    --border:        rgba(255,255,255,0.07);
    --border2:       rgba(255,255,255,0.13);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg:     0 8px 24px rgba(0,0,0,0.4);
    --green-bg:      #052E16;
    --green-text:    #4ADE80;
    --green-border:  #166534;
    --red-bg:        #1F0707;
    --red-text:      #F87171;
    --red-border:    #7F1D1D;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.screen { display: none; flex: 1; flex-direction: column; min-height: 0; padding: 1rem 1.15rem; }
.screen.active { display: flex; }

/* ── Header ─────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0.95rem 1.15rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}

.back-btn {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}
.back-btn:active { background: var(--bg3); }

.header-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,98,204,0.35);
}

/* ── Lang screen centering ───────────────────────────── */
#s-lang { justify-content: center; }

/* ── Hero (language screen) ──────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 2rem;
  text-align: center;
}
.hero-logo {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 18px;
  filter: drop-shadow(0 4px 12px rgba(0,98,204,0.25));
}
.hero-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.hero-sub {
  font-size: 14px;
  color: var(--text3);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.lang-picker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background 0.15s, box-shadow 0.15s;
  margin-bottom: 12px;
}
.lang-picker-btn:active { background: var(--bg3); box-shadow: none; }
.lang-picker-arrow { font-size: 20px; opacity: 0.6; }
.hero-note {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  margin-top: 4px;
}

/* ── Language full-screen picker ─────────────────────── */
.lang-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.lang-sheet.open {
  pointer-events: all;
  opacity: 1;
}
.lang-sheet-overlay { display: none; }
.lang-sheet-content {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 0 1.15rem;
  transform: translateY(20px);
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.lang-sheet.open .lang-sheet-content { transform: translateY(0); }
.lang-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.lang-sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.lang-sheet-close {
  background: var(--bg2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lang-sheet-content .search-wrap { margin: 0.75rem 0 0.25rem; flex-shrink: 0; }
.lang-sheet-list {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 2rem;
}

/* ── Language pill ───────────────────────────────────── */
.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 20px;
  margin: 1rem 0 0.85rem;
  letter-spacing: 0.01em;
}

/* ── Search ──────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin: 1rem 0 0.75rem;
}
.search-wrap input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap input::placeholder { color: var(--text3); }
.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,98,204,0.12);
  background: var(--bg);
}
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
  opacity: 0.5;
}

/* ── Language list ───────────────────────────────────── */
.lang-alpha-list { display: flex; flex-direction: column; }
.lang-btn {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 13px 4px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.1s;
  width: 100%;
}
.lang-btn:active { background: var(--primary-light); }
.lang-btn .flag { font-size: 22px; line-height: 1; flex-shrink: 0; }
.lang-btn .lname { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.25; }
.lang-btn .lsub  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.lang-btn.hidden { display: none; }

/* ── Category grid ───────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, 1fr);
  gap: 8px;
  margin-top: 0.5rem;
  flex: 1;
  min-height: 0;
}
.cat-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  min-height: 0;
}
.cat-btn:active {
  transform: scale(0.97);
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: none;
}
.cat-btn .icon {
  font-size: 26px;
  margin-bottom: 9px;
  display: block;
  line-height: 1;
}
.cat-btn .clabel {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: block;
  letter-spacing: -0.1px;
}
.cat-btn .csub {
  font-size: 11px;
  color: var(--text3);
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

/* ── Question list ───────────────────────────────────── */
.q-list { display: flex; flex-direction: column; gap: 8px; margin-top: 0.5rem; flex: 1; overflow-y: auto; min-height: 0; }
.q-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, background 0.1s, border-color 0.1s;
  line-height: 1.45;
}
.q-btn:active {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: none;
}
.q-btn .arr {
  color: var(--primary);
  font-size: 18px;
  flex-shrink: 0;
  font-weight: 400;
  opacity: 0.7;
}

/* ── Patient screen layout ───────────────────────────── */
#s-patient { padding-bottom: 0.75rem; }
#response-widget {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ── Question bar (patient screen) ──────────────────── */
.question-bar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  user-select: none;
  flex-shrink: 0;
}
.question-bar.has-audio {
  cursor: pointer;
  border-color: var(--primary);
}
.question-bar.has-audio:active {
  opacity: 0.75;
}
.question-bar.has-audio .question-bar-lang::after {
  content: ' ▶';
  opacity: 0.7;
}
.question-bar-lang {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 5px;
}
.question-bar-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.2px;
}

.response-instruction {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.answer-display {
  margin-top: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.answer-display:not(.empty) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,98,204,0.1);
  cursor: pointer;
}
.answer-display:not(.empty):active {
  opacity: 0.7;
}
.answer-display.empty {
  font-size: 13px;
  font-weight: 400;
  color: var(--text3);
  font-style: italic;
}

.doctor-note {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
  flex-shrink: 0;
}

/* ── Scale widget ────────────────────────────────────── */
.scale-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.scale-btn {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border2);
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
  padding: clamp(8px, 2vw, 16px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.scale-num { font-size: clamp(14px, 4vw, 22px); font-weight: 800; line-height: 1; }
.scale-face { font-size: clamp(14px, 4vw, 22px); line-height: 1; }
.scale-btn:active { transform: scale(0.93); }
.scale-btn.sel {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,98,204,0.35);
}
.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text3);
  padding: 4px 4px 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Yes/No widget ───────────────────────────────────── */
.yesno-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.yn-btn {
  padding: clamp(24px, 8vh, 56px) 10px;
  border-radius: var(--radius);
  border: 2px solid var(--border2);
  font-size: clamp(48px, 15vw, 80px);
  line-height: 1;
  cursor: pointer;
  text-align: center;
  background: var(--bg);
  color: var(--text2);
  transition: all 0.12s;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.yn-btn:active { transform: scale(0.95); }
.yn-btn.yes.sel {
  background: var(--green-bg);
  color: var(--green-text);
  border-color: var(--green-border);
  box-shadow: 0 4px 16px rgba(22,163,74,0.25);
}
.yn-btn.no.sel {
  background: var(--red-bg);
  color: var(--red-text);
  border-color: var(--red-border);
  box-shadow: 0 4px 16px rgba(185,28,28,0.2);
}

/* ── Body map widget ─────────────────────────────────── */
.parts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.part-btn {
  padding: clamp(8px, 2vh, 18px) 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border2);
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.part-icon { font-size: clamp(20px, 6vw, 32px); line-height: 1; }
.part-label { font-size: clamp(10px, 2.5vw, 13px); font-weight: 700; line-height: 1.2; }
.part-btn:active { transform: scale(0.95); }
.part-btn.sel {
  background: var(--primary-light);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,98,204,0.15);
}

/* ── Pill widget ─────────────────────────────────────── */
.pill-wrap { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-content: center; flex: 1; min-height: 0; }
.pill-btn {
  padding: 14px 22px;
  border-radius: 28px;
  border: 1.5px solid var(--border2);
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
}
.pill-btn:active { transform: scale(0.95); }
.pill-btn.sel {
  background: var(--primary-light);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,98,204,0.15);
}

/* ── Duration widget ─────────────────────────────────── */
.dur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dur-btn {
  padding: clamp(10px, 2.5vh, 22px) 8px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border2);
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.dur-icon { font-size: clamp(20px, 6vw, 32px); line-height: 1; }
.dur-btn span:last-child { font-size: clamp(12px, 3vw, 15px); font-weight: 700; }
.dur-btn:active { transform: scale(0.95); }
.dur-btn.sel {
  background: var(--primary-light);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,98,204,0.15);
}

/* ── Follow-up button ────────────────────────────────── */
.followup-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s;
}
.followup-btn:active {
  background: var(--bg3);
  box-shadow: none;
}

/* ── Done / back button ──────────────────────────────── */
.done-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.done-btn:active { background: var(--bg3); }

/* ── Screen transition ───────────────────────────────── */
.screen { animation: fadeSlide 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
