/* =====================================================================
   print.css — official documents (certificates, transcripts, receipts,
   report cards) and printed reports. Loaded with media="print", and
   also applied directly when rendering a document to PDF via the
   browser's print pipeline (§57, §110, §111).
   ===================================================================== */

@font-face {
  font-family: "Amiri";
  src: url("../assets/fonts/Amiri-Regular.ttf") format("truetype");
  font-display: swap;
}

@page payment-receipt {
  size: A5 landscape;
  margin: 8mm;
}

#print-root {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body * {
    visibility: hidden;
  }
  body > *:not(#print-root) {
    display: none !important;
  }
  #print-root,
  #print-root * {
    visibility: visible;
  }
  #print-root {
    position: static;
    display: block !important;
    width: 100%;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    transform: none;
    box-sizing: border-box;
    background: #fff;
  }

  .app-sidebar,
  .app-topbar,
  .no-print,
  .toast-region,
  .offline-banner {
    display: none !important;
  }

  body {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff;
    color: #000;
    font-size: 12pt;
    font-family: "Amiri", var(--font-ar, "Segoe UI", Tahoma, sans-serif);
  }
  a {
    color: #000;
    text-decoration: none;
  }

  .print-page {
    direction: rtl;
    text-align: right;
    page-break-after: always;
    break-after: page;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
    transform: none !important;
    overflow: visible;
    background: #fff;
  }
  .print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .report-document {
    padding: 0.5rem 0.75rem 0.25rem;
  }
  .receipt-document {
    page: payment-receipt;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .receipt-document .receipt-header {
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #1c2c40;
  }
  .receipt-document .receipt-header .school-logo {
    width: 1.5cm;
    height: 1.5cm;
    object-fit: contain;
  }
  .receipt-document .receipt-title {
    margin: 0.3rem 0 0.4rem;
    font-size: 13pt;
  }
  .receipt-document .receipt-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem 0.6rem;
    margin-bottom: 0.4rem;
  }
  .receipt-document .receipt-field {
    min-width: 0;
    padding-bottom: 0.2rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .receipt-document .receipt-label {
    font-size: 7pt;
  }
  .receipt-document .receipt-value {
    font-size: 8.5pt;
    overflow-wrap: anywhere;
  }
  .receipt-document .receipt-summary {
    margin: 0.25rem 0;
    padding: 0.3rem 0.5rem;
  }
  .receipt-document .signature-row {
    margin-top: 0.5rem;
  }
  .receipt-document .report-footer {
    margin-top: 0.35rem;
    font-size: 7pt;
  }

  .report-summary {
    margin: 0 0 0.8rem;
  }

  .summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .report-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    background: #f4f9ff;
    border: 1px solid #d9e9f8;
    border-radius: 10px;
    padding: 0.45rem 0.6rem;
  }

  .summary-label {
    font-size: 7.5pt;
    color: #4b5a6b;
  }

  .summary-value {
    font-size: 9pt;
    font-weight: 700;
    color: #0c2d4d;
  }

  .report-section-title {
    font-size: 11pt;
    font-weight: 700;
    color: #0f2f4c;
    margin: 0 0 0.45rem;
  }

  table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    page-break-inside: auto;
    break-inside: auto;
    table-layout: fixed;
    margin-inline: 0 !important;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  thead {
    display: table-header-group;
  }
  .print-page .data-table {
    width: 100%;
    table-layout: auto;
    direction: rtl;
    border-collapse: collapse;
    font-family: "Amiri", var(--font-ar, "Segoe UI", Tahoma, sans-serif);
    font-size: 8.5pt;
  }
  .print-page .data-table th,
  .print-page .data-table td {
    padding: 3pt 4pt;
    border: 0.4pt solid #b7c2cf;
    overflow-wrap: anywhere;
    vertical-align: middle;
    text-align: right;
  }
  .print-page .data-table th {
    background: #055ba6;
    color: #fff;
    font-weight: 700;
  }
  .fee-statement-print > .data-table {
    break-inside: auto;
    page-break-inside: auto;
  }
  .fee-statement-print > .data-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid #1c2c40;
    padding-bottom: 0.4rem;
    margin-bottom: 0.75rem;
  }
  .report-header__meta {
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
    flex: 1;
    text-align: right;
  }
  .report-title {
    text-align: center;
    margin: 0.35rem 0 0.6rem;
    font-size: 18pt;
  }
  .print-page .report-header,
  .print-page .report-title {
    visibility: visible;
  }
  .scroll-x,
  .students-table-wrap,
  .enrollment-table-wrap,
  .fees-results-scroll {
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
  }
  .student-detail-value,
  .receipt-value,
  .report-stat,
  th,
  td {
    overflow-wrap: anywhere;
  }
}

/* Shared certificate/document layout, also used for on-screen preview
   before printing so what the user sees matches the paper output. */
.receipt-document {
  direction: rtl;
  text-align: right;
  font-family: var(--font-ar, "Segoe UI", Tahoma, sans-serif);
  max-width: 21cm;
  margin: 0 auto;
  background: #fff;
  color: #1c2c40;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(18, 36, 56, 0.08);
  padding: 1.25rem;
}

.receipt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.receipt-school {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.receipt-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 1.1rem 0 1rem;
  color: #1c2c40;
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.receipt-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-bottom: 1px solid #edf1f7;
  padding-bottom: 0.55rem;
}

.receipt-label {
  font-size: 0.76rem;
  color: #5f6f82;
}

.receipt-value {
  font-size: 0.96rem;
  color: #15273d;
  word-break: break-word;
}

.receipt-summary {
  margin: 1rem 0;
  border-top: 2px solid #1c2c40;
  border-bottom: 2px solid #1c2c40;
  padding: 0.75rem 0;
}

.receipt-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
}

.certificate {
  font-family: var(--font-ar, "Segoe UI", Tahoma, sans-serif);
  text-align: center;
  border: 3px double #1c2c40;
  padding: 2.5cm 2cm;
  max-width: 21cm;
  margin: 0 auto;
  background: #fff;
  color: #1c2c40;
}
.certificate h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}
.certificate h2 {
  font-size: 1.3rem;
  margin: 1rem 0;
  border-bottom: 1px solid #bf9e75;
  display: inline-block;
  padding-bottom: 0.25rem;
}
.certificate p {
  font-size: 1.05rem;
  line-height: 2;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #1c2c40;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}
.report-summary {
  margin: 0 0 1rem;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}
.report-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: #f4f9ff;
  border: 1px solid #d9e9f8;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.summary-label {
  font-size: 0.72rem;
  color: #5f6f82;
}
.summary-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0c2d4d;
  word-break: break-word;
}
.report-section-title {
  margin: 0 0 0.6rem;
  font-size: 0.96rem;
  font-weight: 700;
  color: #0f2f4c;
}
.report-header .school-name {
  font-weight: 700;
  font-size: 1.1rem;
}
.report-header .school-logo {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
  margin-inline-end: 0.75rem;
  vertical-align: middle;
}
.report-header .doc-meta {
  font-size: 0.8rem;
  color: #4b5a6b;
}
.report-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #4b5a6b;
}

.signature-row {
  display: flex;
  justify-content: space-around;
  margin-top: 3rem;
}
.signature-block {
  text-align: center;
}
.signature-line {
  border-top: 1px solid #1c2c40;
  width: 8rem;
  margin: 0 auto 0.5rem;
}
