/*
 * ESCHOOL V123 - strict A4 printing for all cards and tabular reports.
 * The page margin is owned by @page so it is repeated by the browser on every
 * physical page. Containers must never clip content or force a one-page height.
 */

@media screen {
  body.print-body {
    min-height: 100vh !important;
    height: auto !important;
    overflow: visible !important;
    background: #e7edf2 !important;
    padding: 12mm !important;
  }

  body.print-body > .strict-print-sheet,
  body.print-body > .copier-report-page,
  body.print-body > .certificate:not(.student-certificate-v14),
  body.print-body > .report-page,
  body.print-body > .print-page {
    margin-inline: auto !important;
    outline: 1px solid #d5dde5;
    box-shadow: 0 16px 42px rgba(15, 23, 42, .16);
  }
}

@media print {
  @page {
    margin: 12mm !important;
  }

  /* إفادة الطالب لها اشتراط سابق مستقل: ورقة 21x29 سم وهوامش داخلية 3 سم. */
  @page student-certificate {
    size: 210mm 290mm !important;
    margin: 0 !important;
  }

  .student-certificate-v14,
  #studentCertificatePrint {
    page: student-certificate;
  }

  html,
  body,
  body.print-body {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .container,
  .page,
  .panel,
  .card,
  .section,
  .report-page,
  .print-page,
  .letter-page,
  .document-page,
  .strict-print-sheet,
  .copier-report-page,
  .table-card,
  .table-responsive,
  .wide-table-wrap,
  .data-table-wrap,
  .print-table-wrap {
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin-inline: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  section:has(table),
  .section:has(table),
  .panel:has(table),
  .card:has(table) {
    page-break-inside: auto !important;
    break-inside: auto !important;
    overflow: visible !important;
  }

  .section {
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  /* يشمل أسماء الحاويات القديمة المختلفة بين البطاقات من دون تعديل كل تقرير منفرد. */
  [class*="print-sheet"],
  [class*="report-sheet"],
  [class*="print-page"],
  [class*="report-page"] {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin-inline: 0 !important;
    overflow: visible !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
    box-shadow: none !important;
  }

  .certificate:not(.student-certificate-v14),
  .print-all .multi-print-page,
  .report-polished:not(.student-certificate-v14) {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  .print-all .multi-print-page:not(:last-of-type) {
    page-break-after: always !important;
    break-after: page !important;
  }

  table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  thead {
    display: table-header-group !important;
  }

  tfoot {
    display: table-footer-group !important;
  }

  tbody {
    display: table-row-group !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }

  th,
  td {
    overflow: visible !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
  }

  img,
  svg,
  canvas {
    max-width: 100% !important;
  }

  .topbar,
  .app-navigator,
  .print-toolbar,
  .print-actions,
  .page-actions,
  .no-print,
  .site-print-path,
  .breadcrumb,
  .page-url,
  .print-url {
    display: none !important;
  }
}
