/* =============================================
   SUPERTEK CRM — Color Theme
   Primary : linear-gradient(135deg, oklch(66% .18 250), oklch(46% .235 266))
   Solid   : #006dec  (fallback / text / borders)
   Text    : #000000 (Black)
   Base    : #ffffff (White)
============================================= */

:root {
  /* SUPERTEK brand (variable names kept as --red-* so existing views keep working) */
  --brand-start: #1795fa;
  --brand-end:   #1c3dd8;
  --brand-grad:  linear-gradient(135deg, #1795fa, #1c3dd8);
  --brand-grad-v: linear-gradient(180deg, #1795fa 0%, #1c3dd8 100%);
  --red:       #006dec;
  --red-dark:  #1c3dd8;
  --red-light: #eef4ff;
  --red-mid:   rgba(0,109,236,0.10);
  --black:     #000000;
  --gray-100:  #f5f7fb;
  --gray-200:  #e9edf5;
  --gray-300:  #d9dfea;
  --gray-500:  #7c869a;
  --gray-700:  #3f4859;
  --white:     #ffffff;
  --green:     #16a34a;
  --amber:     #d97706;
  --blue:      #2563eb;
  --badge-orange: #f59e0b;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-100);
  color: var(--black);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--gray-200); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ============ LAYOUT ============ */
.crm-layout { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--brand-grad-v);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(28,61,216,0.12);
}
/* thin, subtle scrollbar on the blue sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.3) transparent; }

/* White logo block on top */
.sidebar-logo {
  background: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.sidebar-logo-img {
  width: 100%;
  max-width: 110px;
  height: auto;
  display: block;
  flex-shrink: 0;
}
/* Logo image already carries the brand name, so the text block is hidden */
.sidebar-logo-text,
.sidebar-logo-sub { display: none; }
.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: var(--brand-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 18px 0 12px; }
.nav-section { margin-bottom: 18px; }
.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  padding: 0 24px;
  margin-bottom: 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 12px;
  padding: 10px 12px;
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border-left: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: rgba(255,255,255,0.14);
  color: var(--white);
}
.nav-link.active {
  background: var(--white);
  color: var(--red-dark);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(10,30,120,0.18);
}
.nav-link:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}
.nav-link i { font-size: 17px; width: 20px; text-align: center; }

/* Count badges (orange pills like the design) */
.nav-badge {
  margin-left: auto;
  background: var(--badge-orange);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
  line-height: 1.5;
}
.nav-link.active .nav-badge { background: var(--badge-orange); color: var(--white); }

/* Small tag badges inside nav, e.g. "Multi" */
.sidebar .badge,
.sidebar .nav-link span[style*="font-size:9px"],
.sidebar .nav-link span[style*="font-size: 9px"] {
  background: rgba(255,255,255,0.22) !important;
  color: var(--white) !important;
}

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user .user-avatar {
  background: var(--white);
  color: var(--red-dark);
}
.user-name  { font-size: 13px; font-weight: 600; color: var(--black); }
.user-role  { font-size: 11px; color: var(--gray-500); }
.sidebar-user .user-name { color: var(--white); }
.sidebar-user .user-role { color: rgba(255,255,255,0.75); }
.user-status{ width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-left: auto; flex-shrink:0; }

/* ============ MAIN CONTENT ============ */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 19px;
  font-weight: 700;
  color: #0b1b3f;
  flex: 1;
}
.topbar-title span {
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-500);
  margin-left: 6px;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 7px 12px;
  width: 240px;
}
.topbar-search:focus-within { border-color: var(--red); background: var(--white); }
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--black);
  width: 100%;
}
.topbar-search input::placeholder { color: var(--gray-500); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--red); background: var(--brand-grad); color: var(--white); border: none; }
.btn-primary:hover,
.btn-primary:focus { background: var(--red-dark); color: var(--white); box-shadow: 0 6px 16px rgba(28,61,216,0.25); }
.btn-outline   { background: var(--white); color: var(--red); border: 1.5px solid var(--red); }
.btn-outline:hover { background: var(--red-light); }
.btn-secondary { background: var(--white); color: var(--black); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-100); border-color: var(--red); color: var(--red-dark); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger    { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #dc2626; color: var(--white); }

/* ============ PAGE CONTENT ============ */
.page-content { padding: 28px; flex: 1; }

/* ============ STAT CARDS ============ */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
}
.stat-card.red::after   { background: var(--brand-grad); }
.stat-card.green::after { background: var(--green); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.blue::after  { background: var(--blue); }

.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--gray-500); }
.stat-value { font-size: 30px; font-weight: 800; color: var(--black); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--gray-500); }
.stat-icon  {
  position: absolute; right: 18px; top: 18px;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.stat-icon.red   { background: var(--red-light); color: var(--red); }
.stat-icon.green { background: #f0fdf4; color: var(--green); }
.stat-icon.amber { background: #fffbeb; color: var(--amber); }
.stat-icon.blue  { background: #eff6ff; color: var(--blue); }

/* ============ CARDS / PANELS ============ */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
}
.card-title { font-size: 15px; font-weight: 700; color: #0b1b3f; flex: 1; }
.card-body  { padding: 20px 22px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafd; }
th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gray-500);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--black);
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fbff; }

.td-name  { font-weight: 600; color: var(--black); }
.td-email { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ============ BADGES / STATUS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-red    { background: #fef2f2; color: #dc2626; }
.badge-green  { background: #f0fdf4; color: #16a34a; }
.badge-amber  { background: #fffbeb; color: #d97706; }
.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }
.badge-fb     { background: #e7f0fd; color: #1877f2; }

/* ============ SOURCE / CAMPAIGN TAG ============ */
.fb-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e7f0fd;
  border: 1px solid #bed3f8;
  color: #1877f2;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
}
.fb-tag .fb-dot {
  width: 14px; height: 14px;
  background: #1877f2;
  border-radius: 3px;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============ SCORE BAR ============ */
.score-wrap { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.score-track { flex: 1; height: 5px; background: var(--gray-200); border-radius: 3px; }
.score-fill  { height: 5px; border-radius: 3px; }
.score-num   { font-size: 12px; font-weight: 700; min-width: 24px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 6px;
}
.form-label .req { color: #dc2626; margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  color: var(--black);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(0,109,236,0.12); }
.form-control::placeholder { color: var(--gray-500); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-error { font-size: 12px; color: #dc2626; margin-top: 4px; }
.form-hint  { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

/* ============ ALERTS ============ */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ============ PAGINATION ============ */
.pagination { display: flex; align-items: center; gap: 4px; padding: 14px 22px; border-top: 1px solid var(--gray-200); }
.page-link {
  padding: 6px 11px;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
  font-size: 13px;
  color: var(--black);
  text-decoration: none;
  transition: all 0.15s;
  background: var(--white);
}
.page-link:hover    { background: var(--red-light); border-color: var(--red); color: var(--red); }
.page-link.active   { background: var(--brand-grad); color: var(--white); border-color: var(--red); }
.page-link.disabled { color: var(--gray-300); pointer-events: none; }

/* ============ TABS ============ */
.tab-nav { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-link {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab-link:hover { color: var(--black); }
.tab-link.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}
.empty-state i  { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--black); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ============ LOGIN PAGE (legacy classes) ============ */
.login-page {
  min-height: 100vh;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--brand-grad);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 12px;
}
.login-title { font-size: 22px; font-weight: 800; color: var(--black); }
.login-sub   { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ============ DROPDOWN ACTIONS ============ */
.action-menu { position: relative; display: inline-block; }
.action-btn  {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 16px;
  transition: all 0.15s;
}
.action-btn:hover { background: var(--gray-100); color: var(--black); }
.action-drop {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  min-width: 140px;
  z-index: 200;
}
.action-menu:hover .action-drop { display: block; }
.action-drop a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--black);
  text-decoration: none;
}
.action-drop a:hover { background: var(--gray-100); }
.action-drop a.danger { color: #dc2626; }
.action-drop a.danger:hover { background: #fef2f2; }

/* ============ RESPONSIVE ============ */
@media (max-width: 992px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrap { margin-left: 0; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row  { grid-template-columns: 1fr; }
}

/* ============ SUPERTEK BRAND (modern browsers: exact oklch colors) ============ */
@supports (color: oklch(50% 0.1 250)) {
  :root {
    --brand-grad:   linear-gradient(135deg, oklch(66% .18 250), oklch(46% .235 266));
    --brand-grad-v: linear-gradient(180deg, oklch(66% .18 250), oklch(46% .235 266));
  }
}
