/* ==========================================================================
   UPI Invoice Generator - Stylesheet
   Usetra Tools Design System
   ========================================================================== */

:root {
  --theme-color: #2563eb;
  --theme-color-dark: #1d4ed8;
  --theme-color-light: #eff6ff;
  --theme-color-border: #bfdbfe;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.12);
}

/* Base resets & layout */
.inv-app-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1rem 3rem 1rem;
}

/* Breadcrumb */
.inv-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.inv-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.inv-breadcrumb a:hover {
  color: var(--theme-color);
}
.inv-breadcrumb .separator {
  color: #cbd5e1;
}

/* Hero Header */
.inv-hero {
  text-align: center;
  margin-bottom: 2rem;
}
.inv-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: var(--theme-color-light);
  color: var(--theme-color);
  border: 1px solid var(--theme-color-border);
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.inv-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 0.75rem 0;
}
.inv-hero p {
  max-width: 720px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Toolbar Bar */
.inv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}
.inv-toolbar-left,
.inv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.inv-tool-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}
.inv-color-pickers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.inv-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border-color);
  transition: transform 0.15s;
}
.inv-color-dot:hover,
.inv-color-dot.active {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--text-main);
}
.inv-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.inv-btn-secondary:hover {
  background: #e2e8f0;
}
.inv-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.25rem;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
  transition: all 0.15s;
}
.inv-btn-primary:hover {
  background: #15803d;
  transform: translateY(-1px);
}

/* Studio Layout (Form vs Preview) */
.inv-studio-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(520px, 1.25fr);
  gap: 2rem;
  align-items: start;
}
@media (max-width: 1024px) {
  .inv-studio-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Panel */
.inv-form-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.inv-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.inv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.inv-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.inv-card-title .icon {
  font-size: 1.1rem;
}

/* Form Groups & Inputs */
.inv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.inv-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .inv-grid-2, .inv-grid-3 {
    grid-template-columns: 1fr;
  }
}
.inv-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.inv-field:last-child {
  margin-bottom: 0;
}
.inv-field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}
.inv-field label span.opt {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}
.inv-input, .inv-select, .inv-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.inv-input:focus, .inv-select:focus, .inv-textarea:focus {
  outline: none;
  border-color: var(--theme-color);
  box-shadow: 0 0 0 3px var(--theme-color-light);
}

/* Logo Upload Box */
.inv-logo-uploader {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-subtle);
  transition: all 0.15s;
  position: relative;
}
.inv-logo-uploader:hover {
  border-color: var(--theme-color);
  background: var(--theme-color-light);
}
.inv-logo-preview {
  max-height: 56px;
  max-width: 160px;
  object-fit: contain;
}
.inv-logo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 10px;
  cursor: pointer;
}

/* Line Items Table in Form */
.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.inv-items-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border-color);
}
.inv-items-table td {
  padding: 0.4rem;
  vertical-align: middle;
}
.inv-items-table .td-item { width: 44%; }
.inv-items-table .td-qty { width: 14%; }
.inv-items-table .td-rate { width: 18%; }
.inv-items-table .td-tax { width: 16%; }
.inv-items-table .td-del { width: 8%; text-align: center; }

.inv-btn-del-row {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 4px;
  font-size: 1rem;
  transition: background 0.15s;
}
.inv-btn-del-row:hover {
  background: #fee2e2;
}

.inv-btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  background: var(--theme-color-light);
  color: var(--theme-color);
  border: 1px dashed var(--theme-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.inv-btn-add-row:hover {
  background: var(--theme-color);
  color: #ffffff;
}

/* Payment & UPI Highlight Card */
.inv-card-upi {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}
.inv-upi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* ==========================================================================
   A4 Document Preview Canvas (Right Column & Print View)
   ========================================================================== */
.inv-preview-wrapper {
  position: sticky;
  top: 1.5rem;
}
.inv-paper-a4 {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  min-height: 840px;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1e293b;
  position: relative;
  box-sizing: border-box;
}

/* Invoice Header Top */
.a4-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px solid var(--theme-color);
}
.a4-brand {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.a4-logo-img {
  max-height: 52px;
  max-width: 180px;
  object-fit: contain;
}
.a4-business-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.a4-business-details {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-line;
}
.a4-invoice-meta {
  text-align: right;
}
.a4-invoice-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--theme-color);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.a4-meta-table {
  font-size: 0.8125rem;
  margin-left: auto;
}
.a4-meta-table td {
  padding: 0.15rem 0.5rem;
}
.a4-meta-table td.lbl {
  color: var(--text-muted);
  font-weight: 600;
}
.a4-meta-table td.val {
  font-weight: 700;
  color: var(--text-main);
}

/* Bill To / From Two-Column */
.a4-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}
.a4-party-block h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--theme-color);
  font-weight: 800;
  margin: 0 0 0.5rem 0;
}
.a4-party-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}
.a4-party-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-line;
}

/* Preview Items Table */
.a4-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}
.a4-table th {
  background: var(--theme-color);
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.65rem 0.85rem;
  letter-spacing: 0.02em;
}
.a4-table th:first-child {
  border-top-left-radius: 4px;
}
.a4-table th:last-child {
  border-top-right-radius: 4px;
}
.a4-table td {
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #e2e8f0;
  color: var(--text-main);
}
.a4-table tr:nth-child(even) td {
  background: #f8fafc;
}
.a4-table .t-num { text-align: right; }

/* Totals & QR Section Layout */
.a4-bottom-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1rem;
}

/* Dynamic UPI QR Card inside Invoice */
.a4-upi-card {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.a4-qr-canvas-holder {
  background: #ffffff;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.a4-qr-canvas-holder canvas {
  width: 100px;
  height: 100px;
  display: block;
}
.a4-upi-text {
  flex: 1;
}
.a4-upi-title {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.a4-upi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}
.a4-upi-id-pill {
  display: inline-block;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-family: monospace;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1e293b;
}

/* Bank Wire Box (Optional alternative) */
.a4-bank-details {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #cbd5e1;
}
.a4-bank-details strong {
  color: var(--text-main);
}

/* Totals Box */
.a4-totals-box {
  width: 100%;
}
.a4-totals-table {
  width: 100%;
  font-size: 0.875rem;
}
.a4-totals-table td {
  padding: 0.4rem 0.25rem;
}
.a4-totals-table .lbl {
  color: var(--text-muted);
  font-weight: 600;
}
.a4-totals-table .val {
  text-align: right;
  font-weight: 700;
  color: var(--text-main);
}
.a4-totals-table tr.grand-total td {
  border-top: 2px solid var(--theme-color);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--theme-color);
  padding-top: 0.65rem;
}

/* Amount in words banner */
.a4-amount-words {
  margin-top: 1rem;
  background: #f1f5f9;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: #334155;
  font-style: italic;
}
.a4-amount-words strong {
  font-style: normal;
  color: var(--text-main);
}

/* Notes & Signatory */
.a4-footer-row {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.a4-notes-block {
  max-width: 60%;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.a4-notes-block h5 {
  margin: 0 0 0.35rem 0;
  font-size: 0.75rem;
  color: var(--text-main);
  text-transform: uppercase;
  font-weight: 700;
}
.a4-sign-block {
  text-align: right;
}
.a4-sign-line {
  border-top: 1px solid #0f172a;
  width: 150px;
  margin-bottom: 0.35rem;
}
.a4-sign-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   Print Optimization (@media print)
   ========================================================================== */
@media print {
  /* Hide page header, hero, toolbar, form controls, footer, ads */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  header, nav, .inv-hero, .inv-toolbar, .inv-form-panel, [data-global-header], [data-global-footer], .inv-seo-section, .sm-toast {
    display: none !important;
  }
  .inv-app-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .inv-studio-grid {
    display: block !important;
  }
  .inv-preview-wrapper {
    position: static !important;
  }
  .inv-paper-a4 {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: auto !important;
    width: 100% !important;
  }
  @page {
    size: A4 portrait;
    margin: 12mm 15mm;
  }
}

/* SEO Educational Guide */
.inv-seo-section {
  max-width: 960px;
  margin: 4.5rem auto 0;
  border-top: 1px solid var(--border-color);
  padding-top: 3rem;
}
.inv-seo-section h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1rem;
}
.inv-seo-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.75rem 0 0.75rem;
}
.inv-seo-section p, .inv-seo-section li {
  color: #475569;
  font-size: 1rem;
  line-height: 1.7;
}

/* Feature comparison table */
.inv-comp-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.inv-comp-table th, .inv-comp-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9375rem;
}
.inv-comp-table th {
  background: var(--bg-subtle);
  font-weight: 700;
}
.inv-comp-table tr:last-child td {
  border-bottom: none;
}
.inv-check { color: #16a34a; font-weight: 700; }
.inv-cross { color: #dc2626; font-weight: 700; }

/* FAQ Accordion */
.inv-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.inv-faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}
.inv-faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: left;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inv-faq-question .arrow {
  transition: transform 0.2s;
}
.inv-faq-item.open .inv-faq-question .arrow {
  transform: rotate(180deg);
}
.inv-faq-answer {
  padding: 0 1.25rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  display: none;
}
.inv-faq-item.open .inv-faq-answer {
  display: block;
}
