/* Styles pour la lettre (A4, une seule page) */
:root {
  --brand: #0b5fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  color: var(--text);
  background: #f6f7fb;
}

.page { max-width: 980px; margin: 24px auto 64px; padding: 0 16px; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  margin: 16px 0 20px;
}

.btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn:hover { filter: brightness(0.98); }

/* Feuille A4 */
.sheet.a4 {
  width: 210mm;
  min-height: 297mm;
  background: white;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
  overflow: hidden; /* évite les débordements visuels */
}

.letter {
  padding: 22mm 20mm; /* marges internes pour tenir en une page */
}

.letter-header {
  display: flex;
  flex-direction: column; /* Logos au-dessus, titre/sous-titre en dessous */
  align-items: center; /* centrer horizontalement */
  gap: 10px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.logos { display: flex; gap: 18px; align-items: center; }
.logo-item { width: 110px; height: 68px; display: flex; align-items: center; justify-content: center; }
.logo-item img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Remonter légèrement les logos 1 (République) et 3 (Banque de France) */
.logos .logo-item:first-child,
.logos .logo-item:last-child {
  transform: translateY(-18px);
}

/* Agrandir uniquement les deux logos latéraux */
.logos .logo-item:first-child,
.logos .logo-item:last-child {
  width: 160px;
  height: 96px;
}

.identite { text-align: center; width: 100%; }
.identite h1 { font-size: 20px; line-height: 1.2; margin: 0 0 4px; }
.identite .meta { margin: 0; color: var(--muted); font-size: 13px; }

.letter-meta {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 10px;
}
.letter-meta p { margin: 2px 0; font-size: 13.5px; }
.date-lieu { text-align: right; color: var(--muted); }

.letter-body p { margin: 10px 0; font-size: 14.5px; line-height: 1.55; }
.letter-body strong { font-weight: 700; }

.letter-footer {
  border-top: 1px dashed var(--border);
  margin-top: 12px; padding-top: 10px; color: var(--muted); font-size: 12.5px;
}
.letter-footer .ref { margin-top: 4px; font-style: italic; }

/* Signature (plaque notaire) */
.signature {
  margin: 12px auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signature img {
  max-width: 220px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0.95;
}

.help { max-width: 210mm; margin: 18px auto 0; color: var(--muted); font-size: 13px; }
.help h2 { margin: 18px 0 6px; font-size: 16px; color: var(--text); }

/* Impression */
@page { size: A4; margin: 0; }
@media print {
  body { background: white; }
  .toolbar, .help { display: none !important; }
  .sheet.a4 { border: none; box-shadow: none; border-radius: 0; margin: 0; width: 210mm; height: 297mm; overflow: hidden; }
  /* Réduire légèrement les marges internes pour rester sur 1 page */
  .letter { padding: 12mm 12mm; }
  /* Réduire l’en-tête pour gagner de la place */
  .letter-header { gap: 8px; padding-bottom: 10px; margin-bottom: 12px; }
  .logos { gap: 10px; }
  .logo-item { width: 86px; height: 52px; }
  /* Les logos latéraux restent un peu plus grands mais plus compacts qu’à l’écran */
  .logos .logo-item:first-child,
  .logos .logo-item:last-child { width: 100px; height: 62px; transform: translateY(-10px); }
  /* Corps du texte un peu plus serré */
  .letter-body p { margin: 5px 0; line-height: 1.42; font-size: 13.6px; }
  /* Signature plus compacte */
  .signature { margin: 8px auto 6px; }
  .signature img { max-width: 170px; max-height: 90px; }
  /* Pied de page plus compact */
  .letter-footer { margin-top: 10px; padding-top: 8px; font-size: 12px; }
}

/* Accessibilité utilitaire */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Mode export PDF: réduire légèrement les marges/espaces pour rester sur 1 page */
body.exporting .letter { padding: 18mm 16mm; }
body.exporting .letter-body p { margin: 8px 0; }
body.exporting .signature { margin: 8px auto 6px; }
