/* SpecRadar Dashboard Layout & Components */

/* ── Sidebar ── */
.dash-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.dash-sidebar .logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.dash-sidebar .logo span { color: var(--sidebar-accent); font-weight: 700; font-size: 1rem; font-family: var(--font-mono); }
.dash-sidebar .logo .cursor { display: inline-block; width: 2px; height: 1em; background: var(--sidebar-accent); margin-left: 2px; animation: blink 1s step-end infinite; vertical-align: text-bottom; }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }
.dash-sidebar nav { padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 2px; }
.dash-sidebar nav a {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius);
  font-size: 0.75rem; text-decoration: none; color: var(--sidebar-muted);
  transition: all 0.15s;
  font-family: var(--font-mono);
}
.dash-sidebar nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.dash-sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-accent); }
.dash-sidebar nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.dash-sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.6875rem; color: #64748B;
  font-family: var(--font-mono);
}
.dash-sidebar .sidebar-footer .status-line { display:flex; align-items:center; gap:0.375rem; margin-bottom:0.25rem; }
.dash-sidebar .sidebar-footer .status-ok { color: #22C55E; }
.dash-sidebar .sidebar-footer .status-dot { width:4px; height:4px; border-radius:50%; background:#22C55E; flex-shrink:0; }
.sidebar-user {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.sidebar-user .user-email {
  font-size: 0.75rem; color: var(--sidebar-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user .user-plan {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.625rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem; border-radius: var(--radius-full);
  width: fit-content;
}
.plan-free { background: #1E293B; color: #64748B; }
.plan-starter { background: rgba(8,145,178,0.15); color: var(--sidebar-accent); }
.plan-pro { background: rgba(139,92,246,0.15); color: #A78BFA; }
.sidebar-user .logout-btn {
  font-size: 0.6875rem; color: #64748B;
  text-decoration: none; cursor: pointer;
  background: none; border: none; text-align: left;
  padding: 0; transition: color 0.15s;
}
.sidebar-user .logout-btn:hover { color: var(--sidebar-text); }

/* ── Hamburger menu (mobile) ── */
.hamburger-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 0.5rem; color: var(--text-primary);
}
.hamburger-btn svg { width: 20px; height: 20px; }
.sidebar-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 19;
}

/* ── Gate overlay ── */
.gate-overlay {
  position: relative;
  max-height: calc(100vh - 280px);
  overflow: hidden;
}
.gate-overlay .gate-blur {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}
.gate-overlay .gate-cta {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(248,250,252,0.7);
  z-index: 5;
  padding: 2rem;
}
.gate-cta-box {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--divider);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.gate-cta-box h2 {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.gate-cta-box p {
  font-size: 0.875rem; color: var(--text-secondary);
  margin-bottom: 1.25rem; line-height: 1.6;
}
.gate-cta-box .gate-buttons {
  display: flex; gap: 0.75rem; justify-content: center;
}

/* ── Main content ── */
.dash-main { margin-left: var(--sidebar-width); background: #F8FAFC; min-height: 100vh; }

.dash-topbar {
  background: #fff;
  border-bottom: 1px solid var(--divider);
  padding: 0.875rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.dash-topbar h1 { font-size: 1.125rem; font-weight: 600; font-family: var(--font-mono); }
.agent-badge { display:inline-flex; align-items:center; gap:0.25rem; font-size:0.5625rem; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; padding:0.125rem 0.5rem; border-radius:var(--radius-full); background:var(--sidebar-active-bg); color:var(--sidebar-accent); font-family:var(--font-mono); margin-left:0.5rem; }
.agent-dot { width:5px; height:5px; border-radius:50%; background:var(--sidebar-accent); animation:blink 2s ease-in-out infinite; }

/* ── Metrics ── */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; padding: 1.5rem 2rem 0; }
.metric-card {
  background: #fff; border-radius: var(--radius-lg); padding: 1.25rem;
  border: 1px solid var(--divider);
}
.metric-card .label {
  font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600; margin-bottom: 0.375rem;
  font-family: var(--font-mono);
}
.metric-card .value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; font-family: var(--font-mono); }
.metric-card .sub { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 0.25rem; }
.metric-card .accent-val { color: var(--accent); }
.metric-card .green-val { color: var(--green); }
.metric-card .amber-val { color: var(--amber); }

/* ── Tabs ── */
.tab-bar {
  display: flex; gap: 0;
  padding: 0 2rem;
  margin-top: 1.25rem;
  border-bottom: 1px solid var(--divider);
  background: #fff;
  overflow-x: auto;
}
.tab-btn {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-tertiary);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--sidebar-accent); border-bottom-color: var(--sidebar-accent); }
.tab-btn svg { flex-shrink: 0; }

/* ── Theme cards ── */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1.5rem 2rem;
}
.themes-grid .theme-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: calc(50% - 0.5rem);
}
.theme-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.15s;
}
.theme-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
}
.theme-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.theme-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.theme-health {
  display: flex; align-items: center; gap: 0.375rem;
  font-size: 0.6875rem; font-weight: 600;
  white-space: nowrap;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.04);
}
.health-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.theme-metrics {
  display: flex; gap: 1.25rem; flex-wrap: wrap;
}
.theme-metric {
  display: flex; flex-direction: column;
}
.tm-value {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.2;
  font-family: var(--font-mono);
}
.tm-mrr { color: var(--accent); }
.tm-cross { color: var(--purple); }
.tm-accel { color: var(--red); }
.tm-label {
  font-size: 0.6875rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 500;
}
.theme-section {
  padding: 0.75rem;
  border-radius: var(--radius);
  background: #F8FAFC;
}
.theme-section-label {
  font-size: 0.6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #64748B; margin-bottom: 0.375rem;
}
.theme-section-text {
  font-size: 0.8125rem; color: var(--text-secondary);
  line-height: 1.6;
}
.theme-strategy {
  background: var(--green-bg);
  border-left: 3px solid var(--green);
}
.strategy-label { color: var(--green); }
.theme-patterns {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.pattern-badge {
  font-size: 0.625rem; font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid;
  background: transparent;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}
.theme-signals {
  display: flex; flex-direction: column; gap: 0.375rem;
}
.product-group {
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  background: #F8FAFC;
  margin-bottom: 0.375rem;
}
.product-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.25rem;
}
.product-name {
  font-size: 0.8125rem; font-weight: 600;
  color: var(--text-primary);
}
.product-count {
  font-size: 0.6875rem; color: var(--text-tertiary);
  font-weight: 500;
}
.problem-item {
  font-size: 0.75rem; color: var(--text-secondary);
  line-height: 1.5; padding-left: 0.75rem;
  position: relative;
}
.problem-item::before {
  content: "\00b7";
  position: absolute; left: 0;
  color: var(--text-tertiary); font-weight: 700;
}
.theme-actions {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--divider);
  margin-top: auto;
}
.theme-drill {
  display: inline-flex; align-items: center;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--accent); text-decoration: none;
  cursor: pointer; transition: color 0.15s;
}
.theme-drill:hover { color: var(--accent-hover); }
.theme-share-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  font-size: 0.6875rem; font-weight: 500;
  color: var(--text-tertiary); text-decoration: none;
  padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.theme-share-btn:hover { color: var(--accent); background: rgba(8,145,178,0.06); }

/* ── Filter bar ── */
.filter-bar {
  padding: 1.25rem 2rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.filter-bar .filter-input {
  padding: 0.5rem 0.75rem; border: 1px solid var(--divider);
  border-radius: var(--radius); font-size: 0.8125rem;
  background: #fff; color: var(--text-primary); outline: none;
  transition: border-color 0.15s;
}
.filter-bar .filter-input:focus { border-color: var(--accent); }
.filter-bar select.filter-input { cursor: pointer; min-width: 120px; }
.filter-bar .result-count { margin-left: auto; font-size: 0.8125rem; color: var(--text-tertiary); }

.source-pills { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.source-pill {
  padding: 0.375rem 0.75rem; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 500;
  border: 1px solid var(--divider); background: #fff;
  color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; text-decoration: none;
}
.source-pill:hover { border-color: var(--accent); color: var(--accent); }
.source-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Pain rows ── */
.pain-grid { padding: 0 2rem 2rem; }

.pain-row {
  background: #fff; border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.625rem;
  transition: all 0.15s;
  display: grid;
  grid-template-columns: 1fr 140px 120px;
  gap: 1rem; align-items: start;
}
.pain-row:hover { border-color: #CBD5E1; box-shadow: var(--shadow-sm); }
.pain-row.sweet-spot { border-left: 3px solid var(--green); }

.pain-title {
  font-size: 0.9375rem; font-weight: 600; color: var(--text-primary);
  line-height: 1.4; margin-bottom: 0.375rem;
}
.pain-meta {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--text-tertiary);
}
.pain-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: #CBD5E1; }
.pain-opp {
  font-size: 0.8125rem; color: var(--text-secondary);
  margin-top: 0.5rem; line-height: 1.5;
}

.severity-gauge { display: flex; align-items: center; gap: 0.5rem; }
.severity-bar-lg {
  flex: 1; height: 6px; border-radius: var(--radius-full); background: #E2E8F0;
  overflow: hidden;
}
.severity-bar-lg .fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.3s ease;
}
.severity-num {
  font-size: 0.8125rem; font-weight: 700; min-width: 28px; text-align: right;
}

.evidence-badges {
  display: flex; flex-direction: column; gap: 0.375rem;
  align-items: flex-end;
}
.ev-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: var(--radius-full);
  font-size: 0.6875rem; font-weight: 500;
}
.ev-shopify { background: var(--green-bg); color: var(--green); }
.ev-reddit { background: var(--amber-bg); color: var(--amber); }
.ev-cross { background: var(--purple-bg); color: var(--purple); }

.tag-pill {
  display: inline-block;
  padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem; font-weight: 500;
  background: var(--bg-surface); color: var(--text-secondary);
}
.tag-pill.market { background: var(--blue-bg); color: var(--blue); }
.tag-pill.velocity-acc { background: var(--red-bg); color: var(--red); }
.tag-pill.velocity-stable { background: var(--bg-surface); color: #64748B; }

.effort-tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.0625rem 0.4375rem; border-radius: var(--radius-sm);
  font-size: 0.6875rem; font-weight: 600;
}
.effort-1, .effort-2 { background: var(--green-bg); color: var(--green); }
.effort-3 { background: var(--amber-bg); color: var(--amber); }
.effort-4, .effort-5 { background: var(--red-bg); color: var(--red); }

.sweet-spot-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.125rem 0.5rem; border-radius: var(--radius-full);
  font-size: 0.6875rem; font-weight: 600;
  background: linear-gradient(135deg, var(--green-bg), var(--green-light));
  color: var(--green); border: 1px solid #A7F3D0;
}

/* ── Theme filter banner ── */
.theme-filter-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 1rem;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  margin: 0 2rem 0.75rem;
  font-size: 0.8125rem; color: var(--blue);
}
.clear-theme-btn {
  font-size: 0.75rem; color: var(--blue);
  cursor: pointer; text-decoration: none;
  padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.clear-theme-btn:hover { background: rgba(29,78,216,0.08); }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 1rem 0;
}
.pagination .page-btn {
  padding: 0.375rem 0.75rem; border-radius: var(--radius);
  font-size: 0.8125rem; font-weight: 500;
  border: 1px solid var(--divider); background: #fff;
  color: var(--text-secondary); cursor: pointer;
  text-decoration: none; transition: all 0.15s;
}
.pagination .page-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination .page-info { font-size: 0.8125rem; color: var(--text-tertiary); }

/* ── Loading indicator ── */
.htmx-indicator {
  display: none;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}
.htmx-indicator.htmx-request {
  display: block;
}
.htmx-indicator .spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--divider);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.noscript-msg {
  text-align: center; padding: 4rem 1rem;
  color: var(--text-secondary); font-size: 0.9375rem;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .themes-grid { grid-template-columns: 1fr; }
  .themes-grid .theme-card:last-child:nth-child(odd) { max-width: 100%; }
}

@media (max-width: 768px) {
  .dash-sidebar {
    transform: translateX(-100%);
    z-index: 30;
  }
  .dash-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .hamburger-btn {
    display: block;
  }
  .dash-main { margin-left: 0; }
  .dash-topbar { padding: 0.875rem 1rem; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); padding: 1rem; gap: 0.5rem; }
  .pain-row { grid-template-columns: 1fr; }
  .tab-bar { padding: 0 1rem; }
  .theme-card { padding: 1.25rem; }
  .filter-bar { padding: 1rem; }
  .pain-grid { padding: 0 1rem 1rem; }
  #evidence-overlay > div { max-width: 95vw !important; }
  #matrix-chart { max-height: 300px; }
  details[style] { margin-left: 1rem !important; margin-right: 1rem !important; }
}
