/* Lavaboard — Analytics Dashboard v1.0.0 */

/* ─── Tokens ─── */
:root {
  /* Lava palette — hex for max browser compat */
  --brand:        #f92b00;   /* molten lava orange-red  */
  --brand-bright: #ff5c2e;   /* bright lava             */
  --brand-dim:    #b82000;   /* deep lava               */
  --brand-glow:   rgba(249, 43, 0, 0.16);
  --brand-pulse:  rgba(249, 43, 0, 0.08);
  --bg:           #111010;   /* volcanic rock           */
  --bg-1:         #181614;
  --bg-2:         #1f1c1a;
  --bg-3:         #272320;
  --border:       #3a3330;
  --border-subtle:#272320;
  --text:         #f0ede8;
  --text-2:       #a09790;
  --text-3:       #6b625c;
  --up:           #22c55e;
  --down:         #ef4444;
  --up-bg:        rgba(34, 197, 94, 0.12);
  --down-bg:      rgba(239, 68, 68, 0.12);
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 1px 3px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.3);
  --lava-shadow:  0 0 40px rgba(249, 43, 0, 0.12);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Auth Screen ─── */
#auth-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(249,43,0,0.12), transparent),
    radial-gradient(ellipse 40% 30% at 20% 80%, rgba(184,32,0,0.08), transparent);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: min(400px, 90vw);
  box-shadow: var(--shadow), var(--lava-shadow);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--brand-glow);
  border: 1px solid rgba(249,43,0,0.3);
  margin-bottom: 0.75rem;
}
.auth-logo-mark svg { width: 24px; height: 24px; }
.auth-logo .biz-name { font-size: 1.25rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.auth-logo .powered { font-size: 0.75rem; color: var(--text-3); margin-top: 0.25rem; }
.auth-card h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.375rem; }
.auth-card p { font-size: 0.875rem; color: var(--text-2); margin-bottom: 1.5rem; }
.auth-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 1rem;
}
.auth-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(249,43,0,0.12);
}
.auth-btn {
  width: 100%;
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: #faf9f7;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}
.auth-btn:hover { opacity: 0.9; box-shadow: 0 4px 16px rgba(249,43,0,0.35); }
.auth-btn:active { transform: scale(0.98); }
.auth-error { color: var(--down); font-size: 0.8125rem; margin-top: 0.75rem; display: none; }

/* ─── App Shell ─── */
#app { display: none; min-height: 100vh; }
#app.visible { display: flex; flex-direction: column; }

/* ─── Header ─── */
.header {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-logo {
  display: flex; align-items: center; gap: 0.625rem;
  text-decoration: none;
}
.header-logo-mark {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249,43,0,0.3);
}
.header-logo-mark svg { width: 14px; height: 14px; }
.header-logo-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: #faf9f7;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249,43,0,0.3);
}
.header-wordmark {
  font-size: 0.9375rem; font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.header-wordmark span { color: var(--brand); }
.header-biz-name { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.header-separator { width: 1px; height: 20px; background: var(--border); }
.header-section { font-size: 0.875rem; color: var(--text-2); }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.live-badge {
  display: flex; align-items: center; gap: 0.375rem;
  background: var(--up-bg);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 100px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--up);
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--up);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.date-badge {
  font-size: 0.75rem;
  color: var(--text-3);
}
.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  color: var(--text-2);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--text-2); color: var(--text); }

/* ─── Nav ─── */
.nav {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0 1rem;
  height: 44px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
  border-radius: 0;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--brand); border-bottom-color: var(--brand); }
.nav-icon { width: 14px; height: 14px; opacity: 0.8; }

/* ─── Main Content ─── */
.main { flex: 1; padding: 1.75rem 1.5rem; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ─── Pages ─── */
.page { display: none; animation: fadeIn 0.2s ease-out; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { font-size: 0.875rem; color: var(--text-2); margin-top: 0.25rem; }
.page-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ─── Date Picker ─── */
.date-picker {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.date-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.date-btn:hover { color: var(--text); background: var(--bg-2); }
.date-btn.active { color: var(--brand); background: var(--bg-3); }

/* ─── Stat Cards ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: rgba(249,43,0,0.4); }
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(249,43,0,0.2), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover::after { opacity: 1; }
.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.625rem; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-bottom: 0.625rem; }
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 100px;
}
.stat-trend.up { color: var(--up); background: var(--up-bg); }
.stat-trend.down { color: var(--down); background: var(--down-bg); }
.stat-trend.neutral { color: var(--text-2); background: var(--bg-3); }
.stat-compare { font-size: 0.75rem; color: var(--text-3); margin-top: 0.375rem; }
.stat-sparkline { margin-top: 0.75rem; }

/* ─── Panels ─── */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-title { font-size: 0.875rem; font-weight: 600; }
.panel-subtitle { font-size: 0.75rem; color: var(--text-3); }
.panel-body { padding: 1.25rem 1.5rem; }
.panel-body-flush { padding: 0; }

/* Column spans */
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-7  { grid-column: span 7; }
.col-6  { grid-column: span 6; }
.col-5  { grid-column: span 5; }
.col-4  { grid-column: span 4; }

/* ─── Chart Containers ─── */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100% !important; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  padding: 0.625rem 1.5rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(249,43,0,0.04); }

/* ─── Progress Bar ─── */
.progress-rows { display: flex; flex-direction: column; gap: 0.875rem; }
.progress-row {}
.progress-row-header { display: flex; justify-content: space-between; font-size: 0.8125rem; margin-bottom: 0.375rem; }
.progress-row-label { font-weight: 500; }
.progress-row-count { color: var(--text-2); }
.progress-bar-track { height: 4px; background: var(--bg-3); border-radius: 100px; overflow: hidden; }
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  border-radius: 100px;
  transition: width 0.6s ease-out;
}

/* ─── Traffic Source Rows ─── */
.source-list { display: flex; flex-direction: column; }
.source-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.source-item:last-child { border-bottom: none; }
.source-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.source-info { flex: 1; min-width: 0; }
.source-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-pct { font-size: 0.75rem; color: var(--text-3); }
.source-bar-track { height: 3px; background: var(--bg-3); border-radius: 100px; margin-top: 0.375rem; overflow: hidden; }
.source-bar-fill { height: 100%; border-radius: 100px; }
.source-value { font-size: 0.875rem; font-weight: 600; color: var(--text-2); flex-shrink: 0; }

/* ─── Geo List ─── */
.geo-list { display: flex; flex-direction: column; gap: 0; }
.geo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6875rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.geo-item:last-child { border-bottom: none; }
.geo-rank { font-size: 0.75rem; font-weight: 700; color: var(--text-3); width: 18px; text-align: center; }
.geo-flag { font-size: 1rem; }
.geo-name { flex: 1; font-size: 0.875rem; font-weight: 500; }
.geo-count { font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.geo-bar { width: 60px; height: 3px; background: var(--bg-3); border-radius: 100px; overflow: hidden; }
.geo-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-dim), var(--brand)); border-radius: 100px; }

/* ─── Lead Log ─── */
.lead-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}
.lead-item:hover { background: rgba(249,43,0,0.04); }
.lead-item:last-child { border-bottom: none; }
.lead-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-glow);
  border: 1px solid rgba(249,43,0,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand-bright);
  flex-shrink: 0;
}
.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 0.9375rem; font-weight: 600; }
.lead-email { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.125rem; }
.lead-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.lead-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.175rem 0.5rem;
  border-radius: 100px;
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.lead-tag.source-google { background: rgba(66,133,244,0.15); color: #4285f4; border-color: rgba(66,133,244,0.3); }
.lead-tag.source-direct { background: var(--brand-glow); color: var(--brand-bright); border-color: rgba(249,43,0,0.3); }
.lead-tag.source-facebook { background: rgba(24,119,242,0.15); color: #1877f2; border-color: rgba(24,119,242,0.3); }
.lead-time { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }

/* ─── AI Insights ─── */
.insights-hero {
  background: linear-gradient(135deg, #1e1612, #181614);
  border: 1px solid rgba(249,43,0,0.22);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.insights-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(249,43,0,0.14), transparent 70%);
  pointer-events: none;
}
.insights-hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(184,32,0,0.08), transparent 70%);
  pointer-events: none;
}
.insights-week-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); margin-bottom: 1rem; }
.insights-summary { font-size: 1.0625rem; line-height: 1.7; color: #e2ddd8; position: relative; z-index: 1; }
.insights-summary strong { color: var(--text); }

.insight-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.insight-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.insight-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.insight-icon.rec { background: rgba(66,133,244,0.15); }
.insight-icon.warn { background: rgba(245,158,11,0.15); }
.insight-icon.win { background: var(--up-bg); }
.insight-text { font-size: 0.9rem; line-height: 1.6; color: #cec9c3; }
.insight-text strong { color: var(--text); }

.refresh-insights-btn {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  padding: 0.625rem 1.125rem;
  color: #faf9f7;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.refresh-insights-btn:hover { opacity: 0.85; box-shadow: 0 4px 16px rgba(249,43,0,0.35); }
.refresh-insights-btn.loading { opacity: 0.6; pointer-events: none; }

/* ─── Reports ─── */
.report-preview {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.report-preview-header {
  background: var(--bg-2);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.report-brand { display: flex; align-items: center; gap: 0.75rem; }
.report-brand-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: #faf9f7;
  flex-shrink: 0;
}
.report-brand-name { font-weight: 700; font-size: 1rem; }
.report-date { font-size: 0.8125rem; color: var(--text-2); }
.report-body { padding: 2rem; }
.report-section { margin-bottom: 2rem; }
.report-section-title { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 1rem; }
.report-metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.report-metric {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.report-metric-label { font-size: 0.75rem; color: var(--text-3); margin-bottom: 0.375rem; }
.report-metric-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; }

/* ─── SEO Page ─── */
.keyword-table tbody td { font-size: 0.875rem; }
.position-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.pos-1-3 { background: var(--up-bg); color: var(--up); }
.pos-4-10 { background: rgba(66,133,244,0.15); color: #4285f4; }
.pos-11-plus { background: var(--bg-3); color: var(--text-2); }

/* ─── Setup Banner ─── */
.setup-banner {
  background: rgba(249,43,0,0.08);
  border: 1px solid rgba(249,43,0,0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}
.setup-banner-icon { font-size: 1.125rem; }
.setup-banner-text { flex: 1; color: var(--text-2); }
.setup-banner-text strong { color: var(--text); }
.setup-banner-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}
.setup-banner-link:hover { text-decoration: underline; }

/* ─── Loading State ─── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-3);
}
.empty-state-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.375rem; }
.empty-state-body { font-size: 0.875rem; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .col-8  { grid-column: span 12; }
  .col-7  { grid-column: span 12; }
  .col-5  { grid-column: span 12; }
  .col-4  { grid-column: span 6; }
}
@media (max-width: 640px) {
  .main { padding: 1.25rem 1rem; }
  .col-4  { grid-column: span 12; }
  .col-6  { grid-column: span 12; }
  .header-section { display: none; }
  .date-badge { display: none; }
  .stat-value { font-size: 1.625rem; }
  .page-actions { width: 100%; overflow-x: auto; }
}
