/* ==========================================================================
   OSF Tax Invoice - Authentic Tally Multi-Copy Print & PDF Engine
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.invoice-sheet-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 25px;
  margin: 0 auto;
  width: 100%;
}

.invoice-sheet {
  width: 210mm;
  max-width: 210mm;
  min-height: 285mm;
  background: #ffffff;
  padding: 6mm 8mm;
  color: #000000;
  box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  margin: 0 auto;
  position: relative;
}

/* Master Outer Border Table */
.inv-outer-table {
  width: 100%;
  border: 1.5px solid #000000;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
}

.inv-outer-table > tbody > tr > td, 
.inv-outer-table > tr > td {
  border: 1px solid #000000;
  padding: 3px 5px;
  vertical-align: top;
  background: #ffffff;
}

/* Copy Type Header Banner */
.inv-top-copy {
  text-align: right;
  font-size: 10.5px;
  font-weight: 900;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inv-top-badge {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* Company Branding Header (Balanced 3-Column Center) */
.inv-company-name {
  font-size: 19px;
  font-weight: 900;
  color: #000000;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  text-align: center;
}

.inv-company-tagline {
  font-size: 10px;
  font-weight: 700;
  color: #000000;
  margin-bottom: 2px;
  text-align: center;
}

.inv-company-details {
  font-size: 10px;
  line-height: 1.35;
  color: #000000;
  text-align: center;
}

.inv-logo-large {
  max-height: 72px;
  max-width: 135px;
  object-fit: contain;
  display: block;
}

.inv-bold {
  font-weight: bold;
}

.inv-meta-label {
  font-size: 10.5px;
  line-height: 1.35;
}

/* ==========================================================================
   TALLY ITEMS ROWS (ZERO HORIZONTAL INNER LINES & 100% UNIFIED ALIGNMENT)
   ========================================================================== */
.inv-item-header-th {
  background-color: #f2f2f2 !important;
  font-size: 9.5px;
  font-weight: bold;
  text-align: center;
  padding: 4px 2px;
  border-top: 1px solid #000000 !important;
  border-bottom: 1px solid #000000 !important;
  border-left: 1px solid #000000 !important;
  border-right: 1px solid #000000 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.inv-tally-item-row td {
  border-top: none !important;
  border-bottom: none !important;
  border-left: 1px solid #000000 !important;
  border-right: 1px solid #000000 !important;
  padding: 2.5px 4px !important;
  font-size: 10px;
  vertical-align: top;
  background: #ffffff !important;
}

.inv-tally-filler-row td {
  border-top: none !important;
  border-bottom: none !important;
  border-left: 1px solid #000000 !important;
  border-right: 1px solid #000000 !important;
  padding: 0 !important;
  height: 82mm; /* Proportional full A4 page fit */
  background: #ffffff !important;
}

.inv-items-total-row td {
  border-top: 1.5px solid #000000 !important;
  border-bottom: 1px solid #000000 !important;
  border-left: 1px solid #000000 !important;
  border-right: 1px solid #000000 !important;
  font-weight: bold;
  background-color: #fafafa !important;
  padding: 4px !important;
  font-size: 10.5px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Helpers */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* Tax and Bank Summary Area */
.inv-bank-section {
  font-size: 9.5px;
  line-height: 1.35;
}

.inv-tc-section {
  font-size: 8.5px;
  line-height: 1.25;
}

.inv-tc-section ol {
  padding-left: 14px;
  margin: 2px 0;
}

/* ==========================================================================
   PRINT MEDIA QUERY - MULTI-PAGE ORIGINAL / DUPLICATE / TRIPLICATE
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 5mm;
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 1. HIDE ALL SIBLINGS OF APP CONTAINER */
  body > *:not(.app-container) {
    display: none !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  .app-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  /* 2. HIDE HEADER, NAVIGATION AND NON-BUILDER VIEWS */
  .top-header,
  .app-container > nav,
  #invoiceHistoryView,
  #clientsMasterView,
  #productsMasterView,
  #settingsView,
  #toastContainer,
  .no-print {
    display: none !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  /* 3. INSIDE INVOICE BUILDER VIEW: HIDE ALL FORM CARDS AND GRIDS */
  #invoiceBuilderView {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #invoiceBuilderView > .card:not(#inlinePreviewCard),
  #invoiceBuilderView > .grid-2,
  #invoiceBuilderView > .grid-3,
  #invoiceBuilderView > .grid-4 {
    display: none !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  /* 4. SHOW ONLY THE INLINE PREVIEW CARD */
  #inlinePreviewCard {
    display: block !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #inlinePreviewCard > .card-header {
    display: none !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  #inlinePreviewCard > div:last-child {
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .invoice-sheet-container {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* INDIVIDUAL INVOICE PAGE SHEETS (PAGE BREAK BETWEEN SHEETS) */
  .invoice-sheet {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    margin: 0 0 0 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Page break after each sheet except the last one */
  .invoice-sheet:not(:last-child) {
    page-break-after: always !important;
    break-after: page !important;
  }

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

  .inv-outer-table {
    width: 100% !important;
    border: 1.5px solid #000000 !important;
    page-break-inside: avoid !important;
  }
}

/* ==========================================================================
   Tally Prime Style Digital Signature & DSC Stamp
   ========================================================================== */
.tally-dsc-container {
  display: inline-block;
  text-align: left;
  width: 100%;
  max-width: 190px;
  border: 1px solid #16a34a;
  background-color: #f0fdf4;
  padding: 3px 5px;
  border-radius: 3px;
  box-sizing: border-box;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  margin: 1px auto;
}

.tally-dsc-header {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 8.5px;
  font-weight: 800;
  color: #15803d;
  border-bottom: 0.5px solid #86efac;
  padding-bottom: 1px;
  margin-bottom: 2px;
}

.tally-dsc-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  background: #16a34a;
  color: #ffffff;
  border-radius: 50%;
  font-size: 7.5px;
  font-weight: 900;
  line-height: 1;
}

.tally-dsc-info {
  font-size: 7.5px;
  line-height: 1.2;
  color: #14532d;
}

.tally-dsc-info .lbl {
  font-weight: 700;
  color: #0f172a;
}

.tally-dsc-sign-img {
  max-height: 36px;
  max-width: 110px;
  object-fit: contain;
  margin: 1px auto;
  display: block;
}

