/* ===== Screen only: hide PDF header in normal view ===== */
@media screen {
  .pdf-header {
    display: none;
  }
}

/* ===== Print / PDF styles ===== */
@media print {
  /* Hide elements that should not appear in the PDF report */
  .no-print,
  .navbar,
  .footer,
  .banner,
  button,
  a.export-btn {
    display: none !important;
  }

  /* Preserve colors in the PDF */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* PDF-specific header */
  .pdf-header {
    display: block !important;
    background-color: #416097 !important;
    text-align: center !important;
    padding-top: 20px !important;
    padding-bottom: 15px !important;
    margin: 0 !important;
    color: #ffffff !important;
  }

  .pdf-header img {
    max-width: 70% !important;
    height: auto !important;
    margin: 0 auto 10px auto !important;
    display: block !important;
  }

  .pdf-header h1 {
    color: #ffffff !important;
    margin: 0 !important;
    font-size: 28px !important;
    font-weight: bold !important;
    text-align: center !important;
  }

  /* Remove margins to use the full printable area */
  html,
  body {
    margin: 0;
    padding: 0;
  }

  /* Override Bootstrap containers to use the full A4 width */
  .container,
  .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Avoid Bootstrap re-adding row margins */
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Ensure FAIR details are visible in the PDF */
  #fair-details {
    display: block !important;
  }

  /* Avoid page breaks inside large blocks (charts/tables) */
  .avoid-break,
  .bokeh-block {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #fair-charts {
    page-break-inside: auto;
    break-inside: auto;
  }

  /* Each Bokeh chart should not be split across pages */
  .bokeh-chart {
    display: block;
    width: 100%;
    page-break-inside: avoid;      /* legacy */
    break-inside: avoid-page;      /* modern */
    margin-top: 0.5cm;
    margin-bottom: 0.5cm;
  }

  /* Second chart (bars) should start on a new page */
  #fair-charts .bokeh-chart + .bokeh-chart {
    page-break-before: always;     /* legacy */
    break-before: page;            /* modern */
  }

  /* Optional: make Bokeh figures slightly more compact in the PDF */
  .bokeh-chart .bk-root {
    transform: scale(0.5);
    transform-origin: top left;
  }
}
