/* ============================================================
   PRINT STYLES — Fatura ve Makbuz Baskı CSS
   ============================================================ */

@media print {
  /* Gizle */
  .sidebar,
  .app-header,
  .page-header-actions,
  .btn,
  .no-print,
  .sidebar-overlay,
  .toast-container,
  .modal-overlay { display: none !important; }

  /* Layout resetle */
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }

  .main-area { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }

  /* Sadece yazdırılacak içerik */
  .printable-content { display: block !important; }

  /* Page breaks */
  .page-break-before { page-break-before: always; }
  .page-break-after  { page-break-after: always; }
  .no-page-break     { page-break-inside: avoid; }
}

/* ── Fatura Print Wrapper ── */
.invoice-print {
  width: 210mm;
  min-height: 297mm;
  padding: 12mm;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow-xl);
  border-radius: var(--radius-lg);
  font-family: 'Inter', sans-serif;
  font-size: 10pt;
}

/* Fatura Başlık */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 8mm;
  border-bottom: 2px solid #1E3A8A;
  margin-bottom: 6mm;
}
.invoice-org { flex: 1; }
.invoice-logo {
  width: 60px; height: 60px;
  margin-bottom: 4px;
  object-fit: contain;
}
.invoice-org-name {
  font-size: 14pt;
  font-weight: 700;
  color: #1E3A8A;
  line-height: 1.2;
}
.invoice-org-sub {
  font-size: 9pt;
  color: #64748B;
  margin-top: 2px;
}

.invoice-title-block { text-align: right; }
.invoice-title {
  font-size: 18pt;
  font-weight: 800;
  color: #1E3A8A;
  letter-spacing: -0.02em;
}
.invoice-no {
  font-size: 10pt;
  color: #475569;
  margin-top: 2px;
  font-weight: 600;
}

/* Bilgi Tablosu */
.invoice-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4mm;
  margin-bottom: 6mm;
}
.invoice-info-block {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  padding: 4mm;
}
.invoice-info-block h4 {
  font-size: 7pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1E3A8A;
  margin-bottom: 3mm;
  padding-bottom: 2mm;
  border-bottom: 1px solid #BFDBFE;
}
.invoice-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 9pt;
  margin-bottom: 2mm;
}
.invoice-info-row span:first-child { color: #64748B; }
.invoice-info-row span:last-child  { font-weight: 600; color: #0F172A; }

/* Tüketim Kartı */
.invoice-meter {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 4px;
  padding: 4mm;
  margin-bottom: 6mm;
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.invoice-meter-item {}
.invoice-meter-label { font-size: 7pt; color: #1D4ED8; text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em; }
.invoice-meter-value { font-size: 14pt; font-weight: 800; color: #1E3A8A; margin-top: 2px; }
.invoice-meter-unit  { font-size: 8pt; color: #60A5FA; }
.invoice-meter-sep   { width: 1px; background: #BFDBFE; margin: 2mm 0; }

/* Hesap Tablosu */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6mm;
}
.invoice-table thead th {
  background: #1E3A8A;
  color: #fff;
  padding: 2mm 4mm;
  text-align: left;
  font-size: 8pt;
  font-weight: 600;
}
.invoice-table thead th:last-child { text-align: right; }
.invoice-table tbody td {
  padding: 2.5mm 4mm;
  font-size: 9pt;
  border-bottom: 1px solid #E2E8F0;
  color: #334155;
}
.invoice-table tbody td:last-child { text-align: right; font-weight: 600; color: #0F172A; }
.invoice-table tfoot td {
  padding: 2.5mm 4mm;
  font-size: 9pt;
}
.invoice-table .total-row td {
  background: #1E3A8A;
  color: #fff;
  font-size: 11pt;
  font-weight: 800;
  padding: 3mm 4mm;
}
.invoice-table .subtotal-row td {
  background: #F1F5F9;
  font-weight: 600;
}

/* Footer */
.invoice-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 4mm;
  border-top: 1px solid #E2E8F0;
  margin-top: 4mm;
}
.invoice-note { font-size: 8pt; color: #64748B; max-width: 120mm; line-height: 1.4; }
.invoice-signature { text-align: center; }
.invoice-signature-line { width: 50mm; border-bottom: 1px solid #000; margin: 0 auto 2mm; }
.invoice-signature-label { font-size: 8pt; color: #475569; }

/* ── A5 Tahsilat Makbuzu (148×210mm Ofis) ── */
.receipt-a5 {
  width: 148mm;
  min-height: 100mm;
  padding: 8mm 10mm;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 10pt;
  color: #1a1a1a;
  box-sizing: border-box;
  margin: 0 auto;
}
.ra5-header { text-align: center; margin-bottom: 5mm; }
.ra5-org-name { font-size: 16pt; font-weight: 800; color: #1E3A8A; line-height: 1.2; }
.ra5-org-sub  { font-size: 9pt;  color: #475569; margin-top: 1mm; }
.ra5-doc-label{ font-size: 8pt;  color: #64748B; margin-top: 2mm; letter-spacing: .05em; }
.ra5-doc-type { font-size: 13pt; font-weight: 700; color: #1E3A8A; margin-top: 1mm; letter-spacing: .02em; }

.ra5-stamp {
  text-align: center;
  font-size: 9pt;
  font-weight: 700;
  color: #475569;
  letter-spacing: .15em;
  border-top: 1.5px solid #CBD5E1;
  border-bottom: 1.5px solid #CBD5E1;
  padding: 1.5mm 0;
  margin: 4mm 0;
}

.ra5-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3mm;
  margin-bottom: 3mm;
}
.ra5-info-block, .ra5-detail-block {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 3px;
  padding: 3mm 4mm;
  margin-bottom: 3mm;
}
.ra5-info-title {
  font-size: 7pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #1E3A8A;
  border-bottom: 1px solid #BFDBFE;
  padding-bottom: 1.5mm;
  margin-bottom: 2mm;
}
.ra5-kv {
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  font-size: 9pt;
  margin-bottom: 1.5mm;
}
.ra5-kv span:first-child { color: #64748B; }
.ra5-kv span:last-child, .ra5-kv strong { color: #0F172A; font-weight: 600; }

.ra5-amount-box {
  background: #1E3A8A;
  color: #fff;
  border-radius: 4px;
  text-align: center;
  padding: 5mm 0;
  margin: 4mm 0;
}
.ra5-amount-label { font-size: 8pt; letter-spacing: .1em; font-weight: 600; opacity: .85; }
.ra5-amount-value { font-size: 22pt; font-weight: 800; margin-top: 1.5mm; letter-spacing: -.01em; }

.ra5-footer { margin-top: 5mm; border-top: 1px solid #E2E8F0; padding-top: 4mm; }
.ra5-collector { font-size: 9pt; margin-bottom: 1mm; }
.ra5-office    { font-size: 8pt; color: #64748B; margin-bottom: 3mm; }
.ra5-sig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8mm;
  margin-top: 8mm;
}
.ra5-sig-block  { text-align: center; }
.ra5-sig-line   { border-bottom: 1px solid #94A3B8; margin: 0 4mm 2mm; height: 8mm; }
.ra5-sig-label  { font-size: 7.5pt; color: #64748B; }

@media print {
  @page { size: A5 portrait; margin: 0; }
  .receipt-a5 {
    width: 148mm;
    min-height: 210mm;
    padding: 10mm 12mm;
    box-shadow: none;
    margin: 0;
  }
}

/* Makbuz yazdırılırken arka plan sayfayı tamamen gizle */
@media print {
  body.print-receipt > *:not(#print-root) {
    display: none !important;
  }
  body.print-receipt #print-root {
    display: block !important;
  }
  body.print-receipt #print-root .receipt-a5 {
    width: 148mm;
    min-height: 210mm;
    padding: 10mm 12mm;
    margin: 0;
    box-shadow: none;
  }
}

/* ── Makbuz/Fiş Print (58/80mm Termal) ── */
/* Genişlik --receipt-width ile ayarlanır (ReceiptModel doc.width → 58mm|80mm).
   ReceiptRenderers.toHtml bu değişkeni inline set eder; varsayılan 80mm. */
.receipt-print {
  --receipt-width: 80mm;
  width: var(--receipt-width);
  padding: 4mm;
  font-size: 8pt;
  font-family: 'Courier New', monospace;
  line-height: 1.35;
  background: #fff;
  color: #000;
  margin: 0 auto;
}
.receipt-print .receipt-row { display: flex; justify-content: space-between; gap: 4mm; margin-bottom: 1mm; }
.receipt-print .receipt-row span:last-child { text-align: right; white-space: nowrap; }
.receipt-print .receipt-total {
  border-top: 1px dashed #000; border-bottom: 1px dashed #000;
  padding: 1.5mm 0; margin: 1.5mm 0; font-weight: bold; font-size: 11pt;
}

/* Yapısal blok sınıfları (ReceiptModel → to-html) */
.receipt-print .receipt-rule { border-top: 1px dashed #000; margin: 1.5mm 0; }
.receipt-print .receipt-rule-solid { border-top-style: solid; }
.receipt-print .receipt-space { display: block; }
.receipt-print .rc-text { margin: 0.5mm 0; word-break: break-word; }
.receipt-print .rc-bold { font-weight: bold; }
.receipt-print .rc-left   { text-align: left; }
.receipt-print .rc-center { text-align: center; }
.receipt-print .rc-right  { text-align: right; }
.receipt-print .rc-sm { font-size: 7pt; }
.receipt-print .rc-md { font-size: 9pt; }
.receipt-print .rc-lg { font-size: 12pt; }
.receipt-print .rc-xl { font-size: 15pt; }
.receipt-print .receipt-logo { display: block; margin: 0 auto 2mm; }

/* window.print() konteyneri — normalde gizli, yalnız yazdırmada görünür.
   #print-root body'nin doğrudan çocuğu olduğu için modal-overlay
   display:none kuralından etkilenmez (DOM taşıma hilesine gerek yok). */
#print-root { display: none; }

@media print {
  .invoice-print, .receipt-print {
    box-shadow: none;
    border-radius: 0;
    border: none !important;
    page-break-inside: avoid;
  }
  /* Yazdırma anında yalnız #print-root görünür; gerisi print.css:6-14'te gizli */
  #print-root.print-root-active { display: block !important; }
  #print-root.print-root-active .receipt-print { margin: 0; }
}
