/* ==========================================================================
   Notice-information-doc/css/notice-doc.css  —  DOCUMENT FORMAT
   Formal institutional layout — print-ready — Inter/Georgia mix
   ========================================================================== */

/* ─── Reset + Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #1a1a1a;
  background: #f0f2f5;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.serif { font-family: Georgia, 'Times New Roman', serif; }

/* ─── Format Switcher ────────────────────────────────────────────────────── */
.doc-switcher-bar {
  background: #f5f5f5;
  border-bottom: 1px solid #d0d0d0;
  padding: 8px 32px;
}
.doc-switcher-inner { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  justify-content: flex-end; 
  max-width: 800px; 
  margin: 0 auto; 
}
.fmt-switch-label { font-size: 12px; color: #64748B; text-transform: none; letter-spacing: .01em; font-weight: 600; margin-right: 4px; }
#format-switcher { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fmt-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: #334155;
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
  line-height: 1;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.fmt-switch-btn:hover { background: #E2E8F0; color: #334155; border-color: #CBD5E1; text-decoration: none; }
.fmt-switch-btn.active { background: #1E3A8A; color: #FFFFFF; border-color: #1E3A8A; pointer-events: none; box-shadow: 0 8px 18px rgba(30, 58, 138, 0.2); }

/* ─── Toolbar ────────────────────────────────────────────────────────────── */
.doc-toolbar {
  background: #f5f5f5;
  border-bottom: 1px solid #d0d0d0;
  padding: 10px 32px;
}
.doc-toolbar-inner { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  justify-content: flex-end; 
  max-width: 800px; 
  margin: 0 auto; 
}
.doc-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 18px;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}
.doc-export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}
.doc-export-btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}
.doc-export-btn__icon {
  font-size: 1.18rem;
  line-height: 1;
}
.doc-export-btn__label {
  white-space: nowrap;
}
.doc-export-btn--pdf {
  background: #C2410C;
}
.doc-export-btn--pdf:hover {
  background: #9A3412;
}
.doc-export-btn--word {
  background: #2563EB;
}
.doc-export-btn--word:hover {
  background: #1D4ED8;
}

.mdi {
  display: inline-block;
  font: normal normal normal 14px/1 'Material-Design-Iconic-Font';
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.mdi-file-pdf-box:before {
  content: '\f14d';
}
.mdi-file-word-box:before {
  content: '\f222';
}

/* ─── Page Container ─────────────────────────────────────────────────────── */
.doc-page {
  background: #ffffff;
  max-width: 800px;
  margin: 24px auto 48px;
  padding: 52px 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,.14);
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.doc-header {
  margin-bottom: 20px;
}

.doc-header-table {
  width: 100%;
  border-collapse: collapse;
  border: none !important;
}

.doc-logo-cell {
  width: 160px;
  padding-inline-end: 16px;
  vertical-align: top;
}

.doc-logo {
  max-height: 75px;
  max-width: 160px;
  object-fit: contain;
}

.doc-header-content-cell {
  vertical-align: top;
}
.doc-main-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: #1a252f;
  margin-bottom: 6px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doc-subtitle {
  font-size: 0.8rem !important;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 10px;
  line-height: 1.4;
  white-space: normal !important;
}
.doc-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 18px;
  font-size: 0.88rem;
  color: #444;
  background: #f6f8fb;
  border-inline-start: 4px solid #2c3e50;
  border-radius: 3px;
  margin-top: 4px;
}

html[dir="rtl"] .doc-meta {
  border-radius: 4px 0 0 4px;
}
.meta-treatment, .meta-update {
  margin: 0;
}
.meta-treatment strong, .meta-update strong {
  color: #1a252f;
  font-weight: 700;
}
/* RTL adjustments for document header */
html[dir="rtl"] .meta-treatment strong,
html[dir="rtl"] .meta-update strong {
  margin-right: 0;
  margin-left: 4px;
}
.doc-divider {
  border: none;
  border-top: 2px solid #1a252f;
  margin: 12px 0 28px;
}

/* ─── Rupture visuelle avant sections de formulaire ──────────────────────── */
.doc-section-divider {
  border: none;
  border-top: 1px dashed #2c3e50;
  margin: 40px 0 30px;
  display: block;
}

/* ─── Printable Signature Block ─────────────────────────────────────────── */
.print-signature-block {
  border: 1.5px solid #2c3e50;
  border-radius: 4px;
  padding: 20px 24px;
  margin-top: 25px;
  background: #fdfdfd;
  page-break-inside: avoid;
}

.print-sig-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
  color: #1c1c1c;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.print-sig-row {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1a252f;
  margin-bottom: 20px;
}

.sig-table {
  width: 100%;
  border-collapse: collapse;
}

.sig-table td {
  border: none !important;
  vertical-align: top;
}

.sig-table label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sig-table div {
  border-bottom: 1px solid #ccc;
  height: 45px;
  width: 100%;
  position: relative;
}

.sig-table span {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  color: #94a3b8;
  font-family: Georgia, serif;
  font-style: italic;
  opacity: 0.8;
}

html[dir="rtl"] .sig-table span {
  right: auto;
  left: 2px;
}

/* ─── Catégories de données (cartes sobres) ─────────────────────────────── */
#dynamic-content .data-category-card {
  border: 1.5px solid #dce1e7;
  border-radius: 4px;
  padding: 0;
  margin: 12px 0 16px;
  background: #fff;
  page-break-inside: avoid;
  overflow: hidden;
}
#dynamic-content .data-category-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #f8f9fb;
  border-bottom: 1px solid #dce1e7;
}
#dynamic-content .data-category-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1a252f;
}
#dynamic-content .data-category-meta {
  font-size: 0.8rem;
  color: #475a75;
  font-weight: 600;
  background: #eef2f6;
  padding: 2px 10px;
  border-radius: 12px;
}
#dynamic-content .data-category-body {
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.5;
}
#dynamic-content .data-category-body p {
  margin: 0;
}

/* ─── Finalités (section 4) ─────────────────────────────────────────────── */
.finalites-list {
  margin-top: 4px;
}
.finalite-block {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0;
  margin: 18px 0 24px;
  background: #fff;
  page-break-inside: avoid;
  border-inline-start: 5px solid #1a252f;
  overflow: hidden;
}
.finalite-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}
.finalite-base-label {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: 700;
  font-style: italic;
  color: #1a252f;
}
.finalite-base-chip {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 2px;
  color: #475a75;
  background: transparent;
  border: 1px solid #475a75;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.finalite-items {
  margin: 0;
  padding: 16px 20px 16px 40px;
}
html[dir="rtl"] .finalite-items {
  padding: 16px 40px 16px 20px;
}
.finalite-items li {
  margin-bottom: 8px;
  line-height: 1.6;
  color: #334155;
  font-size: 0.92rem;
}

/* Raffinement selon la base légale */
.finalite-block--legal-obligation { border-inline-start-color: #1e293b; }
.finalite-block--contract { border-inline-start-color: #15803d; }
.finalite-block--legitimate-interest { border-inline-start-color: #b45309; }
.finalite-block--consent { border-inline-start-color: #7e22ce; }

/* ─── Consent Checkboxes (document / print style) ───────────────────────── */
/* Override inline radio with doc-styled checkbox appearance only for document */
.doc-consent-checkbox-wrap { display: flex; gap: 16px; align-items: center; }
.doc-consent-check { display: flex; align-items: center; gap: 5px; font-size: 0.88rem; cursor: pointer; }
.doc-consent-check input[type="radio"] { width: 15px; height: 15px; }

/* ─── Submit + Inputs ────────────────────────────────────────────────────── */
.doc-submit-wrap { margin-top: 20px; }
.doc-submit-btn {
  padding: 10px 36px;
  background: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.doc-submit-btn:hover { background: #1a252f; }
.doc-submit-btn:disabled { opacity: .6; cursor: not-allowed; }

.input--field {
  display: inline-block;
  width: 11em;
  padding: 5px 10px;
  font-size: 0.88rem;
  font-family: inherit;
  color: #333;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.input--field:focus { border-color: #2c3e50; outline: none; }

/* ─── RTL ────────────────────────────────────────────────────────────────── */
.rtl, [dir="rtl"] { direction: rtl; text-align: right; }
html[dir="rtl"] .doc-header { flex-direction: row-reverse; }
html[dir="rtl"] .doc-switcher-inner,
html[dir="rtl"] .doc-toolbar-inner { 
  justify-content: flex-end; 
}
html[dir="rtl"] .fmt-switch-label { display: none; }
html[dir="rtl"] #signature-section { direction: rtl; text-align: right; }
html[dir="rtl"] .signature-option { flex-direction: row-reverse; }
html[dir="rtl"] .signature-option input[type="radio"] { margin-right: 0; margin-left: 10px; }
html[dir="rtl"] .print-sig-fields { direction: rtl; }
html[dir="rtl"] table.rtl-table { direction: rtl; }
html[dir="rtl"] table.rtl-table th,
html[dir="rtl"] #dynamic-content table.rtl-table th,
html[dir="rtl"] table.rtl-table td,
html[dir="rtl"] #dynamic-content table.rtl-table td { text-align: right; }

/* ─── PRINT STYLESHEET ───────────────────────────────────────────────────── */
@media print {
  @page {
    size: A4;
    margin: 15mm 18mm 18mm 18mm;
  }

  /* Masquer éléments écran */
  .no-print,
  .doc-switcher-bar,
  .doc-toolbar {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
    padding: 0;
  }

  .doc-page {
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
  }

  .doc-header { margin-bottom: 10pt; }
  .doc-main-title { font-size: 15pt; }
  .doc-divider { margin: 8pt 0 14pt; }

  /* Empêcher les coupures grossières */
  h1, h2, h3 { page-break-after: avoid; }

  .print-signature-block,
  #signature-section { page-break-inside: avoid; }

  /* Montrer le bloc signature imprimable */
  #print-signature-block { display: block !important; }

  /* Bouton submit masqué à l'impression */
  .doc-submit-wrap { display: none !important; }

  /* Tableaux : en-têtes répétés & couleurs correctes */
  #dynamic-content table {
    page-break-inside: auto;
    border: 1pt solid #000;
  }
  #dynamic-content table thead {
    display: table-header-group;
  }
  #dynamic-content table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  #dynamic-content table th {
    background: #e0e0e0 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-bottom: 1pt solid #000;
  }
  #dynamic-content table td {
    border-bottom: 0.5pt solid #ccc;
  }

  /* Version PDF premium : bordures nettes */
  .finalite-block, .data-category-card, .consent-section, .print-signature-block {
    border: 1pt solid #000 !important;
    background: #fff !important;
  }
  .finalite-block-header, .data-category-card-header {
    background: #f0f0f0 !important;
    border-bottom: 1pt solid #000 !important;
  }
}

/* ─── Consentement (section 11) ─────────────────────────────────────────── */
.consent-section {
  border: 2px solid #1a252f;
  border-radius: 4px;
  background: #fdfdfd;
  margin-block: 16px 10px;
  padding-block: 6px;
  padding-inline: 16px;
  page-break-inside: avoid;
}

/* Nouvelle structure de liste de consentement */
.consent-notice-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.consent-notice-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-block-end: 2px solid #f1f5f9;
  gap: 10px;
  padding-block-end: 3px;
}

.consent-notice-item:last-child {
  border-block-end: none;
  padding-block-end: 0;
}

.consent-notice-text {
  flex: 1;
  color: #1a252f;
  font-size: 0.92rem;
  line-height: 1.2;
}

.consent-notice-choices {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
}

.consent-choice-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.consent-check-box {
  display: inline-block;
  width: 13pt;
  height: 13pt;
  border: 1.5pt solid #1a252f;
  border-radius: 2px;
  background: #fff;
  vertical-align: middle;
}

.consent-choice-label {
  color: #1a252f;
  font-size: 0.88rem;
  font-weight: 700;
}

/* RTL Support */
html[dir="rtl"] .consent-notice-item {
  flex-direction: row-reverse;
}
html[dir="rtl"] .consent-choice-wrap {
  flex-direction: row-reverse;
}

/* Section 6 - Recipients */
.recipients-document {
  margin-block: -22pt -20pt !important;
}

.recipients-list {
  margin: 0 !important;
  padding-inline-start: 18pt;
  list-style-type: disc;
}

.recipients-list li {
  margin: 0 !important;
  line-height: 1.2;
}
 
/* ─── Compact Mode Overrides (A4 optimization) ────────────────────────── */
body.is-compact {
  font-size: 9.3pt;
  line-height: 1.25;
}
body.is-compact .doc-page {
  padding: 15pt 20pt;
  margin-top: 5px;
}
body.is-compact .doc-header { margin-bottom: 2pt; }
body.is-compact .doc-main-title { font-size: 11pt; margin-bottom: 0; }
body.is-compact .doc-subtitle { font-size: 7.5pt !important; margin-bottom: 0; }
body.is-compact .doc-meta { padding: 4pt 10pt; font-size: 8pt; gap: 2pt; margin-top: 1pt; }
body.is-compact .doc-divider { margin: 4pt 0 8pt; border-top-width: 1.5pt; }
body.is-compact .doc-section-divider { margin: 8pt 0 6pt; }
body.is-compact h2 { font-size: 9.5pt; margin-top: 10pt; margin-bottom: 4pt; border-bottom: none; padding: 0; background: #f6f8fb; padding-left: 6pt; }
body.is-compact p { margin-bottom: 4pt; }
 
body.is-compact #dynamic-content .data-category-card { margin: 2pt 0; border-width: 0.5pt; }
body.is-compact #dynamic-content .data-category-card-header { padding: 2pt 8pt; flex-wrap: nowrap; }
body.is-compact #dynamic-content .data-category-name { font-size: 8.5pt; font-weight: bold; }
body.is-compact #dynamic-content .data-category-meta { font-size: 7.5pt; }
body.is-compact #dynamic-content .data-category-body { padding: 2pt 8pt; font-size: 8pt; }
body.is-compact #dynamic-content .data-category-body p { margin: 0; }
 
body.is-compact .finalites-list.is-compact { margin: 2pt 0; }
body.is-compact .finalite-block { display: none; } /* Hide the old blocks in compact mode if any remain */
body.is-compact .finalites-items.is-compact li { font-size: 8.5pt; margin-bottom: 1pt; line-height: 1.2; }
 
body.is-compact .consent-section { padding: 4pt 8pt; margin: 4pt 0; border-width: 1pt; }
body.is-compact .consent-notice-choices { width: 90pt !important; }
body.is-compact .consent-notice-text { font-size: 8.5pt; }
body.is-compact .consent-check-box { width: 9pt; height: 9pt; margin-top: 1pt; }
 
body.is-compact .print-signature-block { padding: 6pt 10pt; margin-top: 10pt; border-width: 1pt; }
body.is-compact .print-sig-title { font-size: 8pt; margin-bottom: 4pt; padding-bottom: 2pt; margin-top: 0; }
body.is-compact .print-sig-row { font-size: 8pt; margin-bottom: 4pt; }
body.is-compact .sig-table label { font-size: 7.5pt; margin-bottom: 2pt; }
body.is-compact .sig-line { height: 12pt; margin-top: 0; }
 
/* QR Code cell behavior */
.doc-qr-cell { vertical-align: top; }
body.is-compact .doc-qr-cell { display: table-cell !important; }
 
@media print {
  body.is-compact { font-size: 9pt; }
  body.is-compact .doc-page { margin: 0; padding: 0; box-shadow: none; }
  /* Ensure QR code is printed if in compact mode */
  body.is-compact .doc-qr-cell { display: table-cell !important; }
}

html[dir="rtl"] .recipients-list {
  padding-inline-start: 18pt;
}
