/* ═══════════════════════════════════════════════════════════════════════════
   强能疼痛专科 — 患者端 H5 设计系统
   Design language: institutional medical (Mayo Clinic / Cleveland Clinic inspired)
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --navy:          #002F6C;
  --navy-dark:     #001F4A;
  --navy-mid:      #00478F;
  --blue-accent:   #0063BF;
  --blue-light:    #EBF2FA;
  --blue-focus:    rgba(0,99,191,.18);
  --teal:          #007B82;
  --surface:       #F5F5F7;
  --card:          #FFFFFF;
  --border:        #E3E3E8;
  --border-focus:  #0063BF;
  --input-bg:      #F4F4F6;
  --text-hd:       #1D1D1F;
  --text-body:     #3A3A3C;
  --text-muted:    #6E6E73;
  --text-light:    #AEAEB2;
  --divider:       #F0F0F2;
  --error:         #B91C1C;
  --error-bg:      #FEF2F2;
  --error-border:  #FECACA;
  --success:       #065F46;
  --success-bg:    #ECFDF5;
  --success-border:#A7F3D0;
  --radius:        16px;
  --radius-sm:     10px;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.03), 0 8px 24px rgba(0,47,108,.05);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100%;
  font-family: -apple-system, "PingFang SC", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--surface);
  color: var(--text-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Institution Header (matches menu.html) ─────────────────────────────── */
.inst-header {
  background: var(--navy);
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.inst-header-inner {
  max-width: 640px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.inst-logo {
  width: 88px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: cover;
  object-position: center;
  background: var(--navy);
  display: block;
}

.inst-name-wrap { flex: 1; min-width: 0; }

.inst-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.1px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-dept {
  font-size: 11px;
  color: rgba(255,255,255,.6);
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* Back button in header */
.inst-back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,.8);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.inst-back:active { color: #fff; }
.inst-back svg { width: 16px; height: 16px; }

/* ── Page Body ──────────────────────────────────────────────────────────── */
.page-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
  padding-bottom: max(32px, calc(env(safe-area-inset-bottom, 0px) + 24px));
}

/* ── Page Header (title + subtitle above the form card) ─────────────────── */
.page-hd {
  margin-bottom: 16px;
  padding-left: 2px;
}

.page-hd-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-hd);
  letter-spacing: -.45px;
  line-height: 1.25;
  margin-bottom: 4px;
}

.page-hd-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Form Card ──────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

/* Legacy: .card is used by existing templates, map to form-card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

/* ── Legacy: .container wraps content ──────────────────────────────────── */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
  padding-bottom: max(32px, calc(env(safe-area-inset-bottom, 0px) + 24px));
}

/* ── Headings inside card ───────────────────────────────────────────────── */
h1, h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-hd);
  letter-spacing: -.35px;
  line-height: 1.3;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--divider);
  margin: 0;
}

h2 { font-size: 16px; padding: 14px 20px 12px; }

/* ── Form body wrapper (inside card) ────────────────────────────────────── */
.form-body {
  padding: 16px 20px 20px;
}

/* when __BODY__ is injected directly into .card, add padding */
.card > form,
.card > .errors,
.card > .success {
  padding: 0 20px 20px;
}

/* 卡内裸段落（diary/checkin 等引导文案直接注入 .card）补齐内边距 */
.card > p {
  padding: 0 20px;
  margin: 14px 0 6px;
}

.card > h1 + form { padding-top: 4px; }

/* ── Labels ─────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-hd);
  margin: 20px 0 8px;
}

label:first-child { margin-top: 4px; }

/* ── Inputs, Selects, Textareas ─────────────────────────────────────────── */
input[type="text"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--text-hd);
  background: var(--input-bg);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--blue-focus);
  background: #fff;
}

textarea { min-height: 88px; resize: vertical; }

/* Select: custom chevron */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Field wrapper ──────────────────────────────────────────────────────── */
.field { margin-bottom: 2px; }

.form-section {
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
}

.form-section:first-of-type {
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
}

/* 字段专业注解（如：采用国际通用疼痛数字评分法 NRS） */
.field-note {
  margin: 2px 0 6px;
  font-size: 12px;
  color: var(--text-muted, #8a94a6);
}

html.elder .field-note { font-size: 15px; }

/* 医学审订署名（教育/康复页尾，medically-reviewed-by 惯例） */
.review-byline {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e3e8f0);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted, #8a94a6);
}

html.elder .review-byline { font-size: 15px; }

/* Required asterisk */
.req { color: var(--error); font-weight: 700; }

/* ── Radio Group ────────────────────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.radio {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 2px 0;
  gap: 0;
  margin: 0;
  font-weight: 400;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-body);
  cursor: pointer;
}

/* Hide default radio; use pill-style label */
.radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Pill appearance via adjacent sibling trick isn't available (no wrapper),
   so keep the radio visible but style it minimally */
.radio input[type="radio"] {
  position: static;
  opacity: 1;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  accent-color: var(--blue-accent);
  flex-shrink: 0;
}

/* ── 疗效公示统计卡 ────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px;
  margin-bottom: 8px;
}

@media (max-width: 420px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  border-radius: 12px;
  background: var(--input-bg);
  padding: 16px 14px;
}

.stat-title { font-size: 13px; font-weight: 700; color: var(--text-hd); margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; color: var(--navy); line-height: 1.1; }
.stat-pending { font-size: 16px; font-weight: 700; color: var(--text-muted); }
.stat-n { font-size: 12px; color: var(--text-muted); margin: 4px 0 8px; }
.stat-criterion { font-size: 11px; color: var(--text-light); line-height: 1.5; }

html.elder .stat-title { font-size: 16px; }
html.elder .stat-value { font-size: 32px; }
html.elder .stat-n, html.elder .stat-criterion { font-size: 14px; }

.review-byline { padding-left: 20px; padding-right: 20px; }

/* ── 患者菜单分组标题 ──────────────────────────────────────────────────────── */
.svc-group-label {
  margin: 22px 6px 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-muted, #8a94a6);
}

.svc-group-label:first-child { margin-top: 4px; }

html.elder .svc-group-label { font-size: 16px; }

/* ── 康复指导动作列表 ──────────────────────────────────────────────────────── */
.rehab-list {
  margin: 10px 0 14px;
  padding-left: 18px;
}

.rehab-list li {
  margin-bottom: 10px;
  line-height: 1.7;
}

html.elder .rehab-list li { font-size: 19px; }

/* 长辈模式样式已迁移至 /public/elder-mode.css（由 elder-mode.js 自动注入，
   不依赖各页面是否引入本文件——menu.html 等独立样式页面同样生效）。 */

/* ── Checkbox Group（多选：危险信号筛查/不良反应等）────────────────────────── */
.checkbox-group {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.radio input[type="checkbox"] {
  position: static;
  opacity: 1;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  accent-color: var(--blue-accent);
  flex-shrink: 0;
}

.checkbox-group .radio {
  align-items: flex-start;
  line-height: 1.5;
}

.checkbox-group .radio input[type="checkbox"] {
  margin-top: 2px;
}

/* ── Rating Group ───────────────────────────────────────────────────────── */
.rating-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}

.rating-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 44px;
  height: 58px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-muted);
  background: var(--input-bg);
  cursor: pointer;
  transition: all .18s ease;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

.rating-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
}

.rating-dot {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-light);
  border-radius: 50%;
  background: #fff;
  box-sizing: border-box;
  display: block;
  flex: 0 0 16px;
}

.rating-value {
  display: block;
  min-height: 16px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.rating-item:has(input:checked) {
  border-color: var(--blue-accent);
  background: var(--blue-light);
  color: var(--blue-accent);
}

.rating-item:has(input:checked) .rating-dot {
  border: 2px solid var(--blue-accent);
  box-shadow: inset 0 0 0 3px #fff;
  background: var(--blue-accent);
}

.rating-item:focus-within {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px var(--blue-focus);
}

/* ── Submit Button ──────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  margin-top: 24px;
  border: none;
  border-radius: 12px;
  background: var(--blue-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  transition: background .18s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { background: var(--navy-mid); transform: scale(.985); }

/* ── Error Banner ───────────────────────────────────────────────────────── */
.errors {
  background: var(--error-bg);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--error);
  line-height: 1.6;
}

.errors div::before { content: "• "; }

/* ── Success Screen ─────────────────────────────────────────────────────── */
.success {
  text-align: center;
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.success-icon svg {
  width: 30px;
  height: 30px;
  color: var(--success);
}

.success-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-hd);
}

.success-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

/* Legacy: direct text inside .success (form.js outputs plain text) */
.success:not(:has(.success-title)) {
  font-size: 17px;
  color: var(--success);
  font-weight: 600;
}

/* ── Profile: info rows ─────────────────────────────────────────────────── */
.info-list {
  margin: 0;
  padding: 0 20px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--divider);
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-muted);
  flex-shrink: 0;
}

.info-value {
  font-size: 15px;
  color: var(--text-hd);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

/* ── Notice / tip strip ─────────────────────────────────────────────────── */
.notice-strip {
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.notice-strip-icon { flex-shrink: 0; color: var(--teal); }
.notice-strip-icon svg { width: 18px; height: 18px; stroke-width: 1.8; }

.notice-strip-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.notice-strip-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 2px;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.page-footer {
  text-align: center;
  padding: 20px 16px 8px;
  border-top: 1px solid var(--divider);
  margin-top: 8px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.footer-brand svg { width: 13px; height: 13px; color: var(--navy-mid); }
.footer-brand-logo {
  width: 58px;
  height: 22px;
  border-radius: 3px;
  object-fit: cover;
  object-position: center;
  display: block;
}
.footer-brand-name { font-size: 12px; font-weight: 600; color: var(--navy-mid); }
.footer-legal { font-size: 11px; color: var(--text-light); }

/* ── Tablet / Desktop ───────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .page-body, .container { padding: 28px 24px; }
  h1 { font-size: 20px; }
}

@media (min-width: 700px) {
  body { background: #F0F0F2; }
  .page-body, .container { padding: 32px; max-width: 640px; }
}
