/* Contractor Invoice — Beautiful & Organized, Single A4 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --inv-primary: #1e3a5f;
  --inv-primary-light: #2d4a6f;
  --inv-accent: #2563eb;
  --inv-bg: #f8fafc;
  --inv-card: #ffffff;
  --inv-border: #e2e8f0;
  --inv-text: #334155;
  --inv-text-muted: #64748b;
  --inv-radius: 12px;
  --inv-radius-sm: 8px;
  --inv-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --inv-shadow-card: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
}

@page { size: A4; margin: 12mm; }
html, body { margin: 0; padding: 0; }

body.inv-print-body {
  width: 210mm;
  margin: 0 auto;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}

.invoice-page.inv-industrial {
  width: 210mm !important;
  max-width: 210mm;
  margin: 0 auto;
  padding: 10px 14px 12px !important;
  box-sizing: border-box;
  background: var(--inv-bg);
  color: var(--inv-text);
  border-radius: var(--inv-radius);
  overflow: hidden;
  box-shadow: var(--inv-shadow-card);
}

@media print {
  .invoice-page.inv-industrial {
    page-break-after: always;
  }
  .invoice-page.inv-industrial:last-of-type {
    page-break-after: auto;
  }
}

.inv-header-bar .inv-page-num-in-header {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.95;
  margin-top: 4px;
}

.inv-page-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--inv-bg);
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-sm);
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}

.inv-page-number-footer {
  text-align: center;
  font-size: 10px;
  color: var(--inv-text-muted);
  margin-top: 8px;
  padding-bottom: 8px;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}

section, table, .summary, .payment { page-break-inside: avoid; }

/* ——— Header ——— */
.inv-header-bar {
  background: linear-gradient(135deg, var(--inv-primary) 0%, var(--inv-primary-light) 100%);
  color: #fff;
  padding: 16px 20px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  border-radius: var(--inv-radius) var(--inv-radius) 0 0;
  margin-bottom: 16px;
}
.inv-header-bar .inv-logo-box {
  flex: 0 0 auto;
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--inv-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-sizing: border-box;
}
.inv-header-bar .inv-company-info {
  flex: 1 1 0;
  min-width: 140px;
  text-align: center;
}
.inv-header-bar .inv-invoice-meta {
  flex: 0 0 auto;
  min-width: 120px;
}
.inv-header-bar .inv-company-name {
  font-size: 28px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.98;
}
.inv-header-bar .inv-company-desc {
  font-size: 10px;
  opacity: 0.88;
  margin-top: 3px;
  line-height: 1.4;
}
.inv-header-bar .inv-invoice-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.inv-header-bar .inv-invoice-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.inv-header-bar .inv-invoice-no-box {
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.12);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', monospace;
  border-radius: var(--inv-radius-sm);
}
.inv-header-bar .inv-date {
  font-size: 11px;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
  opacity: 0.95;
}
.inv-accent-line { display: none; }

.inv-logo-box img {
  max-height: 56px;
  width: auto;
  object-fit: contain;
  display: block;
}
.dir-ltr { direction: ltr; }

/* ——— Section title ——— */
.inv-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--inv-text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--inv-border);
}

/* ——— Bill To / Project card ——— */
.inv-bill-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--inv-card);
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-sm);
  box-shadow: var(--inv-shadow);
}
.inv-bill-section .inv-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--inv-text-muted);
  margin-bottom: 5px;
}
.inv-bill-section .inv-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--inv-primary);
  line-height: 1.45;
}

/* ——— Table ——— */
.inv-table-wrap {
  width: 100%;
  margin-bottom: 16px;
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-sm);
  overflow: hidden;
  background: var(--inv-card);
  box-shadow: var(--inv-shadow);
}
.inv-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10px;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}
.inv-table-wrap thead th {
  background: var(--inv-primary);
  color: #fff;
  padding: 10px 12px;
  text-align: right;
  font-weight: 600;
  border: none;
  font-size: 10px;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}
.inv-table-wrap thead th:first-child { text-align: center; }
.inv-table-wrap tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--inv-border);
  background: var(--inv-card);
  line-height: 1.4;
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}
.inv-table-wrap tbody tr:nth-child(even) td {
  background: var(--inv-bg);
}
.inv-table-wrap tbody tr:last-child td { border-bottom: none; }
.inv-table-wrap .inv-num { text-align: right; font-family: 'Rabar_038', 'Inter', monospace; }
.inv-table-wrap .inv-total-cell { font-weight: 600; background: var(--inv-bg) !important; }

/* ——— Summary + Payment row ——— */
.inv-totals-row {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
@media (max-width: 400px) {
  .inv-totals-row { grid-template-columns: 1fr; }
}

.inv-summary-box.summary {
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-sm);
  overflow: hidden;
  background: var(--inv-card);
  box-shadow: var(--inv-shadow);
}
.inv-summary-box .inv-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--inv-border);
  font-size: 11px;
  background: var(--inv-card);
  font-family: 'Rabar_038', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}
.inv-summary-box .inv-summary-row:last-child { border-bottom: none; }
.inv-summary-box .inv-summary-values { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.inv-summary-box .inv-curr-iqd { font-weight: 700; color: #0d9488; white-space: nowrap; }
.inv-summary-box .inv-curr-usd { font-weight: 700; color: #1e40af; white-space: nowrap; }
.inv-summary-box .inv-curr-sep { color: var(--inv-text-muted); font-weight: 500; margin: 0 2px; }
.inv-summary-box .inv-grand-row .inv-curr-iqd { color: #99f6e4; }
.inv-summary-box .inv-grand-row .inv-curr-usd { color: #93c5fd; }
.inv-summary-box .inv-grand-row .inv-curr-sep { color: rgba(255,255,255,0.9); }
.inv-summary-box .inv-grand-row {
  background: linear-gradient(135deg, var(--inv-primary), var(--inv-primary-light)) !important;
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  padding: 10px 14px !important;
  border-left: 4px solid var(--inv-accent) !important;
}

.inv-payment-box.payment {
  margin-bottom: 0;
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-sm);
  overflow: hidden;
  background: var(--inv-card);
  box-shadow: var(--inv-shadow);
}
.inv-payment-box .inv-payment-head {
  background: var(--inv-primary);
  color: #fff;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
}
.inv-payment-box .inv-payment-body {
  padding: 10px 14px;
  background: var(--inv-bg);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 11px;
}
.inv-payment-box .inv-payment-item span:first-child {
  display: inline;
  font-size: 9px;
  font-weight: 600;
  color: var(--inv-text-muted);
  margin-left: 4px;
}
.inv-payment-box .inv-remaining-block {
  margin: 8px 14px 10px;
  padding: 8px 12px;
  background: var(--inv-card);
  border: 1px solid var(--inv-accent);
  border-radius: var(--inv-radius-sm);
  font-weight: 600;
  font-size: 12px;
}

/* ——— Signatures ——— */
.inv-signatures {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 18px;
  padding: 14px 0 8px;
  border-top: 1px solid var(--inv-border);
  gap: 20px;
}
.inv-signatures .inv-sig-block {
  text-align: center;
  min-width: 120px;
}
.inv-signatures .inv-sig-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--inv-text-muted);
  margin-bottom: 6px;
}
.inv-signatures .inv-sig-line {
  border-bottom: 2px dashed var(--inv-border);
  width: 100%;
  height: 28px;
}
.inv-signatures .inv-terms {
  font-size: 8px;
  color: var(--inv-text-muted);
  max-width: 200px;
  text-align: center;
  line-height: 1.5;
}

@media print {
  html, body { margin: 0; padding: 0; }
  body { background: #fff; }
  .no-print { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .invoice-page.inv-industrial {
    width: 210mm !important;
    max-width: 210mm !important;
    box-shadow: none !important;
    page-break-after: avoid;
    background: #fff !important;
  }
  .inv-header-bar {
    margin-left: 0;
    margin-right: 0;
    flex-wrap: nowrap;
    gap: 24px;
    padding: 14px 18px 16px;
  }
  .inv-header-bar .inv-logo-box { flex: 0 0 auto; min-width: 70px; }
  .inv-header-bar .inv-company-info { flex: 1 1 0; min-width: 160px; }
  .inv-header-bar .inv-invoice-meta { flex: 0 0 auto; min-width: 130px; }
  .inv-bill-section, .inv-table-wrap, .inv-summary-box, .inv-payment-box {
    box-shadow: none !important;
  }
  section, table, .summary, .payment { page-break-inside: avoid; }
  #printableArea, #printableArea * { visibility: visible; }
  #printableArea { position: relative !important; }
}
