/* 
  =========================================
  AURA INVOICE — PREMIUM CSS DESIGN SYSTEM
  =========================================
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Theme Variables --- */
:root {
  /* HSL Color Palette (Dark Theme Default) */
  --bg-hue: 222;
  --bg-sat: 47%;
  --bg-light: 6%; /* Deep dark background */
  
  --background: hsl(var(--bg-hue), var(--bg-sat), var(--bg-light));
  --card-bg: hsla(var(--bg-hue), 25%, 12%, 0.7);
  --card-hover: hsla(var(--bg-hue), 25%, 16%, 0.8);
  --border: hsla(var(--bg-hue), 16%, 22%, 0.6);
  --text-primary: hsl(var(--bg-hue), 20%, 95%);
  --text-secondary: hsl(var(--bg-hue), 12%, 65%);
  --text-muted: hsl(var(--bg-hue), 8%, 45%);
  
  --primary-hue: 243;
  --primary-sat: 75%;
  --primary-light: 59%;
  --primary: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
  --primary-hover: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 8%));
  --primary-glow: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.15);
  
  --secondary: hsl(190, 90%, 45%);
  --secondary-glow: hsla(190, 90%, 45%, 0.15);
  
  --success: hsl(142, 70%, 45%);
  --success-glow: hsla(142, 70%, 45%, 0.15);
  
  --warning: hsl(38, 92%, 50%);
  --danger: hsl(350, 80%, 55%);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  
  --glow-radius: 400px;
}

/* --- Light Theme Overrides --- */
body.light-theme {
  --bg-hue: 210;
  --bg-sat: 20%;
  --bg-light: 98%; /* Pearl White */
  
  --background: hsl(var(--bg-hue), var(--bg-sat), var(--bg-light));
  --card-bg: hsla(var(--bg-hue), 30%, 100%, 0.8);
  --card-hover: hsla(var(--bg-hue), 20%, 94%, 0.9);
  --border: hsla(var(--bg-hue), 15%, 88%, 0.8);
  --text-primary: hsl(var(--bg-hue), 30%, 10%);
  --text-secondary: hsl(var(--bg-hue), 15%, 40%);
  --text-muted: hsl(var(--bg-hue), 10%, 60%);
  
  --primary-light: 50%;
  --primary: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
  --primary-hover: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 8%));
  --primary-glow: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.08);
  
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.1);
}

/* --- General Resets & Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Glowing cursor background pointer effect */
body::before {
  content: '';
  position: absolute;
  top: var(--mouse-y, -1000px);
  left: var(--mouse-x, -1000px);
  width: var(--glow-radius);
  height: var(--glow-radius);
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s ease;
}

/* Typography styles */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--background);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Header & Shell --- */
header.app-header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: hsla(var(--bg-hue), var(--bg-sat), var(--bg-light), 0.7);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 1.5rem;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white !important;
  font-weight: 800;
  -webkit-text-fill-color: white !important;
}

nav.main-nav {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: var(--card-hover);
}

.nav-btn.active {
  color: var(--primary);
  background: var(--primary-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Theme switch toggle button */
.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.theme-toggle:hover {
  transform: rotate(20deg) scale(1.05);
  background: var(--card-hover);
  border-color: var(--text-muted);
}

/* --- Base Layout & Shell States --- */
main.app-viewport {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: none;
  animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-section.active {
  display: block;
}

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

/* --- Common UI Components --- */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.glass-card:hover {
  box-shadow: var(--shadow-lg);
}

.glow-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glow-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.3);
}

.glow-btn:active {
  transform: translateY(1px);
}

.glow-btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.glow-btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

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

.form-input, .form-select, .form-textarea {
  background: hsla(var(--bg-hue), 20%, 8%, 0.4);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: all 0.2s ease;
}

body.light-theme .form-input, 
body.light-theme .form-select, 
body.light-theme .form-textarea {
  background: hsla(var(--bg-hue), 20%, 96%, 0.8);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* --- 1. Dashboard View --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.metric-trend {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-trend.up {
  color: var(--success);
}
.metric-trend.down {
  color: var(--danger);
}

.analytics-charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 968px) {
  .analytics-charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-container {
  min-height: 250px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Recent Invoices Ledger Table */
.recent-invoices-section {
  display: flex;
  flex-direction: column;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.ledger-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

table.ledger-table th {
  background: hsla(var(--bg-hue), 20%, 8%, 0.3);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

body.light-theme table.ledger-table th {
  background: hsla(var(--bg-hue), 10%, 95%, 0.5);
}

table.ledger-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

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

table.ledger-table tr:hover td {
  background: var(--card-hover);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.paid {
  background: var(--success-glow);
  color: var(--success);
}
.status-badge.sent {
  background: var(--primary-glow);
  color: var(--primary);
}
.status-badge.overdue {
  background: hsla(350, 80%, 55%, 0.15);
  color: var(--danger);
}
.status-badge.draft {
  background: hsla(var(--bg-hue), 8%, 45%, 0.15);
  color: var(--text-secondary);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

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

.action-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--card-hover);
}

/* --- 2. Invoice Editor View --- */
.editor-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
}

.editor-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  position: sticky;
  top: 90px;
  padding-right: 0.5rem;
}

.control-section-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Color select dots grid */
.color-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

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

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--text-primary);
  transform: scale(1.1);
}

.color-swatch.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  font-size: 0.75rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Image logo drop zone */
.logo-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  background: hsla(var(--bg-hue), 20%, 8%, 0.2);
  transition: all 0.2s ease;
  position: relative;
}

.logo-upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.logo-upload-zone p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.logo-preview-img {
  max-height: 50px;
  max-width: 150px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

/* Ledgers interactive lines custom grid */
.item-line-row {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1.25fr 1.25fr 1.25fr auto;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.item-line-headers {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1.25fr 1.25fr 1.25fr auto;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  font-weight: 700;
  padding: 0 0.25rem;
}

/* AI Receipts parser integration layout */
.ai-helper-card {
  background: linear-gradient(135deg, hsla(243, 75%, 59%, 0.1), hsla(190, 90%, 45%, 0.1));
  border: 1px dashed var(--primary);
}

.ai-upload-input {
  display: none;
}

.ai-status-msg {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 0.5rem;
  display: none;
}

/* Right Pane: Page PDF-like replica container */
.preview-pane-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.preview-controls-bar {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.invoice-a4-canvas {
  background: white;
  color: #0f172a;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  width: 100%;
  aspect-ratio: 1 / 1.414; /* Standard A4 proportion */
  padding: 3rem;
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Customized templates styling dynamic hooks */
.invoice-a4-canvas[data-template="corporate"] {
  border-top: 24px solid var(--brand-primary, var(--primary));
}

.invoice-a4-canvas[data-template="glass"] {
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
}

.invoice-a4-canvas[data-template="glass"]::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--brand-primary, var(--primary)) 0%, transparent 80%);
  opacity: 0.15;
  filter: blur(20px);
}

.invoice-a4-canvas[data-template="bold"] {
  border-left: 16px solid var(--brand-primary, var(--primary));
}

.invoice-preview-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3rem;
}

.invoice-preview-logo-placeholder {
  height: 48px;
  max-width: 180px;
  display: flex;
  align-items: center;
}

.invoice-logo-img {
  max-height: 48px;
  object-fit: contain;
}

.invoice-org-details {
  text-align: right;
  font-size: 0.85rem;
  color: #475569;
}

.invoice-org-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.invoice-info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.invoice-meta-section {
  text-align: right;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: end;
  column-gap: 1.5rem;
  row-gap: 0.5rem;
  font-size: 0.9rem;
}

.invoice-meta-label {
  color: #64748b;
  font-weight: 500;
}

.invoice-meta-val {
  color: #0f172a;
  font-weight: 700;
}

.client-bill-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.client-name-preview {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.client-address-preview {
  color: #475569;
  font-size: 0.85rem;
  white-space: pre-line;
}

/* Custom ledger inside PDF replica */
.preview-ledger-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  flex: 1;
}

.preview-ledger-table th {
  border-bottom: 2px solid #e2e8f0;
  color: #64748b;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.75rem 0.5rem;
  text-align: left;
}

.preview-ledger-table th.num-col,
.preview-ledger-table td.num-col {
  text-align: right;
}

.preview-ledger-table td {
  border-bottom: 1px solid #f1f5f9;
  padding: 0.85rem 0.5rem;
  color: #334155;
  font-size: 0.85rem;
  vertical-align: top;
}

.preview-ledger-table td .item-desc-val {
  font-weight: 600;
  color: #0f172a;
}

.preview-ledger-totals-block {
  width: 280px;
  align-self: flex-end;
  display: grid;
  grid-template-columns: 1fr 1fr;
  row-gap: 0.5rem;
  column-gap: 1rem;
  font-size: 0.9rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
  margin-bottom: 2rem;
}

.preview-total-label {
  color: #64748b;
}

.preview-total-val {
  text-align: right;
  font-weight: 600;
  color: #334155;
}

.preview-total-final-row {
  grid-column: span 2;
  display: flex;
  justify-content: space-between;
  font-size: 1.15rem;
  font-weight: 800;
  border-top: 2px double #e2e8f0;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  color: var(--brand-primary, var(--primary));
}

.invoice-preview-footer {
  border-top: 1px solid #f1f5f9;
  padding-top: 1.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notes-block-preview {
  max-width: 60%;
}

.terms-block-preview {
  text-align: right;
}

/* --- 3. Client Portal View --- */
.portal-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 968px) {
  .portal-layout {
    grid-template-columns: 1fr;
  }
}

.portal-action-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 90px;
}

.portal-status-header {
  text-align: center;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.portal-status-header.paid {
  background: var(--success-glow);
  border: 1px solid var(--success);
}

.portal-status-header.pending {
  background: var(--primary-glow);
  border: 1px solid var(--primary);
}

.portal-status-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.portal-status-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* portal live comment feed */
.comment-feed-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.comment-item {
  background: hsla(var(--bg-hue), 20%, 8%, 0.2);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

body.light-theme .comment-item {
  background: hsla(var(--bg-hue), 20%, 96%, 0.6);
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
}

.comment-body {
  color: var(--text-primary);
  line-height: 1.4;
}

/* --- 4. Interactive Stripe Gateway Overlay Modals --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.payment-modal-box {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 450px;
  width: 90%;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.modal-overlay.active .payment-modal-box {
  transform: translateY(0);
}

.stripe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.stripe-lock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Card Inputs Simulation layout */
.credit-card-inputs {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: hsla(var(--bg-hue), 20%, 8%, 0.3);
  margin-bottom: 1.5rem;
}

.credit-card-inputs input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
}

.cc-expiry-cvc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* Loading animations */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success layout screens */
.payment-success-layout {
  text-align: center;
  display: none;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-icon-badge {
  width: 64px;
  height: 64px;
  background: var(--success-glow);
  color: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem auto;
  border: 2px solid var(--success);
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  pointer-events: none;
  display: none;
}

/* --- Dynamic print setups --- */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-family: 'Helvetica', 'Arial', sans-serif !important;
  }
  
  header.app-header, 
  nav.main-nav,
  .no-print,
  .editor-controls-panel,
  .preview-controls-bar,
  .portal-action-sidebar,
  body::before,
  button,
  .glow-btn,
  .glow-btn-secondary {
    display: none !important;
  }
  
  main.app-viewport {
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .view-section {
    display: block !important;
  }
  
  .editor-layout {
    grid-template-columns: 1fr !important;
  }
  
  .invoice-a4-canvas {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    aspect-ratio: auto !important;
    color: black !important;
  }
  
  .preview-ledger-totals-block {
    margin-bottom: 0 !important;
  }
}
