/* ========================================
   ListingLock Admin Analytics
   ======================================== */

html { scroll-behavior: smooth; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar.collapsed { transform: translateX(-220px); }
.sidebar.collapsed .sidebar-toggle { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--fg); }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: none;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg); color: var(--fg); }
.nav-item.active { background: var(--accent-lighter); color: var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .nav-item { color: var(--fg-muted); }

/* ── Main wrap ────────────────────────────────────────────────────────────── */
.main-wrap {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}
.main-wrap.sidebar-collapsed { margin-left: 0; }

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; }
.top-bar-title { font-size: 16px; font-weight: 700; color: var(--fg); letter-spacing: -0.02em; }

.top-bar-right { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}

.period-filter {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.period-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}
.period-btn:hover { color: var(--fg); }
.period-btn.active { background: var(--bg-white); color: var(--accent); box-shadow: var(--shadow-xs); }

.update-time {
  font-size: 11px;
  color: var(--fg-muted);
  white-space: nowrap;
}

/* ── Content ──────────────────────────────────────────────────────────────── */
.analytics-content {
  padding: 28px;
  flex: 1;
}

.analytics-section {
  margin-bottom: 48px;
  scroll-margin-top: 80px;
}

.section-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.sub-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 24px 0 10px;
}

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: -0.04em;
  line-height: 1;
}
.stat-card .sub {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 4px;
}
.stat-card .pct {
  font-size: 11px;
  font-weight: 600;
  margin-top: 3px;
}
.pct.positive { color: var(--green); }
.pct.negative { color: var(--red); }
.pct.neutral  { color: var(--fg-muted); }

/* ── Data table ────────────────────────────────────────────────────────────── */
.data-table {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 10px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.data-table td {
  font-size: 13px;
  color: var(--fg);
  padding: 9px 16px;
  border-bottom: 1px solid var(--bg);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td.num { font-weight: 700; text-align: right; }
.data-table td.muted { color: var(--fg-muted); }

/* ── Funnel visual ─────────────────────────────────────────────────────────── */
.funnel-visual {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.funnel-row + .funnel-row { border-top: 1px solid var(--bg); }
.funnel-row .f-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  width: 200px;
  flex-shrink: 0;
}
.funnel-row .f-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}
.funnel-row .f-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.4s ease;
}
.funnel-row .f-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.funnel-row .f-pct {
  font-size: 11px;
  color: var(--fg-muted);
  width: 48px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Verified breakdown ──────────────────────────────────────────────────────── */
.verified-grid { display: flex; gap: 16px; }
.verified-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  box-shadow: var(--shadow-sm);
}
.verified-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.verified-dot.verified { background: var(--green); }
.verified-dot.unverified { background: var(--amber, #d97706); }
.verified-item .v-label { font-size: 12px; color: var(--fg-muted); font-weight: 600; }
.verified-item .v-count { font-size: 20px; font-weight: 800; color: var(--fg); letter-spacing: -0.04em; }

/* ── Device grid ────────────────────────────────────────────────────────────── */
.device-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.device-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  flex: 1;
}
.device-item .d-icon { font-size: 20px; margin-bottom: 6px; }
.device-item .d-pct { font-size: 22px; font-weight: 800; color: var(--fg); letter-spacing: -0.04em; }
.device-item .d-label { font-size: 11px; color: var(--fg-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Score bands ─────────────────────────────────────────────────────────────── */
.score-bands { display: flex; gap: 12px; flex-wrap: wrap; }
.score-band {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  min-width: 150px;
  flex: 1;
  box-shadow: var(--shadow-sm);
}
.score-band .band-label { font-size: 12px; font-weight: 600; color: var(--fg-muted); margin-bottom: 8px; }
.score-band .band-count { font-size: 24px; font-weight: 800; color: var(--fg); letter-spacing: -0.04em; }

/* ── Chart ─────────────────────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.chart-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height 0.3s ease;
}
.chart-bar-label { font-size: 10px; color: var(--fg-muted); text-align: center; }
.chart-bar-val { font-size: 10px; font-weight: 600; color: var(--fg-muted); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state-card {
  background: var(--bg-white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

/* ── Meta Ads ────────────────────────────────────────────────────────────────── */
.meta-cta-block {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font);
}
.cta-btn:hover { background: var(--accent-hover); }
.cta-btn.paused { background: var(--amber, #d97706); }

/* ── Two col ────────────────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── Audit Funnel filters ──────────────────────────────────────────────────── */
.af-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.af-filters label {
  font-size: 13px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.af-filters select,
.af-filters input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-white);
  color: var(--fg);
}
.af-filters input[type="text"] { width: 140px; }
.af-filters #af-refresh-btn {
  margin-left: auto;
}

/* ── Audit Funnel step dots ────────────────────────────────────────────────── */
.af-step-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}
.af-step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.af-step-dot.done { background: var(--green); }
.af-step-dot.skip { background: var(--amber); }

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-220px);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrap {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .top-bar {
    padding: 12px 16px;
  }
  .analytics-content {
    padding: 16px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Color vars (amber) ─────────────────────────────────────────────────────── */
:root {
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
}