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

:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a5f;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --amber-500: #f59e0b;
  --red-500: #ef4444;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Login Page ───────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
  margin: 1rem;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue-800);
  margin-bottom: 0.25rem;
  text-align: center;
}

.login-card .subtitle {
  color: var(--gray-500);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ─── Layout ───────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--blue-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sidebar-header .user-info {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 1.5rem;
  max-width: 1200px;
}

/* Mobile hamburger */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--blue-900);
  color: white;
  align-items: center;
  padding: 0 1rem;
  z-index: 90;
  gap: 0.75rem;
}

.hamburger {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ─── Page Header ──────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header p {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ─── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

/* ─── Progress Bars ────────────────────────────────────────────────────── */
.progress-item { margin-bottom: 1rem; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
  color: var(--gray-600);
}

.progress-label .value { font-weight: 600; color: var(--gray-800); }

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background: var(--blue-500);
}

.progress-fill.complete { background: var(--green-500); }
.progress-fill.warning { background: var(--amber-500); }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.15s;
}

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

textarea { resize: vertical; min-height: 80px; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--blue-600); color: white; }
.btn-primary:hover { background: var(--blue-700); }

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

.btn-danger { background: var(--red-500); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-success { background: var(--green-600); color: white; }
.btn-success:hover { opacity: 0.9; }

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

.btn-icon {
  padding: 0.375rem;
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  border-radius: 4px;
}

.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }

.btn-copy {
  padding: 0.25rem 0.625rem;
  background: var(--blue-50);
  color: var(--blue-600);
  border: 1px solid var(--blue-200);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-copy:hover { background: var(--blue-100); }
.btn-copy.copied { background: var(--green-500); color: white; border-color: var(--green-500); }

/* ─── Grid ─────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ─── Stat Cards ───────────────────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue-600);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* ─── Number Input Row ─────────────────────────────────────────────────── */
.number-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.number-input-row input[type="number"] {
  width: 80px;
  text-align: center;
  -moz-appearance: textfield;
}

.number-input-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.number-input-row .stepper {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--gray-300);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--gray-600);
  transition: all 0.15s;
  flex-shrink: 0;
}

.number-input-row .stepper:hover { background: var(--blue-50); border-color: var(--blue-300); color: var(--blue-600); }

/* ─── Accordion / Expandable ───────────────────────────────────────────── */
.accordion-item {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.5rem;
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  font-family: inherit;
  text-align: left;
}

.accordion-trigger:hover { background: var(--gray-50); }

.accordion-trigger .chevron {
  transition: transform 0.2s;
  color: var(--gray-400);
}

.accordion-item.open .accordion-trigger .chevron { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: 0 1rem 1rem;
}

.accordion-item.open .accordion-body { display: block; }

/* ─── Message Card ─────────────────────────────────────────────────────── */
.message-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.875rem;
  margin-bottom: 0.625rem;
}

.message-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.message-card-header .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-text {
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.6;
}

.message-note {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-style: italic;
  margin-top: 0.5rem;
}

/* ─── Table ────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tr:hover td { background: var(--gray-50); }

/* ─── Status Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-new { background: var(--blue-100); color: var(--blue-700); }
.badge-messaged { background: #fef3c7; color: #92400e; }
.badge-replied { background: #d1fae5; color: #065f46; }
.badge-signed_up { background: #dcfce7; color: #166534; }

/* ─── Filter Tabs ──────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.filter-tab:hover { border-color: var(--blue-300); color: var(--blue-600); }
.filter-tab.active { background: var(--blue-600); color: white; border-color: var(--blue-600); }

/* ─── Checkbox ─────────────────────────────────────────────────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-600);
}

.checkbox-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

/* ─── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--gray-800);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ─── Empty State ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--gray-400);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.875rem; }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding: 1rem; padding-top: calc(56px + 1rem); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-card { padding: 0.75rem; }
  .stat-value { font-size: 1.5rem; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ─── Utility ──────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.hidden { display: none !important; }
