/* ============================================================
   NHS DESIGN SYSTEM — VARIABLES
   ============================================================ */
:root {
  --nhs-blue:      #005eb8;
  --nhs-dark-blue: #003087;
  --nhs-green:     #007f3b;
  --nhs-red:       #d5281b;
  --nhs-yellow:    #ffeb3b;
  --nhs-aqua:      #00a499;
  --nhs-orange:    #ed8b00;
  --text:          #212b32;
  --text-secondary:#4c6272;
  --border:        #d8dde0;
  --bg:            #f0f4f5;
  --surface:       #ffffff;
  --shadow:        0 1px 3px rgba(0,0,0,.12);
  --r:             4px;
  --r-sm:          4px;
  --r-xs:          4px;
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-size: 16px;
  line-height: 1.5;
}
button  { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
a { color: var(--nhs-blue); }
ul { list-style: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ============================================================
   LOADING / PROCESSING SCREENS
   ============================================================ */
.screen-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--surface);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--nhs-blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-title { font-size: 18px; font-weight: 700; color: var(--text); text-align: center; }
.processing-sub   { font-size: 14px; color: var(--text-secondary); text-align: center; margin-top: 4px; }

.pulse-ring {
  position: absolute;
  width: 100px; height: 100px;
  border: 2px solid rgba(0,94,184,.3);
  border-radius: 50%;
  animation: pulse-out 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse-out {
  0%   { transform: scale(.8); opacity: .8; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes float-logo {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.float { animation: float-logo 2s ease-in-out infinite; }

/* ============================================================
   ONBOARDING
   ============================================================ */
.screen-onboarding {
  min-height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.onboard-hero {
  background: var(--nhs-dark-blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: max(48px, calc(env(safe-area-inset-top) + 32px)) 20px 32px;
}
.onboard-title    { font-size: 32px; font-weight: 700; color: #fff; }
.onboard-sub      { font-size: 16px; color: rgba(255,255,255,.8); max-width: 280px; line-height: 1.5; }

.onboard-body {
  padding: 28px 20px 32px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.onboard-card {
  background: var(--surface);
}
.onboard-card-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.onboard-card-sub   { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }

.demo-notice {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 16px;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.screen-home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-header {
  background: var(--nhs-dark-blue);
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-name  { font-size: 16px; font-weight: 700; color: #fff; }
.day-badge {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 2px;
  border: 1px solid rgba(255,255,255,.25);
}

.home-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.home-greeting h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.home-greeting p  { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* Status card */
.status-card {
  border-radius: var(--r);
  padding: 16px;
  border-left: 4px solid transparent;
}
.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.status-meta  { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.risk-pill {
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 2px;
  color: #fff; letter-spacing: .04em;
}
.status-finding { font-size: 15px; font-weight: 600; line-height: 1.45; }
.status-advice  { font-size: 14px; margin-top: 4px; line-height: 1.4; }

.status-card--empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--nhs-blue) !important;
  text-align: left;
  padding: 20px;
}
.empty-icon  { font-size: 28px; margin-bottom: 8px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text); }
.empty-sub   { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

.home-actions { display: flex; flex-direction: column; gap: 10px; }

/* History */
.section-title {
  font-size: 13px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 10px;
}
.history-list  { display: flex; flex-direction: column; gap: 4px; }
.history-item  {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border-radius: var(--r);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  width: 100%;
  text-align: left;
  transition: background .1s;
}
.history-item:hover, .history-item:active { background: #f0f4f5; }
.history-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.history-info  { flex: 1; min-width: 0; }
.history-date  { font-size: 12px; color: var(--text-secondary); display: block; }
.history-text  {
  font-size: 14px; color: var(--text);
  display: block; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.history-risk  { font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* ============================================================
   FLOW SCREENS (CHECK-IN / RESULT)
   ============================================================ */
.screen-flow {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.flow-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--nhs-dark-blue);
  border-bottom: none;
  position: sticky; top: 0; z-index: 20;
}
.back-btn {
  width: 36px; height: 36px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.85);
  transition: background .15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover, .back-btn:active { background: rgba(255,255,255,.15); }

.step-track {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.step-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  transition: all .2s;
}
.step-dot--active {
  background: #fff;
  width: 20px; border-radius: 2px;
}
.step-dot--done { background: rgba(255,255,255,.6); }
.step-count { font-size: 12px; color: rgba(255,255,255,.7); margin-left: 6px; }

.flow-title {
  flex: 1;
  font-size: 15px; font-weight: 600;
  color: #fff; text-align: center;
}

.flow-progress {
  height: 4px;
  background: var(--nhs-yellow);
  transition: width .4s ease;
  flex-shrink: 0;
}

.flow-body {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

.step-wrap { display: flex; flex-direction: column; gap: 16px; }
.step-title { font-size: 22px; font-weight: 700; color: var(--text); }
.step-sub   { font-size: 15px; color: var(--text-secondary); margin-top: -8px; }

/* Symptoms grid */
.symptom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.symptom-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .1s, background .1s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.symptom-card:active { opacity: .85; }
.symptom-card--on {
  border-color: var(--nhs-blue);
  background: #e8f0fb;
}
.s-emoji { font-size: 22px; }
.s-label {
  font-size: 13px; font-weight: 500;
  color: var(--text); line-height: 1.3;
}
.symptom-card--on .s-label { color: var(--nhs-blue); font-weight: 700; }

/* Vitals */
.vitals-card { padding: 20px; }
.vital-label { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--text); }

.pain-display {
  font-size: 52px; font-weight: 700; line-height: 1;
  transition: color .2s;
  margin-bottom: 2px;
  color: var(--text);
}
.pain-display sub {
  font-size: 18px; font-weight: 400; color: var(--text-secondary);
  vertical-align: baseline;
}
.pain-name { font-size: 14px; color: var(--text-secondary); min-height: 20px; margin-bottom: 10px; }

.pain-slider {
  width: 100%; height: 6px;
  -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 3px; outline: none;
}
.pain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--nhs-blue); cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,94,184,.4);
}
.pain-slider::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--nhs-blue); border: none; cursor: pointer;
}
.pain-scale {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-secondary);
  margin-top: 6px;
}

.temp-wrap { margin-top: 4px; }
.temp-input { font-size: 18px !important; font-weight: 600 !important; }
.vital-hint { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

/* Photo step */
.photo-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--r);
  height: 220px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  transition: border-color .2s;
}
.photo-empty { text-align: center; color: var(--text-secondary); }
.photo-empty-icon { font-size: 40px; margin-bottom: 8px; }
.photo-empty p    { font-size: 14px; }
.photo-preview    {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: calc(var(--r) - 2px);
}
.photo-retake {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(0,0,0,.55); color: #fff;
  padding: 6px 14px; border-radius: 2px;
  font-size: 12px; font-weight: 600;
}
.photo-btns { display: flex; flex-direction: column; gap: 8px; }

/* ============================================================
   RESULT SCREEN
   ============================================================ */
.result-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.risk-hero {
  border-radius: var(--r);
  border: 1px solid var(--border);
  border-left: 5px solid transparent;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
}
.risk-orb {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
  flex-shrink: 0;
}
.risk-level { font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.risk-lbl   { font-size: 14px; font-weight: 400; margin-top: 2px; color: var(--text-secondary); }

.result-card { padding: 18px; }
.card-label {
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}
.findings { display: flex; flex-direction: column; gap: 8px; }
.finding  {
  font-size: 15px; color: var(--text); line-height: 1.5;
  padding-left: 16px; position: relative;
}
.finding::before { content: '·'; position: absolute; left: 4px; color: var(--nhs-blue); font-size: 20px; line-height: 1; }
.advice-text { font-size: 15px; color: var(--text); line-height: 1.6; }

.escalate-notice {
  background: #fdf2f2; border: 1px solid #f7a5a5;
  border-left: 5px solid var(--nhs-red);
  border-radius: var(--r); padding: 14px 16px;
  font-size: 15px; color: #7a0a0a; font-weight: 600;
}

.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============================================================
   CHAT SCREEN
   ============================================================ */
.screen-chat {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-hdr-info  { flex: 1; min-width: 0; }
.chat-hdr-title { font-size: 15px; font-weight: 700; color: #fff; }
.chat-hdr-sub   { font-size: 12px; color: rgba(255,255,255,.7); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overscroll-behavior: contain;
}

.chat-empty {
  display: flex; flex-direction: column;
  align-items: flex-start; gap: 14px;
  padding: 24px 4px;
}
.chat-empty-msg {
  font-size: 15px; color: var(--text);
  max-width: 300px; line-height: 1.55;
}
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface); border: 1px solid var(--nhs-blue);
  color: var(--nhs-blue); padding: 8px 14px;
  border-radius: 2px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover, .chip:active { background: #e8f0fb; }

.bubble-row {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 92%;
}
.bubble-row--user { align-self: flex-end; flex-direction: row-reverse; }
.ai-orb {
  width: 30px; height: 30px;
  background: var(--nhs-dark-blue); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 4px;
}
.bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 16px 16px 16px;
  padding: 10px 14px;
  font-size: 15px; line-height: 1.55;
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: 100%;
  word-wrap: break-word;
}
.bubble-row--user .bubble {
  background: var(--nhs-blue); color: #fff;
  border-color: var(--nhs-blue);
  border-radius: 16px 0 16px 16px;
}

/* Typing animation */
.typing-dots { display: flex; gap: 4px; align-items: center; height: 18px; padding: 0 2px; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--text-secondary); border-radius: 50%;
  animation: tdot 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes tdot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

.chat-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.chat-row { display: flex; gap: 8px; align-items: center; }
.chat-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 16px; color: var(--text);
  outline: none; transition: border-color .15s;
}
.chat-input:focus { border-color: var(--nhs-blue); }
.chat-input:disabled { opacity: .5; }
.send-btn {
  width: 44px; height: 44px; border-radius: var(--r);
  background: var(--nhs-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s;
}
.send-btn:hover  { background: #006130; }
.send-btn:active { opacity: .85; }
.send-btn:disabled { background: var(--border); pointer-events: none; }
.chat-legal {
  font-size: 12px; color: var(--text-secondary);
  text-align: center; margin-top: 8px; line-height: 1.4;
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 52px;
  border-radius: var(--r);
  font-size: 16px; font-weight: 700;
  transition: background .1s, opacity .1s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  text-decoration: none;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--nhs-green); color: #fff; border-bottom: 4px solid #005a2b; }
.btn-primary:hover { background: #006130; }
.btn-primary:disabled {
  background: var(--border); color: var(--text-secondary);
  cursor: not-allowed; opacity: 1; border-bottom: none;
}
.btn-secondary {
  background: var(--surface); color: var(--nhs-blue);
  border: 2px solid var(--nhs-blue);
}
.btn-secondary:hover { background: #e8f0fb; }
.btn-ghost   { background: transparent; color: var(--text-secondary); font-weight: 500; }
.btn-ghost:hover { color: var(--text); }

/* Form fields */
.field       { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field-label { font-size: 15px; font-weight: 700; color: var(--text); }
.field-input {
  background: var(--surface);
  border: 2px solid var(--text-secondary);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 16px; color: var(--text);
  outline: none; transition: border-color .15s;
  width: 100%;
  -webkit-appearance: none; appearance: none;
}
.field-input:focus { border-color: var(--text); box-shadow: 0 0 0 3px var(--nhs-yellow); }
select.field-input { cursor: pointer; }

/* Demo bar */
.demo-bar {
  background: var(--nhs-dark-blue);
  text-align: center; font-size: 12px;
  color: rgba(255,255,255,.6); padding: 8px;
  letter-spacing: .04em;
}
