/* Print Stylesheet - Optimized for A4 Black & White Printing */

@page {
  size: A4 portrait;
  margin: 15mm 20mm;
}

@media print {
  /* Reset colors for B&W printing */
  * {
    color: #000 !important;
    background: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-size: 11pt;
    line-height: 1.4;
  }

  /* Hide web-only elements */
  .no-print,
  .site-header,
  .print-button,
  button,
  nav {
    display: none !important;
  }

  /* Show print-only elements */
  .print-only {
    display: block !important;
  }

  /* Typography for print */
  h1 {
    font-size: 22pt;
    margin-top: 0;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    margin-top: 20pt;
    margin-bottom: 10pt;
    page-break-after: avoid;
    border-bottom: 2pt solid #000 !important;
    padding-bottom: 5pt;
  }

  h3 {
    font-size: 14pt;
    margin-top: 15pt;
    margin-bottom: 8pt;
    page-break-after: avoid;
  }

  h4 {
    font-size: 12pt;
    margin-top: 10pt;
    margin-bottom: 6pt;
    page-break-after: avoid;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }

  /* Links */
  a {
    color: #000 !important;
    text-decoration: none !important;
    font-weight: normal;
  }

  a[href]:after {
    content: "";  /* Don't print URLs */
  }

  /* QR Codes - Critical for scanning */
  .qr-code {
    display: inline-block !important;
    width: 1.5cm !important;
    height: 1.5cm !important;
    min-width: 1.5cm !important;
    min-height: 1.5cm !important;
    border: 1pt solid #000 !important;
    padding: 2pt !important;
    margin-left: 3pt !important;
    vertical-align: middle !important;
    background: #fff !important;
  }

  .qr-code svg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  .qr-wrapper {
    display: inline-block !important;
    vertical-align: middle !important;
  }

  .link-with-qr {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3pt !important;
    margin: 2pt 0 !important;
    page-break-inside: avoid !important;
  }

  /* Sections */
  .section {
    page-break-inside: avoid;
    margin-bottom: 15pt;
    padding: 0;
    border: none;
  }

  /* Lists */
  ul, ol {
    margin-left: 15pt;
    margin-bottom: 10pt;
  }

  li {
    margin-bottom: 4pt;
  }

  /* Tables */
  table {
    page-break-inside: avoid;
    border: 1pt solid #000 !important;
  }

  th, td {
    padding: 6pt;
    border: 1pt solid #000 !important;
  }

  th {
    font-weight: bold;
    background: #f0f0f0 !important;
  }

  /* Footer with page numbers */
  .site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9pt;
    border-top: 1pt solid #000;
    padding-top: 5pt;
  }

  /* Page numbers using counter */
  @page {
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
    }
  }

  /* Prevent breaks inside important elements */
  h2, h3, h4, h5, h6 {
    page-break-after: avoid !important;
  }

  img, figure, table, pre {
    page-break-inside: avoid !important;
  }

  /* Ensure good contrast for QR codes */
  .qr-code path {
    fill: #000 !important;
  }

  /* First page header */
  .page-content > h1:first-child {
    text-align: center;
    margin-bottom: 20pt;
  }
}

/* High quality print mode */
@media print and (min-resolution: 300dpi) {
  .qr-code {
    width: 1.8cm !important;
    height: 1.8cm !important;
  }
}
