/* ===================================================
   OnlineInvoicesMaker.com — Invoice Generator Styles
   Modern & Professional Redesign
   =================================================== */

/* ===================== GENERATOR LAYOUT ===================== */
.generator-body {
  overflow: hidden;
}

.generator-page {
  padding-top: var(--header-height);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f0f2f8;
}

[data-theme="dark"] .generator-page {
  background: #0b1120;
}

/* ===================== TOOLBAR ===================== */
.generator-toolbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.toolbar-btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.toolbar-btn-outline:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(99,102,241,0.06);
}

.toolbar-btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  padding: 9px 22px;
  font-size: 0.88rem;
}

.toolbar-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(99,102,241,0.45);
}

.toolbar-btn-primary:active {
  transform: translateY(0);
}

.toolbar-btn-success {
  background: var(--success);
  color: white;
}

.toolbar-btn-success:hover { filter: brightness(1.1); }

/* Currency selector in toolbar */
.toolbar-currency-select {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 14px;
  padding-right: 30px;
  min-width: 110px;
  transition: all 0.2s ease;
}

.toolbar-currency-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* ===================== TEMPLATE BAR ===================== */
.template-select-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  position: relative;
}
.template-select-bar::-webkit-scrollbar { display: none; }

.template-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-right: 4px;
}

.template-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.template-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99,102,241,0.06);
}

.template-pill.active {
  border-color: var(--primary);
  color: white;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 3px 10px rgba(99,102,241,0.3);
}

/* ===================== GENERATOR MAIN LAYOUT ===================== */
.generator-main {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* LEFT: Form panel — always flex on desktop */
.generator-form-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px 64px;
  background: #f0f2f8;
  border-right: 1px solid var(--border);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

[data-theme="dark"] .generator-form-panel {
  background: #0b1120;
}

.generator-form-panel::-webkit-scrollbar { width: 4px; }
.generator-form-panel::-webkit-scrollbar-track { background: transparent; }
.generator-form-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.generator-form-panel::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* RIGHT: Preview panel — always flex on desktop */
.generator-preview-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 32px;
  background: #e8eaf3;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

[data-theme="dark"] .generator-preview-panel {
  background: #060d1a;
}

.generator-preview-panel::-webkit-scrollbar { width: 4px; }
.generator-preview-panel::-webkit-scrollbar-track { background: transparent; }
.generator-preview-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ===================== QUICK PRESETS STRIP ===================== */
.presets-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.presets-strip-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding-right: 4px;
}

/* ===================== FORM SECTIONS ===================== */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.form-section:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  border-color: rgba(99,102,241,0.2);
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-card);
  transition: background 0.15s;
}

.form-section-header:hover { background: rgba(99,102,241,0.03); }

.section-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(79,70,229,0.08));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.form-section:hover .section-icon {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
}

.form-section-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  margin-left: 6px;
}

.section-toggle-icon {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.25s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 6px;
}

.form-section.collapsed .section-toggle-icon { transform: rotate(-90deg); }

/* Animated collapse — mobile-mobile.css handles max-height transition */
.form-section.collapsed .form-section-body {
  display: none;
}

.form-section-body {
  padding: 18px;
  border-top: 1px solid var(--border-light);
}

/* ===================== FORM INPUTS ===================== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row.three-col { grid-template-columns: 1fr 1fr 1fr; }
.form-row.full { grid-template-columns: 1fr; }
.form-row:last-child { margin-bottom: 0; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg);
  transition: all 0.2s ease;
  line-height: 1.5;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
  background: var(--bg-card);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

textarea.form-control {
  resize: vertical;
  min-height: 76px;
  line-height: 1.6;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 14px;
  padding-right: 34px;
}

/* ===================== LOGO UPLOAD ===================== */
.logo-upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-upload-area:hover {
  border-color: var(--primary);
  background: rgba(99,102,241,0.03);
}

.logo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.logo-preview-box {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  overflow: hidden;
  flex-shrink: 0;
}

.logo-preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-placeholder-icon { font-size: 1.4rem; color: var(--text-muted); }

.logo-upload-text { text-align: left; }
.logo-upload-text strong { font-size: 0.88rem; color: var(--text-primary); display: block; margin-bottom: 3px; }
.logo-upload-text span { font-size: 0.75rem; color: var(--text-muted); }

/* ===================== ITEMS TABLE ===================== */
.items-table-wrapper {
  overflow-x: auto;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.items-table th {
  text-align: left;
  padding: 10px 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.items-table td {
  padding: 6px 4px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}

.items-table tbody tr:last-child td {
  border-bottom: none;
}

.items-table .item-input {
  padding: 8px 9px;
  border: 1.5px solid transparent;
  border-radius: 7px;
  font-size: 0.84rem;
  color: var(--text-primary);
  background: transparent;
  width: 100%;
  transition: all 0.2s ease;
}

.items-table .item-input:hover {
  border-color: var(--border);
  background: var(--bg);
}

.items-table .item-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.1);
  background: var(--bg-card);
}

.col-desc { min-width: 160px; }
.col-qty { width: 58px; }
.col-rate { width: 88px; }
.col-tax { width: 68px; }
.col-amount { width: 88px; text-align: right; }
.col-action { width: 38px; text-align: center; }

.item-amount-cell {
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  padding: 0 10px;
  white-space: nowrap;
  font-size: 0.85rem;
}

.ai-desc-btn {
  padding: 3px 7px;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  border: none;
  border-radius: 4px;
  font-size: 0.67rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 600;
}

.ai-desc-btn:hover { background: var(--primary); color: white; }

.remove-item-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244,63,94,0.07);
  color: #f43f5e;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.78rem;
  margin: auto;
}

.remove-item-btn:hover {
  background: #f43f5e;
  color: white;
}

.add-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: rgba(99,102,241,0.06);
  color: var(--primary);
  border: 2px dashed rgba(99,102,241,0.25);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
  letter-spacing: 0.01em;
}

.add-item-btn:hover {
  background: rgba(99,102,241,0.1);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ===================== TOTALS PANEL ===================== */
.totals-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 12px;
  border: 1px solid var(--border);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.86rem;
}

.totals-row:last-child { border-bottom: none; }

.totals-row .label { color: var(--text-secondary); font-weight: 500; }
.totals-row .value { font-weight: 700; color: var(--text-primary); }

.totals-row.discount-row .value { color: #10b981; }

.totals-row.total-row {
  border-top: 2px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
  background: rgba(99,102,241,0.04);
  border-radius: 0 0 12px 12px;
  padding: 14px 16px;
  margin: 8px -20px -18px;
}

.totals-row.total-row .label {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.totals-row.total-row .value {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--primary);
}

/* ===================== INVOICE PREVIEW ===================== */
.preview-container {
  width: 100%;
  max-width: 700px;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
}

.preview-controls-left {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
  animation: livePulse 2s infinite;
  flex-shrink: 0;
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.preview-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-scale-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.78rem;
}

.preview-scale-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(99,102,241,0.06);
}

.zoom-level-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 38px;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
}

/* ===================== INVOICE DOCUMENT ===================== */
.invoice-document {
  width: 100%;
  background: white;
  box-shadow: 0 8px 40px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  border-radius: 6px;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  color: #1a1a2e;
}

/* Template: Classic */
.invoice-document.template-classic {
  border-top: 5px solid #6366f1;
}

.inv-header-classic {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 32px;
  border-bottom: 2px solid #f1f5f9;
}

.inv-logo-area img { max-width: 120px; max-height: 60px; object-fit: contain; }
.inv-logo-placeholder {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.4rem;
}

.inv-title-area { text-align: right; }
.inv-title { font-size: 2rem; font-weight: 900; color: #6366f1; letter-spacing: 0.1em; }
.inv-number { font-size: 0.78rem; color: #64748b; margin-top: 6px; }
.inv-number span { font-weight: 700; color: #1a1a2e; }

.inv-body { padding: 24px 32px; }

.inv-billing-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.inv-from, .inv-to, .inv-dates {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-section-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: #6366f1;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid #6366f1;
  display: inline-block;
}

.inv-company-name { font-size: 0.95rem; font-weight: 800; color: #1a1a2e; margin-bottom: 2px; }
.inv-detail-text { font-size: 0.78rem; color: #475569; line-height: 1.5; }
.inv-date-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; }
.inv-date-row .inv-date-label { color: #64748b; }
.inv-date-row .inv-date-val { font-weight: 700; color: #1a1a2e; }

/* Items Table in Preview */
.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.82rem;
}

.inv-items-table thead tr {
  background: #6366f1;
  color: white;
}

.inv-items-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inv-items-table thead th:last-child { text-align: right; }

.inv-items-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}

.inv-items-table tbody tr:hover { background: #f8fafc; }
.inv-items-table tbody tr:nth-child(even) { background: #fafafa; }

.inv-items-table tbody td {
  padding: 10px 12px;
  color: #1a1a2e;
  vertical-align: middle;
}

.inv-items-table tbody td:last-child {
  text-align: right;
  font-weight: 700;
}

.inv-item-desc { font-weight: 600; }
.inv-item-sub-desc { font-size: 0.72rem; color: #64748b; margin-top: 2px; }

.inv-totals-section {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 28px;
}

.inv-totals-table { width: 260px; font-size: 0.82rem; }

.inv-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}

.inv-total-row .inv-tl { color: #64748b; }
.inv-total-row .inv-tv { font-weight: 600; color: #1a1a2e; }

.inv-grand-total {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.inv-grand-total .inv-tl {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inv-grand-total .inv-tv {
  font-size: 1.2rem;
  font-weight: 900;
  color: white;
}

.inv-notes-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-top: 20px;
  border-top: 2px dashed #e2e8f0;
}

.inv-notes-col h4 {
  font-size: 0.7rem;
  font-weight: 800;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.inv-notes-col p {
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.6;
}

.inv-footer {
  background: #f8fafc;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid #e2e8f0;
  margin-top: 16px;
}

.inv-footer-brand { font-size: 0.72rem; color: #94a3b8; }
.inv-footer-brand strong { color: #6366f1; }

.inv-qr-code { width: 48px; height: 48px; }

/* Template: Modern */
.invoice-document.template-modern {
  background: #0f172a;
  color: white;
}

.inv-header-modern {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  padding: 40px 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.inv-header-modern .inv-title { color: rgba(255,255,255,0.9); font-size: 1.8rem; }
.inv-header-modern .inv-number { color: rgba(255,255,255,0.7); }
.inv-header-modern .inv-company-name { color: white; }
.inv-header-modern .inv-detail-text { color: rgba(255,255,255,0.7); }

.inv-body-modern { padding: 28px 32px; }
.inv-body-modern .inv-section-label { color: #818cf8; border-bottom-color: #818cf8; }
.inv-body-modern .inv-company-name { color: white; }
.inv-body-modern .inv-detail-text { color: #94a3b8; }
.inv-body-modern .inv-date-row .inv-date-label { color: #64748b; }
.inv-body-modern .inv-date-row .inv-date-val { color: #e2e8f0; }

.inv-body-modern .inv-items-table thead tr { background: #1e293b; }
.inv-body-modern .inv-items-table tbody tr { border-bottom-color: #1e293b; }
.inv-body-modern .inv-items-table tbody tr:nth-child(even) { background: #1e293b; }
.inv-body-modern .inv-items-table tbody td { color: #e2e8f0; }
.inv-body-modern .inv-total-row .inv-tl { color: #64748b; }
.inv-body-modern .inv-total-row .inv-tv { color: #e2e8f0; }
.inv-body-modern .inv-total-row { border-bottom-color: #1e293b; }
.inv-body-modern .inv-notes-section { border-top-color: #1e293b; }
.inv-body-modern .inv-notes-col p { color: #94a3b8; }

.inv-footer-modern {
  background: #1e293b;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Template: Minimal */
.invoice-document.template-minimal { font-family: 'Plus Jakarta Sans', sans-serif; }

.inv-header-minimal {
  padding: 40px 40px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.inv-title-minimal {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: #6366f1;
  text-transform: uppercase;
  background: rgba(99,102,241,0.08);
  padding: 6px 14px;
  border-radius: 4px;
}

.inv-body-minimal { padding: 0 40px 32px; }
.inv-body-minimal .inv-billing-section {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
}

.inv-body-minimal .inv-items-table thead tr { background: transparent; color: #1a1a2e; }
.inv-body-minimal .inv-items-table thead { border-bottom: 2px solid #1a1a2e; }
.inv-body-minimal .inv-items-table thead th { padding-top: 0; color: #1a1a2e; }

/* Template: Bold */
.invoice-document.template-bold .inv-header-bold {
  background: linear-gradient(135deg, #1e1b4b, #6366f1);
  padding: 40px 32px;
}

/* ===================== VOICE INPUT ===================== */
.voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.voice-btn:hover, .voice-btn.recording {
  background: #f43f5e;
  color: white;
  border-color: #f43f5e;
  animation: voicePulse 1s infinite;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(244,63,94,0); }
}

/* ===================== COLOR PICKER ===================== */
.color-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2.5px solid transparent;
}

.color-swatch:hover, .color-swatch.active {
  transform: scale(1.2);
  border-color: white;
  box-shadow: 0 0 0 2px var(--primary), 0 3px 8px rgba(0,0,0,0.2);
}

/* ===================== PRESET BUTTONS ===================== */
.preset-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 7px 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99,102,241,0.06);
  transform: translateY(-1px);
}

/* ===================== STATUS BADGE ===================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-badge.draft { background: rgba(100,116,139,0.1); color: #64748b; }
.status-badge.sent { background: rgba(6,182,212,0.1); color: #0891b2; }
.status-badge.paid { background: rgba(16,185,129,0.1); color: #059669; }

/* ===================== AI MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-card);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  max-width: 520px;
  width: 100%;
  transform: scale(0.93) translateY(16px);
  transition: all 0.3s ease;
}

.modal-overlay.open .modal-box {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h3 i { color: var(--primary); }

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close-btn:hover { color: #f43f5e; border-color: #f43f5e; background: rgba(244,63,94,0.06); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===================== SHARE MODAL ===================== */
.share-link-input {
  display: flex;
  gap: 8px;
}

.share-link-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.copy-link-btn {
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-link-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ===================== TOAST NOTIFICATIONS ===================== */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  min-width: 280px;
  animation: toastIn 0.3s ease;
  font-size: 0.87rem;
  font-weight: 500;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #f43f5e; }
.toast.info { border-left: 4px solid var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===================== SAVED INVOICES PANEL ===================== */
.saved-invoices-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: 340px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.1);
}

.saved-invoices-panel.open { transform: translateX(0); }

.saved-invoice-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.saved-invoice-card:hover {
  border-color: var(--primary);
  background: rgba(99,102,241,0.04);
  transform: translateY(-1px);
}

/* ===================== TEMPLATE GALLERY ===================== */
.template-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.template-gallery-item {
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
}

.template-gallery-item:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(99,102,241,0.15);
}

.template-gallery-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.template-gallery-preview {
  height: 160px;
  overflow: hidden;
  background: #f8fafc;
}

.template-gallery-label {
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.use-tpl-btn {
  font-size: 0.72rem;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s;
}

.use-tpl-btn:hover { filter: brightness(1.1); }

/* ===================== MOBILE TAB SWITCHER ===================== */
.mobile-tab-switcher {
  display: none;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-tab {
  flex: 1;
  padding: 13px;
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 3px solid transparent;
}

.mobile-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(99,102,241,0.04);
}

/* ===================== SECTION COMPLETION INDICATOR ===================== */
.section-complete-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  margin-left: auto;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ===================== SIGNATURE PAD ===================== */
#signatureCanvas {
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  cursor: crosshair;
  width: 100%;
  max-width: 100%;
  display: block;
  touch-action: none;
  transition: border-color 0.2s;
}

#signatureCanvas:hover { border-color: var(--primary); }

/* ===================== PROGRESS TRACKER ===================== */
.progress-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  position: relative;
}

.progress-step:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -4px;
  width: 1px;
  height: 24px;
  background: var(--border);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.2s;
}

.progress-step.done .step-num {
  background: #10b981;
  border-color: #10b981;
  color: white;
}

.step-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-step.done .step-label { color: #059669; }

/* ===================== INVOICE COLOR PANEL ===================== */
.color-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 14px;
}

.color-panel-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .generator-main {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .mobile-tab-switcher {
    display: flex !important;
  }

  /* On mobile, panels are controlled by JS via inline style + mobile-active class */
  /* Default state: form shown (set by MobileView.init()), preview hidden */
  .generator-form-panel {
    height: auto !important;
    min-height: 50vh;
    overflow-y: visible !important;
  }

  .generator-preview-panel {
    height: auto !important;
    min-height: 60vh;
    overflow-y: visible !important;
    padding: 16px 20px;
  }

  .generator-preview-panel.mobile-active {
    align-items: center;
  }

  .generator-toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px;
    gap: 8px;
  }

  .toolbar-btn-text { display: none; }

  .template-select-bar {
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 600px) {
  .generator-form-panel { padding: 14px 14px 80px !important; }
  .generator-preview-panel { padding: 12px 10px !important; }
  .form-row { grid-template-columns: 1fr !important; }
  .progress-steps { display: none; }

  .generator-toolbar { padding: 8px 12px; gap: 6px; }
  .toolbar-btn { padding: 8px 10px; font-size: 0.8rem; }
  .toolbar-left, .toolbar-right { gap: 6px; flex-wrap: wrap; }

  /* Scale invoice preview on small phone */
  .invoice-preview-wrap {
    transform: scale(0.75);
    transform-origin: top center;
    width: 133%;
    margin-left: -16.5%;
  }
}

@media (max-width: 400px) {
  .generator-form-panel { padding: 10px 10px 80px; }
  .invoice-preview-wrap { transform: scale(0.62); transform-origin: top center; }
}
