/* OK Web Design — Client Intelligence Dashboard v1.0.0 */

/* ─── Tokens ─── */
:root {
  --brand: oklch(62% 0.18 161);
  --brand-dim: oklch(52% 0.14 161);
  --brand-glow: oklch(62% 0.18 161 / 0.15);
  --bg: oklch(12% 0.01 240);
  --bg-1: oklch(15% 0.012 240);
  --bg-2: oklch(18% 0.014 240);
  --bg-3: oklch(21% 0.015 240);
  --border: oklch(28% 0.015 240);
  --border-subtle: oklch(22% 0.012 240);
  --text: oklch(92% 0.008 240);
  --text-2: oklch(65% 0.01 240);
  --text-3: oklch(45% 0.01 240);
  --up: oklch(68% 0.17 145);
  --down: oklch(62% 0.18 25);
  --up-bg: oklch(68% 0.17 145 / 0.12);
  --down-bg: oklch(62% 0.18 25 / 0.12);
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px oklch(0% 0 0 / 0.4), 0 4px 16px oklch(0% 0 0 / 0.2);
}

/* ─── 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);
  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);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .biz-name { font-size: 1.25rem; font-weight: 600; color: var(--text); }
.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;
  margin-bottom: 1rem;
}
.auth-input:focus { border-color: var(--brand); }
.auth-btn {
  width: 100%;
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: oklch(12% 0.01 240);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.auth-btn:hover { opacity: 0.9; }
.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-dot {
  width: 28px; height: 28px;
  background: var(--brand);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: oklch(12% 0.01 240);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.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 oklch(68% 0.17 145 / 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: oklch(100% 0 0 / 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(--text); 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;
}
.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: oklch(100% 0 0 / 0.02); }

/* ─── 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: 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: 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: oklch(100% 0 0 / 0.02); }
.lead-item:last-child { border-bottom: none; }
.lead-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-2);
  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: oklch(67% 0.17 250 / 0.15); color: oklch(67% 0.17 250); border-color: oklch(67% 0.17 250 / 0.3); }
.lead-tag.source-direct { background: var(--brand-glow); color: var(--brand); border-color: oklch(62% 0.18 161 / 0.3); }
.lead-tag.source-facebook { background: oklch(56% 0.17 250 / 0.15); color: oklch(56% 0.17 250); border-color: oklch(56% 0.17 250 / 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, oklch(18% 0.025 161), oklch(16% 0.015 240));
  border: 1px solid oklch(62% 0.18 161 / 0.2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.insights-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, oklch(62% 0.18 161 / 0.12), 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: oklch(88% 0.008 240); }
.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: oklch(67% 0.17 250 / 0.15); }
.insight-icon.warn { background: oklch(75% 0.15 65 / 0.15); }
.insight-icon.win { background: var(--up-bg); }
.insight-text { font-size: 0.9rem; line-height: 1.6; color: oklch(80% 0.008 240); }
.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: oklch(12% 0.01 240);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.refresh-insights-btn:hover { opacity: 0.85; }
.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-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: oklch(67% 0.17 250 / 0.15); color: oklch(67% 0.17 250); }
.pos-11-plus { background: var(--bg-3); color: var(--text-2); }

/* ─── Setup Banner ─── */
.setup-banner {
  background: oklch(67% 0.17 250 / 0.1);
  border: 1px solid oklch(67% 0.17 250 / 0.25);
  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: oklch(80% 0.01 240); }
.setup-banner-text strong { color: var(--text); }
.setup-banner-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: oklch(67% 0.17 250);
  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; }
}
