/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #e85d04;
  --primary-d: #c94e00;
  --dark:      #1a1a2e;
  --dark2:     #16213e;
  --text:      #333;
  --muted:     #666;
  --border:    #ddd;
  --bg:        #f7f8fa;
  --card:      #ffffff;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);

  /* brand colours */
  --hp-red:   #ee2e24;
  --hp-green: #007a3d;
  --bp-blue:  #003b8e;
  --bp-gold:  #f9a11b;
  --ioc-blue: #1a3f7a;
  --ioc-red:  #e31837;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
a { color: inherit; text-decoration: none; }

/* ─── Top Bar ───────────────────────────────────────────────── */
.topbar {
  background: var(--dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; }
.logo-icon { font-size: 22px; }
.logo-accent { color: var(--primary); }
.main-nav { display: flex; gap: 28px; }
.main-nav a { color: #ccc; font-size: 14px; font-weight: 500; transition: color .2s; }
.main-nav a:hover { color: #fff; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }

/* ─── Shortcuts ─────────────────────────────────────────────── */
.shortcuts-bar { background: var(--dark2); border-bottom: 2px solid var(--primary); }
.shortcuts-inner { display: flex; overflow-x: auto; scrollbar-width: none; }
.shortcuts-inner::-webkit-scrollbar { display: none; }
.shortcuts-inner a {
  color: #aaa; padding: 10px 16px; font-size: 13px; white-space: nowrap;
  transition: all .2s; border-bottom: 3px solid transparent;
}
.shortcuts-inner a:hover, .shortcuts-inner a.active {
  color: #fff; border-bottom-color: var(--primary); background: rgba(255,255,255,.05);
}

/* ─── Hero ──────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--dark) 0%, #2d1b69 100%);
  color: #fff; padding: 40px 0 36px; text-align: center;
}
.hero h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.hero p  { color: #bbb; font-size: 15px; }

/* ─── Main Grid ─────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  padding: 28px 16px;
  align-items: start;
}
.form-card, .preview-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.form-card h2, .preview-card h2 {
  font-size: 18px; font-weight: 700; color: var(--dark);
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--primary);
}

/* ─── Template (Oil Company) Selector ──────────────────────── */
.template-grid { display: flex; gap: 12px; margin-top: 8px; }
.template-option {
  flex: 1; cursor: pointer; text-align: center;
  border: 2px solid var(--border); border-radius: var(--radius);
  padding: 10px 8px 8px; transition: all .2s;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.template-option:hover { border-color: var(--primary); color: var(--primary); }
.template-option.selected { border-color: var(--primary); background: #fff5f0; color: var(--primary); }

.tpl-preview {
  width: 100%; height: 72px; border-radius: 4px;
  margin-bottom: 6px; padding: 6px 8px;
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 3px;
}
.tpl-logo-img { width: 40px; height: 40px; object-fit: contain; }
.tpl-lines { display: flex; flex-direction: column; gap: 2px; width: 100%; margin-top: 4px; }
.tpl-lines span { display: block; height: 2px; border-radius: 2px; background: currentColor; opacity: .3; }
.tpl-lines span.short { width: 55%; }

/* HP */
.tpl1 { background: linear-gradient(135deg, #fff5f0, #ffeee6); color: var(--hp-red); border: 1px solid #ffc4b4; }
/* BPCL */
.tpl2 { background: linear-gradient(135deg, #e8f0ff, #d0e0ff); color: var(--bp-blue); border: 1px solid #aac4ff; }
/* IOC */
.tpl3 { background: linear-gradient(135deg, #fff0f2, #ffe0e4); color: var(--ioc-red); border: 1px solid #ffb0bc; }

/* ─── Form ──────────────────────────────────────────────────── */
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
legend {
  font-weight: 700; font-size: 12px; color: var(--primary);
  padding: 0 6px; text-transform: uppercase; letter-spacing: .5px;
}
.field-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-group:last-child { margin-bottom: 0; }
.field-row { display: flex; gap: 12px; }
.field-row .field-group { flex: 1; }
label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
input, select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text); background: #fff;
  transition: border-color .2s, box-shadow .2s; outline: none;
}
input:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,93,4,.12);
}
input::placeholder { color: #bbb; }
textarea {
  width: 100%; padding: 9px 12px; resize: vertical;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
  transition: border-color .2s, box-shadow .2s; outline: none;
}
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,93,4,.12); }
textarea::placeholder { color: #bbb; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn {
  flex: 1; padding: 12px 20px; border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 700; cursor: pointer; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-d); transform: translateY(-1px); }
.btn-primary:disabled { background: #ccc; color: #999; cursor: not-allowed; transform: none; }
.btn-secondary { background: #f0f0f0; color: var(--dark); }
.btn-secondary:hover { background: #e0e0e0; }

/* ─── Preview Panel ─────────────────────────────────────────── */
.preview-card { position: sticky; top: 80px; }
.preview-wrapper {
  min-height: 300px; border: 2px dashed var(--border);
  border-radius: var(--radius); display: flex;
  align-items: center; justify-content: center; overflow: auto;
  background: #f0f0f0;
}
.preview-placeholder { text-align: center; color: #bbb; padding: 32px; }
.preview-placeholder span { font-size: 48px; display: block; margin-bottom: 12px; }
.preview-placeholder p { font-size: 14px; line-height: 1.5; }
.bill-output { width: 100%; padding: 12px; }

/* ── Required star ──────────────────────────────────────────── */
.req { color: var(--primary); }

/* ── Auto-computed inline hint (e.g. GST State/UT Code) ───────── */
.field-hint { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; margin-top: 2px; display: block; }

/* ═══════════════════════════════════════════════════════════════
   RECEIPT — authentic thermal slip
   ═══════════════════════════════════════════════════════════════ */
.receipt {
  position: relative;
  width: 260px;
  margin: 0 auto;
  background: #ffffff;
  padding: 14px 14px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15), 3px 3px 0 #bbb;
}

/* Crumpled-paper shading — soft diagonal fold shadows + a vignette,
   layered on top of the logo and text so it reads as the paper
   surface itself being creased, not a flat printout. The actual
   gradients are generated per-bill in JS (buildBill -> genCrumpleBg)
   and set as an inline background-image, so the pattern differs
   from bill to bill instead of sitting in the same spot every time. */
.r-crumple {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Logo centered in a thin border box — border is deliberately a
   softer gray (not solid black) since genLogoFilter (templates.js)
   is applied to this whole box, so the border fades/darkens along
   with the logo art instead of staying a stark black square */
.r-logo-box {
  display: flex; justify-content: center; align-items: center;
  border: 1.5px solid #555;
  width: 56px; height: 56px;
  margin: 0 auto 8px;
  padding: 3px;
}
.r-logo-img { width: 100%; height: 100%; object-fit: contain; }

/* Pre-formatted text block — monospace, preserves spaces */
.r-text {
  position: relative;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 13px;
  line-height: 1.55;
  color: #111;
  margin: 0;
  white-space: pre;
  /* Subtle blur simulates thermal ink diffusion on paper */
  filter: blur(0.45px);
}

/* Printer dead-column defect — a stack of per-line segments (see
   genDefectSegments in templates.js), one fixed column for the whole
   bill, that lightens whatever ink falls under it. Pure white with a
   soft fade at both edges and NO dark tint anywhere in the gradient —
   a dead heating element doesn't leave a mark on blank paper, so this
   must stay invisible over the white background and only show up as
   faded ink where it actually crosses a printed character. */
.r-defect-seg {
  position: absolute;
  width: 1ch;
  background: linear-gradient(
    to right,
    rgba(255,255,255,0)   0%,
    rgba(255,255,255,.9) 30%,
    rgba(255,255,255,.9) 70%,
    rgba(255,255,255,0)   100%
  );
  pointer-events: none;
}

/* ─── Info Section ──────────────────────────────────────────── */
.info-section { background: var(--card); padding: 48px 0; border-top: 1px solid var(--border); }
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.info-card {
  text-align: center; padding: 24px 16px;
  border-radius: var(--radius); border: 1px solid var(--border); transition: box-shadow .2s;
}
.info-card:hover { box-shadow: var(--shadow); }
.info-icon { font-size: 32px; margin-bottom: 12px; }
.info-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.info-card p  { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ─── Footer ────────────────────────────────────────────────── */
.footer { background: var(--dark); color: #aaa; padding: 32px 0 20px; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.footer-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: #fff; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }
.footer-links a { font-size: 13px; color: #aaa; transition: color .2s; }
.footer-links a:hover { color: var(--primary); }
.footer-social { display: flex; gap: 16px; }
.footer-social a { font-size: 14px; font-weight: 700; background: #333; padding: 6px 10px; border-radius: 4px; transition: background .2s; }
.footer-social a:hover { background: var(--primary); color: #fff; }
.footer-copy { font-size: 12px; color: #555; }

/* ─── Tabs ──────────────────────────────────────────────────── */
.tab-bar { background: var(--card); border-bottom: 2px solid var(--border); }
.tab-inner { display: flex; }
.tab-btn {
  padding: 14px 32px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Bulk checkbox grid ────────────────────────────────────── */
.check-grid { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 4px; }
.check-opt {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; text-transform: none; letter-spacing: 0;
}
.check-opt input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary);
}
.bulk-hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: center; }
.company-group-label {
  font-size: 11px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .4px;
  margin: 12px 0 8px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.bulk-station-group:first-child .company-group-label { border-top: none; margin-top: 0; padding-top: 0; }

/* ─── Book platform tiles (Amazon / Flipkart) ──────────────── */
.tpl-amazon, .tpl-flipkart {
  font-weight: 700; font-size: 15px; letter-spacing: .3px;
}
.tpl-amazon { background: linear-gradient(135deg, #232f3e, #131a22); color: #ff9900; border: 1px solid #37475a; }
.tpl-flipkart { background: linear-gradient(135deg, #2874f0, #1a56c4); color: #ffe500; border: 1px solid #1a56c4; }

/* ─── Book mode preview column wider — A4 invoice needs room ─ */
.main-grid.book-mode { grid-template-columns: 1fr 500px; }
@media (max-width: 960px) {
  .main-grid.book-mode { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   TAX INVOICE — Amazon.in / Flipkart style A4 layout
   ═══════════════════════════════════════════════════════════════ */
.invoice-scale-wrap { width: 100%; zoom: 0.55; }
.invoice-a4 {
  width: 794px; min-height: 1123px; margin: 0 auto; background: #fff; color: #111;
  font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.5;
  padding: 28px 32px 18px; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
}

.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.inv-doctitle { text-align: right; font-size: 13px; font-weight: 700; max-width: 320px; }
.inv-orig { font-size: 11px; font-weight: 400; color: #555; margin-top: 2px; }

.amazon-logo-img { height: 34px; width: auto; }

.inv-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #555; letter-spacing: .3px; margin-bottom: 2px; }
.inv-strong { font-weight: 700; }
.inv-muted { color: #666; font-size: 10.5px; }
.inv-gap { margin-top: 10px; }
.inv-gap-sm { margin-top: 6px; }
.inv-align-right { text-align: right; }

table.inv-parties, table.inv-meta, table.inv-items { width: 100%; border-collapse: collapse; }
table.inv-parties { margin-bottom: 14px; }
table.inv-parties td.inv-half { width: 50%; vertical-align: top; }
table.inv-parties td.inv-sold-by { padding-right: 16px; text-align: left; }
table.inv-parties td.inv-ship-to { padding-left: 16px; }

table.inv-meta { margin-bottom: 14px; }
table.inv-meta td { padding: 2px 0; font-size: 11.5px; }
table.inv-meta td:last-child { text-align: right; }

table.inv-items th, table.inv-items td {
  border: 1px solid #999; padding: 6px 8px; text-align: left; font-size: 11px; vertical-align: top;
}
table.inv-items th { background: #f0f0f0; font-weight: 700; font-size: 10px; }
table.inv-items .inv-right { text-align: right; }

.inv-post-table { border: 1px solid #999; border-top: none; padding: 10px 12px; }
.inv-words-label { margin-bottom: 2px; }
.inv-sign { margin-top: 30px; text-align: right; font-size: 12px; }
.inv-sign-space { min-height: 36px; }
.inv-signature-img { width: 100px; height: auto; vertical-align: bottom; }

.inv-note { margin-top: 4px; font-size: 11px; color: #444; }

.inv-footer { margin-top: auto; padding-top: 8px; border-top: 1px solid #ccc; font-size: 9.5px; color: #666; text-align: center; }
.inv-footer div { margin-bottom: 2px; }

/* ═══════════════════════════════════════════════════════════════
   FLIPKART TAX INVOICE — layout distinct from the Amazon template
   ═══════════════════════════════════════════════════════════════ */
.fk-title { text-align: center; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.fk-italic { font-style: italic; }

table.fk-topbar { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.fk-sold { vertical-align: top; font-size: 11px; line-height: 1.6; }
.fk-invnum-cell { width: 220px; vertical-align: top; text-align: right; }
.fk-qr-wrap { margin-bottom: 6px; }
.fk-qr-img { display: block; margin-left: auto; width: 70px; height: auto; }
.fk-invnum-box { display: inline-block; border: 1px dashed #999; padding: 6px 10px; font-size: 11px; }

table.fk-parties { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.fk-order-col { width: 26%; vertical-align: top; font-size: 11px; padding-right: 12px; }
.fk-addr-col  { width: 37%; vertical-align: top; font-size: 11px; padding-right: 12px; }
.fk-addr-head { font-size: 12px; margin-bottom: 2px; }

.fk-total-items { font-size: 11px; margin-bottom: 6px; }

table.fk-items th, table.fk-items td { font-size: 10.5px; }

.fk-grandtotal { text-align: right; margin-top: 10px; font-size: 13px; }
.fk-grandtotal-amt { font-weight: 700; font-size: 16px; margin-left: 8px; }

.fk-sign { margin-top: 20px; margin-bottom: 16px; text-align: right; font-size: 12px; }

.fk-footer-block { margin-top: auto; }
.fk-brand-block { text-align: right; margin-bottom: 12px; }
.fk-brand-img { width: 90px; height: auto; }

.fk-footer { font-size: 9.5px; color: #444; border-top: 1px solid #ccc; padding-top: 8px; }
.fk-footer div { margin-bottom: 3px; }

/* ─── Site Footer ───────────────────────────────────────────── */
.site-footer { padding: 24px 0 40px; text-align: center; color: var(--muted); font-size: 12px; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .main-nav { display: none; }
  .nav-toggle { display: block; }
  .hero h1 { font-size: 22px; }
  .field-row { flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .template-grid { gap: 8px; }
}
