/* ==========================================================================
   ToolNest - Professional Universal Invoice Generator Stylesheet
   8 Distinct Professional Business Templates + Responsive Editing Engine
   ========================================================================== */

/* Invoice Studio Workspace Layout */
.invoice-studio {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Step-by-Step Tabs Navigation */
.inv-steps-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface-subtle);
  padding: 0.4rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: thin;
}

.inv-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-lg);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.inv-step-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.inv-step-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.inv-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.75rem;
}
.inv-step-btn.active .inv-step-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Step Content Sections */
.inv-step-panel {
  display: none;
  animation: fadeIn 0.15s ease-in-out;
}
.inv-step-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Form Sections Card */
.inv-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.inv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.inv-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Two-column, Three-column responsive form grids */
.inv-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.inv-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.inv-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .inv-grid-2, .inv-grid-3, .inv-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Logo Upload Container */
.inv-logo-uploader {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.inv-logo-preview-box {
  width: 140px;
  height: 80px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-subtle);
  overflow: hidden;
  position: relative;
}

.inv-logo-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Line Items Table in Editor */
.inv-items-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  margin-bottom: 1rem;
}

.inv-edit-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.inv-edit-table th {
  background: var(--bg-surface-subtle);
  padding: 0.75rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  text-align: left;
}

.inv-edit-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.inv-edit-table tr:hover {
  background: rgba(2, 132, 199, 0.02);
}

.inv-row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Template Selector Grid */
.inv-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.inv-template-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1rem;
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.inv-template-card:hover {
  border-color: var(--brand-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.inv-template-card.active {
  border-color: var(--brand-blue);
  background: var(--brand-gradient-soft);
  box-shadow: 0 0 0 2px var(--brand-blue);
}

.inv-template-thumb {
  height: 120px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.35rem;
  pointer-events: none;
  overflow: hidden;
}

.inv-template-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.inv-template-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Live Preview Sheet */
.inv-preview-sheet-wrap {
  background: #525659;
  padding: 2.5rem 1rem;
  border-radius: var(--radius-xl);
  overflow: auto;
  display: flex;
  justify-content: center;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.inv-sheet {
  width: 100%;
  max-width: 800px;
  min-height: 1050px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 3rem 2.8rem;
  font-family: var(--font-sans);
  position: relative;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.5;
}

/* Zoom Controls Bar */
.inv-zoom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ==========================================================================
   TEMPLATES STYLING (8 Visually Distinct Templates)
   ========================================================================== */

/* 1. Classic Business */
.inv-sheet.tmpl-classic {
  font-family: Georgia, 'Times New Roman', serif;
  color: #111827;
}
.inv-sheet.tmpl-classic .sheet-header {
  border-bottom: 2px solid #111827;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}
.inv-sheet.tmpl-classic .sheet-title {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #111827;
  text-transform: uppercase;
}
.inv-sheet.tmpl-classic table th {
  background: transparent;
  border-top: 1px solid #111827;
  border-bottom: 2px solid #111827;
  color: #111827;
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 0.6rem 0.5rem;
}
.inv-sheet.tmpl-classic table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 0.5rem;
}
.inv-sheet.tmpl-classic .total-line-grand {
  border-top: 2px solid #111827;
  border-bottom: 3px double #111827;
}

/* 2. Modern Minimal */
.inv-sheet.tmpl-modern {
  font-family: var(--font-sans);
  color: #0f172a;
}
.inv-sheet.tmpl-modern .sheet-header {
  margin-bottom: 2.5rem;
}
.inv-sheet.tmpl-modern .sheet-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--inv-primary, #0284c7);
  letter-spacing: -0.02em;
}
.inv-sheet.tmpl-modern table th {
  background: #f8fafc;
  color: #64748b;
  font-size: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
}
.inv-sheet.tmpl-modern table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.inv-sheet.tmpl-modern .meta-box {
  background: #f8fafc;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
}

/* 3. Corporate Premium */
.inv-sheet.tmpl-corporate {
  padding: 0;
}
.inv-sheet.tmpl-corporate .sheet-top-banner {
  background: var(--inv-primary, #0f172a);
  color: #ffffff;
  padding: 2.5rem 2.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.inv-sheet.tmpl-corporate .sheet-top-banner .sheet-title {
  color: #ffffff;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}
.inv-sheet.tmpl-corporate .sheet-body {
  padding: 2.5rem 2.8rem;
}
.inv-sheet.tmpl-corporate table th {
  background: #1e293b;
  color: #ffffff;
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
}
.inv-sheet.tmpl-corporate table tr:nth-child(even) {
  background: #f8fafc;
}
.inv-sheet.tmpl-corporate table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

/* 4. Elegant Professional */
.inv-sheet.tmpl-elegant {
  color: #334155;
}
.inv-sheet.tmpl-elegant .sheet-header {
  border-bottom: 2px solid #b45309;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}
.inv-sheet.tmpl-elegant .sheet-title {
  font-size: 2.2rem;
  font-weight: 300;
  color: #b45309;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.inv-sheet.tmpl-elegant table th {
  background: #fffbeb;
  color: #92400e;
  border-top: 1px solid #fef3c7;
  border-bottom: 1px solid #fde68a;
  padding: 0.75rem;
  font-size: 0.8rem;
}
.inv-sheet.tmpl-elegant table td {
  padding: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

/* 5. Creative Agency */
.inv-sheet.tmpl-creative {
  position: relative;
  overflow: hidden;
}
.inv-sheet.tmpl-creative::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 100%;
  background: linear-gradient(180deg, #0284c7 0%, #7c3aed 100%);
}
.inv-sheet.tmpl-creative .sheet-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #0284c7 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.inv-sheet.tmpl-creative table th {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  font-weight: 700;
  padding: 0.75rem;
  border-radius: var(--radius-md);
}

/* 6. Retail Invoice */
.inv-sheet.tmpl-retail {
  font-size: 13px;
}
.inv-sheet.tmpl-retail .sheet-header {
  text-align: center;
  border-bottom: 1px dashed #64748b;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}
.inv-sheet.tmpl-retail table th {
  border-top: 1px dashed #64748b;
  border-bottom: 1px dashed #64748b;
  background: transparent;
  padding: 0.5rem;
}
.inv-sheet.tmpl-retail table td {
  padding: 0.5rem;
  border-bottom: 1px dotted #cbd5e1;
}

/* 7. Freelance Invoice */
.inv-sheet.tmpl-freelance {
  color: #1e293b;
}
.inv-sheet.tmpl-freelance .sheet-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #059669;
}
.inv-sheet.tmpl-freelance .highlight-bank-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  margin-top: 1.5rem;
}
.inv-sheet.tmpl-freelance table th {
  background: #f0fdf4;
  color: #065f46;
  padding: 0.75rem;
}

/* 8. International Invoice */
.inv-sheet.tmpl-international {
  border: 1px solid #cbd5e1;
}
.inv-sheet.tmpl-international .tax-crossborder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  background: #f8fafc;
}
.inv-sheet.tmpl-international table th {
  background: #0369a1;
  color: #ffffff;
  padding: 0.75rem;
  font-size: 0.8rem;
}

/* Print Specific Isolation Rules for Invoices */
#toolnest-isolated-print-invoice {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body.printing-invoice {
    background: #ffffff !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Completely hide entire web application shell, header, nav, modals, and buttons */
  body.printing-invoice * {
    visibility: hidden !important;
  }

  /* Make ONLY the isolated invoice container visible */
  body.printing-invoice #toolnest-isolated-print-invoice,
  body.printing-invoice #toolnest-isolated-print-invoice * {
    visibility: visible !important;
  }

  body.printing-invoice #toolnest-isolated-print-invoice {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    border: none !important;
  }

  body.printing-invoice #toolnest-isolated-print-invoice .inv-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  /* Page break rules inside invoice table */
  body.printing-invoice table {
    page-break-inside: auto;
  }
  body.printing-invoice tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  body.printing-invoice thead {
    display: table-header-group;
  }
  body.printing-invoice tfoot {
    display: table-footer-group;
  }
}
