/* ============================================================
   Diginera Forms — Design System
   Aesthetic: "Warm Precision" — refined SaaS tool with character
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --teal-500: #14b8a6;
  --green-600: #16a34a;
  --red-500: #ef4444;

  --surface: #fafaf8;
  --card: #ffffff;
  --card-border: #e8e8e4;
  --sidebar-bg: #111113;
  --sidebar-hover: #1c1c1f;
  --sidebar-active: #252529;
  --sidebar-text: #a1a1aa;
  --sidebar-text-active: #fafafa;

  --text-primary: #111113;
  --text-secondary: #52525a;
  --text-muted: #a1a1aa;
  --text-link: var(--blue-600);

  --ring-focus: rgba(37, 99, 235, 0.35);
  --shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-dropdown: 0 8px 24px rgba(0,0,0,.1);
  --radius: 10px;
  --radius-lg: 14px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

code, pre, .font-mono {
  font-family: var(--font-mono) !important;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ---- Links ---- */
a { transition: color 0.15s ease; }

/* ---- Custom focus ring ---- */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-focus);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-focus);
  border-color: var(--blue-500);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  text-decoration: none;
  line-height: 1.5;
}
.btn-primary {
  background: var(--blue-600);
  color: white;
}
.btn-primary:hover { background: var(--blue-700); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.25); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover { background: #f4f4f2; border-color: #d4d4d0; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--text-primary); }
.btn-danger {
  background: transparent;
  color: var(--red-500);
}
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; gap: 0.375rem; }
.btn svg { flex-shrink: 0; }
.btn-lg { padding: 0.625rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: #d4d4d0;
}

/* ---- Form Inputs ---- */
.input {
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: white;
  color: var(--text-primary);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-muted); }
.input:hover { border-color: #d4d4d0; }

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}
.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ---- Tables ---- */
.table-wrap {
  overflow: hidden;
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap thead { background: #fafaf8; }
.table-wrap th {
  padding: 0.75rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}
.table-wrap td {
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #f4f4f2;
}
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap tbody tr { transition: background 0.1s; }
.table-wrap tbody tr:hover { background: #fafaf8; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 6px;
  letter-spacing: 0.01em;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f4f4f5; color: #52525b; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--sidebar-bg);
  width: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
}
.sidebar-brand {
  padding: 1.25rem 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  color: white;
  letter-spacing: -0.01em;
}
.sidebar-nav {
  padding: 0.75rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-text);
  border-radius: 8px;
  transition: all 0.12s ease;
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}
.sidebar-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.5;
  flex-shrink: 0;
}
.sidebar-link.active svg,
.sidebar-link:hover svg { opacity: 0.85; }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* Admin content area */
.admin-content {
  margin-left: 240px;
  min-height: 100vh;
  background: var(--surface);
}
.admin-header {
  background: white;
  border-bottom: 1px solid var(--card-border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-main {
  padding: 2rem;
  max-width: 1200px;
}

/* ---- Stat Cards ---- */
.stat-card {
  padding: 1.5rem;
}
.stat-card .stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

/* ---- Progress Bar ---- */
.progress-bar {
  height: 4px;
  background: #e8e8e4;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--blue-600);
  transition: width 0.4s ease;
}

/* ---- Step Indicator ---- */
.step-dots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e8e8e4;
  transition: all 0.2s;
}
.step-dot.active { background: var(--blue-600); width: 24px; border-radius: 4px; }
.step-dot.done { background: var(--green-600); }

/* ---- Alerts ---- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---- Hero section (landing) ---- */
.hero {
  background: #0c0c0e;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0);
  background-size: 32px 32px;
}
.hero::after {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(37,99,235,.15), transparent 70%);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; }

/* ---- Feature cards ---- */
.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* ---- Pricing cards ---- */
.pricing-card { transition: transform 0.2s, box-shadow 0.2s; }
.pricing-card:hover { transform: translateY(-4px); }
.pricing-popular {
  border: 2px solid var(--blue-600);
  position: relative;
}

/* ---- FAQ accordion ---- */
details summary {
  list-style: none;
  cursor: pointer;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}
details[open] summary::after { transform: rotate(-135deg); }

/* ---- Copy button ---- */
.copy-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #a1a1aa;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,.14); color: white; }

/* ---- Code block ---- */
.code-block {
  background: #18181b;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}
.code-block pre {
  padding: 1.25rem 1.5rem;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: #e4e4e7;
  overflow-x: auto;
  margin: 0;
}
.code-block .copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin: 0 auto 1rem;
}

/* ---- Page transitions ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.4s ease both; }
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }

/* ---- Google button ---- */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  width: 100%;
}
.btn-google:hover { background: #f8f8f6; box-shadow: var(--shadow-card-hover); }

/* ---- GitHub button ---- */
.btn-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  background: #24292f;
  color: #fff;
  border: 1px solid #24292f;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  width: 100%;
}
.btn-github:hover { background: #32383e; box-shadow: var(--shadow-card-hover); }

/* ---- Microsoft button ---- */
.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  width: 100%;
}
.btn-microsoft:hover { background: #f8f8f6; box-shadow: var(--shadow-card-hover); }

/* ---- Navbar (public pages) ---- */
.navbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.navbar-dark {
  background: rgba(12,12,14,.85);
  border-color: rgba(255,255,255,.06);
}

/* ---- Footer ---- */
.footer {
  background: #0c0c0e;
  color: #71717a;
}

/* ---- Misc ---- */
.divider { height: 1px; background: var(--card-border); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Responsive / Mobile
   ============================================================ */

/* Sidebar overlay (mobile backdrop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 25;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* Mobile nav (landing page dropdown) */
.mobile-nav {
  display: none;
  flex-direction: column;
  background: rgba(12,12,14,.97);
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 0.75rem 1.5rem 1.25rem;
  gap: 0;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  display: block;
  padding: 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #a1a1aa;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover { color: white; }

/* Mobile-only elements — hidden by default, shown in mobile media query */
.admin-mobile-brand { display: none; }

/* Hamburger button */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,.08); }
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.2s ease;
}

@media (max-width: 768px) {
  /* Show hamburgers on mobile */
  .hamburger { display: flex; }

  /* ---- Landing nav ---- */
  .navbar-dark .hamburger { color: #a1a1aa; }
  .navbar .hamburger { color: var(--text-secondary); }

  /* ---- Admin sidebar ---- */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 30;
  }
  .sidebar.open { transform: translateX(0); }

  /* ---- Admin content ---- */
  .admin-content { margin-left: 0; }

  .admin-header {
    padding: 0 1rem;
    justify-content: space-between;
  }
  .admin-header-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .admin-main {
    padding: 1rem;
  }

  /* ---- Tables ---- */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Code blocks ---- */
  .code-block pre {
    font-size: 0.75rem;
  }

  /* ---- Pricing grid (landing) ---- */
  .pricing-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
    margin: 0 -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .pricing-scroll-wrap > div {
    min-width: 700px;
  }

  /* ---- Hero section ---- */
  .hero { padding: 4rem 0 3rem; }

  /* ---- Admin header brand (show on mobile) ---- */
  .admin-mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text-primary);
    text-decoration: none;
  }
}

@media (min-width: 769px) {
  /* On desktop, admin-header-start is just a flex container for the email */
  .admin-header-start { display: contents; }
  /* Sidebar always visible on desktop */
  .sidebar { transform: none !important; }
  /* Hide overlay on desktop */
  .sidebar-overlay { display: none !important; }
}

/* Drag-and-drop (SortableJS) */
.drag-handle { cursor: grab; color: var(--text-muted); opacity: 0.5; user-select: none; font-size: 1rem; line-height: 1; letter-spacing: -2px; }
.drag-handle:hover { opacity: 1; }
.drag-ghost { opacity: 0.4; background: var(--bg-secondary); }
.sortable-chosen { box-shadow: var(--shadow-card-hover); }

/* ---- WYSIWYG Builder ---- */
.builder-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.builder-palette { width: 220px; flex-shrink: 0; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg); overflow: hidden; position: sticky; top: 1rem; }
.builder-palette-header { padding: 0.75rem 1rem; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--card-border); }
.palette-item { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 1rem; cursor: grab; font-size: 0.8125rem; color: var(--text-secondary); border-bottom: 1px solid var(--card-border); user-select: none; transition: background 0.1s; }
.palette-item:hover, .palette-item:active { background: var(--surface); color: var(--text-primary); }
.palette-item:last-child { border-bottom: none; }
.palette-item-icon { width: 28px; height: 28px; border-radius: 6px; background: #eff6ff; color: var(--blue-600); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.builder-canvas-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.builder-canvas { display: flex; flex-direction: column; gap: 0.625rem; min-height: 120px; }
.builder-field-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); transition: box-shadow 0.15s, border-color 0.15s; }
.builder-field-card:hover { border-color: #d4d4d0; box-shadow: var(--shadow-card-hover); }
.builder-field-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.875rem 1rem; }
.builder-field-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.builder-field-body .input, .builder-field-body textarea.input, .builder-field-body select.input { pointer-events: none; opacity: 0.85; }
.builder-field-actions { display: flex; gap: 0.25rem; flex-shrink: 0; padding-top: 0.125rem; }
.builder-field-edit { border-top: 1px solid var(--card-border); padding: 1rem; background: var(--surface); }
.builder-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.builder-drop-zone { border: 2px dashed var(--card-border); border-radius: var(--radius); padding: 3rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; transition: border-color 0.15s, background 0.15s; }
.sortable-ghost { opacity: 0.35 !important; background: #eff6ff !important; border: 2px dashed var(--blue-500) !important; border-radius: var(--radius) !important; }
.palette-item.sortable-chosen { box-shadow: var(--shadow-dropdown); border-radius: 8px; background: var(--surface); }

/* ---- Builder Preview Pane ---- */
.builder-preview { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); margin-top: 1.5rem; overflow: hidden; }
.builder-preview-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--card-border); background: var(--surface); }
.builder-preview-form { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; max-width: 560px; }
.builder-preview-field { display: flex; flex-direction: column; gap: 0.375rem; }
.builder-preview-field .input { pointer-events: auto; opacity: 1; }
.builder-preview-field select.input { appearance: auto; }
