/* Impresión de la pantalla (reglas @media print generales). */

.print-title { display: none; }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .page { width: 100%; padding: 0; }
  .sidebar, .hero, .view-tabs, .kpi-grid, .insight, #territorialView, details, .footer-note, .confirm-overlay, .chart-modal-overlay, .sr-only { display: none !important; }
  #interanualView[hidden] { display: none !important; }
  /* Solo la PRIMERA seccion de interanual arranca sin salto de pagina: viene
     pegada al titulo de impresion. Antes la regla no estaba acotada y, al mudarse
     "Estacionalidad" a esta vista, esa segunda seccion tambien perdia su hoja
     propia y quedaba apilada contra el final de "Comparacion entre años". */
  #interanualView .insight + .analysis-section { break-before: auto; page-break-before: auto; }
  .print-title {
    display: block;
    margin: 0 0 6mm;
    padding: 5mm 6mm;
    border: 1px solid #d9e4f2;
    border-radius: 5mm;
    background: #fff;
    color: #111827;
  }
  .print-title h1 {
    margin: 1mm 0 1mm;
    font-size: 20pt;
    letter-spacing: 0;
  }
  .print-title p {
    margin: 0;
    font-size: 10pt;
    color: #667085;
  }
  .print-eyebrow {
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0;
    font-weight: 900;
    color: #14306e;
  }
  .chart-grid, .analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6mm;
    margin-top: 0;
  }
  .panel {
    box-shadow: none;
    border: 1px solid #d9e4f2;
    border-radius: 4mm;
    padding: 4mm;
    break-inside: avoid;
    page-break-inside: avoid;
    background: #fff;
  }
  .panel h2 { font-size: 13pt; }
  .note { font-size: 8.5pt; }
  .panel-title-row .info, .chart-expand-btn, .chart-print-btn { display: none; }
  canvas { height: 68mm !important; margin-top: 3mm; }
  .chart-canvas-box { height: 68mm !important; margin-top: 3mm; }
  .analysis-section {
    break-before: page;
    page-break-before: always;
    margin-top: 0;
  }
  .section-head {
    margin: 0 0 4mm;
    padding: 0;
  }
  .section-head h2 { font-size: 16pt; }
  .section-head p { font-size: 9pt; max-width: none; }
  .analysis-grid canvas { height: 56mm !important; }
  .analysis-grid .chart-canvas-box { height: 56mm !important; }
  @page { size: A4 landscape; margin: 8mm; }

  /* Imprimir un solo gráfico: printChart() (js/charts/chart-modal.js) marca con
     .print-hide-sibling a todo lo que no sea ancestro/el propio panel
     elegido, usando display:none para que no queden hojas en blanco
     (visibility:hidden no libera el espacio y paginaba de más). */
  html[data-print-only] .print-title { display: none !important; }
  html[data-print-only] .print-hide-sibling { display: none !important; }
  html[data-print-only] .analysis-section {
    break-before: auto;
    page-break-before: auto;
  }
  html[data-print-only] .chart-grid,
  html[data-print-only] .analysis-grid {
    grid-template-columns: 1fr !important;
  }
  html[data-print-only] .print-target {
    padding: 6mm !important;
  }
  html[data-print-only] .print-target canvas,
  html[data-print-only] .print-target .chart-canvas-box {
    height: 150mm !important;
  }
}
