/* =========================================================
   CEPART — Feuille de style partagée des questionnaires
   Reproduction fidèle des formulaires papier + remplissage
   en ligne + impression / export PDF. Palette du logo.
   ========================================================= */

:root {
  --ink:      #1b2a30;
  --ink-2:    #3c4d53;
  --ink-3:    #6f7f84;
  --line:     #c9d2d3;
  --teal:     #45808f;
  --teal-2:   #336370;
  --teal-3:   #244c57;
  --teal-50:  #eaf1f2;
  --brick:    #bf5440;
  --brick-2:  #9f4130;
  --brick-50: #f9ece7;
  --paper:    #ffffff;
  --stage:    #e7eaea;
  --sans: "DM Sans", Arial, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--stage);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Barre d'outils (écran seulement) ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(27,42,48,.96);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 20px;
  flex-wrap: wrap;
}
.toolbar .tb-title {
  font-weight: 600; font-size: 14.5px; letter-spacing: .01em;
  display: flex; align-items: center; gap: 10px;
}
.toolbar .tb-title .tb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brick); }
.toolbar .spacer { flex: 1; }
.toolbar a.tb-back { color: #c5d2d4; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.toolbar a.tb-back:hover { color: #fff; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: background .2s, border-color .2s, transform .15s;
  white-space: nowrap;
}
.tb-btn svg { width: 15px; height: 15px; }
.tb-btn.primary { background: var(--teal); color: #fff; }
.tb-btn.primary:hover { background: var(--teal-2); transform: translateY(-1px); }
.tb-btn.ghost { background: transparent; color: #d6e0e1; border-color: rgba(255,255,255,.28); }
.tb-btn.ghost:hover { border-color: #fff; color: #fff; }
.tb-hint { font-size: 12px; color: #9fb0b2; display: inline-flex; align-items: center; gap: 6px; }
.tb-hint .dot { width: 7px; height: 7px; border-radius: 50%; background: #54c08a; box-shadow: 0 0 0 3px rgba(84,192,138,.25); }

/* ---------- Pages A4 ---------- */
.doc { padding: 28px 16px 60px; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.sheet {
  background: var(--paper);
  width: 210mm;
  min-height: 297mm;
  padding: 11mm 16mm 10mm;
  box-shadow: 0 10px 40px -12px rgba(20,37,43,.3);
  position: relative;
  display: flex; flex-direction: column;
}

/* ---------- En-tête document ---------- */
.dh { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 20px; margin-bottom: 2mm; }
.dh-logo img { height: 52px; width: auto; display: block; }
.dh-title { text-align: center; }
.dh-title h1 {
  font-size: 23px; font-weight: 600; letter-spacing: -.01em; margin: 0; color: var(--ink);
}
.dh-title .sub { font-size: 12.5px; color: var(--ink-3); font-style: italic; margin-top: 2px; }
.dh-rule { height: 3px; background: linear-gradient(90deg, var(--brick), var(--teal)); border-radius: 2px; margin: 1.5mm 0 3.5mm; }

/* ---------- Lignes de champ ---------- */
.frow { display: flex; align-items: baseline; gap: 10px; margin: 3px 0; flex-wrap: wrap; }
.frow .lbl { font-size: 14px; color: var(--ink); white-space: nowrap; }
.frow .lbl.b { font-weight: 600; }

/* Champ rempli en pointillés (input à soulignement) */
.fill {
  flex: 1 1 120px; min-width: 80px;
  border: 0; border-bottom: 1.6px dotted var(--ink-3);
  background: transparent; font: inherit; color: var(--teal-3);
  padding: 1px 4px 3px; line-height: 1.5;
}
.fill::placeholder { color: #b9c2c4; font-style: italic; }
.fill:focus { outline: none; border-bottom-color: var(--teal); border-bottom-style: solid; background: var(--teal-50); }
.fill.short { flex: 0 1 130px; }
.fill.med { flex: 0 1 230px; }

/* Bloc multi-lignes en pointillés */
.flines {
  width: 100%; border: 0; resize: none; font: inherit; color: var(--teal-3);
  background-image: repeating-linear-gradient(transparent 0 21px, var(--ink-3) 21px 22px);
  background-attachment: local;
  line-height: 22px; padding: 0 4px; margin: 3px 0 5px;
  border-bottom: 0;
}
.flines:focus { outline: none; }

/* ---------- Sections ---------- */
.sec-h { font-size: 15px; font-weight: 700; color: var(--ink); margin: 8px 0 4px; }
.sec-sub { font-size: 13px; color: var(--ink-2); text-decoration: underline; margin: 5px 0 3px; }
.q { font-size: 13.5px; color: var(--ink); margin: 5px 0 2px; line-height: 1.4; }
.q .small { color: var(--ink-2); }

/* ---------- Oui / Non (à entourer) ---------- */
.qline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.qline .q { margin: 0; flex: 1 1 60%; }
.choices { display: inline-flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.opt {
  font: inherit; font-size: 13.5px; color: var(--ink-2);
  background: transparent; cursor: pointer;
  width: 42px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; transition: border-color .15s, color .15s, background .15s;
  display: inline-grid; place-items: center; padding: 0;
}
.opt:hover { color: var(--teal-2); border-color: var(--line); }
.opt.on { border-color: var(--brick); color: var(--brick-2); font-weight: 600; background: var(--brick-50); }

/* Variante "Précisez …" sur la même ligne */
.precise { display: flex; align-items: baseline; gap: 8px; flex: 1 1 200px; }
.precise .lbl { white-space: nowrap; color: var(--ink); }

/* ---------- Pied de page document ---------- */
.dfoot {
  margin-top: auto;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end;
  font-size: 11px; color: var(--ink-3); letter-spacing: .02em;
}
.dfoot div { white-space: nowrap; }

/* ---------- Bloc signature ---------- */
.sign-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 24px; margin-top: 3mm; }
.sign-cell { display: flex; flex-direction: column; gap: 4px; }
.sign-cell .sl { font-size: 14px; color: var(--ink); }
.sign-cell .sb { border-bottom: 1.6px dotted var(--ink-3); min-height: 30px; }
.sign-cell .sb input { width: 100%; border: 0; background: transparent; font: inherit; color: var(--teal-3); padding: 2px 2px 4px; }
.sign-cell .sb input:focus { outline: none; }

/* Encadré important */
.important {
  border: 1.6px solid var(--line); border-left: 4px solid var(--brick);
  background: #fcf7f4; border-radius: 6px; padding: 10px 14px; margin: 4mm 0 3mm;
  font-size: 13.5px; color: var(--ink); line-height: 1.45;
}
.important b { color: var(--brick-2); }

/* Encadré crochet (ex. [ DIABÈTE par exemple ]) */
.bracket { display: inline-flex; align-items: baseline; gap: 2px; flex: 0 1 240px; }
.bracket .br { color: var(--ink-3); font-size: 16px; }

/* ---------- Schéma corporel ---------- */
.schema-wrap { margin: 6mm 0; }
.schema {
  position: relative; width: 100%; max-width: 165mm; margin: 0 auto;
  height: 600px;
}
.schema .side-tag {
  position: absolute; top: 0; font-size: 14px; font-weight: 600; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 5px; padding: 4px 14px; background: #fff;
}
.schema .side-tag.left { left: 0; }
.schema .side-tag.right { right: 0; }
.schema .body-svg {
  position: absolute; left: 50%; top: 28px; transform: translateX(-50%);
  height: 540px; width: auto; z-index: 0;
}
.bx {
  position: absolute; z-index: 2;
  border: 1.4px solid var(--teal); border-radius: 5px; background: rgba(255,255,255,.96);
  padding: 4px 7px 5px; width: 150px; box-shadow: 0 1px 3px rgba(20,37,43,.08);
}
.bx.center { width: 124px; border-color: var(--brick); }
.bx .bx-l { font-size: 12.5px; font-weight: 600; color: var(--ink); display: block; }
.bx .bx-i {
  width: 100%; border: 0; border-bottom: 1px dotted var(--ink-3);
  background: transparent; font: inherit; font-size: 12.5px; color: var(--teal-3); padding: 1px 2px;
}
.bx .bx-i:focus { outline: none; border-bottom-color: var(--teal); border-bottom-style: solid; }

/* ---------- Impression ---------- */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; }
  .toolbar, .noprint { display: none !important; }
  .doc { padding: 0; gap: 0; }
  .sheet {
    width: 210mm; height: 296mm; min-height: 0; box-shadow: none;
    padding: 11mm 16mm 9mm;
    overflow: hidden;
    page-break-after: always; break-after: page;
  }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  .fill, .flines, .bx .bx-i, .sign-cell .sb input { color: #143; }
  .fill:focus, .bx .bx-i:focus { background: transparent; border-bottom-style: dotted; }
  .opt.on { background: transparent; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .important { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive (mobile : on met la feuille à l'échelle) ---------- */
@media (max-width: 800px) {
  .doc { padding: 14px 0 40px; gap: 16px; }
  .sheet {
    width: 100%; min-height: auto; padding: 22px 18px 28px;
    box-shadow: 0 6px 20px -10px rgba(20,37,43,.3);
  }
  .schema { height: 560px; }
  .bx { width: 38vw; max-width: 150px; }
  .dh-title h1 { font-size: 21px; }
  .dh-logo img { height: 52px; }
  .sign-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .frow .lbl { font-size: 14px; }
  .schema { height: 480px; }
  .schema .body-svg { height: 430px; }
  .bx { padding: 3px 5px 4px; }
  .bx .bx-l { font-size: 11px; }
}
