@charset "UTF-8";

/* ──────────────────────────────────────────
   LIGHT MODE TOKENS (default)
────────────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --card: #ffffff;
  --card-border: #e5e7eb;
  --text: #0f172a;
  --text-dim: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  --sidebar-bg: #0f172a;
  --sidebar-text: #f8fafc;
  --sidebar-link: #e2e8f0;
  --sidebar-link-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-border: rgba(255, 255, 255, 0.12);
  --sidebar-muted: rgba(226, 232, 240, 0.75);
}

/* ──────────────────────────────────────────
   BASE BODY
────────────────────────────────────────── */
.admin-theme {
  font-family: "Manrope", sans-serif;
  background: radial-gradient(circle at top, #eef2ff 0%, #f8fafc 55%, #f4f6fb 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ──────────────────────────────────────────
   DARK MODE TOKENS
────────────────────────────────────────── */
.admin-theme[data-admin-theme="dark"] {
  --bg: #09111f;
  --surface: #111827;
  --surface-muted: #172033;
  --border: #253146;
  --card: #111827;
  --card-border: #253146;
  --text: #e5eefc;
  --text-dim: #94a3b8;
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --shadow: 0 24px 48px rgba(2, 6, 23, 0.45);
  --sidebar-bg: #020617;
  --sidebar-text: #e2e8f0;
  --sidebar-link: #cbd5e1;
  --sidebar-link-hover-bg: rgba(148, 163, 184, 0.16);
  --sidebar-border: rgba(148, 163, 184, 0.18);
  --sidebar-muted: rgba(203, 213, 225, 0.72);
  background: radial-gradient(circle at top, #13213d 0%, #09111f 52%, #050b16 100%);
  color: var(--text);
}

/* ──────────────────────────────────────────
   SHELL & HEADER
────────────────────────────────────────── */
.admin-shell { min-height: 100vh; }

.admin-header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  color: var(--text);
}

.admin-theme[data-admin-theme="dark"] .admin-header {
  background: rgba(9, 17, 31, 0.96);
  color: var(--text);
}

.admin-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.admin-subtitle {
  color: var(--text-dim);
  margin-top: 6px;
  font-size: 14px;
}

/* ──────────────────────────────────────────
   FOOTER & SIDEBAR
────────────────────────────────────────── */
.admin-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-dim);
}

.admin-sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.admin-sidebar a { color: var(--sidebar-link); }
.admin-sidebar a:hover { background: var(--sidebar-link-hover-bg); }

.sidebar-top { border-bottom: 1px solid var(--sidebar-border); }
.sidebar-bottom { border-top: 1px solid var(--sidebar-border); color: var(--sidebar-muted); }
.sidebar-close { color: var(--sidebar-text); opacity: 0.85; }
.sidebar-close:hover { opacity: 1; }

.nav-item { border: 1px solid transparent; }

.sidebar-category {
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 18px 0 6px;
  padding: 0 12px;
  text-transform: uppercase;
}

.sidebar-category:first-of-type {
  margin-top: 12px;
}

.nav-item.active {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  color: #fff;
}

.nav-item.active i { color: #fff; }

/* ──────────────────────────────────────────
   PAGE & CARDS & TILES
────────────────────────────────────────── */
/* .admin-page { margin: 0 auto; } */

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  color: var(--text);
}

.admin-hero {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  color: #fff;
}

.admin-eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--text-dim);
}

.admin-big-number {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}

.admin-tile {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: var(--text);
}

.admin-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.admin-tile-title { font-weight: 800; color: var(--text); }
.admin-tile-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.admin-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  flex-shrink: 0;
}

/* ──────────────────────────────────────────
   FORM INPUTS & SELECTS — both modes visible
────────────────────────────────────────── */
.admin-input,
.admin-select,
select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.admin-input:focus,
.admin-select:focus,
select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* Dark mode form elements */
.admin-theme[data-admin-theme="dark"] .admin-input,
.admin-theme[data-admin-theme="dark"] .admin-select,
.admin-theme[data-admin-theme="dark"] select,
.admin-theme[data-admin-theme="dark"] input[type="text"],
.admin-theme[data-admin-theme="dark"] input[type="email"],
.admin-theme[data-admin-theme="dark"] input[type="password"],
.admin-theme[data-admin-theme="dark"] input[type="number"],
.admin-theme[data-admin-theme="dark"] input[type="search"],
.admin-theme[data-admin-theme="dark"] textarea {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

/* Native browser select options in dark mode */
.admin-theme[data-admin-theme="dark"] select option {
  background: #172033;
  color: #e5eefc;
}

/* Labels */
label, .admin-theme label { color: var(--text-dim); }
.admin-theme[data-admin-theme="dark"] label { color: var(--text-dim); }

.admin-form-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.admin-alert {
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  padding: 12px 14px;
}

.admin-alert-success {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.admin-alert-danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.admin-theme[data-admin-theme="dark"] .admin-alert-success {
  background: rgba(22, 101, 52, 0.24);
  border-color: rgba(134, 239, 172, 0.34);
  color: #86efac;
}

.admin-theme[data-admin-theme="dark"] .admin-alert-danger {
  background: rgba(153, 27, 27, 0.24);
  border-color: rgba(252, 165, 165, 0.34);
  color: #fca5a5;
}

/* ──────────────────────────────────────────
   BUTTONS
────────────────────────────────────────── */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.2s ease, transform 0.2s ease;
}

.admin-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

.admin-btn-primary { background: var(--primary); color: #fff; }
.admin-btn-primary:hover { background: var(--primary-dark); color: #fff; }

.admin-btn-secondary { background: var(--sidebar-bg); }

.admin-btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.admin-btn-ghost:hover { background: var(--surface-muted); }

.admin-theme[data-admin-theme="dark"] .admin-btn-ghost {
  color: var(--text);
  border-color: var(--border);
}

.admin-theme[data-admin-theme="dark"] .admin-btn-ghost:hover { background: var(--surface-muted); }

.admin-btn-inverse {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}

.admin-btn-inverse:hover { background: rgba(255, 255, 255, 0.16); }

.admin-btn-danger { background: var(--danger); color: #fff; }
.admin-btn-danger:hover { background: #b91c1c; }

/* ──────────────────────────────────────────
   LINKS
────────────────────────────────────────── */
.admin-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.admin-link:hover { text-decoration: underline; }

/* ──────────────────────────────────────────
   PILLS / BADGES
────────────────────────────────────────── */
.admin-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}

.admin-pill-group { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.admin-pill-success  { background: #dcfce7; color: #166534; }
.admin-pill-attention { background: #fef3c7; color: #92400e; }
.admin-pill-neutral  { background: #e2e8f0; color: #334155; }
.admin-pill-warning  { background: #fee2e2; color: #991b1b; }
.admin-pill-info     { background: #dbeafe; color: #1d4ed8; }
.customer-support-sidebar .sidebar-category,
.customer-support-sidebar .nav-item:not([href="/admin"]):not([href="/admin/user-analytics"]) { display: none !important; }

/* Dark mode pill adjustments */
.admin-theme[data-admin-theme="dark"] .admin-pill-success  { background: rgba(22,101,52,.30);  color: #86efac; }
.admin-theme[data-admin-theme="dark"] .admin-pill-attention { background: rgba(146,64,14,.30);  color: #fcd34d; }
.admin-theme[data-admin-theme="dark"] .admin-pill-neutral  { background: rgba(51,65,85,.50);   color: #cbd5e1; }
.admin-theme[data-admin-theme="dark"] .admin-pill-warning  { background: rgba(153,27,27,.30);  color: #fca5a5; }
.admin-theme[data-admin-theme="dark"] .admin-pill-info     { background: rgba(29,78,216,.30); color: #93c5fd; }

/* ──────────────────────────────────────────
   TABLES
────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  color: var(--text);
  min-width: 860px;
}

.admin-table-wrap {
  overflow: auto;
  border-radius: 12px;
}

.admin-table thead {
  background: #081227;
  color: #fff;
}

.admin-table th,
.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.admin-table thead th {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 2;
}

.admin-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-muted) 72%, transparent); }
.admin-table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.admin-table tbody tr:last-child td { border-bottom: 0; }

.admin-table code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  padding: 2px 6px;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table-enhancer {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 12px;
}

.admin-table-enhancer-title {
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 700;
}

.admin-table-enhancer-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-table-quick-search,
.admin-table-column-filter {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  height: 36px;
  padding: 0 11px;
}

.admin-table-quick-search {
  min-width: 240px;
}

.admin-table-empty-row td {
  color: var(--text-dim);
  font-weight: 700;
  padding: 22px 14px;
  text-align: center;
}

@media (max-width: 760px) {
  .admin-table-enhancer {
    align-items: stretch;
  }

  .admin-table-enhancer-controls,
  .admin-table-quick-search,
  .admin-table-column-filter {
    width: 100%;
  }

  .admin-table {
    min-width: 760px;
  }
}

/* ──────────────────────────────────────────
   FILTER & FORMS
────────────────────────────────────────── */
.admin-filter-bar {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
}

.admin-filter { display: flex; flex-direction: column; gap: 6px; }

.admin-filter-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}

.admin-filter-toggle { gap: 10px; }
.admin-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.admin-toggle input { width: 16px; height: 16px; }
.admin-card + .admin-card { margin-top: 20px; }

/* ──────────────────────────────────────────
   GRIDS & METRICS
────────────────────────────────────────── */
.admin-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.admin-grid-compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.admin-metric {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
}

.admin-metric-compact { padding: 12px; }
.admin-metric-compact span { font-size: 11px; }

.admin-metric span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.admin-metric strong { font-size: 20px; color: var(--text); }

/* ──────────────────────────────────────────
   SECTIONS & LISTS
────────────────────────────────────────── */
.admin-section { margin-top: 20px; }
.admin-section-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; color: var(--text); }

.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.admin-list li {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

.admin-form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.admin-muted { color: var(--text-dim); }

.admin-empty {
  padding: 18px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: var(--surface-muted);
  color: var(--text-dim);
  text-align: center;
}

.admin-file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ──────────────────────────────────────────
   ICON BUTTON
────────────────────────────────────────── */
.admin-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #e2e8f0;
  color: var(--text);
}

.admin-icon-btn:hover { border-color: var(--border); background: #cbd5f5; }

.admin-theme[data-admin-theme="dark"] .admin-icon-btn {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(23, 32, 51, 0.92);
  color: #e5eefc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.admin-theme[data-admin-theme="dark"] .admin-icon-btn:hover {
  border-color: rgba(96, 165, 250, 0.28);
  background: rgba(34, 48, 74, 0.98);
  color: #ffffff;
}

/* ──────────────────────────────────────────
   CAMPAIGN / SPLIT / CHIP / RECORD
────────────────────────────────────────── */
.admin-campaign { display: flex; flex-direction: column; gap: 16px; }

.admin-campaign-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

.admin-chip-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.admin-chip {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-muted);
  color: var(--text);
}

.admin-chip-title { font-weight: 600; font-size: 14px; color: var(--text); }
.admin-chip-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.admin-record-list { display: grid; gap: 10px; }

.admin-record {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fdfdfd;
  font-size: 13px;
  color: var(--text);
}

.admin-theme[data-admin-theme="dark"] .admin-record { background: var(--surface-muted); color: var(--text); }

/* ──────────────────────────────────────────
   SUMMARY / ACCORDION
────────────────────────────────────────── */
.admin-card-nested { padding: 0; }

.admin-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}

.admin-summary::marker, .admin-summary::-webkit-details-marker { display: none; }

.admin-summary-title { font-weight: 700; font-size: 15px; color: var(--text); }
.admin-summary-sub { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.admin-summary-metrics { display: flex; gap: 16px; color: var(--text-dim); font-size: 12px; }

.admin-card-nested > .admin-section { padding: 0 20px 18px 20px; }

.admin-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.admin-table-wrap .admin-table { border-radius: 0; border: none; }

/* ──────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-campaign-header { flex-direction: column; }
  .admin-summary { flex-direction: column; align-items: flex-start; }
  .admin-summary-metrics { flex-wrap: wrap; }
}

/* ──────────────────────────────────────────
   AUTH
────────────────────────────────────────── */
.admin-auth { display: flex; align-items: center; justify-content: center; padding: 48px 20px; min-height: 100vh; }
.admin-auth-card { max-width: 380px; width: 100%; text-align: center; }
.admin-auth-card .admin-input { margin-bottom: 12px; }

/* ──────────────────────────────────────────
   LOG VIEW
────────────────────────────────────────── */
.admin-log-view {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #1e293b;
  background: #0b1120;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
}

/* ──────────────────────────────────────────
   UTILITY
────────────────────────────────────────── */
.contents { display: contents; }

/* ──────────────────────────────────────────
   DARK MODE — Tailwind class fixes
   Ensures hard-coded Tailwind gray classes
   are readable in dark mode
────────────────────────────────────────── */

/* Headings always follow --text token */
.admin-theme[data-admin-theme="dark"] h1,
.admin-theme[data-admin-theme="dark"] h2,
.admin-theme[data-admin-theme="dark"] h3,
.admin-theme[data-admin-theme="dark"] h4,
.admin-theme[data-admin-theme="dark"] h5,
.admin-theme[data-admin-theme="dark"] h6 {
  color: var(--text);
}

/* Table cells in dark */
.admin-theme[data-admin-theme="dark"] table td,
.admin-theme[data-admin-theme="dark"] table th {
  color: var(--text);
  border-color: var(--border);
}

/* Pre/code: keep own colour */
.admin-theme[data-admin-theme="dark"] pre { color: inherit; }

/* Tailwind gray text classes — fix invisible text in dark */
.admin-theme[data-admin-theme="dark"] .text-gray-500,
.admin-theme[data-admin-theme="dark"] .text-gray-400 { color: #94a3b8 !important; }

.admin-theme[data-admin-theme="dark"] .text-gray-600,
.admin-theme[data-admin-theme="dark"] .text-gray-700,
.admin-theme[data-admin-theme="dark"] .text-gray-800,
.admin-theme[data-admin-theme="dark"] .text-gray-900 { color: var(--text) !important; }

/* Tailwind border classes in dark */
.admin-theme[data-admin-theme="dark"] .border-gray-200,
.admin-theme[data-admin-theme="dark"] .border-gray-300 { border-color: var(--border) !important; }

/* Tailwind bg-gray-50/100 panels in dark — must contrast */
.admin-theme[data-admin-theme="dark"] .bg-gray-50,
.admin-theme[data-admin-theme="dark"] .bg-gray-100 {
  background-color: var(--surface-muted) !important;
  color: var(--text) !important;
}

/* White backgrounds in dark = surface */
.admin-theme[data-admin-theme="dark"] .bg-white {
  background-color: var(--surface) !important;
}
