/* ═══════════════════════════════════════════════════════════════
   print.css — قالب طباعة A4 احترافي
   - تخفي جميع عناصر الصفحة عدا الفاتورة
   - تنسيق مثالي لـ A4 مع ضبط الهوامش
   - دعم المعاينة والطباعة المباشرة
   ═══════════════════════════════════════════════════════════════ */

#printArea { display: none; }

@media print {
  /* ─── إعادة تعيين الصفحة ─── */
  * {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #0f172a;
  }

  /* ─── إخفاء جميع عناصر التطبيق ─── */
  #app { display: none !important; }
  #modal { display: none !important; }
  #toasts { display: none !important; }
  .app-shell { display: none !important; }
  .app-main { display: none !important; }
  .app-header { display: none !important; }
  .sidebar { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .nav-item { display: none !important; }
  .container { display: none !important; }
  .page-title { display: none !important; }
  .btn-group { display: none !important; }
  
  /* إظهار الفاتورة فقط */
  #printArea {
    display: block !important;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ─── إعدادات الصفحة ─── */
  @page {
    size: A4;
    margin: 0;
    padding: 0;
  }

  /* ─── إزالة الكسر التلقائي ─── */
  @page :first {
    margin-top: 0;
    margin-bottom: 0;
  }

  body {
    line-height: 1;
  }
}

.pr-page {
  font-family: 'Cairo', sans-serif;
  color: #0f172a; direction: rtl;
  width: 210mm; min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  padding: 15mm;
  box-sizing: border-box;
}

.pr-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 10mm; border-bottom: 3px solid #0f766e;
  margin-bottom: 8mm;
}
.pr-company { flex: 1; }
.pr-logo { height: 22mm; max-width: 60mm; object-fit: contain; margin-bottom: 4mm; }
.pr-company-name { font-size: 22pt; font-weight: 900; color: #0f172a; margin: 0 0 2mm 0; }
.pr-company-name-en { font-size: 11pt; color: #64748b; margin: 0 0 4mm 0; }
.pr-company-info { font-size: 9pt; color: #475569; line-height: 1.8; }
.pr-company-info b { color: #0f172a; }

.pr-invoice-badge { text-align: center; min-width: 50mm; }
.pr-badge-title {
  background: #0f766e; color: #fff;
  padding: 4mm 8mm; border-radius: 2mm;
  font-size: 14pt; font-weight: 800; margin-bottom: 3mm;
  display: inline-block;
}
.pr-badge-sub { font-size: 8pt; color: #64748b; margin-bottom: 3mm; letter-spacing: 1px; }
.pr-qr { width: 32mm; height: 32mm; margin: 0 auto; display: block; image-rendering: pixelated; }
.pr-qr-label { font-size: 7pt; color: #94a3b8; margin-top: 2mm; }

.pr-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; margin-bottom: 8mm; }
.pr-meta-card {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 2mm; padding: 4mm 5mm;
}
.pr-meta-title {
  font-size: 10pt; font-weight: 800; color: #0f766e;
  margin-bottom: 3mm; padding-bottom: 2mm;
  border-bottom: 1px solid #cbd5e1;
}
.pr-meta-row { font-size: 9pt; line-height: 1.9; }
.pr-meta-row b { color: #0f172a; }

.pr-driver {
  background: #fef3c7; border: 1px solid #fde68a;
  border-radius: 2mm; padding: 3mm 5mm; margin-bottom: 5mm; font-size: 9pt;
}

.pr-items { width: 100%; border-collapse: collapse; margin-bottom: 6mm; font-size: 9pt; }
.pr-items thead { background: #0f766e; color: #fff; }
.pr-items th { padding: 3mm 2mm; font-weight: 700; text-align: right; border: 1px solid #0f766e; }
.pr-items th.center { text-align: center; }
.pr-items td { padding: 2.5mm 2mm; border: 1px solid #e2e8f0; vertical-align: middle; }
.pr-items td.center { text-align: center; }
.pr-items tbody tr:nth-child(even) { background: #f8fafc; }
.pr-items tfoot { background: #f1f5f9; font-weight: 700; }
.pr-items tfoot td { padding: 3mm 2mm; }

.pr-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; margin-top: 5mm; margin-bottom: 8mm; }
.pr-totals { width: 100%; border-collapse: collapse; font-size: 10pt; }
.pr-totals td { padding: 2.5mm 3mm; border: 1px solid #e2e8f0; }
.pr-totals tr.grand td {
  background: #0f766e; color: #fff; font-size: 12pt; font-weight: 800;
  padding: 4mm 3mm;
}
.pr-totals tr.grand td:last-child,
.pr-totals td:last-child { text-align: left; font-family: 'JetBrains Mono', monospace; }

.pr-notes {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 2mm; padding: 4mm 5mm;
  font-size: 9pt; line-height: 1.8;
}
.pr-notes b { color: #0f172a; }
.pr-notes .tafqeet { font-style: italic; color: #475569; margin-top: 2mm; }

.pr-bottom {
  margin-top: auto; padding-top: 5mm;
  border-top: 2px solid #e2e8f0;
  text-align: center; font-size: 8pt; color: #94a3b8;
}
.pr-bottom b { color: #0f766e; }
