/* dashboard.css — Analytics Dashboard & Shared Shell Components */

body { min-height: 100vh; }

/* ── Top nav ───────────────────────────────────────────────────────────────── */
.nav {
  height: var(--hh);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.nav-title  { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.nav-right  { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ── Page layout ───────────────────────────────────────────────────────────── */
.page { max-width: 1400px; margin: 0 auto; padding: 28px 28px 60px; width: 100%; }

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

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px 22px;
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--card-shadow-hover);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  margin-bottom: 12px;
  color: var(--text);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-trend {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 6px;
}
.stat-trend.up   { color: var(--red); }
.stat-trend.down { color: var(--accent); }

/* ── Grid layouts ──────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Panel ─────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.panel-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.panel-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.panel-sub { font-size: 12px; color: var(--text-muted); }
.panel-body { padding: 20px 22px; }

/* ── Activity chart ────────────────────────────────────────────────────────── */
.chart-wrap { padding: 18px 22px 12px; }
canvas { display: block; width: 100%; }

/* ── Click heatmap ─────────────────────────────────────────────────────────── */
.heatmap-wrap    { padding: 14px 22px 18px; position: relative; }
#heatmapCanvas   { border-radius: 10px; width: 100%; height: auto; display: block; background: var(--surface2); border: 1px solid var(--border); }
.heatmap-legend  { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11.5px; color: var(--text-dim); }
.legend-grad     { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(59,130,246,.2), rgba(139,92,246,.6), rgba(239,68,68,1)); }

/* ── Top errors list ───────────────────────────────────────────────────────── */
.error-rank-list    { padding: 6px 0; }
.error-rank-item    { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.error-rank-item:last-child { border: none; }
.error-rank-item:hover { background: var(--surface2); }
.rank-num           { font-size: 12px; font-weight: 800; color: var(--text-dim); min-width: 22px; }
.rank-bar-wrap      { flex: 1; min-width: 0; }
.rank-text          { font-size: 12.5px; font-family: var(--mono); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.rank-bar-bg        { height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.rank-bar           { height: 100%; background: var(--red); border-radius: 3px; transition: width 0.4s; }
.rank-count         { font-size: 12.5px; font-weight: 700; color: var(--red); min-width: 30px; text-align: right; }

/* ── Sessions table ────────────────────────────────────────────────────────── */
.sessions-table               { width: 100%; border-collapse: collapse; }
.sessions-table th            { text-align: left; padding: 12px 22px; font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); background: var(--surface2); }
.sessions-table td            { padding: 13px 22px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.sessions-table tr:last-child td { border: none; }
.sessions-table tr:hover td   { background: var(--surface2); cursor: pointer; }
.sessions-table .url-cell     { color: var(--blue); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* ── Core Web Vitals grid ──────────────────────────────────────────────────── */
.cwv-grid   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 18px 22px; }
.cwv-item   { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.cwv-name   { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.cwv-val    { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.cwv-unit   { font-size: 12px; color: var(--text-dim); margin-left: 2px; font-weight: 600; }
.cwv-status { font-size: 11px; font-weight: 600; margin-top: 4px; }
.cwv-good  { color: var(--accent); }
.cwv-needs { color: var(--orange); }
.cwv-poor  { color: var(--red); }

/* ── Domain list ───────────────────────────────────────────────────────────── */
.domain-list  { padding: 6px 0; }
.domain-item  { display: flex; align-items: center; gap: 12px; padding: 11px 22px; border-bottom: 1px solid var(--border); }
.domain-item:last-child { border: none; }
.domain-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.domain-name  { font-size: 13.5px; font-weight: 500; flex: 1; color: var(--text); }
.domain-count { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }

/* ── Explicit Light Theme Refinements for Dashboard ────────────────────────── */
[data-theme="light"] .stat-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .stat-card:hover {
  border-color: #059669;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .stat-icon {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

[data-theme="light"] .panel {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .panel-header {
  background: #ffffff;
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .cwv-item {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] #heatmapCanvas {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sessions-table th {
  background: #f1f5f9;
  color: #475569;
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sessions-table td {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sessions-table tr:hover td {
  background: #f8fafc;
}

[data-theme="light"] .error-rank-item:hover {
  background: #f8fafc;
}

[data-theme="light"] .domain-item {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}
