/* ==========================================================================
   A4 Document Print & Vector Rendering Styles
   ========================================================================== */

.invoice-doc {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #1e293b;
  line-height: 1.5;
  font-size: 13px;
}

.invoice-doc * {
  box-sizing: border-box;
}

/* Header Grid */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.inv-brand-col {
  max-width: 55%;
}

.inv-logo-img {
  max-height: 46px;
  max-width: 220px;
  margin-bottom: 6px;
  object-fit: contain;
}

.inv-company-details {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

.inv-title-col {
  text-align: right;
  max-width: 40%;
}

.inv-doc-type {
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.inv-badge-status {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.status-issued { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.status-paid { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.status-draft { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.status-overdue { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  text-align: right;
  font-size: 11.5px;
}

.inv-meta-label {
  font-weight: 600;
  color: #64748b;
}

.inv-meta-value {
  font-weight: 700;
  color: #0f172a;
}

/* Parties / Bill To Section */
.inv-parties {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 14px;
}

.inv-party-box {
  flex: 1;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
}

.inv-party-heading {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #d97706;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.inv-party-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 3px;
}

.inv-party-text {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.4;
}

/* Items Table */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 11.5px;
}

.inv-table th {
  background-color: #0f172a;
  color: #ffffff;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}

.inv-table th.text-right, .inv-table td.text-right {
  text-align: right;
}

.inv-table th.text-center, .inv-table td.text-center {
  text-align: center;
}

.inv-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.inv-table tr:nth-child(even) td {
  background-color: #f8fafc;
}

.inv-item-name {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.inv-item-desc {
  font-size: 10.5px;
  color: #64748b;
  line-height: 1.35;
  white-space: pre-line;
}

/* Totals Area */
.inv-bottom-section {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.inv-payment-col {
  flex: 1.2;
}

.inv-payment-box {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  background-color: #f8fafc;
}

.inv-payment-title {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: #0f172a;
  margin-bottom: 6px;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 3px;
}

.inv-bank-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 1.5px 0;
}

.inv-bank-label {
  color: #64748b;
  font-weight: 600;
}

.inv-bank-value {
  color: #0f172a;
  font-weight: 700;
  font-family: monospace;
}

.inv-totals-col {
  flex: 1;
}

.inv-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.inv-totals-table td {
  padding: 3.5px 0;
  font-size: 11.5px;
}

.inv-totals-table .total-label {
  color: #64748b;
  font-weight: 600;
}

.inv-totals-table .total-val {
  text-align: right;
  color: #0f172a;
  font-weight: 700;
}

.inv-grand-total-row td {
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  padding: 6px 0;
}

.inv-grand-total-row .total-label {
  font-size: 13.5px;
  font-weight: 900;
  color: #0f172a;
  text-transform: uppercase;
}

.inv-grand-total-row .total-val {
  font-size: 18px;
  font-weight: 900;
  color: #d97706;
}

/* Footer Section */
.inv-footer {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: #94a3b8;
}

.inv-footer-legal {
  line-height: 1.4;
}

.inv-footer-page {
  font-weight: 700;
}

/* Continuation Header for Page 2+ */
.inv-continuation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #cbd5e1;
  margin-bottom: 12px;
}

.inv-continuation-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inv-continuation-logo {
  height: 30px;
  width: auto;
}

.inv-continuation-meta {
  text-align: right;
}

.inv-continuation-badge {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.inv-continuation-table-header {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* @media print for exact A4 physical paper / save-to-pdf */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  
  .app-navbar, .editor-pane, .preview-toolbar, .mobile-view-tabs, .preview-bottom-dock, .page-badge-corner, .page-break-divider, .btn-page-mode, .page-mode-group {
    display: none !important;
  }
  
  .workbench-container {
    display: block !important;
    height: auto !important;
  }
  
  .preview-pane {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  
  .preview-stage {
    position: static !important;
    width: auto !important;
    height: auto !important;
    transform: none !important;
    margin: 0 !important;
  }

  .a4-pages-container {
    position: static !important;
    transform: none !important;
    display: block !important;
    width: 100% !important;
    gap: 0 !important;
  }

  .a4-sheet {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 12mm 15mm !important;
    width: 100% !important;
    height: 297mm !important;
    min-height: 297mm !important;
    box-sizing: border-box !important;
    page-break-after: always !important;
    break-after: page !important;
    overflow: hidden !important;
  }

  .a4-sheet:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .inv-header { break-inside: avoid; page-break-inside: avoid; }
  .inv-parties { break-inside: avoid; page-break-inside: avoid; }
  .inv-table tr { break-inside: avoid; page-break-inside: avoid; }
  .inv-bottom-section { break-inside: avoid; page-break-inside: avoid; }
  .inv-footer { break-inside: avoid; page-break-inside: avoid; }
  
  .invoice-doc [contenteditable="true"] {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }
  
  @page {
    size: A4 portrait;
    margin: 0;
  }
}
