/* ===================================================================
   InvoiceForge — Premium Design System
   =================================================================== */

/* — Google Fonts — */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* — CSS Custom Properties — */
:root {
  /* Colors - Dakshi Admin Dark Theme */
  --color-navy:        #ffffff; /* Main text in dark mode */
  --color-navy-light:  #f3f4f6; /* gray-100 */
  --color-navy-mid:    #e5e7eb; /* gray-200 */
  --color-blue:        #3b82f6; /* Accent */
  --color-blue-dark:   #2563eb;
  --color-sky:         #0ea5e9;
  --color-sky-light:   #38bdf8;
  --color-slate-50:    #111827; /* Background gray-900 */
  --color-slate-100:   #1f2937; /* Card gray-800 */
  --color-slate-200:   #374151; /* Borders gray-700 */
  --color-slate-300:   #4b5563; /* gray-600 */
  --color-slate-400:   #6b7280; /* gray-500 */
  --color-slate-500:   #9ca3af; /* gray-400 */
  --color-slate-600:   #d1d5db; /* Body text gray-300 */
  --color-slate-700:   #f3f4f6; /* gray-100 */
  --color-white:       #111827; /* Inverted white (useful for flat cards etc) */
  --color-card-bg:     #1f2937; /* Dark Card Background */
  --color-success:     #22c55e;
  --color-success-bg:  rgba(34, 197, 94, 0.2);
  --color-danger:      #ef4444;
  --color-danger-bg:   rgba(239, 68, 68, 0.2);
  --color-warning:     #f59e0b;
  --color-warning-bg:  rgba(245, 158, 11, 0.2);

  /* Gradients */
  --gradient-primary:  linear-gradient(135deg, var(--color-blue) 0%, var(--color-sky) 100%);
  --gradient-hero:     linear-gradient(160deg, #111827 0%, #1f2937 40%, #111827 100%);
  --gradient-card:     linear-gradient(145deg, #1f2937 0%, #374151 100%);
  --gradient-glass:    linear-gradient(135deg, rgba(31,41,55,0.7) 0%, rgba(31,41,55,0.3) 100%);

  /* Typography */
  --font-body:    'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Poppins', sans-serif;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Shadows - Dark Theme Adjustments */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,0.5), 0 2px 4px -2px rgba(0,0,0,0.4);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,0.6), 0 4px 6px -4px rgba(0,0,0,0.4);
  --shadow-xl:   0 20px 25px -5px rgba(0,0,0,0.7), 0 8px 10px -6px rgba(0,0,0,0.5);
  --shadow-2xl:  0 25px 50px -12px rgba(0,0,0,0.8);
  --shadow-glow: 0 0 25px rgba(59,130,246,0.3), 0 0 45px rgba(14,165,233,0.1);
  --shadow-card-hover: 0 20px 40px -8px rgba(0,0,0,0.8), 0 0 15px rgba(59,130,246,0.15);

  /* Border Radius */
  --radius-sm:   0.375rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-2xl:  1.25rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --container-max: 1200px;
  --navbar-height: 72px;
}

/* — Base Reset — */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-navy);
  background-color: var(--color-slate-50);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 800px 600px at 20% 10%, rgba(59,130,246,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 600px 400px at 80% 80%, rgba(14,165,233,0.05) 0%, transparent 70%);
  background-color: var(--color-slate-50);
  pointer-events: none;
  z-index: -1;
}

/* — Typography — */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-navy);
}

h1 { font-size: 2.5rem; letter-spacing: -0.025em; }
h2 { font-size: 1.875rem; letter-spacing: -0.02em; }
h3 { font-size: 1.375rem; letter-spacing: -0.015em; }
h4 { font-size: 1.125rem; }

p {
  color: var(--color-slate-600);
  line-height: 1.7;
}

a {
  color: var(--color-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-blue-dark);
}

/* — Container — */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ===================================================================
   Navbar
   =================================================================== */
/* — Navbar — */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-slate-100);
  border-bottom: 1px solid var(--color-slate-200);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  height: var(--navbar-height);
  display: flex;
  align-items: center;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-glow);
  transition: transform var(--transition-spring);
}

.navbar-brand:hover .brand-icon {
  transform: rotate(-8deg) scale(1.08);
}

.navbar-brand .brand-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.3rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-slate-600); /* Dark text for light theme */
  transition: all var(--transition-base);
  text-decoration: none;
  position: relative;
}

.navbar-links a:hover {
  color: var(--color-navy);
  background: rgba(15,23,42,0.05);
}

.navbar-links a.active {
  color: var(--color-blue-dark);
  background: rgba(59,130,246,0.1);
}

.navbar-links a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

.navbar-links .nav-icon {
  font-size: 1.1rem;
  opacity: 0.8;
}

/* Mobile hamburger */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-slate-300);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.navbar-toggle:hover {
  background: rgba(255,255,255,0.08);
}

/* ===================================================================
   Hero Section
   =================================================================== */
.hero {
  text-align: center;
  padding: var(--space-3xl) 0 var(--space-2xl);
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -72px;
  left: 0;
  right: 0;
  height: 400px;
  background: var(--gradient-hero);
  z-index: -1;
  clip-path: ellipse(120% 100% at 50% 0%);
}

.hero h1 {
  color: var(--color-white);
  font-size: 2.75rem;
  margin-bottom: var(--space-md);
  animation: fadeInUp 0.6s ease-out both;
}

.hero h1 .accent {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--color-slate-400);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* ===================================================================
   Cards
   =================================================================== */
/* — Cards — */
.card {
  background: var(--color-card-bg);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.05);
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
  border-color: rgba(59,130,246,0.2);
}

.card:hover::before {
  opacity: 1;
}

.card-flat {
  composes: card;
  background: var(--color-white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-slate-200);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.card-flat:hover {
  box-shadow: var(--shadow-sm);
  transform: none;
}

/* Template Cards */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-xl);
  padding: var(--space-xl) 0 var(--space-3xl);
}

.template-card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-slate-200);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-smooth);
  cursor: pointer;
  animation: fadeInUp 0.5s ease-out both;
}

.template-card:nth-child(1) { animation-delay: 0.05s; }
.template-card:nth-child(2) { animation-delay: 0.12s; }
.template-card:nth-child(3) { animation-delay: 0.19s; }
.template-card:nth-child(4) { animation-delay: 0.26s; }
.template-card:nth-child(5) { animation-delay: 0.33s; }
.template-card:nth-child(6) { animation-delay: 0.40s; }

.template-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-6px);
  border-color: rgba(59,130,246,0.25);
}

.template-card .template-preview {
  height: 200px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-preview .preview-mockup {
  width: 120px;
  padding: 14px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: perspective(600px) rotateY(-4deg) rotateX(2deg);
  transition: transform var(--transition-smooth);
}

.template-card:hover .preview-mockup {
  transform: perspective(600px) rotateY(0deg) rotateX(0deg) scale(1.05);
}

.preview-mockup .mock-header {
  height: 6px;
  border-radius: 3px;
  margin-bottom: 8px;
}

.preview-mockup .mock-line {
  height: 3px;
  background: var(--color-slate-200);
  border-radius: 2px;
  margin-bottom: 5px;
}

.preview-mockup .mock-line:nth-child(3) { width: 80%; }
.preview-mockup .mock-line:nth-child(4) { width: 60%; }

.preview-mockup .mock-divider {
  height: 1px;
  background: var(--color-slate-200);
  margin: 10px 0;
}

.preview-mockup .mock-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.preview-mockup .mock-row span {
  height: 3px;
  border-radius: 2px;
  background: var(--color-slate-200);
}

.preview-mockup .mock-row span:first-child { width: 55%; }
.preview-mockup .mock-row span:last-child { width: 20%; }

.preview-mockup .mock-total {
  height: 4px;
  width: 40%;
  border-radius: 2px;
  margin-left: auto;
  margin-top: 8px;
}

.template-card .template-body {
  padding: var(--space-lg) var(--space-xl) var(--space-xl);
}

.template-card .template-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: var(--space-xs);
  color: var(--color-navy);
}

.template-card .template-desc {
  font-size: 0.875rem;
  color: var(--color-slate-500);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}

.btn:hover::after {
  background: rgba(255,255,255,0.1);
}

.btn:active {
  transform: scale(0.97);
}

/* Primary */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(59,130,246,0.35), 0 1px 2px rgba(59,130,246,0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(59,130,246,0.4), 0 2px 4px rgba(59,130,246,0.25);
  transform: translateY(-1px);
}

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

/* Secondary */
.btn-secondary {
  background: var(--color-white);
  color: var(--color-navy);
  border: 1.5px solid var(--color-slate-200);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--color-blue);
  color: var(--color-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239,68,68,0.35);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-slate-500);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* Sizes */
.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* ===================================================================
   Form Styles
   =================================================================== */
.form-section {
  margin-bottom: var(--space-xl);
}

.form-section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-navy);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-slate-100);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.form-section-title .section-icon {
  font-size: 1.2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-md) var(--space-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-slate-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-navy);
  background: var(--color-white);
  border: 1px solid var(--color-slate-200);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--color-white);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--color-slate-200);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-navy);
  background: var(--color-white);
  transition: all var(--transition-base);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-slate-400);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--color-slate-300);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* ===================================================================
   Tables
   =================================================================== */
.table-wrapper {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15, 23, 42, 0.05);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--color-slate-100);
  padding: 1rem 1.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--color-slate-400);
  border-bottom: 1px solid var(--color-slate-200);
}

td {
  padding: 1.25rem;
  border-bottom: 1px solid var(--color-slate-200);
  color: var(--color-slate-600);
}

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

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Line-items table in form */
.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table thead th {
  background: var(--color-slate-50);
  padding: 0.75rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--color-slate-200);
  text-align: left;
}

.items-table thead th:last-child {
  text-align: center;
  width: 60px;
}

.items-table tbody td {
  padding: 0.5rem 0.5rem;
  vertical-align: middle;
}

.items-table tbody td .form-input {
  padding: 0.55rem 0.7rem;
  font-size: 0.875rem;
}

.items-table tbody td:last-child {
  text-align: center;
}

.items-table .row-total {
  font-weight: 600;
  color: var(--color-navy);
  min-width: 100px;
  text-align: right;
  padding-right: 0.75rem;
}

/* Totals summary */
.totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

.totals-card {
  width: 320px;
  background: var(--color-slate-50);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-slate-200);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.totals-row .totals-label {
  color: var(--color-slate-500);
  font-weight: 500;
}

.totals-row .totals-value {
  font-weight: 600;
  color: var(--color-navy);
}

.totals-row.grand-total {
  border-top: 2px solid var(--color-slate-200);
  margin-top: var(--space-sm);
  padding-top: var(--space-md);
}

.totals-row.grand-total .totals-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-navy);
}

.totals-row.grand-total .totals-value {
  font-size: 1.2rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.totals-row .tax-input {
  width: 70px;
  padding: 0.35rem 0.5rem;
  text-align: right;
  border: 1.5px solid var(--color-slate-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-navy);
  outline: none;
  transition: border-color var(--transition-fast);
}

.totals-row .tax-input:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* ===================================================================
   Badges / Pills
   =================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--color-success-bg);
  color: #15803d;
}

.badge-danger {
  background: var(--color-danger-bg);
  color: #b91c1c;
}

.badge-warning {
  background: var(--color-warning-bg);
  color: #a16207;
}

.badge-info {
  background: rgba(59,130,246,0.1);
  color: var(--color-blue-dark);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ===================================================================
   Toast Notifications
   =================================================================== */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-height) + var(--space-md));
  right: var(--space-lg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  min-width: 320px;
  max-width: 420px;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--color-blue);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  pointer-events: all;
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
  overflow: hidden;
}

.toast.toast-exit {
  animation: toastSlideOut 0.3s ease-in both;
}

.toast-success {
  border-left-color: var(--color-success);
}

.toast-error {
  border-left-color: var(--color-danger);
}

.toast-warning {
  border-left-color: var(--color-warning);
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-navy);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--color-slate-400);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--color-navy);
}

/* Toast progress bar */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--color-blue);
  animation: toastProgress 4s linear both;
}

.toast-success::after { background: var(--color-success); }
.toast-error::after   { background: var(--color-danger); }

/* ===================================================================
   Loading Spinner
   =================================================================== */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-slate-200);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* Full-page loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-overlay .spinner {
  width: 52px;
  height: 52px;
  border-width: 4px;
  border-color: rgba(255,255,255,0.2);
  border-top-color: var(--color-sky-light);
}

.loading-overlay .loading-text {
  color: var(--color-white);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  animation: pulse 1.8s ease-in-out infinite;
}

/* Inline loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) 0;
  gap: var(--space-lg);
}

.loading-state p {
  font-size: 0.95rem;
  color: var(--color-slate-400);
}

/* ===================================================================
   Modal
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.modal {
  background: var(--color-white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  width: 90%;
  max-width: 520px;
  padding: var(--space-2xl);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-spring);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--color-slate-400);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-navy);
  background: var(--color-slate-100);
}

/* ===================================================================
   Pagination
   =================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xl) 0;
}

.pagination .page-btn {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-slate-200);
  background: var(--color-white);
  color: var(--color-slate-600);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: var(--font-body);
}

.pagination .page-btn:hover:not(:disabled) {
  border-color: var(--color-blue);
  color: var(--color-blue);
  background: rgba(59,130,246,0.04);
}

.pagination .page-btn.active {
  background: var(--gradient-primary);
  color: var(--color-white);
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}

.pagination .page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  padding: 0 var(--space-md);
  font-size: 0.875rem;
  color: var(--color-slate-500);
  font-weight: 500;
}

/* ===================================================================
   Empty State
   =================================================================== */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-lg);
  opacity: 0.6;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--color-navy);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 0.95rem;
  color: var(--color-slate-400);
  max-width: 360px;
  margin: 0 auto var(--space-xl);
}

/* ===================================================================
   Page Header (for inner pages)
   =================================================================== */
.page-header {
  padding: var(--space-2xl) 0 var(--space-lg);
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: var(--space-xs);
}

.page-header .page-subtitle {
  color: var(--color-slate-500);
  font-size: 1rem;
}

.page-header .template-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: 0.35rem 0.9rem;
  background: rgba(59,130,246,0.08);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-blue-dark);
}

/* ===================================================================
   Generate Button Area
   =================================================================== */
.generate-section {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-3xl);
}

.btn-generate {
  padding: 1rem 3rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-xl);
  background: var(--gradient-primary);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
  transition: all var(--transition-smooth);
  font-family: var(--font-heading);
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn-generate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.btn-generate:hover {
  box-shadow: 0 6px 24px rgba(59,130,246,0.45);
  transform: translateY(-2px);
}

.btn-generate:hover::before {
  left: 100%;
}

.btn-generate:active {
  transform: translateY(0) scale(0.98);
}

/* ===================================================================
   Animations / Keyframes
   =================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(110%);
  }
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--color-slate-100) 25%, var(--color-slate-200) 37%, var(--color-slate-100) 63%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ===================================================================
   Utility Classes
   =================================================================== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================================================================
   Responsive Breakpoints
   =================================================================== */
@media (max-width: 768px) {
  :root {
    --navbar-height: 64px;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }

  .hero h1 { font-size: 2rem; }
  .hero p  { font-size: 0.95rem; }

  .container { padding: 0 var(--space-md); }

  .template-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .totals-section {
    justify-content: stretch;
  }

  .totals-card {
    width: 100%;
  }

  .navbar-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(15,23,42,0.98);
    backdrop-filter: blur(20px);
    padding: var(--space-md);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: var(--space-xs);
  }

  .navbar-links.open {
    display: flex;
  }

  .navbar-toggle {
    display: block;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .toast {
    min-width: 280px;
    max-width: calc(100vw - 2rem);
    right: var(--space-md);
  }

  .btn-generate {
    width: 100%;
    padding: 1rem 2rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .table-wrapper {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }

  .card { padding: var(--space-lg); }

  .template-card .template-body {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
  }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}

/* ===================================================================
   WYSIWYG Form Styles
   =================================================================== */

.wysiwyg-body {
    background-color: var(--color-slate-100);
}

.wysiwyg-page {
    background: #fff;
    color: #000;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 4rem;
}

/* Force text inside the invoice to be black but exclude specific elements that need white text */
.wysiwyg-page *:not(th):not(.btn) {
    color: #000 !important;
}

/* Exempt placeholders so they can be slightly grey if needed, but black is fine */
.wysiwyg-page input::placeholder, .wysiwyg-page textarea::placeholder {
    color: rgba(0,0,0,0.5) !important;
}
.wysiwyg-page {
    padding: 36px 42px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
    border-radius: 4px;
    position: relative;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    color: #000;
    font-size: 11.5px;
    line-height: 1.5;
    font-weight: 500;
}

.wysiwyg-page .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 14px;
    border-bottom: 2.5px solid #000;
}
.wysiwyg-page .header-left h1 {
    font-size: 21px;
    font-weight: 800;
    color: #000;
    margin-bottom: 0;
}
.wysiwyg-page .header-left .tagline {
    font-size: 11px;
    color: #6b7280;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.wysiwyg-page .header-right {
    text-align: right;
    font-size: 10.5px;
    color: #000;
    line-height: 1.7;
    font-weight: 600;
}
.wysiwyg-page .header-right a {
    color: #000;
    text-decoration: none;
    font-weight: 700;
}
.wysiwyg-page .title {
    text-align: center;
    padding: 12px 0;
    font-size: 17px;
    font-weight: 800;
    color: #000;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid #d1d5db;
}
.wysiwyg-page .company-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 0;
    font-size: 11px;
    color: #000;
    border-bottom: 1px solid #d1d5db;
    gap: 8px;
}
.wysiwyg-page .company-details p { margin-bottom: 1px; }
.wysiwyg-page .label { font-weight: 800; color: #000; }
.wysiwyg-page .info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1.5px solid #d1d5db;
    margin-top: 14px;
}
.wysiwyg-page .info-block { padding: 14px 16px; }
.wysiwyg-page .info-block:first-child { border-right: 1.5px solid #d1d5db; }
.wysiwyg-page .info-block h3 {
    font-size: 11px;
    font-weight: 800;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.wysiwyg-page .original-badge {
    display: inline-block;
    border: 2px solid #000;
    color: #000;
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 4px;
}
/* work-order removed */
.wysiwyg-page .table-wrapper { 
    margin-top: 16px; 
    position: relative;
    z-index: 1;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    border: none;
}
.wysiwyg-page .table-wrapper::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 90%;
    background-image: var(--watermark-img, url('https://i.postimg.cc/9FGZ1ddN/IMG-20240907-WA0001.jpg'));
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.12;
    z-index: -1;
    pointer-events: none;
}
.wysiwyg-page table.wysiwyg-table {
    width: 100%;
    border-collapse: collapse;
}
.wysiwyg-page table.wysiwyg-table th {
    background: #000;
    color: #fff !important;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1.5px solid #000;
}
.wysiwyg-page table.wysiwyg-table td {
    padding: 6px 8px;
    border: 1.5px solid #d1d5db;
    vertical-align: top;
    color: #000;
}
.wysiwyg-page table.wysiwyg-table .align-r { text-align: right; }

.wysiwyg-page .grand-total-row {
    display: flex;
    justify-content: flex-end;
    border: 1.5px solid #e5e7eb;
    border-top: none;
}
.wysiwyg-page .gt-cell {
    background: transparent;
    color: #000;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.wysiwyg-page .gt-cell .gt-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.wysiwyg-page .gt-cell .gt-amount {
    font-size: 21px;
    font-weight: 800;
}

.wysiwyg-page .bottom-section {
    display: grid;
    grid-template-columns: 2fr 3fr;
    border: 1.5px solid #d1d5db;
    margin-top: 16px;
}
.wysiwyg-page .bottom-block { padding: 14px 16px; }
.wysiwyg-page .bottom-block:first-child { border-right: 1.5px solid #d1d5db; }
.wysiwyg-page .bottom-block h4 {
    font-size: 11px;
    font-weight: 800;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.wysiwyg-page .bottom-block p {
    font-size: 11.5px;
    color: #000;
    line-height: 1.6;
    font-weight: 600;
}
.wysiwyg-page .bank-table { width: 100%; font-size: 11.5px; }
.wysiwyg-page .bank-table td { padding: 3px 0; border: none !important; color: #000; }
.wysiwyg-page .bank-table td:first-child { font-weight: 600; width: 120px; text-align: left; }
.wysiwyg-page .bank-table td:last-child { font-weight: 800; text-align: left; }

.wysiwyg-page .signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
}
.wysiwyg-page .sig-block { 
    text-align: center; 
    padding: 10px 16px; 
    display: flex;
    flex-direction: column;
}
.wysiwyg-page .sig-block:first-child { border-right: 1.5px solid #d1d5db; }
.wysiwyg-page .org-name {
    font-size: 10px;
    font-weight: 800;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.wysiwyg-page .sig-line {
    border-top: 1.5px solid #000;
    margin-top: auto;
    padding-top: 6px;
    font-size: 10.5px;
    color: #000;
    font-weight: 700;
}
.wysiwyg-page .sig-img {
    max-height: 120px;
    width: auto;
    display: block;
    margin: 4px auto 0;
    object-fit: contain;
}
.wysiwyg-page .footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 2.5px solid #000;
    text-align: center;
    font-size: 10px;
    color: #000;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* ===================================================================
   Global Footer & Status Pills
   =================================================================== */
.global-footer {
  margin-top: auto;
  padding: 3rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: var(--color-slate-50);
  text-align: center;
  color: var(--color-slate-500);
  font-size: 0.85rem;
}
.global-footer a {
  color: var(--color-slate-400);
  margin: 0 0.5rem;
  transition: color var(--transition-fast);
}
.global-footer a:hover {
  color: var(--color-white);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-pill.generated {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.status-pill.failed {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Invisible inputs */
.wysiwyg-input, .wysiwyg-textarea {
    border: 1px dashed transparent;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    padding: 4px;
    width: 100%;
    outline: none;
    transition: all 0.2s;
    border-radius: 4px;
}
.wysiwyg-input:hover, .wysiwyg-textarea:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}
.wysiwyg-input:focus, .wysiwyg-textarea:focus {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.wysiwyg-input.inline-input {
    display: inline-block;
    width: auto;
    min-width: 150px;
    padding: 2px 6px;
}
.wysiwyg-input.bold-input {
    font-weight: 800;
}
.wysiwyg-input.name-input {
    font-size: 14px;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 4px;
}
.address-textarea {
    resize: none;
    height: 50px;
}

@media print {
    .no-print {
        display: none !important;
    }
}

/* Premium Search Bar UI */
.search-wrapper {
    position: relative;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-slate-400);
}

.search-input-premium {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-body);
    font-weight: 500;
    color: #1f2937;
    background: #f1f5f9;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.search-input-premium:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.search-input-premium::placeholder {
    color: var(--color-slate-400);
}
