/* ============================================================
   Cabinet Médical VADE — Questionnaires TNDs
   Shared stylesheet : screen (form) + print (PDF) modes.
   The same QEngine markup is styled two ways:
     - on screen  : interactive, comfortable
     - @media print : faithful reproduction of the paper PDF
   ============================================================ */

:root {
  --ink:        #1a1a1a;
  --ink-soft:   #555;
  --muted:      #8a8a8a;
  --line:       #d8d8d2;
  --line-soft:  #efeee8;
  --accent:     #1a4a6b;   /* cabinet blue */
  --accent-2:   #c0392b;   /* section-band red (DIVA) */
  --band-blue:  #e8eef4;
  --row-tint:   #fbeef0;   /* pink alternating tint (SRS proche) */
  --bg:         #f4f3ef;
  --card:       #ffffff;
  --ok:         #2e7d32;
  --warn:       #c62828;
  --radius:     10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- page chrome (screen only) ---- */
.qpage { max-width: 920px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.qhead {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 1rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.qhead img { height: 46px; width: auto; object-fit: contain; }
.qhead .qhead-txt .dr   { font-size: 13px; font-weight: 600; color: var(--accent); }
.qhead .qhead-txt .sub  { font-size: 11px; color: var(--muted); }

/* ---- questionnaire title block ---- */
.qtitle      { text-align: center; margin: 0.5rem 0 1rem; }
.qtitle h1   { font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.qtitle h2   { font-size: 14px; font-weight: 500; color: var(--ink-soft); margin-top: 2px; }
.qtitle .filledby {
  font-size: 12px; font-style: italic; color: var(--ink-soft);
  margin-top: 8px; max-width: 640px; margin-left: auto; margin-right: auto;
}
.qinstructions {
  font-size: 12.5px; color: var(--ink-soft);
  background: #faf9f6; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 10px 14px; margin: 0.75rem 0 1.25rem;
}
.qscale-legend {
  font-size: 12px; color: var(--ink-soft); text-align: center;
  margin-bottom: 1rem;
}
.qscale-legend b { color: var(--ink); }

/* ============================================================
   LIKERT TABLE
   ============================================================ */
.q-likert { margin-bottom: 1.5rem; }

.q-section-band {
  background: var(--accent);
  color: #fff; font-weight: 600; font-size: 13px;
  padding: 6px 12px; border-radius: 4px;
  margin: 1.25rem 0 0;
}

.q-table {
  width: 100%; border-collapse: collapse;
  background: var(--card); margin-bottom: 0.5rem;
}
.q-table th, .q-table td {
  border: 1px solid var(--line); vertical-align: middle;
}
.q-itemhead { width: auto; }
.q-scalehead {
  font-size: 10.5px; font-weight: 600; color: var(--accent);
  text-align: center; padding: 6px 4px; width: 78px; line-height: 1.25;
}
.q-itemcell {
  font-size: 13px; padding: 9px 10px; color: var(--ink);
}
.q-num { font-weight: 700; margin-right: 2px; }
.q-optcell { text-align: center; padding: 8px 4px; }
.q-optcell input[type=radio] {
  width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent);
}
.q-table tbody tr:nth-child(even) td { background: #fcfcfa; }
.q-table tbody tr:hover td { background: #f3f6f9; }
.q-table tr.q-missing td { background: #fff4f4 !important; }

/* print-mode circle marks (used in doctor PDF view) */
.q-mark {
  display: inline-block; width: 15px; height: 15px;
  border: 1.5px solid var(--ink-soft); border-radius: 50%;
}
.q-mark-on { background: var(--ink); border-color: var(--ink); }

/* ---- identification block ---- */
.q-idblock {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.q-idblock .f label {
  display: block; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: 3px;
}
.q-idblock .f input, .q-idblock .f select {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); outline: none;
}
.q-idblock .f input:focus, .q-idblock .f select:focus { border-color: var(--accent); }

/* ---- navigation / actions ---- */
.q-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line-soft);
}
.q-prog { font-size: 12px; color: var(--muted); }
.btn {
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 20px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: background .15s;
}
.btn:hover { background: var(--line-soft); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #15405e; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.q-alert {
  font-size: 13px; color: var(--warn);
  background: #fff4f4; border: 1px solid #f3c9c9;
  border-radius: 8px; padding: 9px 14px; margin: 0.75rem 0;
  display: none;
}
.q-alert.show { display: block; }

/* ============================================================
   PRINT  —  reproduce the paper PDF
   ============================================================ */
@media print {
  @page { size: A4; margin: 14mm 12mm; }

  /* force every element to keep its colours/fills when printing —
     this MUST be attached to a selector to take effect */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    background: #fff;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .qpage { max-width: none; margin: 0; padding: 0; }

  /* hide interactive chrome */
  .no-print, .q-nav, .qinstructions .editonly { display: none !important; }

  .qhead { border-color: #000; }
  .qtitle h1 { font-size: 15pt; }
  .qtitle h2 { font-size: 11pt; }

  /* keep rows from splitting across pages */
  .q-table tr, .q-idblock { page-break-inside: avoid; }
  .q-section-band { page-break-after: avoid; }

  /* exact-ish ink: thin black rules, white cells */
  .q-table th, .q-table td { border: 1px solid #000; }
  .q-table tbody tr:nth-child(even) td,
  .q-table tbody tr:hover td { background: #fff !important; }
  .q-scalehead { color: #000; }

  /* radios disappear in print; show the chosen circle instead */
  .q-optcell input[type=radio] { display: none; }

  /* answer marks: a checked answer prints as a solid black disc.
     Defined with explicit ink so it survives even if a browser
     still strips background-color. */
  .q-mark {
    border: 1.4px solid #000 !important;
    background: #fff !important;
  }
  .q-mark-on {
    background: #000 !important;
    border-color: #000 !important;
  }
  .dv-box {
    border: 1.4px solid #000 !important;
    background: #fff !important;
  }
  .dv-box-on {
    background: #000 !important;
    border-color: #000 !important;
  }
}

/* utility */
.center { text-align: center; }
.muted  { color: var(--muted); }

/* ============================================================
   DIVA-5  —  two-column symptom layout
   ============================================================ */
.q-diva { margin-bottom: 1.5rem; }

.dv-band {
  color: #fff; font-weight: 700; font-size: 13.5px;
  padding: 8px 14px; border-radius: 4px; margin: 1.5rem 0 0.5rem;
}
.dv-band-red  { background: var(--accent-2); }
.dv-band-navy { background: #1f2d4a; font-size: 12.5px; }

.dv-instructions {
  font-size: 12px; color: var(--ink-soft);
  margin: 0.5rem 0 1rem;
}
.dv-item {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.85rem 1rem; margin-bottom: 0.85rem; background: var(--card);
  page-break-inside: avoid;
}
.dv-qhead { display: flex; gap: 10px; margin-bottom: 0.75rem; }
.dv-code {
  flex: 0 0 auto; background: #1f2d4a; color: #fff;
  font-weight: 700; font-size: 12px; border-radius: 4px;
  padding: 4px 9px; height: fit-content;
}
.dv-qtext { font-size: 12.5px; }
.dv-qtext i { color: var(--ink-soft); }

.dv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.dv-colhead {
  font-size: 12px; font-weight: 700; color: var(--accent);
  margin-bottom: 6px;
}
.dv-checklist { list-style: none; }
.dv-checklist li {
  display: flex; gap: 7px; font-size: 12px;
  margin-bottom: 4px; align-items: flex-start;
}
.dv-checklist li input[type=checkbox] {
  margin-top: 2px; width: 14px; height: 14px;
  accent-color: var(--accent); flex: 0 0 auto;
}
.dv-box {
  display: inline-block; width: 12px; height: 12px;
  border: 1.5px solid var(--ink-soft); border-radius: 3px;
  flex: 0 0 auto; margin-top: 2px;
}
.dv-box-on { background: var(--ink); border-color: var(--ink); }
.dv-autre { flex-direction: column; gap: 4px; margin-top: 6px; }
.dv-autre-lbl { font-weight: 600; font-size: 11.5px; }
.dv-autre-field, .dv-details-field {
  width: 100%; font-family: inherit; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; resize: vertical;
}
.dv-autre-print {
  min-height: 36px; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font-size: 12px;
  white-space: pre-wrap;
}
.dv-present {
  margin-top: 8px; font-size: 12px; font-weight: 600;
  display: flex; gap: 12px; align-items: center;
}
.dv-radio { font-weight: 400; cursor: pointer; }
.dv-radio.dv-block { display: block; margin: 3px 0; }
.dv-pres-opt { display: inline-flex; gap: 5px; align-items: center; margin-right: 14px; }
.dv-footnote { font-size: 11px; font-style: italic; color: var(--ink-soft); margin-top: 6px; }

.dv-crit { border: 1px solid var(--line); border-radius: 8px; padding: 0.85rem 1rem; background: var(--card); }
.dv-q { font-size: 12.5px; margin: 0.5rem 0; }
.dv-agerow { display: flex; gap: 8px; align-items: center; font-size: 12px; margin-top: 8px; }
.dv-age { width: 60px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; }
.dv-age-print { display: inline-block; min-width: 50px; border-bottom: 1px solid #000; }
.dv-drow {
  display: flex; gap: 14px; align-items: center;
  font-size: 12.5px; padding: 8px 10px;
  background: #1f2d4a; color: #fff; border-radius: 4px; margin-bottom: 4px;
}
.dv-dtext { flex: 1; }
.dv-drow .dv-box { border-color: #fff; }
.dv-closing { font-size: 12.5px; font-weight: 700; margin: 0.85rem 0 0.5rem; }
.dv-details { margin-top: 0.5rem; }
.dv-details-print {
  min-height: 90px; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px; font-size: 12px; white-space: pre-wrap;
}

@media print {
  .dv-item, .dv-crit { page-break-inside: avoid; border-color: #000; }
  .dv-autre-field, .dv-details-field { border: 1px solid #000; }
  .dv-checklist li input[type=checkbox] { display: none; }
}

/* ============================================================
   NOTES BLOCK  —  free-text area at end of each questionnaire
   ============================================================ */
.q-notes-block {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 1rem;
}
.q-notes-label {
  font-size: 12px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 6px;
}
.q-notes-field {
  width: 100%; font-family: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; resize: vertical; color: var(--ink);
  background: #fff;
}
.q-notes-field:focus { outline: none; border-color: var(--accent); }
.q-notes-print {
  min-height: 72px; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px;
  font-size: 12px; white-space: pre-wrap; background: #fff;
}

@media print {
  .q-notes-block { border-top: 1px solid #000; }
  .q-notes-field  { display: none; }
  .q-notes-print  { border: 1px solid #000; min-height: 60px; }
}

/* ============================================================
   PATIENT APP  —  selection cards, step bar, done screen
   ============================================================ */
.qstepbar {
  font-size: 12px; color: var(--accent); font-weight: 600;
  margin-bottom: 0.75rem;
}
.qsel-grid { display: grid; gap: 10px; margin-bottom: 1.25rem; }
.qsel-card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; cursor: pointer; background: var(--card);
  transition: border-color .15s, background .15s;
}
.qsel-card:hover { border-color: var(--accent); }
.qsel-card.on { border-color: var(--accent); background: #f3f7fa; }
.qsel-card input[type=checkbox] {
  width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent);
  flex: 0 0 auto;
}
.qsel-title { display: block; font-size: 14px; font-weight: 600; }
.qsel-meta  { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.done-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 1.5rem; text-align: center;
}
.done-card p { margin: 0.4rem 0; font-size: 14px; }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  padding: 2rem 1rem;
}
.landing .l-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 2.5rem; max-width: 460px;
  width: 100%; text-align: center;
}
.landing h1 { font-size: 20px; margin-bottom: 4px; }
.landing .l-sub { font-size: 13px; color: var(--muted); margin-bottom: 1.75rem; }
.landing .l-actions { display: grid; gap: 12px; }
.landing .l-btn {
  display: block; text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 14px; border-radius: 10px; border: 1px solid var(--line);
  color: var(--ink); background: #fff; transition: background .15s;
}
.landing .l-btn:hover { background: var(--line-soft); }
.landing .l-btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.landing .l-btn.primary:hover { background: #15405e; }

/* ============================================================
   DOCTOR DASHBOARD
   ============================================================ */
.dash-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.dash-stat { font-size: 12px; color: var(--muted); margin-bottom: 1rem; }
.dash-table { width: 100%; border-collapse: collapse; background: var(--card); }
.dash-table th, .dash-table td {
  border: 1px solid var(--line); padding: 9px 11px;
  font-size: 13px; text-align: left;
}
.dash-table th {
  background: #f4f3ef; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
}
.dash-table tbody tr:hover td { background: #f3f6f9; }
.dash-qs { font-size: 12px; color: var(--ink-soft); }

/* PDF detail view */
.pdf-head {
  display: flex; justify-content: space-between;
  border-bottom: 2px solid var(--accent); padding-bottom: 10px;
  margin-bottom: 1.25rem; font-size: 12px;
}
.pdf-cabinet b { color: var(--accent); font-size: 13px; }
.pdf-patient { text-align: right; }
.pdf-q { margin-bottom: 2rem; }
.pdf-score {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--accent); background: #eef3f7;
  padding: 4px 12px; border-radius: 4px; margin-bottom: 0.75rem;
}

@media print {
  .pdf-q { page-break-before: always; }
  .pdf-q:first-of-type { page-break-before: avoid; }
  .pdf-head { page-break-after: avoid; }
}

/* ============================================================
   BRANDING  —  logo + landing background
   ============================================================ */
.qhead-logo {
  height: 44px; width: auto; object-fit: contain;
}
.qhead { gap: 16px; }

/* landing page background image */
.landing-bg {
  background-image:
    linear-gradient(rgba(244,243,239,.55), rgba(244,243,239,.85)),
    url('assets/bg.jpg');
  background-size: cover;
  background-position: center;
}
.l-logo {
  width: 260px; max-width: 80%; height: auto;
  display: block; margin: 0 auto 0.5rem;
}
.l-card {
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(2px);
  box-shadow: 0 10px 40px rgba(26,74,107,.13);
}

@media print {
  .qhead-logo { height: 40px; }
}

/* ---- dashboard row actions (open / archive / restore) ---- */
.btn-sm {
  font-size: 12px; padding: 5px 12px; border-radius: 6px;
}
.dash-actions {
  display: flex; gap: 6px; white-space: nowrap;
}
