/* styles/results.css — Dashboard/results page styles only */

/* ── Main content area ── */
.results-main {
  max-width: 860px; margin: 0 auto;
  padding: 0 2rem 5rem;
}

/* ── Sticky toolbar ── */
.toolbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--dark2);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 2rem; gap: 1rem; flex-wrap: wrap;
}
.toolbar-title {
  font-size: 12px; color: rgba(255,255,255,0.4); white-space: nowrap;
}
.toolbar-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.btn-tool {
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent; color: rgba(255,255,255,0.7);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer; transition: all 0.15s;
  min-height: 36px;
}
.btn-tool:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-tool:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-tool--ai {
  background: var(--gradient); border: none; color: #fff; font-weight: 500;
}
.btn-tool--ai:hover { opacity: 0.9; }
.btn-spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  animation: spin 0.7s linear infinite; vertical-align: middle;
}

/* Active filter chips in toolbar */
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(249,178,51,0.2); color: var(--gold);
  font-size: 11px; font-weight: 600;
  border: 1px solid rgba(249,178,51,0.3);
}
.filter-chip button {
  background: none; border: none; color: var(--gold);
  cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0; margin-left: 2px; min-height: unset;
}

/* ── Dashboard sections ── */
.results-section { margin-top: 2.5rem; }

.section-heading {
  font-family: var(--font-display);
  font-size: 1.75rem; color: var(--dark); margin-bottom: 0.25rem;
  line-height: 1.2;
}
.section-heading::after {
  content: ''; display: block; margin-top: 6px;
  height: 2px; width: 48px; border-radius: 2px;
  background: var(--gradient);
}
.section-sub { font-size: 13px; color: var(--muted); margin-bottom: 1.25rem; }
.section-header-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem;
}

/* ── Summary stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 1.5rem;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 1.25rem;
}
.stat-label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 0.5rem;
}
.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 700; line-height: 1;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-sub {
  display: block; font-size: 11px; color: var(--muted); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Skeleton placeholders for stat cards */
.stat-card-skeleton {
  height: 110px; margin: 0;
}

/* ── AI Policy Brief panel ── */
.ai-panel {
  border-top: 4px solid transparent;
  border-image: var(--gradient) 1;
  margin-top: 1.5rem; margin-bottom: 0; overflow: hidden;
}
.ai-panel-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid var(--border);
}
.ai-panel-title { display: flex; align-items: center; gap: 8px; }
.ai-panel-title h3 { font-size: 16px; font-weight: 600; }
.ai-icon { color: var(--gold); font-size: 1.2rem; }
.ai-panel-meta { font-size: 11px; color: var(--muted); flex: 1; }
.ai-regenerate {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; font-size: 12px; color: var(--mid); cursor: pointer;
  transition: background 0.15s; min-height: 32px;
}
.ai-regenerate:hover { background: #f5f5f3; }
.ai-close {
  background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px; min-height: unset;
}
.ai-close:hover { color: var(--dark); }
.ai-content { padding: 1rem 1.5rem 1.5rem; }
.ai-content ul { padding-left: 1.25rem; margin-top: 0.5rem; list-style: disc; }
.ai-content li {
  font-size: 15px; line-height: 1.75; color: var(--mid); margin-bottom: 0.75rem;
}
.ai-content li::marker { color: var(--pink); }

/* ── Per-question breakdown ── */
.sort-controls {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.sort-pill {
  padding: 5px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; font-size: 12px; color: var(--muted);
  cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
  min-height: 34px;
}
.sort-pill:hover { border-color: var(--dark); color: var(--dark); }
.sort-pill--active {
  background: var(--dark); color: #fff; border-color: var(--dark);
}

/* Collapsible category sections */
details.cat-section { margin-bottom: 1rem; }
details.cat-section > summary {
  cursor: pointer; list-style: none;
  padding: 0.75rem 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--dark);
  user-select: none;
}
details.cat-section > summary::-webkit-details-marker { display: none; }
details.cat-section > summary::after {
  content: '▾'; transition: transform 0.2s; color: var(--muted); font-size: 12px;
}
details.cat-section[open] > summary::after { transform: rotate(-180deg); }

/* Per-question row */
.q-rows { margin-top: 8px; }
.q-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.q-row:last-child { border-bottom: none; }
.q-num {
  font-size: 11px; color: var(--muted); font-weight: 600;
  font-family: var(--font-display); text-align: right;
}
.q-text {
  font-size: 13px; color: var(--dark); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.q-bar-wrap {
  display: flex; align-items: center; gap: 0; min-width: 100px;
  height: 20px; border-radius: 4px; overflow: hidden;
  position: relative;
}
.q-bar-yes {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff;
  transition: width 0.4s ease; min-width: 0;
}
.q-bar-no {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #880E4F;
  background: #FFB3C8;
  transition: width 0.4s ease; flex: 1;
}
.q-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.q-badge--urgency    { background: #fff3e0; color: #7c4d00; }
.q-badge--importance { background: var(--no-bg); color: var(--no-tx); }

/* ── Heatmap section ── */
.heatmap-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  margin-top: 1rem;
}
.heatmap-legend {
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  margin-top: 1rem; justify-content: center;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.legend-label { font-size: 12px; color: var(--mid); }

/* Heatmap tooltip */
.heatmap-tooltip {
  position: fixed; z-index: 1000;
  background: var(--dark); color: #fff;
  border-radius: 10px; padding: 12px 16px;
  max-width: 260px; pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transition: opacity 0.1s;
}
.tt-cat {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 4px;
}
.tt-q   { font-size: 13px; line-height: 1.4; margin-bottom: 8px; color: #fff; }
.tt-stats {
  display: flex; gap: 8px; font-size: 11px; color: rgba(255,255,255,0.6);
  margin-bottom: 4px; flex-wrap: wrap;
}
.tt-quad { font-size: 11px; color: var(--gold); font-weight: 500; }

/* ── Demographic filters ── */
.filter-bar {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.filter-group { margin-bottom: 1rem; }
.filter-group:last-child { margin-bottom: 0; }
.filter-label {
  display: block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 8px;
}
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  padding: 5px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; font-size: 12px; color: var(--mid);
  cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
  min-height: 34px;
}
.filter-pill:hover { border-color: var(--dark); color: var(--dark); }
.filter-pill--active {
  background: var(--dark2); color: #fff; border-color: var(--dark2);
}
.clear-filters {
  display: inline-block; margin-top: 0.75rem;
  font-size: 12px; color: var(--muted); text-decoration: none;
  transition: color 0.15s;
}
.clear-filters:hover { color: var(--pink); }

/* ── Chart containers ── */
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  margin-top: 12px;
}
.chart-title {
  font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 1rem;
}
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px;
}

/* ── Category consensus panel ── */
.category-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 1rem;
}
.cat-card {
  border-left: 4px solid var(--cat-color, var(--dark));
}
.cat-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 0.5rem; gap: 8px;
}
.cat-card-name { font-size: 14px; font-weight: 700; color: var(--dark); line-height: 1.3; }
.cat-card-count { font-size: 11px; color: var(--muted); white-space: nowrap; padding-top: 2px; }
.cat-card { padding: 1.25rem; }
.cat-yes-pct {
  font-family: var(--font-display);
  font-size: 3.5rem; font-weight: 700; line-height: 1; margin: 0.5rem 0;
  color: var(--cat-color, var(--dark));
}
.cat-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0.75rem; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.badge--urgency    { background: #fff3e0; color: #7c4d00; }
.badge--importance { background: var(--no-bg); color: var(--no-tx); }
.cat-top-label { font-size: 11px; font-weight: 600; color: var(--muted);
                 text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.cat-top-list { list-style: none; padding: 0; }
.cat-top-list li {
  font-size: 13px; color: var(--mid); line-height: 1.5; padding: 3px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 0.5px solid var(--border);
}
.cat-top-list li:last-child { border-bottom: none; }

/* ── Date range pills ── */
.date-range-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.dr-pill {
  padding: 5px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  background: transparent; font-size: 12px; color: var(--muted);
  cursor: pointer; transition: all 0.15s; font-family: var(--font-body);
  min-height: 34px;
}
.dr-pill:hover { border-color: var(--dark); color: var(--dark); }
.dr-pill--active {
  background: var(--dark); color: #fff; border-color: var(--dark);
}

/* ── Error card ── */
.error-card {
  padding: 2.5rem; text-align: center;
}
.error-card p { font-size: 15px; color: var(--muted); margin-bottom: 1.5rem; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-icon { font-size: 3rem; color: var(--border); margin-bottom: 1rem; }
.empty-state h2 {
  font-family: var(--font-display); font-size: 2rem;
  color: var(--dark); margin-bottom: 0.5rem;
}
.empty-state p { font-size: 15px; color: var(--muted); }

/* ── Responsive ── */
@media (max-width: 700px) {
  .results-main { padding: 0 1rem 4rem; }
  .toolbar { padding: 0.5rem 1rem; }
  .charts-row { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr; }
  .q-row { grid-template-columns: 24px 1fr; }
  .q-bar-wrap, .q-badge { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
