/* A4 RTL print. The printed report is a first-class deliverable here — it is the
   thing that gets handed to the finance department — so the screen chrome is
   fully removed rather than merely hidden behind a media query afterthought.

   Status is carried by TEXT LABELS in print, because a printed page may be
   greyscale. */

.print-only { display: none; }

@media print {
  @page { size: A4; margin: 14mm 12mm; }

  html, body {
    background: #fff !important;
    font-size: 10.5pt;
    color: #000;
  }

  /* remove every piece of app chrome */
  .sidebar, .filters, .btn, .btn-row, .row-actions, .icon-btn,
  #toasts, .overlay, .no-print, .tiles, .hero, .chart-card, .page-head__row .spacer {
    display: none !important;
  }

  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  #view { animation: none !important; }

  .print-only { display: block; }

  /* letterhead */
  .print-head {
    display: flex !important; align-items: flex-start; gap: 10mm;
    border-bottom: 1.5pt solid #000; padding-bottom: 4mm; margin-bottom: 6mm;
  }
  .print-head__mark { width: 18mm; height: 18mm; flex: none; }
  .print-head__logo { width: 100%; height: 100%; object-fit: contain; display: block; }
  .print-head__office { font-size: 15pt; font-weight: 700; letter-spacing: -0.01em; }
  .print-head__officesub { font-size: 9pt; color: #444; }
  .print-head__title { font-size: 13pt; font-weight: 700; margin-top: 2mm; }
  .print-head__meta { margin-inline-start: auto; text-align: end; font-size: 8.5pt; color: #333; }
  .print-head__meta div { white-space: nowrap; }

  .print-filters {
    display: block !important; font-size: 8.5pt; color: #333;
    border: 0.5pt solid #999; padding: 2mm 3mm; border-radius: 2mm; margin-bottom: 4mm;
  }

  /* totals block must never be orphaned from its table */
  .print-summary {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 3mm; margin-bottom: 5mm; break-inside: avoid;
  }
  .print-summary .cell { border: 0.5pt solid #999; padding: 2mm 3mm; border-radius: 1.5mm; }
  .print-summary .label { font-size: 8pt; color: #444; }
  .print-summary .value { font-size: 12pt; font-weight: 700; }

  /* tables */
  .table-wrap { box-shadow: none !important; border-radius: 0; overflow: visible; }
  .table-scroll { overflow: visible !important; }
  table.data { width: 100%; font-size: 8.5pt; border-collapse: collapse; }
  table.data thead { display: table-header-group; }   /* repeat on every page */
  table.data tfoot { display: table-row-group; }
  table.data th, table.data td {
    border: 0.5pt solid #999; padding: 1.4mm 2mm;
    white-space: normal; color: #000;
  }
  table.data thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.data tbody tr { break-inside: avoid; }
  table.data tbody tr:hover { background: transparent; }
  table.data tfoot td { background: #eee !important; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .group-row td { background: #ddd !important; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* A defaulted client must stay obvious on a greyscale printout: the متعثر badge
     carries the words, and the row gets a heavy rule rather than a colour. */
  tr.row-defaulted td { background: transparent !important; box-shadow: none !important; }
  tr.row-defaulted td:first-child { border-inline-start: 2pt solid #000 !important; }
  tr.row-defaulted { font-weight: 700; }
  .callout-danger { border: 1pt solid #000 !important; padding: 3mm !important; break-inside: avoid; }

  /* status: text, not colour */
  .badge {
    border: 0.4pt solid #666 !important; background: transparent !important;
    color: #000 !important; padding: 0 1mm; border-radius: 1mm; font-size: 8pt;
  }
  .badge svg { display: none; }

  .print-foot {
    display: block !important; margin-top: 5mm; padding-top: 2mm;
    border-top: 0.5pt solid #999; font-size: 8pt; color: #444;
  }

  a { color: #000; text-decoration: none; }
  .page-head { margin-bottom: 0; }
  .page-head h1, .page-head .sub, .section > h2 { display: none; }
}
