/* ─────────────────────────────────────────────────────────────────────────────
   CleanInbox — Global Design System
   Dark mode by default. Light mode available via [data-theme="light"].
   Theme persisted in localStorage → ci_theme
───────────────────────────────────────────────────────────────────────────── */

/* ── Dark theme (default) ─────────────────────────────────────────────────── */
:root {
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #a5b4fc;
  --accent:         #22d3ee;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;

  /* Dark surfaces */
  --bg:             #0f0f13;
  --bg-card:        #18181f;
  --bg-subtle:      #1f1f28;
  --bg-hover:       #26262f;
  --border:         #2e2e3a;
  --border-light:   #3a3a48;

  /* Text */
  --text:           #f1f0ff;
  --text-muted:     #8b8a9e;
  --text-subtle:    #56546a;

  /* Glow effects */
  --glow:           0 0 40px rgba(99,102,241,.15);
  --glow-sm:        0 0 16px rgba(99,102,241,.12);

  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:      0 20px 60px rgba(0,0,0,.5);
}

/* ── Light theme ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:             #ffffff;
  --bg-card:        #ffffff;
  --bg-subtle:      #f9fafb;
  --bg-hover:       #f3f4f6;
  --border:         #e5e7eb;
  --border-light:   #d1d5db;

  --text:           #111827;
  --text-muted:     #6b7280;
  --text-subtle:    #9ca3af;

  --glow:           none;
  --glow-sm:        none;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

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

img, svg { max-width: 100%; }

/* ── Navigation ───────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 48px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(15,15,19,.85);
}

[data-theme="light"] nav {
  background: rgba(255,255,255,.9);
}

.nav-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-light);
  letter-spacing: -.5px;
}
.nav-logo span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: color .2s;
}
.nav-links a:hover { color: var(--text); }

/* Theme toggle button */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .2s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--primary); background: var(--bg-hover); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none !important;
  white-space: nowrap;
  letter-spacing: .1px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px rgba(99,102,241,.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 0 28px rgba(99,102,241,.45);
  transform: translateY(-1px);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 1.5px solid var(--border-light);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-light);
  background: rgba(99,102,241,.08);
}

.btn-ghost {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: 10px; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

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

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

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-subtle);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-newsletter  { background: rgba(139,92,246,.2); color: #c4b5fd; border: 1px solid rgba(139,92,246,.3); }
.badge-promotional { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.badge-spam        { background: rgba(239,68,68,.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.badge-success     { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.25); }
.badge-failed      { background: rgba(239,68,68,.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.badge-pending     { background: rgba(107,114,128,.15);color: var(--text-muted); border: 1px solid var(--border); }

[data-theme="light"] .badge-newsletter  { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
[data-theme="light"] .badge-promotional { background: #fef3c7; color: #92400e; border-color: #fde68a; }
[data-theme="light"] .badge-spam        { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
[data-theme="light"] .badge-success     { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
[data-theme="light"] .badge-failed      { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  border: 1px solid;
  max-width: 320px;
}
.toast-success { background: rgba(16,185,129,.15); color: #6ee7b7; border-color: rgba(16,185,129,.3); }
.toast-error   { background: rgba(239,68,68,.15);  color: #fca5a5; border-color: rgba(239,68,68,.3); }
.toast-info    { background: rgba(99,102,241,.15); color: var(--primary-light); border-color: rgba(99,102,241,.3); }

[data-theme="light"] .toast-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
[data-theme="light"] .toast-error   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
[data-theme="light"] .toast-info    { background: #ede9fe; color: #4338ca; border-color: #c4b5fd; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(.95); }
  to   { opacity: 1; transform: none; }
}

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-subtle);
  font-size: 12px;
  margin: 20px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-gradient {
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.w-full { width: 100%; }
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ── Scrollbar (dark) ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-subtle); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Mobile nav ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  nav { padding: 14px 20px; }
  .nav-links a:not(.btn) { display: none; }
}
