/* ====== INTASGO THEME (local to tool) ====== */
:root{
  --brand:#F6BD60;
  --bg-1:#202d45;
  --bg-2:#1B263B;
  --bg-3:#151d2c;
  --card:#0D1B2A;
  --panel:#0e1521;
  --text:#FDF0D5;
  --muted:#a9b1c6;
  --border:rgba(255,255,255,.10);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  font-family:'Jost', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", "Noto Sans", sans-serif;
  margin:0;
  padding:24px;
  background: linear-gradient(180deg,var(--bg-1),var(--bg-2),var(--bg-3));
  color:var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ====== Header ====== */
.header-row{
  display:grid; grid-template-columns: auto 1fr auto; align-items:center; gap:14px;
  margin:0 0 18px 0;
}
.header-row .brand{ justify-self:start; }
.header-row .main-title{ justify-self:center; }
.header-row .adfree-switch{ justify-self:end; }
.brand{
  display:flex; align-items:center; gap:.6rem;
  font-weight:800; color:var(--text);
  letter-spacing:.3px;
}
.brand .mark{
  display:inline-flex; align-items:center; justify-content:center;
  background: var(--brand);
  border-radius:8px; padding:6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.brand .mark img{ width:20px; height:20px; display:block; }
.main-title{ font-size:1.8rem; font-weight:800; margin:0; }

/* Ad‑Free switch button (header) */
.adfree-switch{
  display:inline-flex; align-items:center; gap:8px;
  padding:10px 14px;
  border-radius:9999px;
  border:1px solid rgba(246,189,96,.65);
  background: linear-gradient(180deg, #171f2e, var(--panel));
  color: var(--brand);
  font-weight:800;
  letter-spacing:.2px;
  text-decoration:none;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: background .2s ease, transform .06s ease, box-shadow .2s ease, color .2s ease;
  white-space: nowrap;
}
.adfree-switch:hover{
  background:#2c3e50;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 0 0 3px rgba(246,189,96,.12) inset;
}
.adfree-switch:active{ transform: translateY(0); }
.adfree-switch i{ color: var(--brand); }
.adfree-switch:focus{ outline:none; box-shadow: 0 0 0 3px rgba(246,189,96,.25); }

@media (max-width:640px){
  .adfree-switch{ padding:9px 12px; font-size:.95rem; }
}

/* Compact header for very small phones */
@media (max-width: 420px){
  .main-title{ font-size:1.2rem; }
  .adfree-switch{ padding:6px 10px; font-size:.90rem; gap:6px; }
}

/* Disabled state for header switch */
.adfree-switch.is-disabled{
  opacity:.55;
  cursor:not-allowed;
  filter: saturate(.8);
}

/* Pulse highlight for bottom CTA when guiding user */
.pulse-highlight{
  animation: pulseGlow 1.1s ease-in-out 0s 4 alternate;
}
@keyframes pulseGlow{
  from{ box-shadow: 0 0 0 0 rgba(246,189,96,.0), 0 0 0 0 rgba(246,189,96,.0) inset; }
  to{   box-shadow: 0 0 0 6px rgba(246,189,96,.18), 0 0 0 4px rgba(246,189,96,.12) inset; }
}

/* ====== Layout ====== */
.container{
  display:flex; gap:20px; flex-wrap:wrap;
}
form, #preview-section{
  flex:1 1 360px;
  background: var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:18px;
  min-width: 300px;
}
#preview-section{ text-align:center; }

/* ====== Headings ====== */
h2{
  font-size:1.1rem; font-weight:800;
  margin:2px 0 10px; color:#fff;
}

/* ====== Inputs ====== */
#invoice-form input,
#invoice-form select{
  width:100%;
  margin-bottom:10px;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--panel);
  color:var(--text);
  outline:none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
#invoice-form input::placeholder{ color:#8f98ad; }
#invoice-form input:focus,
#invoice-form select:focus{
  border-color: rgba(246,189,96,.65);
  box-shadow: 0 0 0 4px rgba(246,189,96,.12);
}

/* File label */
.label-file{
  display:inline-flex; align-items:center; gap:8px;
  font-weight:700; color:var(--brand);
  margin:4px 0 8px; cursor:pointer;
}
#businessLogo{ display:block; }

/* ====== Logo Uploader (dropzone + preview) ====== */
.logo-uploader{ margin: 6px 0 10px; }
.logo-dropzone{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:6px; width:100%; min-height:110px;
  border:2px dashed rgba(255,255,255,.18);
  border-radius:12px;
  background:#0f1a2a;
  color:var(--text);
  cursor:pointer;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.logo-dropzone i{ color:var(--brand); font-size:22px; }
.logo-dropzone .title{ font-weight:800; }
.logo-dropzone .hint{ color:var(--muted); font-size:.9rem; }
.logo-dropzone:hover, .logo-dropzone:focus{
  border-color: rgba(246,189,96,.55);
  box-shadow: 0 0 0 4px rgba(246,189,96,.12);
  outline:none; background:#112033;
}
.logo-dropzone.drag{ border-color: rgba(246,189,96,.8); box-shadow: 0 0 0 5px rgba(246,189,96,.16); }

.logo-preview{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:12px; padding:10px; text-align:center;
}
.logo-preview img{ max-width: 220px; max-height: 120px; width:auto; height:auto; display:block; margin: 6px auto 10px; object-fit: contain; }
.logo-note{ color: var(--muted); font-size:.9rem; margin-bottom:8px; }
.logo-actions{ display:flex; gap:10px; justify-content:center; }

/* button variants */
.btn.small{ padding:9px 12px; font-size:.95rem; width:auto; }
.btn.danger{ border-color: rgba(230,57,70,.55); color:#ff7b7b; }

/* 2-up rows */
.row-2{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
@media (max-width:640px){ .row-2{ grid-template-columns:1fr; } }

/* ====== Table ====== */
#invoice-form table{
  width:100%; border-collapse: collapse;
  background: var(--panel); color:var(--text);
  border:1px solid var(--border); border-radius:12px; overflow:hidden;
}
#invoice-form thead th{
  text-align:left; padding:10px; font-weight:700; background: rgba(246,189,96,.08);
  border-bottom:1px solid var(--border);
}
#invoice-form tbody td{
  padding:10px; border-bottom:1px solid var(--border);
}
#invoice-form tbody tr:last-child td{ border-bottom:none; }

/* Make inputs inside items table fill the cell */
#items input.desc,
#items input.qty,
#items input.price { width: 100%; }

/* (Reverted) Keep original item table styles for on-page preview */

/* Icon button (modern, circular) */
.icon-btn{
  display:inline-flex; align-items:center; justify-content:center;
  width:36px; height:36px;
  border-radius:9999px;
  border:1px solid rgba(246,189,96,.55);
  background: linear-gradient(180deg, #171f2e, var(--panel));
  color: var(--brand);
  cursor:pointer;
  transition: background .2s ease, transform .06s ease, box-shadow .2s ease, opacity .2s ease;
}
.icon-btn i{ pointer-events:none; }
.icon-btn:hover{ background:#2c3e50; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.icon-btn:active{ transform: translateY(0); }

/* Remove variant with subtle danger accent */
.icon-btn.remove{
  border-color: rgba(230, 57, 70, .55);
  color: #ff7b7b;
}
.icon-btn.remove:hover{
  box-shadow: 0 6px 18px rgba(230,57,70,.25), 0 0 0 3px rgba(230,57,70,.10) inset;
}

/* Mobile-responsive Items table */
@media (max-width: 640px){
  #items thead{ display:none; }
  #items{ border:0; }
  #items tbody{ display:block; }
  #items tr{
    display:block;
    background: var(--panel);
    border:1px solid var(--border);
    border-radius:12px;
    padding:8px 12px;
    margin:0 0 10px 0;
  }
  #items td{
    display:grid;
    grid-template-columns: 110px 1fr;
    align-items:center;
    gap:8px;
    padding:8px 0;
    border:none;
  }
  #items td::before{
    content: attr(data-label);
    font-weight:700;
    color:#fff;
  }
  #items td.total{ font-weight:800; }
  #items td.cell-remove{ justify-content:end; }
  #items td.cell-remove::before{ content:""; }
  #items td.cell-remove button{ width:36px; height:36px; }
}

/* ====== Buttons ====== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  width:100%;
  padding:13px 16px;
  border-radius:12px;
  border:1px solid rgba(246,189,96,.6);
  background: linear-gradient(180deg, #171f2e, var(--panel));
  color: var(--brand);
  font-weight:800;
  letter-spacing:.3px;
  cursor:pointer;
  transition: transform .06s ease, background .2s ease, opacity .2s ease;
}
.btn:hover{ background:#2c3e50; transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }

.btn-primary{
  background: var(--brand);
  color:#0e1521;
  border-color: rgba(246,189,96,.9);
}
.btn-primary:hover{ filter: brightness(1.05); transform: translateY(-1px); }

.actions{ display:grid; gap:10px; margin-top:12px; }

.actions .usage-chip{
  display:none;
  justify-self:end;
  padding:4px 10px;
  font-size:.9rem;
  color:#cdd0e1;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(14,21,33,.6);
  letter-spacing:.2px;
}
.actions .usage-chip.show{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.actions .usage-chip.near-limit{
  color:#f6bd60;
  border-color:rgba(246,189,96,.4);
}
.actions .usage-chip.limit-hit{
  color:#ffb3b3;
  border-color:rgba(239,68,68,.45);
  background:rgba(239,68,68,.12);
}

/* Disabled email button */
#send-email[disabled]{
  opacity:.55; cursor:not-allowed;
  filter: grayscale(0.15);
}

/* ====== Summary card ====== */
.summary-card{
  border:1px solid var(--border);
  background: #0f1a2a;
  border-radius:12px;
  padding:12px;
}
.summary-card p{ margin:6px 0; color:var(--muted); }
.summary-card p.grand{ color:#fff; font-weight:800; }

/* ====== Preview canvas ====== */
#invoice-preview{
  border:1px solid var(--border);
  background:#fff; color:#000;
  font-family:'Jost', sans-serif;
  border-radius:12px;
  overflow:hidden;
}
#invoice-preview canvas{ max-width:100%; height:auto; display:block; }

/* ====== Hint text ====== */
.hint{
  font-size:.95rem; color: var(--muted);
  margin:10px 0 0;
}

/* ====== Signature pad ====== */
.signature-wrap{
  border:1px solid var(--border);
  background:#0f1a2a;
  border-radius:12px;
  padding:12px;
  margin-top:8px;
}
#signaturePad{
  display:block;
  width:100%;
  height:auto;
  background:#0e1521;
  border:1px dashed rgba(255,255,255,.2);
  border-radius:8px;
  touch-action:none;
}
.sig-actions{ margin-top:8px; display:flex; gap:8px; justify-content:flex-end; }

/* ====== Modal (kept for future) ====== */
.modal-overlay{
  position: fixed; inset:0;
  background: rgba(0,0,0,0.55);
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
  backdrop-filter: blur(6px) saturate(120%);
}
.modal-content{
  background: var(--card);
  color: var(--text);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  min-width: 320px; max-width: 92vw;
  text-align:center;
}
#modal-email-input{
  width:100%; padding:12px; margin:16px 0 10px;
  border-radius:12px; border:1px solid var(--border);
  background: var(--panel); color: var(--text);
  outline:none;
}
#modal-send-btn, #modal-close-btn{
  width:100%; margin-top:10px;
  border:none;
}

/* ====== Responsive ====== */

@media (max-width: 640px) {
  .header-row {
    grid-template-columns: auto 1fr; /* Allow title to take available space */
    gap: 12px;
  }
  .header-row .main-title {
    grid-column: 1 / -1; /* Make title span full width */
    order: 2; /* Move title below brand/switch */
    text-align: center;
    font-size: 1.4rem; /* Better base for mobile */
    line-height: 1.3;
  }
  .header-row .brand {
    order: 1;
  }
  .header-row .adfree-switch {
    order: 1;
    justify-self: end;
  }
}

/* Responsive */
@media (max-width: 600px) {
    .header {
        flex-direction: column;
    }

    .invoice-details .details,
    .customer-details .details {
        grid-template-columns: 1fr;
    }

    .totals {
        justify-content: center;
    }

    .totals .summary {
        width: 100%;
        max-width: none;
    }
}

/* Ultra-small devices (<= 360px) */
@media (max-width:360px){
  .main-title{ font-size:1.05rem; white-space: normal; }
  .overlay-box h2{ font-size:1.4rem; }
  .overlay-box p{ font-size:1rem; }
}


/* ====== Partial payment UI ====== */
.partial-box{
  border:1px solid var(--border);
  background:#0f1a2a;
  border-radius:12px;
  padding:12px;
  margin-top:8px;
}
.muted{ color: var(--muted); font-size:.9rem; }
#duePreview{ opacity:.9; }


/* ====== Global Loader ====== */

#appLoader {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease, visibility .25s ease;
}
#appLoader.active {
  visibility: visible;
  opacity: 1;
}
.loader-spin {
  width: 52px; height: 52px;
  border: 5px solid rgba(255,255,255,0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Download Overlay ====== */
#downloadOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  visibility: hidden;
  opacity: 0;
  transition: opacity .3s ease, visibility .3s ease;
}
#downloadOverlay.active {
  visibility: visible;
  opacity: 1;
}
.overlay-box {
  background: var(--card);
  padding: 28px 34px;
  border-radius: 14px;
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: popUp .4s ease;
  width: min(90vw, 420px);
}
.overlay-box h2 {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 1.8rem;
}
.overlay-box p {
  color: var(--text);
  font-size: 1.2rem;
}
.overlay-sub { color: var(--muted); font-size: .95rem; margin-top: 6px; }

/* Small spinner shown in download overlay heading */
.overlay-spinner{
  display:inline-block; vertical-align:middle;
  width:18px; height:18px; margin-right:8px;
  border:2px solid rgba(255,255,255,0.25);
  border-top-color: var(--brand);
  border-radius:50%;
  animation: spin .8s linear infinite;
}
@keyframes popUp {
  from { transform: scale(.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* keeps target clear of any sticky header */
#adfree { scroll-margin-top: 80px; }

/* ====== Premium Ad‑Free CTA (pill) ====== */
.cta-adfree{
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
  width:100%;
  min-height:44px;
  padding:12px 18px;
  border-radius:9999px;
  background: linear-gradient(180deg, #171f2e, var(--panel));
  border:1px solid rgba(246,189,96,.65);
  color: var(--brand);
  font-weight:800;
  letter-spacing:.3px;
  text-decoration:none;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  transition: background .2s ease, transform .06s ease, box-shadow .2s ease, color .2s ease;
  white-space: nowrap; /* prevent wrap on mobile */
}
.cta-adfree:hover{
  background:#2c3e50;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0,0,0,.45), 0 0 0 4px rgba(246,189,96,.12) inset;
}
.cta-adfree:active{ transform: translateY(0); }
.cta-adfree:focus{ outline:none; box-shadow: 0 0 0 3px rgba(246,189,96,.25); }
.cta-adfree i{ color: var(--brand); }
/* Disabled/locked subscription CTA */
.cta-adfree.is-locked{ opacity:.6; pointer-events:none; filter: grayscale(.2); }

@media (max-width:640px){
  .cta-adfree{ padding:12px 16px; }
}

/* Extra compact CTA for small phones */
@media (max-width: 420px){
  .cta-adfree{ padding:10px 14px; font-size:.95rem; gap:8px; }
  .cta-adfree i{ font-size: 0.95em; }
}

/* ====== Ad/Ad-Free mode gates ====== */
[data-mode="adfree"] .with-ad-only { display: none !important; }
[data-mode="ad"] .adfree-only { display: none !important; }
[data-mode="adfree"] #downloadOverlay .overlay-sub { display: none !important; }

/* Simple badges reused by notice modal */
.badge-ok{ display:inline-block; padding:4px 10px; border-radius:999px; background:rgba(34,197,94,.16); border:1px solid rgba(34,197,94,.35); color:#bbf7d0; font-weight:700; font-size:.9rem; }
.badge-warn{ display:inline-block; padding:4px 10px; border-radius:999px; background:rgba(239,68,68,.16); border:1px solid rgba(239,68,68,.35); color:#fecaca; font-weight:700; font-size:.9rem; }

/* ====== Restore box (Ad-Free key input) ====== */
#restoreBox.restore-box{
  margin-top:12px;
  display:inline-block;
  width:100%;
  max-width:640px;
  text-align:left;
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#restoreBox .code-input{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#0f1a2a;
  color:var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing:.4px;
}
#restoreBox .code-input::placeholder{ color:#8f98ad; }
#restoreBox .code-input:focus{ border-color: rgba(246,189,96,.65); box-shadow: 0 0 0 4px rgba(246,189,96,.12); outline:none; }
#restoreBox .btn{ width:100%; white-space:nowrap; }
#restoreBox .row-2{ align-items:center; }

/* FAQ Section Styles */
.faq-item {
  margin-bottom: 1.5rem;
}

.faq-item h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
}

section:has(h2.faq-title) {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}