/* ============================================================================
   Livret officiel EPCF (document ministère TP-01303) : vue + impression.

   Principe WYSIWYG : le document affiché à l'écran EST le document imprimé.
   Les champs remplissables (.lv-f contenteditable, .lv-cb cases à cocher) sont
   invisibles en tant que tels à l'impression : seul leur contenu s'imprime,
   exactement comme le formulaire Word officiel (placeholders gris compris).

   Toutes les dimensions du document sont en mm/pt (fidèles au .docx officiel :
   A4 portrait, marges G 15mm / D 19mm, Arial, accent magenta #D60093).
   ========================================================================= */

/* --- Habillage écran (hors document) ---
   Le gris des statuts et des aides (#636a77) tient 4,9:1 sur le fond de la page dans les deux habillages ; l'ancien (#6b7280) n'en
   tenait que 4,4 (lot 3, tâche 10). */
.lv-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.lv-toolbar h3 { margin: 0; font-size: 1.05rem; }
.lv-status { font-size: 0.8rem; color: var(--c-muted, #636a77); min-width: 90px; }
.lv-status.saving { color: #b45309; }
.lv-status.error { color: #b91c1c; }
.lv-hint { font-size: 0.8rem; color: var(--c-muted, #636a77); margin: 0 0 10px; }

/* Champ « Date de naissance » du profil (Mon suivi) : alimente le livret. */
.ms-naissance {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  font-size: 0.9rem;
}
.ms-naissance label { font-weight: 600; }
.ms-naissance input[type="date"] {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--c-border, #d8d8d2);
  border-radius: 8px;
  background: #fff;
}
.ms-naissance-hint { font-size: 0.8rem; }

/* Liste formateur */
.lv-liste-table { width: 100%; border-collapse: collapse; }
.lv-liste-table th, .lv-liste-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--c-border, #e5e7eb);
}
.lv-name-cell { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lv-statut { font-size: 0.8rem; color: var(--c-muted, #636a77); }
.lv-statut.ok { color: #4d7c0f; }

/* Zone document : mise à l'échelle pour tenir dans la colonne (mobile inclus).
   Le verrou de hauteur (style inline posé en JS) évite le vide sous le scale. */
.lv-scale-outer { overflow: hidden; }
.lv-scale { transform-origin: top left; }

/* --- Le document lui-même --- */
.lv-doc {
  font-family: Arial, Helvetica, sans-serif;
  color: #404040;
  width: 210mm;
  /* Impose l'impression des aplats (bandeaux magenta, cartouches gris, croix
     des cases dessinées en background-image) sur TOUS les supports, même quand
     l'option « Graphiques d'arrière-plan » du navigateur est décochée (défaut
     Chrome/Edge/Firefox/iOS). Sans ça : bandeaux blancs et cases cochées
     invisibles. Propriété héritée → couvre tous les descendants du document. */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.lv-page {
  position: relative;
  width: 210mm;
  height: 296.5mm;
  overflow: hidden;
  box-sizing: border-box;
  background: #fff;
  padding: 15mm 19mm 24mm 15mm;
}
/* À l'écran seulement : ombre + espacement entre pages */
.lv-screen .lv-page { box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18); margin: 0 0 8mm; }
.lv-page.lv-p1 { padding-top: 10mm; }

.lv-doc p { margin: 0; }
.lv-doc table { border-collapse: collapse; table-layout: fixed; }
.lv-doc td { vertical-align: top; padding: 0.4mm 1mm; word-wrap: break-word; }

/* Tailles de police du document (demi-points Word -> pt) */
.lv-doc { font-size: 11pt; }
.lv-s6  { font-size: 6pt; }
.lv-s8  { font-size: 8pt; }
.lv-s10 { font-size: 10pt; }
.lv-s11 { font-size: 11pt; }
.lv-s12 { font-size: 12pt; }
.lv-s14 { font-size: 14pt; }
.lv-s16 { font-size: 16pt; }
.lv-s22 { font-size: 22pt; }
.lv-b { font-weight: 700; }
.lv-i { font-style: italic; }
.lv-center { text-align: center; }
.lv-right { text-align: right; }
.lv-just { text-align: justify; }
.lv-magenta { color: #D60093; }

/* Bandeaux magenta du document officiel */
.lv-banner {
  background: #D60093;
  color: #fff;
  font-weight: 700;
  font-size: 20pt;
  padding: 1mm 3mm;
}
.lv-banner.lv-center { text-align: center; }

/* --- En-tête page 1 (bandeau officiel) --- */
.lv-head { display: flex; gap: 6mm; align-items: flex-start; margin-bottom: 10mm; }
.lv-head-logo { width: 30mm; flex: 0 0 30mm; }
.lv-head-logo img { width: 30mm; height: auto; display: block; }
.lv-head-right { flex: 1; min-width: 0; }
.lv-head-title {
  background: #F7F7F7;
  color: #595959;
  font-weight: 700;
  font-size: 26pt;
  line-height: 1.12;
  padding: 3mm 4mm;
}
.lv-head-band {
  margin-top: 2.5mm;
  height: 9mm;
  background: #F2F2F2;
  position: relative;
}
/* Triangle blanc ◢ du gabarit officiel (dessiné en CSS : rendu identique partout) */
.lv-tri {
  position: absolute;
  right: 1.5mm;
  bottom: 1mm;
  width: 0;
  height: 0;
  border-left: 7mm solid transparent;
  border-bottom: 7mm solid #fff;
}
.lv-tri.lv-tri-small { border-left-width: 4.5mm; border-bottom-width: 4.5mm; }
.lv-band { height: 4mm; background: #F2F2F2; position: relative; }

/* --- Pied de page officiel (cartouche SIGLE) --- */
.lv-foot {
  position: absolute;
  left: 15mm;
  right: 15mm;
  bottom: 9mm;
}
.lv-foot table { width: 100%; }
.lv-foot td {
  border: 0.15mm solid #595959;
  color: #595959;
  font-size: 9pt;
  text-align: center;
  padding: 0.5mm 1mm;
  vertical-align: middle;
}

/* --- Tableaux d'évaluations (bordures grises du doc officiel) --- */
.lv-tbl-borders td { border: 0.15mm solid #808080; }

/* --- Champs remplissables --- */
.lv-f {
  display: block;
  min-height: 4.2mm;
  white-space: pre-wrap;
  outline: none;
  /* Une date/un nom plus large que sa colonne (ex. Dates 16,7mm du tableau
     officiel) passe à la ligne dans sa cellule au lieu de déborder dessus. */
  overflow-wrap: anywhere;
}
span.lv-f { display: inline-block; min-width: 12mm; max-width: 100%; vertical-align: bottom; }
/* Dans une cellule centrée (colonne « Dates »…), le contenu du champ est centré
   aussi (le span a une largeur minimale supérieure au texte). */
td.lv-center .lv-f { text-align: center; }
.lv-f:empty::before { content: attr(data-ph); color: #737373; }
/* Affordance d'édition, à l'écran uniquement */
.lv-edit .lv-f[contenteditable] { border-bottom: 0.3mm dashed #d8b4e2; cursor: text; }
.lv-edit .lv-f[contenteditable]:focus { background: #fdf2f9; border-bottom-color: #D60093; }

/* Cases à cocher : boîte dessinée en CSS (glyphe identique écran/impression),
   croix en X quand cochée, comme le ☒ Word. */
.lv-cb {
  display: inline-block;
  width: 3.6mm;
  height: 3.6mm;
  border: 0.35mm solid #404040;
  vertical-align: -0.6mm;
  box-sizing: border-box;
}
.lv-cb.on {
  background-image:
    linear-gradient(45deg, transparent 44%, #404040 44%, #404040 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, #404040 44%, #404040 56%, transparent 56%);
}
.lv-edit .lv-cb[data-k] { cursor: pointer; }
.lv-edit .lv-cb[data-k]:hover { border-color: #D60093; }

/* Mini-sélecteur de date (édition uniquement, jamais cloné à l'impression) */
.lv-datepick {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #c9c9c4;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 10pt;
  white-space: nowrap;
}
.lv-datepick input[type="date"] { font: inherit; padding: 2px 4px; }
.lv-datepick button {
  font: inherit;
  padding: 3px 8px;
  border: 1px solid #c9c9c4;
  border-radius: 6px;
  background: #f6f6f2;
  cursor: pointer;
}
.lv-datepick button.lv-dp-today { background: #6B7F4E; border-color: #6B7F4E; color: #fff; }

/* Auto-complétion des noms de formateurs / évaluateurs (édition uniquement). */
.lv-namepick {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  min-width: 45mm;
  max-height: 46mm;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #c9c9c4;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  padding: 4px;
}
.lv-namepick-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 10pt;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  white-space: nowrap;
}
.lv-namepick-item:hover { background: #f0f0ea; }

/* Affordance : les champs Nom de visa avec auto-complétion sont cliquables. */
.lv-edit .lv-name[contenteditable] { cursor: pointer; }

/* --- Impression --- */
#livret-print { display: none; }

@media print {
  /* Quand le livret est ouvert, on n'imprime QUE lui. */
  body.livret-printable > *:not(#livret-print) { display: none !important; }
  body.livret-printable #livret-print { display: block !important; }
  /* Sécurité moteur : force les aplats sur chaque élément imprimé. */
  #livret-print, #livret-print * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  #livret-print .lv-page { page-break-after: always; box-shadow: none; margin: 0; }
  #livret-print .lv-page:last-child { page-break-after: auto; }
  /* Les affordances d'édition ne s'impriment jamais */
  #livret-print .lv-f { border-bottom: none !important; background: none !important; }
}

/* NB : la règle « @page { size: A4 portrait; margin: 0 } » du livret est
   injectée dynamiquement (style #livret-page-style, cf. epcf-livret.js) le
   temps qu'un livret est ouvert. En dur ici, elle écraserait le « @page
   A4 landscape » de l'impression du planning (style.css), chargé avant. */
