/* ============================
   BASE
============================ */

body {
  background: #f8fafc;
}

/* ============================
   INVOICE CONTAINER
============================ */

.invoice {
  background: #ffffff;
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  max-width: 840px;
  margin: 0 auto;
  font-size: 14px;
  color: #111827;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.invoice h2 {
  text-align: center;
  margin: 16px 0 20px;
  letter-spacing: 1px;
}

/* ============================
   INVOICE META (Seller / Buyer / Invoice)
============================ */

.invoice-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
}

.invoice-meta strong {
  color: #0f172a;
}

/* ============================
   INVOICE TABLE
============================ */

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.invoice-table th {
  background: #f8fafc;
  font-weight: 600;
  border: 1px solid #cbd5f5;
  padding: 8px;
  text-align: center !important;
  vertical-align: middle;
}

.invoice-table td {
  border: 1px solid #e5e7eb;
  padding: 8px;
}

/* ---- Column alignment ---- */

/* S.No */
.invoice-table th:nth-child(1),
.invoice-table td:nth-child(1) {
  text-align: center;
}

/* Description + HSN */
.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2),
.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3) {
  text-align: left;
}

/* Qty, Rate, Amount */
.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4),
.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5),
.invoice-table th:last-child,
.invoice-table td:last-child {
  text-align: right;
}

/* GST % (per-item mode) */
.invoice-table th:nth-child(6) {
  text-align: center;
}

.invoice-table td:nth-child(6) {
  text-align: right;
}

/* GST Amount */
.invoice-table th:nth-child(7),
.invoice-table td:nth-child(7) {
  text-align: right;
}

/* ============================
   ITEM INPUT TABLE (TOP)
============================ */

#itemTable input.qty {
  min-width: 90px;
  text-align: right;
  padding-right: 8px;
}

#itemTable input.rate {
  min-width: 90px;
  text-align: right;
}

/* GST column toggle */
.gst-col {
  display: none;
}

.per-item .gst-col {
  display: table-cell;
}

/* ============================
   SUMMARY
============================ */

.invoice-summary {
  margin-top: 16px;
  text-align: right;
  font-size: 14px;
}

.invoice-summary strong {
  font-size: 15px;
}

.invoice-summary .text-muted {
  font-style: italic;
}

/* ============================
   SUMMARY ALIGNMENT (LABEL : VALUE)
============================ */

.invoice-summary {
  margin-top: 16px;
  font-size: 14px;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 12px;
  justify-content: end;
}

.invoice-summary > div,
.invoice-summary > strong {
  display: contents;
}

.invoice-summary .label {
  text-align: right;
  white-space: nowrap;
}

.invoice-summary .value {
  text-align: right;
  font-weight: 600;
}


/* ============================
   DISCLAIMER
============================ */

.invoice-disclaimer {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.4;
}

/* ============================
   FOOTER
============================ */

.invoice-footer {
  margin-top: 32px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  color: #475569;
}

/* ============================
   TOOL UI
============================ */

.tool-panel {
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.section-title {
  font-weight: 700;
  font-size: 1.25rem;
}

.section-subtitle {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}

#addItem {
  border-radius: 10px;
}

/* ============================
   MOBILE
============================ */

@media (max-width: 768px) {

  .invoice {
    padding: 18px;
  }

  .invoice-meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .invoice-table th,
  .invoice-table td {
    font-size: 12px;
    padding: 6px;
  }

  .tool-panel {
    padding: 16px !important;
  }

  .btn {
    width: 100%;
  }

  .ad-inner {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
}

/* ============================
   PRINT
============================ */

@page {
  size: A4;
  margin: 12mm;
}



.invoice-bank {
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}

.invoice-qr {
  text-align: center;
}

.qr-text {
  font-size: 11px;
  margin-top: 4px;
  word-break: break-all;
}

.qr-sub {
  font-size: 11px;
  color: #6b7280;
}

.invoice-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 32px;
}

.invoice-bank {
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}

.invoice-qr {
  text-align: center;
}

.qr-text {
  font-size: 11px;
  margin-top: 4px;
  word-break: break-all;
}

.qr-sub {
  font-size: 11px;
  color: #6b7280;
}


/* ============================
   PRINT — MATCH WEBSITE STYLE
============================ */
@media print {

  @page {
    size: A4;
    margin: 14mm;
  }

  body {
    background: #fff;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide website UI */
  header,
  footer,
  nav,
  .intro-wrap,
  .ad-card,
  button {
    display: none !important;
  }

  /* Show invoice */
  #invoicePreview {
    display: block;
    width: 100%;
  }

  /* Keep SAME invoice look as screen */
  .invoice {
    background: #ffffff;
    border: 1px solid #e5e7eb;     /* same as screen */
    border-radius: 14px;           /* same as screen */
    box-shadow: none;              /* printers don’t like shadows */
    padding: 28px;
    color: #111827;
    font-size: 14px;
  }

  /* Tables — same colors as screen */
  .invoice-table th {
    background: #f8fafc;
    border: 1px solid #cbd5f5;
    font-weight: 600;
  }

  .invoice-table td {
    border: 1px solid #e5e7eb;
  }

  /* Summary emphasis (keep modern look) */
  .invoice-summary strong {
    font-size: 15px;
  }

  /* QR size consistency */
  .invoice-qr img {
    width: 120px;
    height: 120px;
  }

  /* Avoid page breaks inside invoice */
  table,
  tr,
  td,
  th {
    page-break-inside: avoid;
  }
  
  .invoice {
    border-width: 1.2px;
  }

  .invoice h2 {
    letter-spacing: 1.2px;
  }
}


.invoice-header {
  border-bottom: 2px solid #000;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.invoice-summary strong {
  font-size: 15px;
  border-top: 2px solid #000;
  padding-top: 6px;
  display: inline-block;
}

 

.invoice-bottom-block {
  page-break-inside: avoid;
  break-inside: avoid;
}
