@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0B0B0F;
  --surface: #16161A;
  --surface-hover: #1E1E26;
  --sidebar-bg: #111115;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.10);
  --text: #EDEDEF;
  --text-muted: #8A8A9A;
  --text-faint: #4A4A5A;
  --primary: #5E6AD2;
  --primary-hover: #6875D8;
  --primary-subtle: rgba(94,106,210,0.15);
  --primary-light: rgba(94,106,210,0.08);
  --accent: #2CB67D;
  --accent-light: rgba(44,182,125,0.12);
  --tag-bg: rgba(255,255,255,0.07);
  --shadow: 0 1px 3px rgba(0,0,0,.5);
  --radius: 6px;
  --sidebar-w: 220px;
}

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

html { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

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

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

/* ──────────────────────────────────────────────
   Sidebar
─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.brand-link:hover { color: var(--text); }
.brand-name { color: var(--text); }

.sidebar-nav {
  padding: 8px 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  margin-bottom: 1px;
  line-height: 1.3;
}
.nav-item svg { flex-shrink: 0; opacity: 0.65; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { background: rgba(255,255,255,0.07); color: var(--text); }
.nav-item.active svg { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
}

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

/* ──────────────────────────────────────────────
   Cards
─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.card + .card { margin-top: 12px; }

/* ──────────────────────────────────────────────
   Stats grid
─────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.stats .card, .admin-grid .card { margin-top: 0; }
.stat { text-align: left; padding: 20px 20px 18px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; }

/* ──────────────────────────────────────────────
   Filters
─────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 10px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.filter-group input, .filter-group select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  min-width: 130px;
  font-family: inherit;
}
.filter-group input::placeholder { color: var(--text-faint); }
.filter-group input:focus, .filter-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-subtle);
}
.filter-group select option { background: var(--surface); color: var(--text); }

/* ──────────────────────────────────────────────
   Buttons
─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
  line-height: 1.3;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }
.btn-outline:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.1); color: #F87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* ──────────────────────────────────────────────
   Tables
─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  color: var(--text-faint); letter-spacing: .5px; white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ──────────────────────────────────────────────
   Tags
─────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500; background: var(--tag-bg);
  color: var(--text-muted); margin: 1px 2px; white-space: nowrap;
}
.tag-ig  { background: rgba(236,72,153,0.12); color: #F472B6; }
.tag-tt  { background: rgba(139,92,246,0.12); color: #A78BFA; }
.tag-yt  { background: rgba(239,68,68,0.12);  color: #F87171; }
.tag-fb  { background: rgba(59,130,246,0.12); color: #60A5FA; }
.tag-xhs { background: rgba(245,158,11,0.12); color: #FCD34D; }
.tag-country { background: rgba(44,182,125,0.12); color: #4ADE80; }
.tag-tier    { background: rgba(14,165,233,0.12); color: #38BDF8; }

/* ──────────────────────────────────────────────
   KOL name
─────────────────────────────────────────────── */
.kol-name { font-weight: 600; color: var(--primary); font-size: 13px; }
.kol-name:hover { color: var(--primary-hover); }

/* ──────────────────────────────────────────────
   Detail pages
─────────────────────────────────────────────── */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.detail-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.detail-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.bio { color: var(--text-muted); font-size: 13px; max-width: 700px; margin: 8px 0 16px; line-height: 1.6; }
.section-title {
  font-size: 11px; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .5px;
  margin: 24px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.platform-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.platform-card { padding: 14px; }
.platform-card .plat-name { font-weight: 600; font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; color: var(--text); }
.platform-card .plat-followers { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.platform-card .plat-er { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.platform-card a { font-size: 12px; color: var(--primary); }

/* ──────────────────────────────────────────────
   Pagination
─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin: 20px 0; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 5px;
  font-size: 12px; border: 1px solid var(--border); color: var(--text-muted);
  transition: background 0.1s;
}
.pagination a:hover { background: var(--surface-hover); color: var(--text); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ──────────────────────────────────────────────
   Results info
─────────────────────────────────────────────── */
.results-info { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; }

/* ──────────────────────────────────────────────
   Campaign rows
─────────────────────────────────────────────── */
.campaign-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); transition: background 0.1s; border-radius: 4px; }
.campaign-row:hover { background: rgba(255,255,255,0.03); }
.campaign-row:last-child { border-bottom: none; }
.campaign-brand { font-weight: 600; font-size: 13px; color: var(--text); }
.campaign-meta { font-size: 12px; color: var(--text-muted); }
.campaign-kols { font-size: 12px; color: var(--primary); font-weight: 600; }

/* ──────────────────────────────────────────────
   Deliverable rows (search page)
─────────────────────────────────────────────── */
.deliv-row td { padding: 0 10px 6px !important; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.015); }
.deliv-grid { display: grid; grid-template-columns: 40px 140px 200px minmax(0,1fr) 50px 90px; gap: 0 12px; padding: 4px 0 2px; }
.deliv-hdr { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); padding-bottom: 4px; border-bottom: 1px solid var(--border); line-height: 1; }
.deliv-hdr-right { text-align: right; }
.deliv-brand { font-size: 12px; font-weight: 600; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.7; min-width: 0; }
.deliv-brand:hover { text-decoration: underline; }
.deliv-campaign { font-size: 12px; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.7; min-width: 0; }
.deliv-campaign:hover { text-decoration: underline; }
.deliv-desc { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.7; min-width: 0; }
.deliv-currency { font-size: 12px; color: var(--text-muted); line-height: 1.7; white-space: nowrap; }
.deliv-rate { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; text-align: right; line-height: 1.7; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.deliv-spacer td { padding: 0 !important; height: 28px; background: transparent; border-bottom: none; }

/* ──────────────────────────────────────────────
   Admin
─────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 24px; }
.admin-card { text-align: left; padding: 20px; transition: background 0.1s, border-color 0.1s; }
.admin-card:hover { background: var(--surface-hover); }
.admin-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.admin-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 6px; }

/* ──────────────────────────────────────────────
   Forms
─────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 10px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; background: var(--bg); color: var(--text);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-faint); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-subtle);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-group input[type="checkbox"] { width: auto; }
.form-group input:disabled, .form-group select:disabled { opacity: 0.5; cursor: not-allowed; }
.form-group select option { background: var(--surface); color: var(--text); }
.form-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ──────────────────────────────────────────────
   Alerts
─────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 12px; }
.alert-error { background: rgba(239,68,68,0.08); color: #F87171; border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: rgba(44,182,125,0.08); color: #4ADE80; border: 1px solid rgba(44,182,125,0.2); }

/* ──────────────────────────────────────────────
   Sub-tables
─────────────────────────────────────────────── */
.sub-section { margin-top: 28px; }
.sub-section-title { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.sub-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sub-table th { text-align: left; padding: 6px 8px; font-size: 10px; text-transform: uppercase; color: var(--text-faint); border-bottom: 1px solid var(--border); letter-spacing: .4px; }
.sub-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.sub-table tr:last-child td { border-bottom: none; }
.sub-table td:last-child { text-align: right; white-space: nowrap; }

/* ──────────────────────────────────────────────
   Autocomplete
─────────────────────────────────────────────── */
.autocomplete-list {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  list-style: none; margin: 3px 0 0; padding: 4px;
  max-height: 200px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.5); font-size: 12px;
}
.autocomplete-list.open { display: block; }
.autocomplete-list li { padding: 6px 8px; cursor: pointer; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.autocomplete-list li:hover, .autocomplete-list li.active { background: var(--primary-subtle); color: var(--text); }

/* ──────────────────────────────────────────────
   Segmented control (KOLs page)
─────────────────────────────────────────────── */
.seg-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; background: var(--surface); }
.seg-btn { padding: 5px 14px; font-size: 12px; font-weight: 500; border: none; cursor: pointer; background: transparent; color: var(--text-muted); text-decoration: none; white-space: nowrap; border-right: 1px solid var(--border); transition: background 0.1s, color 0.1s; font-family: inherit; }
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.seg-btn.active { background: var(--primary); color: #fff; }

/* ──────────────────────────────────────────────
   Mobile header + burger
─────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  z-index: 60;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.burger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-open .burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .burger span:nth-child(2) { opacity: 0; }
.nav-open .burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.nav-overlay.open { opacity: 1; pointer-events: auto; }

/* ──────────────────────────────────────────────
   Responsive
─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 24px 24px 48px; }
}
@media (max-width: 768px) {
  .filters { flex-direction: column; }
  .filter-group input, .filter-group select { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .mobile-header { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 72px 16px 48px; }
}

/* ──────────────────────────────────────────────
   Light mode variables
─────────────────────────────────────────────── */
html.light {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-hover: #EBEBEE;
  --sidebar-bg: #FFFFFF;
  --border: rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.13);
  --text: #111118;
  --text-muted: #5A5A6E;
  --text-faint: #9898A8;
  --primary: #5E6AD2;
  --primary-hover: #4A55C8;
  --primary-subtle: rgba(94,106,210,0.12);
  --primary-light: rgba(94,106,210,0.06);
  --accent: #059669;
  --accent-light: rgba(5,150,105,0.1);
  --tag-bg: rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* Light mode component overrides */
html.light .nav-item:hover { background: rgba(0,0,0,0.04); }
html.light .nav-item.active { background: rgba(94,106,210,0.1); color: var(--primary); }
html.light tbody tr:hover td { background: rgba(0,0,0,0.015); }
html.light .campaign-row:hover { background: rgba(0,0,0,0.025); }
html.light .deliv-row td { background: rgba(0,0,0,0.018); }
html.light .seg-btn:hover { background: rgba(0,0,0,0.04); }
html.light .autocomplete-list { box-shadow: 0 6px 20px rgba(0,0,0,.12); }
html.light .admin-card:hover { background: var(--surface-hover); }

/* Light mode tag overrides (darker foreground for readability) */
html.light .tag-ig  { background: rgba(236,72,153,0.1);  color: #be185d; }
html.light .tag-tt  { background: rgba(139,92,246,0.1);  color: #6d28d9; }
html.light .tag-yt  { background: rgba(239,68,68,0.1);   color: #dc2626; }
html.light .tag-fb  { background: rgba(59,130,246,0.1);  color: #1d4ed8; }
html.light .tag-xhs { background: rgba(245,158,11,0.1);  color: #b45309; }
html.light .tag-country { background: rgba(16,185,129,0.1);  color: #065f46; }
html.light .tag-tier    { background: rgba(14,165,233,0.1);   color: #0369a1; }

/* Light mode alerts */
html.light .alert-error   { background: rgba(239,68,68,0.06);  color: #dc2626; border-color: rgba(239,68,68,0.2); }
html.light .alert-success { background: rgba(16,185,129,0.06); color: #059669; border-color: rgba(16,185,129,0.2); }

/* Light mode danger button */
html.light .btn-danger { background: rgba(239,68,68,0.08); color: #dc2626; border-color: rgba(239,68,68,0.2); }
html.light .btn-danger:hover { background: rgba(239,68,68,0.14); }

/* Light mode btn-outline */
html.light .btn-outline:hover { background: var(--surface-hover); }

/* ──────────────────────────────────────────────
   Theme toggle button (sidebar footer)
─────────────────────────────────────────────── */
.sidebar-footer {
  padding: 8px 6px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  border-radius: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  text-align: left;
}
.theme-toggle svg { flex-shrink: 0; opacity: 0.55; }
.theme-toggle:hover { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.theme-toggle:hover svg { opacity: 0.9; }
html.light .theme-toggle:hover { background: rgba(0,0,0,0.04); }
