/* ==========================================================================
   CRM BlueIa · impression et export PDF
   Deux usages :
   1. Impression directe d'une vue : navigation, boutons et filtres masqués.
   2. printDocument({title, subtitle, content}) de core/download.js : construit
      .print-root (en-tête BlueIa + contenu), masque toute l'application,
      appelle window.print(), puis nettoie.
   Classes : .no-print (masqué à l'impression), .print-only (visible seulement
   à l'impression), .print-landscape (page en paysage), .print-break (saut de
   page avant), .print-keep (bloc insécable).
   ========================================================================== */

.print-root { display: none; }

@page { size: A4 portrait; margin: 14mm 12mm 16mm; }
@page landscape { size: A4 landscape; margin: 12mm 12mm 14mm; }

@media print {
  html, body { height: auto; background: #fff !important; color: #000; font-size: 10.5pt; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .no-print, .sidebar, .page-actions, .toast-stack, .overlay, .popover, .filters, .table-toolbar,
  .pagination, .table-foot, .tabs__list, .btn, .btn-result, .chip, .search, .sidebar__toggle,
  .skeleton, .spinner { display: none !important; }
  .print-only { display: block !important; }
  span.print-only { display: inline !important; }
  tr.print-only { display: table-row !important; }

  .shell { display: block; min-height: 0; }
  .main { display: block; }
  .page-head { padding: 0 0 6mm; }
  .page-body { padding: 0; }
  .view--narrow, .view--medium, .narrow, .medium { max-width: none; }

  .card, .table-card, .kpi, .fieldset, .filters { box-shadow: none !important; border-color: #C9CBC5; }
  .card, .kpi, .print-keep, .timeline__item, .pipeline__card { break-inside: avoid; page-break-inside: avoid; }
  .print-break { break-before: page; page-break-before: always; }
  .print-landscape { page: landscape; }

  .table-wrap { overflow: visible !important; max-height: none !important; min-height: 0; }
  .table { font-size: 8.5pt; border-collapse: collapse; }
  .table thead { display: table-header-group; }
  .table tfoot { display: table-footer-group; }
  .table tr { break-inside: avoid; page-break-inside: avoid; }
  .table th { position: static; background: #EEF0F4 !important; color: #10141B; border-bottom: 1px solid #10141B; height: auto; padding: 4px 6px; }
  .table td { height: auto; padding: 4px 6px; max-width: none; white-space: normal; overflow: visible; overflow-wrap: anywhere; border-bottom: 1px solid #DADCD6; }
  .table tbody tr.is-late td { background: #FDECEC !important; }
  .th-sort { margin: 0; padding: 0; min-height: 0; }
  .th-sort__arrow { display: none; }

  .dash-grid { gap: 4mm; }
  .pipeline { overflow: visible; flex-wrap: wrap; }
  .pipeline__col { max-height: none; flex: 1 1 30%; }
  .pipeline__body { overflow: visible; }
  .tabs__panel { padding-top: 0; }
  a { color: inherit; text-decoration: none; }

  /* Mode document : seul .print-root est imprimé */
  body.is-printing-doc > *:not(.print-root) { display: none !important; }
  body.is-printing-doc > .print-root { display: block !important; }
}

/* En-tête et pied du document imprimé */
.print-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8mm; padding-bottom: 3mm; margin-bottom: 5mm; border-bottom: 2px solid #0A1422; }
.print-head__brand { font-family: var(--font-title); font-weight: 700; font-size: 18pt; letter-spacing: -.02em; color: #0A1422; line-height: 1; }
.print-head__brand small { margin-left: 2mm; font-family: var(--font); font-size: 7.5pt; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #5B6472; }
.print-head__title { font-family: var(--font-title); font-weight: 600; font-size: 13pt; color: #10141B; margin: 3mm 0 0; }
.print-head__sub { font-size: 9pt; color: #5B6472; margin: 1mm 0 0; }
.print-head__meta { text-align: right; font-size: 8.5pt; color: #5B6472; line-height: 1.4; white-space: nowrap; }
.print-head__meta strong { color: #10141B; font-weight: 600; }
.print-foot { margin-top: 6mm; padding-top: 2mm; border-top: 1px solid #C9CBC5; font-size: 8pt; color: #5B6472; display: flex; justify-content: space-between; gap: 6mm; }
.print-section { margin: 6mm 0 3mm; font-family: var(--font-title); font-weight: 600; font-size: 11pt; break-after: avoid; page-break-after: avoid; }
.print-summary { display: flex; flex-wrap: wrap; gap: 2mm 8mm; margin: 0 0 4mm; font-size: 9pt; color: #2A303B; }
.print-summary strong { font-family: var(--font-mono); }
