/* =========================================================
   Dr. Boechat — Formulários digitais (tela / mobile-first)
   Depends on boechat.css tokens.
   ========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--purple-050);
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 56px) clamp(12px, 4vw, 24px) 72px;
}

/* top bar with logo + back */
.app-top {
  width: 100%; max-width: 720px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: clamp(20px, 4vw, 36px);
}
.app-top img { height: 34px; width: auto; display: block; }
.app-top .back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-decoration: none; padding: 8px 12px; border-radius: 999px;
  transition: background 160ms var(--ease-out);
}
.app-top .back:hover { background: var(--purple-100); opacity: 1; }
.app-top .back svg { width: 16px; height: 16px; }

/* ---------- Card ---------- */
.card-form {
  width: 100%; max-width: 720px;
  background: var(--paper);
  border: 1.5px solid var(--purple-200);
  border-radius: var(--radius-frame);
  padding: clamp(22px, 5vw, 48px);
  box-shadow: var(--shadow-2);
}

/* ---------- Form header ---------- */
.f-head { margin-bottom: var(--s-6); }
.f-head .eyebrow { color: var(--purple-500); margin-bottom: var(--s-2); }
.f-head h1 {
  font-size: clamp(26px, 5vw, 36px); line-height: 1.12; font-weight: 700;
  letter-spacing: -0.01em; color: var(--purple-900);
}
.f-head .tagline {
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  font-size: clamp(17px, 3vw, 21px); color: var(--purple-500);
  margin-top: var(--s-3);
}
.f-head p.lead { color: var(--ink-2); font-size: 15px; line-height: 24px; margin-top: var(--s-3); max-width: 56ch; }

/* ---------- Section grouping ---------- */
.f-section { margin-top: var(--s-6); }
.f-section + .f-section { margin-top: var(--s-7); }
.f-section-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: var(--s-4);
  padding-bottom: var(--s-3); border-bottom: 1px solid var(--line);
}
.f-section-head .num {
  flex: none; width: 28px; height: 28px; border-radius: 7px;
  background: var(--purple-700); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.f-section-head h2 { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: 0.01em; }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4) var(--s-4); }
.grid .col-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-2);
}
.field > label .req { color: var(--purple-500); margin-left: 2px; }
.field input[type=text],
.field input[type=tel],
.field input[type=email],
.field input[type=date],
.field input[type=number],
.field select,
.field textarea {
  font-family: var(--font-sans); font-size: 16px; color: var(--ink);
  padding: 13px 15px; min-height: 50px;
  border: 1.5px solid var(--purple-200); border-radius: var(--radius-input);
  background: var(--paper); outline: none; width: 100%;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background 160ms;
}
.field textarea { min-height: 104px; resize: vertical; line-height: 24px; }
.field select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236B3D90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 44px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }

/* hover */
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--purple-300); }
/* focus */
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(107, 61, 144, 0.14);
}
/* filled */
.field.is-filled input, .field.is-filled select, .field.is-filled textarea { background: var(--purple-050); border-color: var(--purple-300); }
.field.is-filled input:focus, .field.is-filled select:focus { background: var(--paper); }
/* error */
.field.is-error input, .field.is-error select, .field.is-error textarea { border-color: var(--warn); }
.field.is-error input:focus, .field.is-error select:focus { box-shadow: 0 0 0 3px rgba(176, 54, 47, 0.14); }
.field .msg { font-size: 12px; color: var(--ink-3); line-height: 17px; }
.field .msg.err { color: var(--warn); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.field .msg.err svg { width: 14px; height: 14px; flex: none; }

/* ---------- Radio / checkbox chips ---------- */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 11px 16px; min-height: 46px;
  border: 1.5px solid var(--purple-200); border-radius: 999px;
  font-size: 14.5px; color: var(--ink-2); background: var(--paper);
  transition: all 160ms var(--ease-out); user-select: none;
}
.choice:hover { border-color: var(--purple-300); background: var(--purple-050); }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice .dot {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--purple-300);
  flex: none; display: grid; place-items: center; transition: all 160ms;
}
.choice.checkbox .dot { border-radius: 6px; }
.choice.checked { border-color: var(--purple-700); background: var(--purple-050); color: var(--purple-900); font-weight: 600; }
.choice.checked .dot { border-color: var(--purple-700); background: var(--purple-700); }
.choice.checked .dot::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: #fff;
}
.choice.checkbox.checked .dot::after {
  content: ""; width: 5px; height: 9px; border-radius: 0; background: transparent;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px);
}

/* ---------- Toggle yes/no inline (for anamnese) ---------- */
.tnf { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 4px; border-bottom: 1px solid var(--line); }
.tnf:last-child { border-bottom: 0; }
.tnf .q { font-size: 14.5px; color: var(--ink); line-height: 21px; flex: 1; }
.tnf .seg2 { display: flex; gap: 6px; flex: none; background: var(--purple-050); padding: 4px; border-radius: 999px; }
.tnf .seg2 button {
  border: 0; background: transparent; cursor: pointer; font-family: var(--font-sans);
  font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 8px 16px; border-radius: 999px;
  min-height: 38px; transition: all 140ms var(--ease-out);
}
.tnf .seg2 button.on-yes { background: var(--purple-700); color: #fff; }
.tnf .seg2 button.on-no { background: var(--ink-2); color: #fff; }

/* ---------- Stepper / progress ---------- */
.stepper { width: 100%; max-width: 720px; margin-bottom: var(--s-5); }
.stepper .bar { height: 5px; background: var(--purple-100); border-radius: 999px; overflow: hidden; }
.stepper .bar > i { display: block; height: 100%; background: var(--purple-700); border-radius: 999px;
  transition: width 360ms var(--ease-out); }
.stepper .steps { display: flex; justify-content: space-between; margin-top: 12px; gap: 6px; }
.stepper .steps .st { font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3);
  display: flex; align-items: center; gap: 7px; }
.stepper .steps .st .ix {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--purple-200);
  display: grid; place-items: center; font-size: 11px; flex: none; background: var(--paper); }
.stepper .steps .st.active { color: var(--purple-700); }
.stepper .steps .st.active .ix { background: var(--purple-700); border-color: var(--purple-700); color: #fff; }
.stepper .steps .st.done .ix { background: var(--purple-100); border-color: var(--purple-300); color: var(--purple-700); }
@media (max-width: 620px) { .stepper .steps .st .lbl { display: none; } }

/* ---------- Footer actions ---------- */
.f-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid var(--line);
}
.f-actions.end { justify-content: flex-end; }
.btn { min-height: 50px; }
.btn-ghost { background: transparent; border: 0; color: var(--ink-2); font-weight: 600;
  font-family: var(--font-sans); font-size: 14px; cursor: pointer; padding: 12px 8px;
  display: inline-flex; align-items: center; gap: 7px; }
.btn-ghost:hover { color: var(--purple-700); }
.btn svg, .btn-ghost svg { width: 17px; height: 17px; }

/* ---------- Review / summary ---------- */
.review { display: flex; flex-direction: column; gap: 2px; }
.review .r-row { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.review .r-row .k { flex: none; width: 40%; max-width: 220px; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.02em; color: var(--ink-3); text-transform: uppercase; }
.review .r-row .v { flex: 1; font-size: 15px; color: var(--ink); }
.review .r-row .v.empty { color: var(--ink-3); font-style: italic; }

/* ---------- Consent / signature ---------- */
.consent-scroll {
  max-height: 320px; overflow-y: auto; padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--purple-050);
  font-size: 14px; line-height: 24px; color: var(--ink-2);
}
.consent-scroll h3 { font-size: 15px; color: var(--ink); margin: var(--s-4) 0 var(--s-2); }
.consent-scroll h3:first-child { margin-top: 0; }
.consent-scroll p { margin-bottom: var(--s-3); }
.sig-pad-wrap { margin-top: var(--s-3); }
.sig-pad {
  width: 100%; height: 180px; border: 1.5px dashed var(--purple-300);
  border-radius: var(--radius-card); background: var(--paper); touch-action: none;
  display: block; cursor: crosshair;
}
.sig-pad.signed { border-style: solid; border-color: var(--purple-500); }
.sig-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.sig-tools .hint { font-size: 12px; color: var(--ink-3); }

/* ---------- Success ---------- */
.done-screen { text-align: center; padding: var(--s-6) 0; }
.done-screen .check {
  width: 72px; height: 72px; border-radius: 50%; background: var(--purple-700);
  display: grid; place-items: center; margin: 0 auto var(--s-5); }
.done-screen .check svg { width: 36px; height: 36px; color: #fff; }
.done-screen h2 { font-size: 26px; color: var(--purple-900); margin-bottom: var(--s-3); }
.done-screen p { color: var(--ink-2); max-width: 44ch; margin: 0 auto; line-height: 25px; }
.done-screen .tagline { font-family: var(--font-serif); font-style: italic; color: var(--purple-500);
  font-size: 20px; margin-top: var(--s-5); }

/* required-summary banner */
.err-banner {
  display: flex; align-items: center; gap: 10px; margin-top: var(--s-4);
  background: rgba(176,54,47,0.07); border: 1px solid rgba(176,54,47,0.25);
  color: var(--warn); border-radius: var(--radius-card); padding: 12px 16px; font-size: 13.5px; font-weight: 600;
}
.err-banner svg { width: 18px; height: 18px; flex: none; }

.hidden { display: none !important; }

/* =========================================================
   CLINICAL SCALES (CSI / FIQR / BPI)
   ========================================================= */
.scale-legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  padding: 14px 18px; background: var(--purple-050);
  border: 1px solid var(--purple-100); border-radius: var(--radius-card);
  margin-bottom: var(--s-4); font-size: 13px; color: var(--ink-2); line-height: 18px;
}
.scale-legend b {
  display: inline-grid; place-items: center; width: 20px; height: 20px;
  border-radius: 5px; background: var(--purple-700); color: #fff;
  font-size: 11.5px; font-weight: 700; vertical-align: middle;
}

.q-block { padding: 20px 0; border-bottom: 1px solid var(--line); }
.q-block:first-of-type { padding-top: 4px; }
.q-block:last-child { border-bottom: 0; }
.q-block .q-head { display: flex; gap: 12px; margin-bottom: 14px; }
.q-block .q-num {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: var(--purple-100); color: var(--purple-700);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.q-block .q-text { font-size: 15px; line-height: 23px; color: var(--ink); padding-top: 2px; }

.scale-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.scale-btn {
  flex: 1 1 auto; min-width: 40px; min-height: 46px;
  border: 1.5px solid var(--purple-200); border-radius: 10px; background: var(--paper);
  font-family: var(--font-sans); font-size: 15px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; transition: background 140ms var(--ease-out), border-color 140ms var(--ease-out),
    color 140ms var(--ease-out), transform 100ms var(--ease-in);
}
.scale-btn:hover { border-color: var(--purple-300); background: var(--purple-050); }
.scale-btn.sel { background: var(--purple-700); border-color: var(--purple-700); color: #fff; }
.scale-btn:active { transform: scale(0.95); }
.scale-anchors {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 9px;
  font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.01em;
}
.scale-anchors span:last-child { text-align: right; }

/* domain header */
.domain-head {
  display: flex; align-items: baseline; gap: 12px; margin: var(--s-6) 0 var(--s-3);
  padding-bottom: var(--s-3); border-bottom: 2px solid var(--purple-700); flex-wrap: wrap;
}
.domain-head .eyebrow { color: var(--purple-500); }
.domain-head h2 { font-size: 22px; font-weight: 700; color: var(--purple-900); letter-spacing: -0.01em; white-space: nowrap; text-wrap: nowrap; }
.domain-head .sub { font-size: 13px; color: var(--ink-3); margin-left: auto; }
.domain-note { font-size: 13.5px; line-height: 21px; color: var(--ink-2); margin-bottom: var(--s-3); max-width: 62ch; }

/* answered progress (sticky) */
.answered-bar {
  position: sticky; top: 0; z-index: 5; width: 100%; max-width: 720px;
  background: var(--purple-050); border: 1px solid var(--purple-100);
  border-radius: 999px; padding: 8px 16px; margin-bottom: var(--s-4);
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-1);
}
.answered-bar .ab-track { flex: 1; height: 6px; background: var(--purple-100); border-radius: 999px; overflow: hidden; }
.answered-bar .ab-track > i { display: block; height: 100%; background: var(--purple-700); border-radius: 999px; transition: width 300ms var(--ease-out); }
.answered-bar .ab-label { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* result panel */
.result {
  background: var(--purple-700); color: #fff; border-radius: var(--radius-frame);
  padding: var(--s-7) var(--s-6); text-align: center; margin-top: var(--s-4);
}
.result-score { font-size: 72px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.result-score .result-max { font-size: 28px; font-weight: 600; opacity: 0.6; }
.result-band {
  display: inline-block; margin-top: var(--s-4); padding: 8px 22px;
  border: 1.5px solid rgba(255,255,255,0.45); border-radius: 999px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
}
.result-cap { margin: var(--s-4) auto 0; max-width: 46ch; color: rgba(255,255,255,0.88); line-height: 24px; font-size: 14.5px; }
.result-bands {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px;
  margin-top: var(--s-6); text-align: left;
}
.result-bands .rb {
  background: rgba(255,255,255,0.10); border-radius: 10px; padding: 10px 12px;
  font-size: 11.5px; line-height: 16px; color: rgba(255,255,255,0.78);
}
.result-bands .rb.on { background: #fff; color: var(--purple-900); font-weight: 600; }
.result-bands .rb b { display: block; font-size: 13px; font-weight: 700; }

/* disclaimer */
.scale-disclaimer {
  font-size: 12.5px; line-height: 19px; color: var(--ink-3);
  background: var(--purple-050); border-radius: var(--radius-card);
  padding: 14px 18px; margin-top: var(--s-5);
}
