/* ===========================
   MODERN-STYLES.CSS
   Base design tokens, components
   and utility classes.

   CSS INCLUDE ORDER (all dashboard pages):
   1. modern-styles.css      — tokens, reset, .container, utilities
   2. dashboard-styles.css   — card, button, metric components
   3. ui-components.css      — toasts, dialogs, spinners
   4. navigation-styles.css  — sidebar navigation
   5. integration-shared.css — shared integration page styles
   6. [page-specific].css    — page-specific styles
   7. dark-mode.css          — theme overrides (MUST be last)
   =========================== */

/* ===== CSS VARIABLES ===== */
:root {
  /* Base colors */
  --color-primary: #4f46e5;
  --color-primary-light: #6366f1;
  --color-primary-dark: #4338ca;
  --color-primary-transparent: rgba(79, 70, 229, 0.1);
  --color-danger: #ef4444;
  --color-danger-dark: #dc2626;
  --color-danger-light: #f87171;
  --color-danger-transparent: rgba(239, 68, 68, 0.1);
  --color-success: #10b981;
  --color-success-dark: #059669;
  --color-success-light: #34d399;
  --color-success-transparent: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-dark: #d97706;
  --color-warning-light: #fbbf24;
  --color-warning-transparent: rgba(245, 158, 11, 0.1);
  --color-info: #3b82f6;
  --color-info-dark: #2563eb;
  --color-info-light: #60a5fa;
  --color-info-transparent: rgba(59, 130, 246, 0.1);

  /* Grays */
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  /* Semantic surfaces — single source of truth for backgrounds */
  --surface-primary: #ffffff;
  --surface-secondary: var(--color-gray-50);
  --surface-tertiary: var(--color-gray-100);
  --surface-inset: var(--color-gray-50);
  --text-primary: var(--color-gray-900);
  --text-secondary: var(--color-gray-500);
  --text-tertiary: var(--color-gray-700);
  --text-muted: var(--color-gray-400);
  --border-default: var(--color-gray-200);
  --border-strong: var(--color-gray-300);
  --input-bg: var(--surface-primary);
  --input-border: var(--color-gray-300);

  /* Status surface colors (light tinted backgrounds for badges/alerts) */
  --color-success-surface: #ecfdf5;
  --color-danger-surface: #fef2f2;
  --color-warning-surface: #fffbeb;
  --color-info-surface: #eff6ff;
  --color-success-text: #047857;
  --color-success-border: #bbf7d0;
  --color-danger-text: #b91c1c;
  --color-danger-border: #fecaca;
  --color-warning-text: #92400e;
  --color-warning-border: #fde68a;
  --color-info-text: #1d4ed8;
  --color-info-border: #bfdbfe;

  /* Overlay backgrounds */
  --blur-overlay-bg: rgba(255, 255, 255, 0.7);

  /* Status colors */
  --color-status-active: var(--color-success);
  --color-status-paused: var(--color-warning);
  --color-status-draft: var(--color-gray-400);
  --color-status-failed: var(--color-danger);
  --color-status-archived: var(--color-gray-600);
  --color-status-completed: var(--color-success);
  --color-status-processing: var(--color-info);
  --color-status-pending: var(--color-gray-500);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

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

  /* Borders */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.375rem;
  --border-radius-lg: 0.5rem;
  --border-radius-xl: 0.75rem;
  --border-radius-2xl: 1rem;
  --border-radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;

  /* Card tokens */
  --card-bg: var(--surface-primary);
  --card-border: 1px solid var(--border-default);
  --card-radius: var(--border-radius-xl);
  --card-shadow: var(--shadow-sm);
  --card-hover-shadow: var(--shadow-md);
  --card-hover-transform: translateY(-2px);
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--surface-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Standard vertical padding for dashboard page content areas */
.page-main {
  padding-top: var(--spacing-xl);
  padding-bottom: var(--spacing-2xl);
}

/* ===== TYPOGRAPHY ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: var(--surface-primary);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  border-radius: var(--border-radius-xl, 12px);
  margin-bottom: var(--spacing-lg, 1.5rem);
  gap: var(--spacing-lg);
}

.page-header > div:first-child {
  flex: 1;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gray-900);
  margin: 0;
  line-height: 1.3;
}

.page-subtitle {
  color: var(--color-gray-500);
  margin: 0.125rem 0 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* ===== COMPONENTS ===== */

/* Cards */
.card {
  background-color: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: var(--card-border);
  overflow: hidden;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

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

.card-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-gray-100);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

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

.card-footer {
  padding: var(--spacing-lg);
  background-color: var(--color-gray-50);
  border-top: 1px solid var(--color-gray-100);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 0.5rem;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  border: none;
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--surface-primary);
  color: var(--color-gray-600);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--surface-secondary);
  border-color: var(--color-gray-300);
}

.btn-danger {
  background-color: var(--surface-primary);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.btn-danger:hover {
  background-color: var(--color-danger-surface);
  border-color: var(--color-danger);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
}

.btn-full {
  width: 100%;
}

/* ============================================================
   Action button family — compact toolbar/inline buttons.
   Loaded from modern-styles.css so every admin page can use them
   (chatbot-styles.css used to define them, but it isn't loaded on
   profile/account/company-details pages, leaving buttons unstyled).
   All colors come from CSS variables redefined in dark-mode.css,
   so dark mode works automatically.
   ============================================================ */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action--primary {
  background: var(--color-primary-transparent, rgba(99, 102, 241, 0.1));
  color: var(--color-primary, #6366f1);
  border: none;
}

.btn-action--primary:hover {
  background: rgba(99, 102, 241, 0.15);
}

.btn-action--secondary {
  background: var(--surface-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-action--secondary:hover {
  background: var(--color-gray-100);
  color: var(--text-primary);
  border-color: var(--color-gray-400);
}

.btn-action--secondary svg { opacity: 0.7; }
.btn-action--secondary:hover svg { opacity: 1; }

.btn-action--danger {
  background: var(--color-danger-transparent, rgba(239, 68, 68, 0.1));
  color: var(--color-danger, #ef4444);
  border: 1px solid var(--color-danger-border, rgba(239, 68, 68, 0.3));
}

.btn-action--danger:hover {
  background: var(--color-danger-surface, #fef2f2);
  border-color: var(--color-danger-border, #fecaca);
}

/* AI / magic CTA — solid gradient to distinguish AI-driven actions. */
.btn-action--ai {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  border: none;
}
.btn-action--ai:hover { opacity: 0.9; }

/* Compact size modifier (pair with any colour modifier). */
.btn-action--sm {
  padding: 4px 10px;
  font-size: 12px;
  gap: 4px;
}

/* Form-aligned size — matches .profile-form-input / .form-input height
   so the button sits flush next to an input or select. Use whenever
   the button is INLINE with a form field (Detect timezone next to
   a select, "+ Add" next to date/text inputs, etc.). */
.btn-action--md {
  padding: 0.6875rem 1rem;  /* matches profile-form-input visual height (with border) */
  font-size: 0.875rem;
}

.btn-add-row--md {
  padding: 0.6875rem 1rem;
  font-size: 0.875rem;
  margin-top: 0;
}

/* Icon-only ghost button for inline ✕ / × dismiss affordances. */
.btn-action--icon {
  padding: 4px;
  background: none;
  border: none;
  color: var(--color-gray-400, #9ca3af);
  border-radius: 6px;
}

.btn-action--icon:hover {
  background: var(--color-gray-100, #f1f5f9);
  color: var(--text-primary, #111827);
}

/* "+ Add row" inserter — small gray rectangular button used at the
   bottom of repeating lists (phones, links, days off, social rows). */
.btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--color-gray-100, #f1f5f9);
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-gray-600, #475569);
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-add-row:hover { background: var(--color-gray-200, #e2e8f0); }

/* Constrain inline SVGs so they don't inflate the button when authors
   omit width/height attributes (very common — the icon's viewBox is
   24x24 but the rendered size depends on declared dimensions). */
.btn-add-row svg,
.btn-action svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* "✕ remove" inline list-row control — small red outlined square. */
.btn-remove-row {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--color-danger-border, #fca5a5);
  border-radius: 6px;
  color: var(--color-danger, #ef4444);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-remove-row:hover { background: var(--color-danger-surface, #fef2f2); }

/* Dropdown menu item — full-width left-aligned popover button. */
.dropdown-menu-item {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary, #111827);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 100ms;
  font-family: inherit;
}

.dropdown-menu-item:hover {
  background: var(--color-gray-50, #f9fafb);
}

.dropdown-menu-item--danger {
  color: var(--color-danger, #ef4444);
}

/* Status Badges */
.status-badge,
.dataset-status {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.25rem;
}

[data-status="completed"],
.status-completed {
  background-color: var(--color-success-surface);
  color: var(--color-status-completed);
}

[data-status="processing"],
.status-processing {
  background-color: var(--color-info-surface);
  color: var(--color-status-processing);
}

[data-status="failed"],
.status-failed {
  background-color: var(--color-danger-surface);
  color: var(--color-status-failed);
}

[data-status="pending"],
.status-pending {
  background-color: var(--surface-tertiary);
  color: var(--color-status-pending);
}

[data-status="partial"],
.status-warning {
  background-color: var(--color-warning-surface);
  color: var(--color-warning-text);
}

[data-status="draft"],
.status-draft {
  background-color: var(--surface-tertiary);
  color: var(--color-status-draft);
}

[data-status="active"],
.status-active {
  background-color: var(--color-success-surface);
  color: var(--color-status-active);
}

[data-status="paused"],
.status-paused {
  background-color: var(--color-warning-surface);
  color: var(--color-status-paused);
}

[data-status="archived"],
.status-archived {
  background-color: var(--surface-tertiary);
  color: var(--color-status-archived);
}

.status-indicator {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.5rem;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  color: var(--color-gray-700);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-gray-300);
  background-color: var(--surface-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.form-hint {
  margin-top: var(--spacing-xs);
  font-size: 0.75rem;
  color: var(--color-gray-500);
}

/* Search Bar */
.search-bar {
  margin-bottom: 2rem;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3.5rem;
  background: var(--surface-primary);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--border-radius-lg);
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-gray-400);
  transition: color 0.3s ease;
  pointer-events: none;
}

.search-bar input:focus + .search-icon {
  color: var(--color-primary);
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  padding: 0.75rem 1.25rem;
  background: var(--surface-primary);
  border-radius: var(--border-radius-lg);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-gray-600);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--color-gray-200);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-tab:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
  background-color: var(--color-primary-transparent);
}

.filter-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

.filter-tab .count {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.15rem 0.5rem;
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
}

.filter-tab.active .count {
  background: rgba(255, 255, 255, 0.25);
}

/* Chatbot Pill */
.chatbot-pill {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  background-color: var(--color-primary-transparent);
  color: var(--color-primary);
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease;
}

.chatbot-pill:hover {
  background-color: var(--color-primary-transparent);
  transform: translateY(-1px);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--surface-primary);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal:not(.hidden) .modal-content {
  transform: translateY(0);
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-gray-100);
}

.modal-footer .btn {
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  font-size: clamp(0.75rem, 2vw, 0.875rem);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-gray-500);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--color-gray-700);
}

/* Deploy modal tabs */
.deploy-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-gray-100);
  padding: 0 1.5rem;
  gap: 0;
}

.deploy-tab {
  padding: 0.65rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-gray-500);
  transition: color 0.2s, border-color 0.2s;
}

.deploy-tab:hover {
  color: var(--text-primary);
}

.deploy-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.deploy-tab-content {
  display: none;
}

.deploy-tab-content.active {
  display: block;
}

/* Deploy code block — unified wrapper for embed code + direct link tabs */
.deploy-code-block {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-top: 0.75rem;
  border: 1px solid var(--color-gray-100);
  border-radius: 8px;
  overflow: hidden;
  background: var(--input-bg);
}

.deploy-code-block .code-preview {
  flex: 1;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 0;
  max-height: 200px;
}

.deploy-code-block .link-input {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-primary);
  outline: none;
}

.deploy-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-left: 1px solid var(--color-gray-100);
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.deploy-copy-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-surface, rgba(79,70,229,0.06));
}

.deploy-copy-btn.copied {
  color: var(--color-success, #16a34a);
}

/* QR download — right-aligned, matches other modal buttons */
.deploy-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  float: right;
  margin-bottom: 1rem;
  min-width: 160px;
}

/* Hide footer border when empty (deploy modal) */
.deploy-modal-footer:empty {
  display: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  min-width: 0;
}

/* QR tips list */
.deploy-qr-tips {
  list-style: none;
  padding: 0;
  margin: 0 0 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.deploy-qr-tips li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.deploy-qr-tips li::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}

/* Cache-clear tip below the embed code block */
.deploy-cache-tip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.deploy-cache-tip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-warning);
  flex-shrink: 0;
}

/* QR code preview */
.qr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
  min-height: 200px;
  position: relative;
}

.qr-preview img {
  max-width: 220px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-gray-100);
}

.qr-preview img[src=""] {
  display: none;
}

.qr-loading {
  color: var(--color-gray-400);
  font-size: 0.875rem;
}

.qr-loading.hidden {
  display: none;
}

/* Confirm dialog overlay — used by showConfirmDialog (ui.js) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-container {
  background: var(--surface-primary);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-gray-900);
  margin: 0;
}

.modal-message {
  font-size: 0.9rem;
  color: var(--color-gray-600);
  margin: 0;
  line-height: 1.5;
}

/* Dropdown */
.dropdown {
  position: relative;
  text-align: right;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 12rem;
  background-color: var(--surface-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-gray-100);
  z-index: 50;
  overflow: hidden;
}

.dropdown-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.dropdown-toggle:hover {
  background-color: var(--color-gray-100);
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--color-gray-700);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  gap: 0.5rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--color-gray-50);
}

.dropdown-item-delete {
  color: var(--color-danger);
}

.dropdown-item-delete:hover {
  background-color: var(--color-danger-surface);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

/* Status Messages */
.status-message {
  padding: 0.75rem;
  border-radius: 0.375rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.status-message.warning {
  background-color: var(--color-warning-surface);
  color: #c2410c;
}

.status-message.info {
  background-color: var(--color-info-surface);
  color: #1d4ed8;
}

.status-message.success {
  background-color: var(--color-success-surface);
  color: #047857;
}

/* Code Preview */
.code-preview {
  background-color: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.875rem;
  max-height: 300px;
  overflow-y: auto;
}

/* ===== STICKY FOOTER — single source of truth =====
   body is flex-column + min-height:100vh (see RESET & BASE above).
   Every page's main content wrapper gets flex:1 so footer stays at bottom. */
main,
.profile-page,
.account-page {
  flex: 1;
}

/* Footer — blends with page background */
footer {
  background: transparent;
  border: none;
  padding: 1.5rem 0;
  position: relative;
  box-shadow: none;
}

footer::before {
  display: none;
}

footer .container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  border: none;
}

footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-gray-400);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--color-gray-400);
  font-size: 0.75rem;
}

.footer-links a::after {
  display: none;
}

.footer-links a {
  color: var(--color-gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
  transition: all 0.2s ease;
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-primary);
  transition: width 0.2s ease;
}

.footer-links a:hover::after {
  width: 100%;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.spinner-icon {
  animation: spin 1.5s linear infinite;
}

/* ===== UTILITY CLASSES ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

.hidden {
  display: none !important;
}

.relative {
  position: relative;
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.cursor-pointer { cursor: pointer; }

/* ===== RESPONSIVE DESIGN ===== */
@media (min-width: 768px) {
  .grid-cols-md-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-cols-lg-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .deploy-tabs { padding: 0 1rem; }
  .deploy-tab { padding: 0.5rem 0.75rem; font-size: 0.8rem; }

  .container {
    padding: 0 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
  }

  .page-header > div:first-child {
    width: 100%;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .page-title {
    font-size: 1.125rem;
  }

  .page-subtitle {
    font-size: 0.8125rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding-top: 1rem;
  }

  .footer-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }
}

/* ============================================
   UNIFIED PAGE HEADER  (Clean Minimal - Option A)
   Shared by all major pages.
   Usage:
     <div class="page-header-unified">
       <div class="page-header-icon"> SVG </div>
       <div class="page-header-text">
         <h1>Title</h1>
         <p>Subtitle</p>
       </div>
     </div>
   ============================================ */
.page-header-unified {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface-primary);
  border: 1px solid var(--color-gray-200, #e5e7eb);
  border-radius: var(--border-radius-xl, 12px);
  margin-bottom: 1.5rem;
}

.page-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--color-gray-50, #f9fafb);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary, #6366f1);
}

.page-header-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-primary, #6366f1);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-header-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gray-900, #111827);
  margin: 0;
  line-height: 1.3;
}

.page-header-text p {
  font-size: 0.8125rem;
  color: var(--color-gray-500, #6b7280);
  margin: 0.125rem 0 0;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .page-header-unified {
    padding: 1rem 1.25rem;
    gap: 0.75rem;
  }
  .page-header-icon {
    width: 38px;
    height: 38px;
  }
  .page-header-icon svg {
    width: 18px;
    height: 18px;
  }
  .page-header-text h1 {
    font-size: 1.125rem;
  }
}

/* ── Structured Data Preview Table ────────────────────────── */
/* Shared between dataset-form.js and dataset-view.js */
.structured-preview-table {
  width: 100%;
  border-collapse: collapse;
}
.structured-preview-table th {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-secondary, #f9fafb);
  border-bottom: 1px solid var(--color-gray-200);
}
.structured-preview-table td {
  padding: 4px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-gray-100);
}
