/* ══════════════════════════════════════════════════════════
   InvoiceFlow — invoice-fields.css
   Styles for extended invoice fields:
   · Invoice Meta Section
   · Notes & Terms Section
   · Payment Details (right column)
   Load AFTER: style.css → inventory.css → responsive.css
══════════════════════════════════════════════════════════ */


/* ── Radio Group (Branch Type) ──────────────────────────── */
.radio-group {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 42px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--ink-mid);
  cursor: pointer;
  user-select: none;
  font-family: 'DM Sans', sans-serif;
}

.radio-option input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: unset !important;   /* override responsive.css global */
  font-size: unset !important;    /* override responsive.css global */
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}


/* ── Payment Details (right column) ─────────────────────── */
.right-payment-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rpd-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Compact inputs inside Payment Details */
.rpd-input {
  padding: 8px 10px !important;
  font-size: 13.5px !important;
}

/* Form groups inside payment details — tighter */
.right-payment-details .form-group {
  gap: 4px;
}

.right-payment-details .form-label {
  font-size: 10.5px;
  letter-spacing: 0.07em;
}


/* ── Notes Section ───────────────────────────────────────── */
#notesSection .form-textarea {
  min-height: 60px;
  resize: vertical;
}

#notesSection .form-label {
  font-size: 10.5px;
}


/* ── Invoice Meta Section ────────────────────────────────── */
#invoiceMetaSection select.form-input {
  cursor: pointer;
}

#invoiceMetaSection .form-label {
  font-size: 10.5px;
}


/* ── Responsive ──────────────────────────────────────────── */

/* On tablet (≤ 992px) right column is full width — stack payment details */
@media (max-width: 992px) {
  .right-payment-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: start;
  }

  .rpd-title { grid-column: 1 / -1; }

  .right-payment-details .form-group { gap: 4px; }
}

@media (max-width: 576px) {
  .right-payment-details {
    grid-template-columns: 1fr;
  }

  .radio-group { gap: 14px; }
  .radio-option { font-size: 13.5px; }

  .rpd-input { font-size: 15px !important; }
}


/* ── PDF Preview Modal ───────────────────────────────────── */

/* Wider modal for PDF viewing */
.modal-box--preview {
  max-width: 900px;
  width: 95vw;
  height: 90vh;
  max-height: 90vh;
}

/* Body fills remaining height so iframe can expand */
.pdf-preview-body {
  padding: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* iframe fills the entire modal body */
#pdfPreviewFrame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: #f4f4f4;
}

/* Action row in modal header (Download + Close) */
.pdf-preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Download button inside preview header */
.btn-preview-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-preview-dl:hover {
  background: var(--accent);
  color: #fff;
}

/* Responsive: full-screen modal on mobile */
@media (max-width: 600px) {
  .modal-box--preview {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  #pdfPreviewFrame {
    border-radius: 0;
  }

  .btn-preview-dl {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ══════════════════════════════════════════════════════════
   ↓↓↓  MERGED FROM: vat-toggle.css  ↓↓↓
   VAT TOGGLE — Load AFTER invoice-fields.css
══════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════
   VAT TOGGLE — vat-toggle.css
   Load AFTER invoice-fields.css
══════════════════════════════════════════════════════════ */


/* ── Visibility Control ─────────────────────────────────── */
body.no-vat-mode .vat-only-field {
  display: none !important;
}

body.no-vat-mode .item-row .item-vat {
  display: none !important;
}

/*
  GRID FIX — Remove phantom VAT column slot when VAT is off.
  Uses CSS variable override so invoice-ui-upgrade.css stays in sync.

  Original 7-col: 2fr  0.55fr  0.75fr  0.9fr  [0.7fr]  1fr  34px
  Non-VAT 6-col:  2fr  0.55fr  0.75fr  0.9fr            1fr  34px
  
  Both .item-row AND .items-header must use the same template
  so headers stay perfectly aligned with inputs below.
*/
body.no-vat-mode {
  --inv-cols: 2fr 0.55fr 0.75fr 0.9fr 1fr 34px;
}

body.no-vat-mode .item-row,
body.no-vat-mode .items-header {
  grid-template-columns: var(--inv-cols) !important;
}


/* ── Toggle Wrapper ─────────────────────────────────────── */
.vat-mode-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── Label ──────────────────────────────────────────────── */
.vat-mode-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  min-width: 96px;
  letter-spacing: 0.02em;
  transition: color 0.2s, opacity 0.2s;
}

body.no-vat-mode .vat-mode-label {
  color: rgba(255, 255, 255, 0.55);
}


/* ── Switch Shell ────────────────────────────────────────── */
.vat-toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.vat-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* ── Track ───────────────────────────────────────────────── */
.vat-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 26px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: background 0.25s, border-color 0.25s;
}

.vat-toggle-switch input:checked + .vat-slider {
  background: #22c55e;
  border-color: #16a34a;
}

/* ── Thumb ───────────────────────────────────────────────── */
.vat-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
}

.vat-toggle-switch input:checked + .vat-slider::before {
  transform: translateX(20px);
}

.vat-toggle-switch input:focus-visible + .vat-slider {
  outline: 2px solid #22c55e;
  outline-offset: 2px;
}


/* ── Non-VAT: Row Total — clean, subtle, no heavy border ── */
body.no-vat-mode .item-subtotal {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--accent, #7c5cbf) !important;
  background: rgba(28, 53, 87, 0.05) !important;  /* same as default style */
  border: none !important;                          /* remove thick border  */
  border-radius: var(--radius-sm, 6px) !important;
  padding: 8px 10px !important;
  text-align: right !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  box-sizing: border-box;
}

/* ── Non-VAT: ROW TOTAL header accent ───────────────────── */
body.no-vat-mode .col-subtotal {
  color: var(--accent, #7c5cbf) !important;
  font-weight: 700 !important;
}

/* ── Non-VAT: Subtle row bg ─────────────────────────────── */
body.no-vat-mode .item-row {
  background: #fafafa;
}


/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  /* On mobile, no-vat mode still uses horizontal scroll — no column override needed */
  body.no-vat-mode .item-row,
  body.no-vat-mode .items-header {
    grid-template-columns: var(--inv-cols) !important;
  }
}

@media (max-width: 480px) {
  .vat-mode-toggle-wrap { gap: 7px; padding: 3px 8px 3px 5px; }
  .vat-mode-label       { font-size: 11px; min-width: 82px; }
  .vat-toggle-switch    { width: 40px; height: 22px; }
  .vat-slider::before   { width: 15px; height: 15px; }
  .vat-toggle-switch input:checked + .vat-slider::before { transform: translateX(17px); }
}

/* ── History Table: VAT Mode Badge ──────────────────────── */
.vat-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  line-height: 1.5;
}

.vat-badge--vat {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.vat-badge--nonvat {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

/* ── Responsive: hide VAT Mode column on very small screens */
@media (max-width: 576px) {
  .col-vat-mode {
    display: none !important;
  }
}


/* ── History Table: Mobile No Column ────────────────────── */
.col-mobile {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mid, #555);
  font-size: 13px;
}

/* Hide on small screens to prevent overflow */
@media (max-width: 768px) {
  .col-mobile {
    display: none !important;
  }
}
/* ══════════════════════════════════════════════════════════
   NON-VAT MODE — Mobile card layout fix (≤ 540px)
   vat-toggle ka grid override card layout ko tod deta tha
══════════════════════════════════════════════════════════ */
@media (max-width: 540px) {
  /* Card layout mein non-vat grid override cancel karo */
  body.no-vat-mode .item-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    background: var(--surface) !important;
    border: 1.5px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 12px !important;
  }

  /* VAT field — already hidden, but also hide its wrapper */
  body.no-vat-mode .item-field--vat {
    display: none !important;
  }

  /* Non-vat item-subtotal — same card style */
  body.no-vat-mode .item-subtotal {
    font-size: 16px !important;
    font-weight: 700 !important;
    text-align: right !important;
    padding: 8px 12px !important;
    background: rgba(28,53,87,0.07) !important;
    border-radius: 6px !important;
    border: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
}


/* ══════════════════════════════════════════════════════════
   INVOICE TYPE SUB-NAVIGATION
   Transparent strip — aligns with .create-layout (max 1200px).
   Both groups use identical segmented pill style.
   No full-width background. No iOS slider. No divider character.
══════════════════════════════════════════════════════════ */

/* ── Outer container — transparent, content-width ────────── */
.invoice-subnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px 10px;
  background: transparent;
  border: none;
  box-shadow: none;
  box-sizing: border-box;
}

/* ── Each group: label + pill strip ─────────────────────── */
.invoice-subnav-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Tiny uppercase group label ─────────────────────────── */
.inv-seg-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-light, #94a3b8);
  white-space: nowrap;
  user-select: none;
}

/* ══════════════════════════════════════════════════════════
   SHARED SEGMENTED PILL CONTAINER + BUTTONS
══════════════════════════════════════════════════════════ */

.inv-seg-pills {
  display: inline-flex;
  align-items: center;
  background: var(--surface, #f1f5f9);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.inv-seg-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-light, #64748b);
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.01em;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.inv-seg-pill:hover:not(.active) {
  background: rgba(28, 53, 87, 0.07);
  color: var(--ink, #1e293b);
}

.inv-seg-pill:focus-visible {
  outline: 2px solid var(--accent, #1C3557);
  outline-offset: 1px;
}

/* ══════════════════════════════════════════════════════════
   ACTIVE COLORS — distinct per pill identity
══════════════════════════════════════════════════════════ */

/* VAT → Deep Navy + Gold text */
.inv-seg-pill--vat.active {
  background: linear-gradient(135deg, #1C3557 0%, #0f2240 100%);
  color: var(--gold-light, #F0D080);
  box-shadow: 0 1px 6px rgba(15, 34, 64, 0.28);
}

/* Non-VAT → Neutral slate */
.inv-seg-pill--novat.active {
  background: #475569;
  color: #f1f5f9;
  box-shadow: 0 1px 5px rgba(71, 85, 105, 0.28);
}

/* Sales → Warm gold */
.inv-seg-pill--sales.active {
  background: linear-gradient(135deg, #b8882e 0%, #d4a84b 100%);
  color: #ffffff;
  box-shadow: 0 1px 6px rgba(184, 136, 46, 0.32);
}

/* Purchase → Royal blue */
.inv-seg-pill--purchase.active {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 1px 6px rgba(37, 99, 235, 0.28);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .invoice-subnav {
    padding: 10px 20px 8px;
    gap: 6px 18px;
  }
}

@media (max-width: 640px) {
  .invoice-subnav {
    padding: 8px 14px 6px;
    gap: 8px 12px;
  }
  .inv-seg-pill {
    padding: 0 12px;
    font-size: 12px;
    height: 28px;
  }
  .inv-seg-label {
    display: none;
  }
}

@media (max-width: 480px) {
  .invoice-subnav {
    padding: 8px 12px 6px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .invoice-subnav-group {
    width: 100%;
  }
  .inv-seg-pills {
    flex: 1;
  }
  .inv-seg-pill {
    flex: 1;
    justify-content: center;
  }
}