/* ==========================================================================
   رصيفي الذكي | SMART BERTH — أنماط الطباعة وتصدير PDF
   Used by: تقارير PDF، لوحات QR للطباعة، سجلات المناوبات.
   ========================================================================== */

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

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --surface-3: #f4f2ea;
    --text: #111310;
    --text-soft: #3b3f36;
    --text-mute: #5f6459;
    --line: #c9c5b6;
    --line-strong: #a9a493;
    --shadow-1: none;
    --shadow-2: none;
    --shadow-3: none;
  }

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

  .sidenav,
  .topbar,
  .nav-scrim,
  .toast-stack,
  .page-foot,
  .no-print,
  .skip-link,
  .tabs,
  .page-head-actions,
  .btn { display: none !important; }

  .shell { display: block; }
  .page { max-width: none; padding: 0; animation: none; }

  .card,
  .metric,
  .record,
  .qr-card,
  .table-wrap {
    border: 1px solid #c9c5b6 !important;
    box-shadow: none !important;
  }

  /* تُمنع القصّة داخل العناصر الصغيرة فقط، حتى لا تُهدر صفحات فارغة */
  .metric, .record, .qr-card, tr { break-inside: avoid; }

  .page-head {
    background: #fff !important;
    border-bottom: 2px solid #4c5742 !important;
    border-radius: 0;
    padding: 0 0 8pt;
    margin-bottom: 12pt;
  }

  .page-head::after { display: none; }

  a { color: #111310 !important; text-decoration: none; }

  table.data { min-width: 0; font-size: 9.5pt; }
  table.data thead th { background: #f0eee6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.data tbody tr:hover { background: none; }
  tr, .record, .qr-card, .metric { break-inside: avoid; }

  /* شبكات ثابتة عند الطباعة حتى لا تتفكك البطاقات */
  .grid-4 { grid-template-columns: repeat(4, 1fr) !important; gap: 6pt !important; }
  .grid-3 { grid-template-columns: repeat(3, 1fr) !important; gap: 6pt !important; }
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; gap: 6pt !important; }
  .metric { padding: 6pt 8pt; gap: 8pt; }
  .metric-copy strong { font-size: 15pt; }

  .print-only { display: revert !important; }
  .print-break { break-before: page; }

  .badge, .chip, .metric-icon, .bar-fill, .identity-seal {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .qr-frame, .qr-card { background: #fff !important; }
  .qr-frame svg, .qr-card svg { max-width: 55mm; }
}

.print-only { display: none; }

/* رأس وتذييل المستند المطبوع */
.print-doc-head {
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12pt;
  padding-bottom: 8pt;
  margin-bottom: 12pt;
  border-bottom: 2px solid #4c5742;
}

.print-doc-head h1 { font-size: 16pt; margin: 0; }
.print-doc-head small { font-size: 9pt; color: #5f6459; }
.print-doc-head .seal { text-align: center; font-size: 8.5pt; border: 1px dashed #9d7f3f; padding: 6pt 10pt; border-radius: 6pt; color: #7d6531; }

.print-signature {
  display: none;
  gap: 24pt;
  margin-top: 24pt;
  padding-top: 10pt;
  border-top: 1px solid #c9c5b6;
  font-size: 9.5pt;
}

.print-signature > div { flex: 1; }
.print-signature .line { margin-top: 22pt; border-bottom: 1px dotted #8d8878; }

@media print {
  .print-doc-head { display: flex; }
  .print-signature { display: flex; }
}

/* ورقة طباعة هويات QR */
.qr-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10mm;
}

@media print {
  .qr-sheet { grid-template-columns: repeat(3, 1fr); gap: 8mm; }
  .qr-sheet .qr-card { padding: 4mm; page-break-inside: avoid; }
}
