/* =============================================
   WhatsApp Invoice Generator - Custom Styles
   Free WhatsApp Invoice Generator with 10+ Templates
   ============================================= */

:root {
  --wig-green: #25D366;
  --wig-green-dark: #128C7E;
  --wig-green-light: #DCF8C6;
  --wig-accent: #075E54;
  --wig-radius: 12px;
  --wig-shadow: 0 4px 24px rgba(0,0,0,0.10);
  --wig-shadow-lg: 0 8px 40px rgba(0,0,0,0.13);
}

/* ---- Tool Wrapper ---- */
#wig-app {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ---- Hero Banner (SEO Content Block) ---- */
.wig-hero {
  background: linear-gradient(135deg, var(--wig-accent) 0%, var(--wig-green-dark) 60%, var(--wig-green) 100%);
  color: #fff;
  padding: 40px 20px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.wig-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.wig-hero h1 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
  line-height: 1.2;
}
.wig-hero p {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  opacity: 0.88;
  margin: 0 auto;
  max-width: 600px;
  line-height: 1.55;
}
.wig-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.wig-hero-badge {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(4px);
}

/* ---- Main Grid ---- */
.wig-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}
@media (max-width: 900px) {
  .wig-main-grid { grid-template-columns: 1fr; }
}

/* ---- Card ---- */
.wig-card {
  background: #fff;
  border-radius: var(--wig-radius);
  box-shadow: var(--wig-shadow);
  overflow: hidden;
}
.wig-card-header {
  background: var(--wig-accent);
  color: #fff;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wig-card-header svg { flex-shrink: 0; }
.wig-card-body { padding: 20px; }

/* ---- Template Picker ---- */
.wig-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 16px;
}
.wig-template-btn {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  background: #fff;
  position: relative;
}
.wig-template-btn:hover {
  border-color: var(--wig-green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,211,102,0.18);
}
.wig-template-btn.active {
  border-color: var(--wig-green);
  background: #f0fdf4;
}
.wig-template-btn .niche-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.wig-template-btn .niche-label { font-size: 0.72rem; font-weight: 600; color: #374151; line-height: 1.3; }
.wig-template-btn .niche-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--wig-green);
  color: #fff;
  font-size: 0.6rem;
  border-radius: 8px;
  padding: 2px 6px;
  font-weight: 700;
}

/* ---- Form Fields ---- */
.wig-form-group { margin-bottom: 14px; }
.wig-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}
.wig-input, .wig-select, .wig-textarea {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  color: #1f2937;
  background: #f9fafb;
  transition: border-color 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}
.wig-input:focus, .wig-select:focus, .wig-textarea:focus {
  outline: none;
  border-color: var(--wig-green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
}
.wig-textarea { resize: vertical; min-height: 70px; }

/* ---- Row Grid ---- */
.wig-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wig-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 500px) {
  .wig-row-2, .wig-row-3 { grid-template-columns: 1fr; }
}

/* ---- Line Items Table ---- */
.wig-items-table { width: 100%; border-collapse: collapse; }
.wig-items-table th {
  background: #f1f5f9;
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  text-align: left;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.wig-items-table td { padding: 6px 4px; }
.wig-items-table .wig-input { padding: 7px 8px; font-size: 0.85rem; }
.wig-item-del {
  background: none;
  border: none;
  cursor: pointer;
  color: #ef4444;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.wig-item-del:hover { background: #fee2e2; }

/* ---- Totals ---- */
.wig-totals {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 10px;
}
.wig-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.88rem;
  color: #374151;
}
.wig-total-row.grand {
  border-top: 2px solid #e2e8f0;
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--wig-accent);
}

/* ---- Color Picker ---- */
.wig-color-swatches {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px;
}
.wig-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}
.wig-swatch:hover, .wig-swatch.active {
  transform: scale(1.25);
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--wig-green);
}

/* ---- Logo Upload ---- */
.wig-logo-upload {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}
.wig-logo-upload:hover { border-color: var(--wig-green); background: #f0fdf4; }
.wig-logo-upload img { max-height: 60px; max-width: 140px; object-fit: contain; }

/* ---- Action Buttons ---- */
.wig-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}
.wig-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  letter-spacing: 0.2px;
  text-decoration: none;
  white-space: nowrap;
}
.wig-btn-whatsapp {
  background: var(--wig-green);
  color: #fff;
  flex: 1;
  justify-content: center;
  min-width: 180px;
}
.wig-btn-whatsapp:hover { background: var(--wig-green-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,211,102,0.35); }
.wig-btn-pdf {
  background: #ef4444;
  color: #fff;
  flex: 1;
  justify-content: center;
}
.wig-btn-pdf:hover { background: #dc2626; transform: translateY(-1px); }
.wig-btn-print {
  background: #6b7280;
  color: #fff;
}
.wig-btn-print:hover { background: #4b5563; }
.wig-btn-reset {
  background: #fff;
  color: #6b7280;
  border: 1.5px solid #e2e8f0;
}
.wig-btn-reset:hover { background: #f1f5f9; }
.wig-btn-add {
  background: #f0fdf4;
  color: var(--wig-accent);
  border: 1.5px dashed var(--wig-green);
  font-size: 0.83rem;
  padding: 7px 14px;
}
.wig-btn-add:hover { background: #dcfce7; }

/* ---- Invoice Preview ---- */
#wig-preview-wrapper {
  position: sticky;
  top: 20px;
}
#wig-invoice-preview {
  background: #fff;
  border-radius: var(--wig-radius);
  box-shadow: var(--wig-shadow-lg);
  min-height: 600px;
  overflow: hidden;
}

/* ---- NICHE TEMPLATES ---- */

/* 1. Classic (Default) */
.tpl-classic .inv-header { background: #075E54; color: #fff; padding: 32px; }
.tpl-classic .inv-header h2 { font-size: 2rem; font-weight: 900; letter-spacing: 2px; }
.tpl-classic .inv-accent { color: #25D366; }
.tpl-classic .inv-table thead tr { background: #075E54; color: #fff; }
.tpl-classic .inv-grand { color: #075E54; }

/* 2. Freelancer */
.tpl-freelancer .inv-header { background: #1e40af; color: #fff; padding: 28px 32px; }
.tpl-freelancer .inv-header h2 { font-size: 1.8rem; font-weight: 800; }
.tpl-freelancer .inv-accent { color: #3b82f6; }
.tpl-freelancer .inv-table thead tr { background: #dbeafe; color: #1e40af; }
.tpl-freelancer .inv-grand { color: #1e40af; }

/* 3. Photography */
.tpl-photography .inv-header {
  background: #111827;
  color: #fff;
  padding: 32px;
  position: relative;
}
.tpl-photography .inv-header::after {
  content: '📷';
  position: absolute; right: 32px; top: 50%; transform: translateY(-50%);
  font-size: 2.5rem; opacity: 0.3;
}
.tpl-photography .inv-header h2 { font-size: 1.8rem; font-weight: 900; letter-spacing: 1px; }
.tpl-photography .inv-accent { color: #f59e0b; }
.tpl-photography .inv-table thead tr { background: #111827; color: #f59e0b; }
.tpl-photography .inv-grand { color: #111827; }

/* 4. Retail / Shop */
.tpl-retail .inv-header { background: #7c3aed; color: #fff; padding: 28px 32px; }
.tpl-retail .inv-header h2 { font-size: 2rem; font-weight: 800; }
.tpl-retail .inv-accent { color: #a78bfa; }
.tpl-retail .inv-table thead tr { background: #ede9fe; color: #7c3aed; }
.tpl-retail .inv-grand { color: #7c3aed; }

/* 5. Consulting */
.tpl-consulting .inv-header { background: #0f172a; color: #fff; padding: 32px; border-bottom: 4px solid #f59e0b; }
.tpl-consulting .inv-header h2 { font-size: 1.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 3px; }
.tpl-consulting .inv-accent { color: #f59e0b; }
.tpl-consulting .inv-table thead tr { background: #0f172a; color: #fbbf24; }
.tpl-consulting .inv-grand { color: #0f172a; }

/* 6. Construction */
.tpl-construction .inv-header { background: #dc2626; color: #fff; padding: 28px 32px; }
.tpl-construction .inv-header h2 { font-size: 2rem; font-weight: 900; }
.tpl-construction .inv-accent { color: #f87171; }
.tpl-construction .inv-table thead tr { background: #fee2e2; color: #dc2626; }
.tpl-construction .inv-grand { color: #dc2626; }

/* 7. Healthcare */
.tpl-healthcare .inv-header { background: #0284c7; color: #fff; padding: 28px 32px; }
.tpl-healthcare .inv-header h2 { font-size: 1.8rem; font-weight: 800; }
.tpl-healthcare .inv-accent { color: #38bdf8; }
.tpl-healthcare .inv-table thead tr { background: #e0f2fe; color: #0284c7; }
.tpl-healthcare .inv-grand { color: #0284c7; }

/* 8. Food & Restaurant */
.tpl-food .inv-header { background: #ea580c; color: #fff; padding: 28px 32px; }
.tpl-food .inv-header h2 { font-size: 2rem; font-weight: 900; }
.tpl-food .inv-accent { color: #fb923c; }
.tpl-food .inv-table thead tr { background: #ffedd5; color: #ea580c; }
.tpl-food .inv-grand { color: #ea580c; }

/* 9. Event Management */
.tpl-event .inv-header {
  background: linear-gradient(135deg, #6d28d9 0%, #db2777 100%);
  color: #fff; padding: 32px;
}
.tpl-event .inv-header h2 { font-size: 1.8rem; font-weight: 800; }
.tpl-event .inv-accent { color: #db2777; }
.tpl-event .inv-table thead tr { background: #fdf2f8; color: #6d28d9; }
.tpl-event .inv-grand { color: #6d28d9; }

/* 10. Real Estate */
.tpl-realestate .inv-header { background: #065f46; color: #fff; padding: 28px 32px; }
.tpl-realestate .inv-header h2 { font-size: 2rem; font-weight: 800; }
.tpl-realestate .inv-accent { color: #34d399; }
.tpl-realestate .inv-table thead tr { background: #d1fae5; color: #065f46; }
.tpl-realestate .inv-grand { color: #065f46; }

/* 11. Beauty & Salon */
.tpl-beauty .inv-header { background: #be185d; color: #fff; padding: 28px 32px; }
.tpl-beauty .inv-header h2 { font-size: 2rem; font-weight: 800; }
.tpl-beauty .inv-accent { color: #f9a8d4; }
.tpl-beauty .inv-table thead tr { background: #fce7f3; color: #be185d; }
.tpl-beauty .inv-grand { color: #be185d; }

/* 12. IT / Software */
.tpl-tech .inv-header {
  background: #0f172a;
  color: #22d3ee;
  padding: 28px 32px;
  font-family: 'Courier New', monospace;
}
.tpl-tech .inv-header h2 { font-size: 1.8rem; font-weight: 900; color: #22d3ee; }
.tpl-tech .inv-accent { color: #22d3ee; }
.tpl-tech .inv-table thead tr { background: #0f172a; color: #22d3ee; }
.tpl-tech .inv-grand { color: #0891b2; }

/* ---- Common Invoice Styles ---- */
.inv-body { padding: 24px 28px; }
.inv-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.inv-meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 3px;
}
.inv-meta-value { font-size: 0.88rem; color: #1e293b; font-weight: 500; }
.inv-logo-area { text-align: right; }
.inv-logo-area img { max-height: 56px; max-width: 140px; object-fit: contain; }
.inv-divider { border: none; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.inv-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.inv-table th {
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.inv-table td { padding: 9px 12px; font-size: 0.87rem; color: #374151; border-bottom: 1px solid #f1f5f9; }
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.inv-totals-inner { min-width: 240px; }
.inv-total-line {
  display: flex; justify-content: space-between;
  padding: 5px 0;
  font-size: 0.87rem;
  color: #374151;
}
.inv-total-line.inv-grand {
  border-top: 2px solid #e2e8f0;
  padding-top: 10px;
  margin-top: 4px;
  font-weight: 800;
  font-size: 1.1rem;
}
.inv-notes { margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.inv-notes-label { font-size: 0.75rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 5px; }
.inv-notes-text { font-size: 0.85rem; color: #475569; line-height: 1.55; }
.inv-footer {
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inv-footer-text { font-size: 0.78rem; color: #94a3b8; }
.inv-stamp {
  display: inline-block;
  border: 3px solid;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
  transform: rotate(-8deg);
}
.inv-stamp.paid { border-color: #22c55e; color: #22c55e; }
.inv-stamp.unpaid { border-color: #ef4444; color: #ef4444; }
.inv-stamp.draft { border-color: #94a3b8; color: #94a3b8; }

/* ---- Signature Pad ---- */
.wig-signature-pad-wrapper {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: crosshair;
}
#wig-signature-pad { display: block; width: 100%; height: 100px; }

/* ---- SEO Text Block ---- */
.wig-seo-content {
  max-width: 1200px;
  margin: 0 auto 32px;
  padding: 0 16px;
}
.wig-seo-content h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 800;
  color: #075E54;
  margin-bottom: 10px;
}
.wig-seo-content p { color: #475569; line-height: 1.7; font-size: 0.95rem; }
.wig-faq-item { border-bottom: 1px solid #e2e8f0; padding: 14px 0; }
.wig-faq-q {
  font-weight: 700; color: #1e293b; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.95rem;
}
.wig-faq-a {
  color: #64748b; font-size: 0.9rem; line-height: 1.6;
  margin-top: 8px; display: none;
}
.wig-faq-a.open { display: block; }

/* ---- Tabs ---- */
.wig-tabs { display: flex; gap: 4px; padding: 12px 16px 0; background: #f8fafc; }
.wig-tab {
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  background: #e2e8f0;
  border: none;
  transition: all 0.15s;
}
.wig-tab.active { background: #fff; color: var(--wig-accent); border-bottom: 2px solid var(--wig-green); }
.wig-tab-content { display: none; }
.wig-tab-content.active { display: block; }

/* ---- Success Toast ---- */
.wig-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--wig-accent); color: #fff;
  padding: 12px 24px; border-radius: 10px;
  font-size: 0.9rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 99999; opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.wig-toast.show { opacity: 1; }

/* ---- Currency Selector ---- */
.wig-currency-flag { font-size: 1.1rem; margin-right: 4px; }

/* ---- Responsive Print ---- */
@media print {
  #wig-app > *:not(#wig-preview-wrapper),
  .wig-actions, .wig-tabs, .wig-hero, .wig-seo-content { display: none !important; }
  #wig-invoice-preview { box-shadow: none !important; }
  .wig-main-grid { grid-template-columns: 1fr; }
}

/* ---- QR Code Area ---- */
.wig-qr-area { text-align: center; padding: 12px; }
.wig-qr-area canvas { max-width: 90px; max-height: 90px; }

/* ---- Watermark ---- */
.inv-watermark {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 8px;
  opacity: 0.04;
  pointer-events: none;
  color: #000;
  white-space: nowrap;
}
