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

:root {
  --bg: #f3f2ef;
  --bg-card: #ffffff;
  --bg-input: #f3f2ef;
  --border: #e0dfdc;
  --text: #191919;
  --text-muted: #666666;
  --primary: #0a66c2;
  --primary-hover: #004182;
  --success: #057642;
  --warning: #b24020;
  --danger: #cc1016;
  --info: #0a66c2;
  --radius: 8px;
  --shadow: 0 0 0 1px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 240px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.sidebar h1 {
  font-size: 16px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  color: var(--primary);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  transition: all .15s;
}

.sidebar nav a:hover, .sidebar nav a.active {
  background: #e8f0fe;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.main { margin-left: 240px; flex: 1; padding: 24px; min-width: 0; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h2 { font-size: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  color: #fff;
}

.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: #000; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #e8f0fe; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"], input[type="number"], input[type="url"],
input[type="password"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

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

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

tr:hover td { background: #f8fafc; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-draft { background: #e2e8f0; color: var(--text-muted); }
.badge-queued { background: #dbeafe; color: #1d4ed8; }
.badge-sending { background: #cffafe; color: #0e7490; }
.badge-sent { background: #dcfce7; color: #15803d; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-paused { background: #fef3c7; color: #b45309; }
.badge-failed { background: #fee2e2; color: #b91c1c; }
.badge-pending { background: #e2e8f0; color: var(--text-muted); }
.badge-resolved { background: #dbeafe; color: #1d4ed8; }
.badge-skipped { background: #fef3c7; color: #b45309; }

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── File Upload ────────────────────────────────────────────── */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}

.file-upload:hover { border-color: var(--primary); background: #eef2ff; }
.file-upload.dragover { border-color: var(--primary); background: #dbeafe; }
.file-upload p { color: var(--text-muted); margin-top: 8px; font-size: 13px; }

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .3s;
}

/* ── Health Indicator ───────────────────────────────────────── */
.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.health-good { background: var(--success); }
.health-warning { background: var(--warning); }
.health-danger { background: var(--danger); }

/* ── Connection Status ──────────────────────────────────────── */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.connection-connected { background: #dcfce7; color: #15803d; }
.connection-disconnected { background: #fee2e2; color: #b91c1c; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }

.tab {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}

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

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; }

/* ── Utilities ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.hidden { display: none !important; }

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  animation: slideIn .3s ease;
  min-width: 300px;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

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

/* ── Auth Pages (login/signup/pending) ─────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f3f2ef;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-logo-icon {
  width: 40px;
  height: 40px;
  background: #0a66c2;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  font-family: inherit;
}

.auth-logo-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  padding: 32px 28px 28px;
  background: #fff;
}

.auth-card .auth-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-card .auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-card .form-group {
  margin-bottom: 18px;
}

.auth-card .form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-card input[type="text"],
.auth-card input[type="password"],
.auth-card input[type="email"] {
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 4px;
  transition: border-color .2s, box-shadow .2s;
}

.auth-card input:focus {
  border-color: #0a66c2;
  box-shadow: 0 0 0 2px rgba(10,102,194,.15);
  background: #fff;
  outline: none;
}

.auth-card .btn-auth {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 24px;
  color: #fff;
  background: #0a66c2;
  cursor: pointer;
  transition: background .2s;
  margin-top: 4px;
}

.auth-card .btn-auth:hover {
  background: #004182;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0a66c2;
  cursor: pointer;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}

.auth-footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-footer a {
  color: #0a66c2;
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-card .auth-link-btn {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  border: 1px solid #0a66c2;
  border-radius: 24px;
  color: #0a66c2;
  background: transparent;
  cursor: pointer;
  text-align: center;
  transition: background .2s, border-color .2s;
  text-decoration: none;
}

.auth-card .auth-link-btn:hover {
  background: #e8f0fe;
  border-color: #004182;
  color: #004182;
  text-decoration: none;
}

/* ── Sidebar Footer (user info + logout) ───────────────────── */
.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info { flex: 1; }

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.user-role {
  display: inline-block;
  margin-top: 2px;
}

/* ── Additional Badges (user statuses) ─────────────────────── */
.badge-approved { background: #dcfce7; color: #057642; }
.badge-rejected { background: #fee2e2; color: #cc1016; }
.badge-deactivated { background: #e2e8f0; color: var(--text-muted); }
.badge-superadmin { background: #fef3c7; color: #b45309; }
.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #e2e8f0; color: var(--text-muted); }

/* ── LinkedIn-inspired refinements ─────────────────────────── */
.sidebar h1 {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: -0.3px;
}

.stat-card .value { color: var(--primary); }

.card {
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow);
}

/* ── Launch Dropdown ────────────────────────────────────────── */
.launch-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 500;
  min-width: 200px;
  overflow: hidden;
}

.launch-dropdown-item {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}

.launch-dropdown-item:hover {
  background: #e8f0fe;
  color: #0a66c2;
}

.launch-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Placeholder Chips (template variables) ────────────────── */
.placeholder-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  border-top: none;
}

.placeholder-chips .chip-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

.placeholder-chips .chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', monospace, inherit;
  color: #4a3aff;
  background: #eee8ff;
  border: 1px solid #d4c8ff;
  border-radius: 14px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.placeholder-chips .chip:hover {
  background: #ddd0ff;
  border-color: #4a3aff;
  transform: translateY(-1px);
}

.placeholder-chips .chip:active {
  transform: translateY(0);
  background: #c8b8ff;
}

/* ── Sidebar Nav Divider ────────────────────────────────────── */
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

/* ── Help & Guide Page ─────────────────────────────────────── */
.help-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.help-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
}

.help-nav-item:hover {
  background: #e8f0fe;
  border-color: #0a66c2;
  text-decoration: none;
  transform: translateY(-1px);
}

.help-nav-icon { font-size: 28px; line-height: 1; }
.help-nav-label { font-size: 13px; font-weight: 500; text-align: center; }

.help-section { scroll-margin-top: 24px; }
.help-section h2 { margin-bottom: 8px; }
.help-section p { font-size: 14px; line-height: 1.7; color: var(--text-muted); }
.help-section a { color: #0a66c2; }
.help-section code {
  background: #f0f2f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #0a66c2;
}

.help-steps { margin-top: 16px; }

.help-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid #f0f2f5;
}

.help-step:last-child { border-bottom: none; }

.help-step-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: #0a66c2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.help-step-content strong { display: block; margin-bottom: 4px; color: var(--text); }
.help-step-content p { margin: 0; font-size: 14px; }

.help-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.help-info-item {
  padding: 16px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #f0f2f5;
}

.help-info-item strong { display: block; margin-bottom: 8px; color: var(--text); }
.help-info-item p { margin: 4px 0; font-size: 13px; line-height: 1.6; }

.help-tip {
  padding: 12px 16px;
  background: #e8f0fe;
  border-radius: 8px;
  border-left: 4px solid #0a66c2;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* FAQ Accordion */
.help-faq-list { margin-top: 8px; }

.help-faq-item {
  border-bottom: 1px solid #f0f2f5;
}

.help-faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: color .15s;
}

.help-faq-q:hover { color: #0a66c2; }

.help-faq-arrow {
  font-size: 12px;
  transition: transform .2s;
  color: var(--text-muted);
}

.help-faq-item.open .help-faq-arrow { transform: rotate(180deg); }

.help-faq-a {
  max-height: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  transition: max-height .3s ease, padding .3s ease;
  padding: 0;
}

.help-faq-item.open .help-faq-a {
  max-height: 200px;
  padding: 0 0 14px;
}

.badge-queued { background: #e8f0fe; color: #0a66c2; }
.badge-sending { background: #e8f5e9; color: #057642; }
.badge-sent { background: #e8f5e9; color: #057642; }
