/* ============================================================
   CRM Pro — Main Stylesheet
   Font: Plus Jakarta Sans + JetBrains Mono
   ============================================================ */

:root {
  --sidebar-w:        260px;
  --topbar-h:         64px;
  --primary:          #EF5AA0;
  --primary-dark:     #3a0ca3;
  --primary-light:    #e8ecff;
  --accent:           #f72585;
  --success:          #06d6a0;
  --warning:          #ffd166;
  --danger:           #ef233c;
  --info:             #4cc9f0;
  --bg-body:          #f0f2f8;
  --bg-card:          #ffffff;
  --sidebar-bg:       #0f0e17;
  --sidebar-text:     rgba(255,255,255,.72);
  --sidebar-active:   #ffffff;
  --sidebar-hover:    rgba(255,255,255,.10);
  --border:           rgba(0,0,0,.07);
  --text-main:        #1a1a2e;
  --text-muted:       #6c757d;
  --radius:           14px;
  --radius-sm:        8px;
  --shadow:           0 4px 24px rgba(67,97,238,.10);
  --shadow-card:      0 2px 12px rgba(0,0,0,.07);
  --transition:       .22s ease;
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  text-decoration: none;
}
.brand-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.05);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-text {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 0 16px 12px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 10px;
  flex: 1;
}
.sidebar-nav .nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 14px 10px 6px;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.sidebar-nav li a i { font-size: 17px; flex-shrink: 0; }
.sidebar-nav li a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav li a.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(67,97,238,.45);
}

.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.45); text-transform: capitalize; }
.btn-logout {
  color: rgba(255,255,255,.45);
  font-size: 19px;
  flex-shrink: 0;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--accent); }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* ── Top bar ─────────────────────────────────────────────────── */
.top-bar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.sidebar-toggle {
  background: none; border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  display: none;
}
.top-bar-title { font-size: 16px; font-weight: 700; flex: 1; }
.top-bar-right { display: flex; align-items: center; gap: 10px; }

/* ── Page body ───────────────────────────────────────────────── */
.page-body { padding: 28px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 22px;
  font-weight: 700;
  font-size: 15px;
}
.card-body { padding: 22px; }

/* ── Stat cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #e8ecff; color: var(--primary); }
.stat-icon.green  { background: #e6faf5; color: var(--success); }
.stat-icon.pink   { background: #fff0f6; color: var(--accent); }
.stat-icon.orange { background: #fff8e6; color: #f4a261; }
.stat-info .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-info .value { font-size: 28px; font-weight: 800; color: var(--text-main); line-height: 1.1; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all var(--transition);
}
.btn-primary   { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm        { font-size: 12.5px; padding: 4px 12px; }

/* ── Tables ───────────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table thead th {
  background: #f7f8ff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table tbody tr:hover td { background: rgba(67,97,238,.03); }
.table td { vertical-align: middle; padding: 12px 14px; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge { font-size: 11.5px; font-weight: 600; border-radius: 6px; padding: 4px 9px; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid #dee2f0;
  font-size: 14px;
  padding: 9px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}
.form-label { font-weight: 600; font-size: 13px; color: var(--text-main); margin-bottom: 6px; }

/* ── Login page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0e17 0%, #1a1a3e 50%, #0f0e17 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(67,97,238,.2) 0%, transparent 70%);
  top: -200px; left: -200px;
  border-radius: 50%;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(247,37,133,.15) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  border-radius: 50%;
}
.login-card {
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 44px 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  position: relative;
  z-index: 1;
}
.login-logo {
  width: 92px; height: 92px;
  background: #fff;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.login-title { font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.login-sub   { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 32px; }

/* ── Follow-up thread ─────────────────────────────────────────── */
.followup-thread { display: flex; flex-direction: column; gap: 14px; }
.followup-item {
  background: #f7f8ff;
  border: 1px solid #e8ecff;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
}
.followup-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.followup-text { font-size: 14px; line-height: 1.65; }

/* ── Alert toast ──────────────────────────────────────────────── */
.toast-container-top {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

/* ── Sidebar collapsed ────────────────────────────────────────── */
.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.sidebar-collapsed .main-content { margin-left: 0; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .page-body { padding: 18px; }
}
@media (max-width: 575px) {
  .login-card { padding: 32px 24px; margin: 16px; }
  .stat-card { padding: 16px; }
  .stat-icon { width: 44px; height: 44px; font-size: 20px; }
  .stat-info .value { font-size: 22px; }
}

/* ── Misc ─────────────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; }
a { color: var(--primary); }
.table-actions { white-space: nowrap; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 800; margin: 0; }
code, .mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.overlay.show { display: block; }
