/* ================= BASE ================= */
* {
   font-family:Cairo,sans-serif;
}
body{
  font-family:Cairo,sans-serif;
  background:#f3f4f6;
  margin:0;
}
.btn.danger,
.btn-cancel.danger {
  background: #dc2626;
  color: #fff;
  border: none;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn.danger:disabled {
  background: #991b1b;
  opacity: .7;
  cursor: not-allowed;
}
.error-banner{
  background:linear-gradient(135deg,#fee2e2,#fecaca);
  color:#991b1b;
  padding:14px 18px;
  border-radius:14px;
  margin:14px 0;
  font-weight:900;
  text-align:center;
  border:1px solid #fca5a5;
  box-shadow:0 6px 18px rgba(220,38,38,.15);
}

/* ===== Success Banner ===== */
.success-banner{
  max-width:1000px;
  margin:20px auto 0;
  background:#ecfdf5;
  color:#065f46;
  padding:14px 18px;
  border-radius:14px;
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  box-shadow:0 10px 25px rgba(0,0,0,.05);
}
.success-banner .icon{
  background:#10b981;
  color:#fff;
  width:26px;
  height:26px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
}

/* ===== Invoice View ===== */
.invoice{
  max-width:1000px;
  margin:10px auto;
  background:#fff;
  padding:30px;
  border-radius:16px;
}

.header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:2px solid #000;
  padding-bottom:12px;
}

.logo-box img.qr{
  width:100px;
  height:140px;
  object-fit:contain;
}


.title{
  text-align:center;
  font-size:22px;
  font-weight:900;
  margin:20px 0;
}

.info{
  font-size:14px;
  line-height:1.8;
  margin-bottom:20px;
}

/* ===== Table ===== */
table{
  width:100%;
  border-collapse:collapse;
}

th,td{
  border:1px solid #ddd;
  padding:10px;
  font-size:14px;
  text-align:center;
}

th{
  background:#f9fafb;
}

.prod{text-align:right}

/* ===== Summary ===== */
.summary{
  margin-top:12px;
  padding:12px 14px;
  border-radius:12px;
  background:#f8fafc;
  border:1px solid #e5e7eb;
}

.summary .row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  font-weight:900;
}
.summary .row div{min-width:220px}

/* ===== Actions ===== */
.actions{
  margin-top:24px;
  display:flex;
  gap:12px;
  justify-content:center;
  flex-wrap:wrap;
}

.actions .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-width:140px;
  height:44px;
  padding:0 18px;
  border-radius:12px;
  font-size:14px;
  font-weight:900;
  text-decoration:none;
  color:#fff;
  cursor:pointer;
  transition:.2s;
}
.actions .btn:hover{opacity:.9}

.btn-a4{background:#2563eb}
.btn-thermal{background:#16a34a}
.btn-back{background:#6b7280}
.btn-return{background:#f97316}
.btn-exchange{background:#0ea5e9}

/* ================================================= */
/* ================= PRINT A4 ====================== */
/* ================================================= */
@media print {

  @page{
    size:A4;
    margin:10mm;
  }

  html,body{
    background:#fff !important;
    margin:0 !important;
    padding:0 !important;
    font-size:12px !important;
    line-height:1.4 !important;
  }

  /* إخفاء كل الواجهة */
  .sidebar,
  .topbar,
  .actions,
  .success-banner,
  button,
  .no-print{
    display:none !important;
  }

  /* الفاتورة تملأ الصفحة */
  .invoice{
    width:100% !important;
    max-width:190mm !important;
    margin:0 auto !important;
    padding:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }

  /* جدول ذكي */
  table{
    width:100% !important;
    font-size:12px !important;
    border-collapse:collapse !important;
  }

  th,td{
    padding:6px !important;
  }

  /* تكرار الهيدر */
  thead{
    display:table-header-group;
  }

  /* منع كسر الصف */
  tr{
    page-break-inside:avoid;
  }

  /* الإجماليات لا تنكسر */
  .summary{
    page-break-inside:avoid;
    margin-top:10px;
  }
}

.invoice-summary-box{
  margin:14px 0;
  padding:14px;
  border-radius:14px;
  background:#f9fafb;
  border:1px solid #e5e7eb;font-family: "Cairo", sans-serif;
}

.sum-group{
  margin-bottom:10px;
  padding-bottom:8px;
  border-bottom:1px dashed #e5e7eb;
}

.sum-group:last-child{
  border-bottom:none;
}

.sum-row{
  display:flex;
  justify-content:space-between;
  margin:6px 0;
  font-size:14px;
}

.sum-row.muted{
  color:#6b7280;
  font-size:13px;
}

.sum-group.final{
  margin-top:10px;
}

.sum-row.big{
  font-size:18px;
  font-weight:900;
}

.sum-row.paid{
  color:#166534;
  font-weight:700;
}

.sum-row.remain{
  color:#991b1b;
  font-weight:700;
}
.sum-row.cod{
  background:#fff7ed;
  padding:6px 10px;
  border-radius:8px;
  border:1px dashed #fdba74;
  color:#9a3412;
  font-weight:900;
}.info-box{
  margin:14px 0;
  padding:12px 14px;
  border-radius:14px;
  background:#ffffff;
  border:1px solid #e5e7eb;
}

.info-row{
  display:grid;
  grid-template-columns:140px 1fr;
  gap:10px;
  padding:4px 0;
  font-size:14px;
}

.info-row b{
  color:#374151;
}

.badge.cod{
  background:#fde68a;
  color:#92400e;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  margin-inline-start:6px;
}
.info-box.compact{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px 18px;
  margin:14px 0;
  padding:12px 14px;
  border-radius:14px;
  background:#ffffff;
  border:1px solid #e5e7eb;
  font-size:13px;
}

.info-cell{
  display:flex;
  justify-content:space-between;
  gap:10px;
}

/* ================== INFO VISIBILITY BOOST ================== */

/* اسم الحقل (التاريخ – العميل – الهاتف...) */
.info-cell span{
  font-size: 14px;
  font-weight: 900;
  color: #0D4088; /* أغمق شوية */
}

/* قيمة الحقل (المهم) */
.info-cell b{
  font-size: 14.5px;        /* 👈 أهم سطر */
  font-weight: 800;         /* 👈 يخليها واضحة */
  color: #0f172a;           /* أغمق لون */
  letter-spacing: .2px;
}

/* التاريخ تحديدًا */
.info-cell b:has(+ span),
.info-cell b{
  line-height: 1.45;
}


.badge.cod{
  background:#fde68a;
  color:#92400e;
  padding:2px 6px;
  border-radius:999px;
  font-size:11px;
  margin-inline-start:6px;
}

/* ================= Installment Box ================= */
.summary {
  margin-top: 10px !important;
  padding: 10px 12px !important;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #dbeafe;
  font-size: 13px;
}

.summary .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  padding: 4px 0;
  line-height: 1.4;
}

.summary .row div {
  white-space: nowrap;
}

.summary .row div:last-child {
  text-align: left;
  font-weight: 700;
}

.summary .row:last-child {
  padding-bottom: 0;
}


@media print {
  * {
    font-family: "Cairo", sans-serif !important;
    letter-spacing: 0 !important;
  }

  body {
    font-family: "Cairo", sans-serif !important;
  }

  table, th, td,
  div, span, b, strong,
  .badge, .title {
    font-family: "Cairo", sans-serif !important;
  }
  @page {
    size: A4;
    margin: 8mm; 
    font-family: "Cairo", sans-serif;
    /* 🔥 ده أهم سطر */
  }

  body { 
    background: #fff !important;
    font-size: 12px !important;
     zoom: 0.90;
  }

  .invoice {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 10px !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* تصغير العناوين */
  .title {
    font-size: 16px !important;
    margin: 6px 0 !important;
  }

  /* ملخص الفاتورة */
  .invoice-summary-box,
  .info-box,
  .summary {
    padding: 8px !important;
    margin: 8px 0 !important;
  }

  /* الجداول */
  table {
    font-size: 11px !important;
  }

  th, td {
    padding: 4px 6px !important;
  }

  /* منع كسر الصفحة في النص */
  .invoice,
  table,
  .invoice-summary-box {
    page-break-inside: avoid;
  }

  /* إخفاء أي أزرار */
  .no-print {
    display: none !important;
  }
    #print-area {
    transform: scale(0.95);
    transform-origin: top center;
  }
    .info-cell b{
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #000 !important;
  }

  .info-cell span{
    font-size: 12px !important;
    color: #333 !important;
  }
}


.gift-row {
  background: #f0fdf4;
}

.gift-row td {
  color: #065f46;
}


@media print {

  /* 1️⃣ الغي أي تأثير للداشبورد */
  body,
  .content,
  .content-wrapper,
  .main-content,
  .page-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 2️⃣ الغي مساحة السايدبار نهائياً */
  .sidebar,
  .sidebar-wrapper {
    display: none !important;
    width: 0 !important;
  }

  /* 3️⃣ خلي الفاتورة في نص الورقة */
  #print-area {
    width: 190mm !important;   /* عرض A4 الحقيقي */
    margin: 0 auto !important; 
    margin-top: 20mm !important; 
  }
