/* ============================================================
   Newsletter App – Custom Styles
   Compatible with Bootstrap 5.3 light/dark themes
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --primary: #6246ea;
  --primary-rgb: 98, 70, 234;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #c8c8d4;
  --sidebar-active-bg: rgba(98,70,234,.25);
  --sidebar-active-text: #ffffff;
  --sidebar-hover-bg: rgba(255,255,255,.06);
  --sidebar-section: #5a5a7a;
  --radius: .75rem;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

/* ── Layout ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
  gap: .5rem;
}

.sidebar-nav { padding: .75rem 0; }

.nav-section {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-section);
  padding: .9rem 1.25rem .25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav .nav-link i { font-size: 1rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover-bg); color: #fff; }
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

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

.avatar-circle {
  width: 34px; height: 34px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

/* ── Main wrapper ──────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-title { font-weight: 600; font-size: 1rem; }

/* ── Page content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1400px;
  width: 100%;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.12); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin-top: .25rem; }
.stat-card .stat-icon {
  position: absolute; right: 1.25rem; top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem; opacity: .12;
}
.stat-card.primary   { background: linear-gradient(135deg,#6246ea,#8b72f5); color: #fff; }
.stat-card.success   { background: linear-gradient(135deg,#0ab39c,#2ed8c3); color: #fff; }
.stat-card.warning   { background: linear-gradient(135deg,#f3a84e,#f7c97e); color: #fff; }
.stat-card.danger    { background: linear-gradient(135deg,#f06292,#ef9a9a); color: #fff; }

/* ── Progress ring (open rate) ─────────────────────────────── */
.ring-wrap { position: relative; width: 64px; height: 64px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-wrap .ring-val {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: .75rem; font-weight: 700;
}

/* ── Badge pill ────────────────────────────────────────────── */
.badge { font-size: .7rem; font-weight: 600; }

/* ── Campaign status badges ─────────────────────────────────── */
.status-draft     { background:#e9ecef; color:#495057; }
.status-scheduled { background:#fff3cd; color:#856404; }
.status-sending   { background:#cff4fc; color:#055160; }
.status-sent      { background:#d1e7dd; color:#0a3622; }
.status-paused    { background:#f8d7da; color:#842029; }

/* ── Table ─────────────────────────────────────────────────── */
.table-hover > tbody > tr { cursor: default; transition: background .1s; }
.table th { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb),.25); border-color: var(--primary); }

/* ── Rich text editor ──────────────────────────────────────── */
#editor-toolbar { border: 1px solid var(--bs-border-color); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; padding: .5rem .75rem; display: flex; gap: .25rem; flex-wrap: wrap; background: var(--bs-tertiary-bg); }
#editor-toolbar button { border: none; background: transparent; border-radius: .375rem; padding: .25rem .45rem; font-size: .9rem; cursor: pointer; color: var(--bs-body-color); }
#editor-toolbar button:hover { background: var(--bs-border-color); }
#editor-toolbar button.active { background: var(--primary); color: #fff; }
#editor-container { border: 1px solid var(--bs-border-color); border-radius: 0 0 var(--radius) var(--radius); min-height: 380px; padding: 1rem 1.25rem; outline: none; font-size: .95rem; line-height: 1.7; }
#editor-container:focus { box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb),.25); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: #5036c8; border-color: #5036c8; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); }

/* ── Import drop zone ──────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.drop-zone.dragover { border-color: var(--primary); background: rgba(var(--primary-rgb),.05); }

/* ── Sidebar overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-overlay.show { display: block; }
  .page-content { padding: 1rem; }
}

/* ── Dark mode tweaks ──────────────────────────────────────── */
[data-bs-theme="dark"] {
  --card-shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
}
[data-bs-theme="dark"] .topbar { background: #1c1c27; }
[data-bs-theme="dark"] .stat-card.primary   { background: linear-gradient(135deg,#4c35c2,#7059d8); }

/* ── Login page ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,#1a1a2e 0%,#16213e 60%,#0f3460 100%);
}
.login-card {
  width: 100%; max-width: 420px;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { font-size: 2.5rem; color: var(--primary); }

/* ── Misc ────────────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-primary   { color: var(--primary) !important; }

/* ── Animate counters ───────────────────────────────────────── */
@keyframes countUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stat-value { animation: countUp .4s ease both; }
