/**
 * MYARTLAB STUDIO - TAX INVOICE & PRINT STYLESHEET
 * Strict GST Tax Invoice formatting, A4 print layout, and high-definition
 * preview modal adhering to Emil Kowalski design engineering principles.
 */

/* ==========================================================================
   1. On-Screen Invoice Preview Modal
   ========================================================================== */

#invoice-preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
  padding: 32px 16px;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  transition: opacity 180ms ease-out;
}

#invoice-preview-modal.open {
  display: flex;
  opacity: 1;
}

.invoice-modal-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(12px) scale(0.99);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

#invoice-preview-modal.open .invoice-modal-container {
  transform: translateY(0) scale(1);
}

.invoice-preview-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0d121c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.invoice-preview-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.invoice-preview-title svg {
  color: #00f0ff;
}

.invoice-preview-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #060a10;
  background: #00f0ff;
  border: 1px solid #00f0ff;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 120ms ease, background-color 150ms ease, box-shadow 150ms ease;
  min-height: 40px;
}

.invoice-btn-primary:hover {
  background: #00d0df;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.invoice-btn-primary:active {
  transform: scale(0.97);
}

.invoice-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  min-height: 40px;
}

.invoice-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   2. Pristine A4 Document Paper Styles (Screen Mockup)
   ========================================================================== */

.invoice-paper-sheet {
  background: #ffffff;
  color: #0f172a;
  border-radius: 8px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 44px 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  box-sizing: border-box;
}

/* Tabular numbers for all monetary and quantitative figures */
.invoice-paper-sheet table,
.invoice-paper-sheet .tabular-nums,
.invoice-meta-value,
.invoice-total-amount {
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum" 1;
  font-feature-settings: "tnum" 1;
}

/* Header Section */
.inv-header-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid #0f172a;
}

.inv-brand-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.inv-brand-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inv-brand-mark img {
  width: 100%;
  height: auto;
}

.inv-brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.inv-brand-name span {
  color: #0284c7;
  font-weight: 600;
  font-size: 16px;
  margin-left: 4px;
}

.inv-seller-address {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.45;
  max-width: 380px;
}

.inv-seller-tax-info {
  margin-top: 6px;
  font-size: 11px;
  color: #334155;
  line-height: 1.5;
}

.inv-seller-tax-info strong {
  color: #0f172a;
}

/* Title & Badge */
.inv-title-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
}

.inv-doc-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #0f172a;
  margin: 0;
  line-height: 1.1;
  text-transform: uppercase;
}

.inv-doc-subtitle {
  font-size: 10.5px;
  font-weight: 700;
  color: #0284c7;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

.inv-doc-original {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #334155;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Meta Data 4-Column Bar */
.inv-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.inv-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inv-meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

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

/* Parties Grid (Bill To / Ship To) */
.inv-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.inv-party-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px 14px;
  background: #ffffff;
}

.inv-party-header {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0284c7;
  margin-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

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

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

/* Table of Items */
.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.inv-items-table th {
  background: #0f172a;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  text-align: left;
}

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

.inv-items-table td {
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  color: #1e293b;
  vertical-align: top;
}

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

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

.inv-item-sub {
  font-size: 11px;
  color: #64748b;
}

/* Bottom Calculation & Summary Grid */
.inv-bottom-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  margin-top: 10px;
}

.inv-words-block {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.inv-words-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.inv-words-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 4px;
}

.inv-words-val {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}

.inv-terms-box {
  font-size: 10px;
  color: #64748b;
  line-height: 1.5;
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
}

.inv-terms-title {
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

/* Totals Summary Column */
.inv-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.inv-summary-table td {
  padding: 5px 8px;
  font-size: 12px;
  color: #334155;
}

.inv-summary-table td.sum-label {
  text-align: left;
}

.inv-summary-table td.sum-val {
  text-align: right;
  font-weight: 600;
  color: #0f172a;
}

.inv-summary-table tr.total-row td {
  padding: 10px 8px;
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  background: #f1f5f9;
}

/* Signatory & Verification Block */
.inv-sign-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.inv-qr-verify {
  display: flex;
  align-items: center;
  gap: 14px;
}

.inv-qr-box {
  width: 64px;
  height: 64px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inv-qr-box svg {
  width: 100%;
  height: 100%;
}

.inv-verify-text {
  font-size: 10.5px;
  color: #64748b;
  line-height: 1.45;
}

.inv-verify-text strong {
  color: #0f172a;
}

.inv-sign-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
}

.inv-sign-company {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 30px;
}

.inv-sign-seal {
  display: inline-block;
  padding: 2px 8px;
  border: 1px dashed #94a3b8;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  color: #0284c7;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.inv-sign-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  border-top: 1px solid #94a3b8;
  padding-top: 4px;
  min-width: 150px;
  text-align: center;
}

/* ==========================================================================
   3. Strict @media print CSS Isolation
   ========================================================================== */

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 11pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide all main website layout elements */
  body > *:not(#invoice-preview-modal):not(#shipping-slip-preview-modal) {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  .site-header,
  .site-footer,
  .floating-admin-toggle,
  .admin-top-bar,
  #track-form,
  #track-results-area,
  #cart-drawer,
  #cart-backdrop,
  .auth-modal,
  .product-modal,
  .policy-modal,
  .invoice-preview-actions-bar {
    display: none !important;
    visibility: hidden !important;
  }

  /* Unveil only the modal container and sheet */
  #invoice-preview-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    opacity: 1 !important;
    width: 100% !important;
  }

  .invoice-modal-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  .invoice-paper-sheet {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .inv-items-table th {
    background: #0f172a !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
  }

  .inv-items-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
  }

  .inv-summary-table tr.total-row td {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
  }

  .inv-meta-grid,
  .inv-words-box,
  .inv-party-card {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    -webkit-print-color-adjust: exact !important;
  }

  /* Shiprocket Shipping Slip Print Rules */
  #shipping-slip-preview-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    opacity: 1 !important;
    width: 100% !important;
  }

  #shipping-slip-preview-modal .om-dialog-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 auto !important;
  }

  #shipping-slip-preview-modal .om-dialog-card > div:first-child,
  #shipping-slip-preview-modal .om-dialog-card > div:nth-child(2) {
    display: none !important;
  }

  #slip-preview-body {
    background: #ffffff !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .shipping-slip-container {
    box-shadow: none !important;
    border: 2px solid #000000 !important;
    margin: 0 auto !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .shipping-slip-container.slip-format-3x5 {
    width: 3in !important;
    max-width: 3in !important;
  }

  .shipping-slip-container.slip-format-4x6 {
    width: 4in !important;
    max-width: 4in !important;
  }
}