/* ═══════════════════════════════════════════════════════════
   NexusLeadPilot Dashboard — Modern Dark-First Design
   ═══════════════════════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

/* ─── CSS Variables (Dark Theme Default) ─────────────────── */
:root {
  /* Primary palette */
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-muted: rgba(99, 102, 241, 0.15);
  --primary-glow: rgba(99, 102, 241, 0.3);

  /* Accent */
  --accent: #22d3ee;
  --accent-muted: rgba(34, 211, 238, 0.15);

  /* Semantic */
  --success: #10b981;
  --success-muted: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-muted: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-muted: rgba(239, 68, 68, 0.15);

  /* Surfaces — dark */
  --bg-base: #0f1117;
  --bg-surface: #1a1d2e;
  --bg-elevated: #232740;
  --bg-hover: #2a2f4a;
  --bg-glass: rgba(26, 29, 46, 0.7);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Borders */
  --border: rgba(148, 163, 184, 0.12);
  --border-hover: rgba(148, 163, 184, 0.25);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --bottom-nav-height: 64px;
}

/* ─── Light Theme ────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-hover: #e2e8f0;
  --bg-glass: rgba(255, 255, 255, 0.8);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* ─── Global Reset ───────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background gradient mesh */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 80% 50% at 20% 40%,
      rgba(99, 102, 241, 0.08) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 80% 20%,
      rgba(34, 211, 238, 0.06) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(
      ellipse 80% 50% at 20% 40%,
      rgba(99, 102, 241, 0.04) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 80% 20%,
      rgba(34, 211, 238, 0.03) 0%,
      transparent 50%
    );
}

a {
  color: var(--primary-hover);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 0.875rem;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════ */

/* ─── Header ─────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  transition: background var(--duration) var(--ease);
}
.hamburger-btn:hover {
  background: var(--bg-hover);
}
.hamburger-btn svg {
  width: 22px;
  height: 22px;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo h1 {
  font-size: 1.125rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-hover), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo .logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  color: white;
}
.logo .logo-icon svg {
  width: 16px;
  height: 16px;
}

.version {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ─── Theme Toggle ───────────────────────────────────────── */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  display: flex;
  align-items: center;
  padding: 2px;
}

.theme-toggle .toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform 0.3s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-toggle .toggle-thumb svg {
  width: 11px;
  height: 11px;
  color: white;
}

[data-theme="light"] .theme-toggle .toggle-thumb {
  transform: translateX(20px);
  background: var(--warning);
}

/* ─── Main Layout ────────────────────────────────────────── */
.main-content {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-right: 1px solid var(--border);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.3s var(--ease);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  list-style: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  user-select: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-muted);
  color: var(--primary-hover);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active svg {
  opacity: 1;
}

.nav-item .nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  min-width: 20px;
  text-align: center;
}

/* ─── Content Area ───────────────────────────────────────── */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-xl);
  max-width: 1400px;
  width: 100%;
}

/* ─── Section Titles ─────────────────────────────────────── */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-title svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

/* ─── Section Transitions ────────────────────────────────── */
.section {
  display: none;
  animation: sectionFadeIn 0.35s var(--ease) both;
}

.section.active {
  display: block;
}

@keyframes sectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   CARDS & CONTAINERS
   ═══════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--duration) var(--ease);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

/* Glass Card Variant */
.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--duration) var(--ease);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:nth-child(1)::before {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.stat-card:nth-child(2)::before {
  background: linear-gradient(90deg, var(--success), #34d399);
}
.stat-card:nth-child(3)::before {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}
.stat-card:nth-child(4)::before {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

.stat-card .stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card:nth-child(1) .stat-icon {
  background: var(--primary-muted);
  color: var(--primary-hover);
}
.stat-card:nth-child(2) .stat-icon {
  background: var(--success-muted);
  color: var(--success);
}
.stat-card:nth-child(3) .stat-icon {
  background: var(--warning-muted);
  color: var(--warning);
}
.stat-card:nth-child(4) .stat-icon {
  background: var(--danger-muted);
  color: var(--danger);
}

.stat-card .stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: var(--space-xs);
}

.stat-card .stat-change {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: var(--space-xs);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.positive {
  color: var(--success);
}
.stat-change.negative {
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-vcard {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--primary-muted);
  color: var(--primary-hover);
  transition: all var(--duration) var(--ease);
  border: none;
  cursor: pointer;
}
.btn-vcard:hover {
  background: var(--primary);
  color: white;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--duration) var(--ease);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-group select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════ */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leads-table thead {
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 5;
}

.leads-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leads-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--duration) var(--ease);
}
.leads-table th.sortable:hover {
  color: var(--primary-hover);
}

.leads-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.leads-table tbody tr {
  transition: background var(--duration) var(--ease);
}
.leads-table tbody tr:hover {
  background: var(--bg-hover);
}
.leads-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.score-badge,
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.priority-high {
  background: var(--success-muted) !important;
  color: var(--success) !important;
}
.priority-medium {
  background: var(--warning-muted) !important;
  color: var(--warning) !important;
}
.priority-low {
  background: var(--danger-muted) !important;
  color: var(--danger) !important;
}
.priority-unknown {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

/* Action Buttons in table */
.action-buttons {
  display: flex;
  gap: var(--space-xs);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-md);
}

.pagination button {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD SECTION
   ═══════════════════════════════════════════════════════════ */

/* Recent Activity */
.recent-activity {
  margin-top: var(--space-xl);
}

.recent-activity h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.activity-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  transform: translateX(4px);
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary-muted);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon svg {
  width: 18px;
  height: 18px;
}

.activity-info {
  flex: 1;
  min-width: 0;
}

.activity-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.activity-stats {
  display: flex;
  gap: var(--space-md);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.activity-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.activity-stat.highlight {
  color: var(--success);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   CAMPAIGNS SECTION
   ═══════════════════════════════════════════════════════════ */

.campaigns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.campaign-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.campaign-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0.7;
}

.campaign-card:hover {
  border-color: var(--primary-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.campaign-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.campaign-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.campaign-card-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.campaign-card-badge.completed {
  background: var(--success-muted);
  color: var(--success);
}
.campaign-card-badge.running {
  background: var(--warning-muted);
  color: var(--warning);
}
.campaign-card-badge.failed {
  background: var(--danger-muted);
  color: var(--danger);
}

.campaign-card-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.campaign-card-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.campaign-stat {
  text-align: center;
}

.campaign-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.campaign-stat-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════
   LEADS SECTION
   ═══════════════════════════════════════════════════════════ */

.leads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.leads-header select {
  padding: 8px 36px 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.leads-tools {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════
   ANALYTICS SECTION
   ═══════════════════════════════════════════════════════════ */

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.analytics-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.analytics-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
}

.analytics-card h3 svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

/* Analytics Trend Cards */
.analytics-trends {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.trend-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--duration) var(--ease);
}

.trend-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.trend-value {
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.trend-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--space-xs);
}

/* ═══════════════════════════════════════════════════════════
   CHARTS
   ═══════════════════════════════════════════════════════════ */

.chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.chart-placeholder .chart-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  opacity: 0.5;
}

.chart-placeholder .chart-text {
  font-size: 0.85rem;
}

/* Bar Chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  height: 200px;
  padding: var(--space-md) 0;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 48px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.5s var(--ease);
  position: relative;
  min-height: 4px;
  background: linear-gradient(
    180deg,
    var(--primary-hover),
    var(--primary)
  ) !important;
}

.bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.bar-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-word;
  max-width: 60px;
}

/* Pie Chart */
.pie-chart {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  padding: var(--space-md) 0;
}

.pie-visual {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  color: var(--text-secondary);
  flex: 1;
}

.legend-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════
   EMPTY / LOADING STATES
   ═══════════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) !important;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  opacity: 0.5;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.empty-message {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Loading Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

[data-theme="light"] .skeleton::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%
  );
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}
.skeleton-text:last-child {
  width: 60%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton-row {
  height: 48px;
  margin-bottom: 4px;
}

/* Loading spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  gap: var(--space-sm);
}

.loading::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════════════════════════════════════
   MARKETING CONTENT
   ═══════════════════════════════════════════════════════════ */

.marketing-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.marketing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.marketing-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

.marketing-body {
  padding: var(--space-lg);
}

.marketing-actions {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.content-preview {
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

#notifications {
  position: fixed;
  top: calc(var(--header-height) + var(--space-md));
  right: var(--space-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 380px;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   BOTTOM NAVIGATION (Mobile)
   ═══════════════════════════════════════════════════════════ */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0 var(--space-sm);
}

.bottom-nav-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  list-style: none;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
}

.bottom-nav-item.active {
  color: var(--primary-hover);
}

.bottom-nav-item.active svg {
  color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════ */

/* Large Tablets / Small Desktops */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-trends {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Tablets */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .hamburger-btn {
    display: flex;
  }

  .content {
    margin-left: 0;
    padding: var(--space-lg);
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .bottom-nav {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .hamburger-btn {
    display: flex;
  }

  .content {
    margin-left: 0;
    padding: var(--space-md);
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg));
  }

  .section-title {
    font-size: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .stat-card {
    padding: var(--space-md);
  }

  .stat-card .stat-value {
    font-size: 1.3rem;
  }

  .campaigns-grid {
    grid-template-columns: 1fr;
  }

  .campaigns-header {
    flex-direction: column;
    align-items: stretch;
  }

  /* Card-based table on mobile */
  .table-container {
    border: none;
  }

  .leads-table thead {
    display: none;
  }

  .leads-table tbody tr {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
  }

  .leads-table tbody tr:hover {
    background: var(--bg-surface);
  }

  .leads-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
  }

  .leads-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-right: var(--space-md);
    flex-shrink: 0;
  }

  .leads-table td:last-child {
    border-bottom: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .leads-header {
    flex-direction: column;
    align-items: stretch;
  }

  .analytics-trends {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    flex-direction: column;
    align-items: center;
  }

  .activity-stats {
    display: none;
  }

  .marketing-actions {
    flex-direction: column;
  }
  .marketing-actions .btn {
    width: 100%;
  }

  #notifications {
    left: var(--space-sm);
    right: var(--space-sm);
    max-width: none;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .logo h1 {
    font-size: 0.95rem;
  }

  .version {
    display: none;
  }

  .campaign-card-stats {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }
}

/* ─── Print Styles ───────────────────────────────────────── */
@media print {
  .header,
  .sidebar,
  .bottom-nav,
  #notifications {
    display: none !important;
  }
  .content {
    margin: 0;
    padding: 0;
  }
  body {
    background: white;
    color: black;
  }
  body::before {
    display: none;
  }
}
