/* =============================================================================
   data_pane.css — full-width demographic analysis pane below the map
   Shown only in structural mode (body.structural-mode)
   ============================================================================= */

/* ---------- Layout: pane below article, hidden by default ---------- */
#data-pane {
  display: none;
  flex-direction: column;
  flex: 0 0 340px;
  background: #fff;
  border-top: 2px solid #ddd;
  overflow: hidden;
}
body.structural-mode #data-pane {
  display: flex;
}

/* ---------- Tab bar ---------- */
.dp-tabbar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  background: #f5f5f5;
  flex-shrink: 0;
  gap: 0;
}
.dp-tab {
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  user-select: none;
  transition: color 0.1s, border-color 0.1s;
}
.dp-tab:hover { color: #222; }
.dp-tab.is-active {
  color: #1a5fbd;
  border-bottom-color: #1a5fbd;
  background: #fff;
}
.dp-tab-spacer { flex: 1; }
.dp-year-sel {
  margin: 0 10px;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* ---------- Tab panels ---------- */
.dp-panel {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 0;
}
.dp-panel.is-active { display: flex; flex-direction: column; }

/* ---------- All-Tracts table ---------- */
.dp-table-wrap {
  overflow: auto;
  flex: 1;
}
table.dp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  white-space: nowrap;
}
table.dp-table thead th {
  position: sticky;
  top: 0;
  background: #f0f0f0;
  padding: 5px 8px;
  text-align: right;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid #ccc;
  user-select: none;
}
table.dp-table thead th:first-child { text-align: left; min-width: 100px; }
table.dp-table thead th.sorted-asc::after  { content: ' ▲'; font-size: 9px; }
table.dp-table thead th.sorted-desc::after { content: ' ▼'; font-size: 9px; }
table.dp-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 80ms;
}
table.dp-table tbody tr:hover     { background: #e8f0ff; }
table.dp-table tbody tr.is-selected { background: #cce0ff !important; }
table.dp-table td {
  padding: 4px 8px;
  text-align: right;
  color: #333;
}
table.dp-table td:first-child { text-align: left; font-weight: 500; }

/* Structural class badge in table */
.dp-class-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Micro heat cell shading via inline style set by JS */

/* ---------- Demographic bar mini-charts ---------- */
.dp-bar-wrap { display: flex; height: 12px; border-radius: 2px; overflow: hidden; }
.dp-bar-seg  { height: 100%; }

/* ---------- Crosstab tab ---------- */
.dp-crosstab-layout {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}
.dp-crosstab-controls {
  flex: 0 0 230px;
  padding: 12px;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  background: #fafafa;
}
.dp-crosstab-controls label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-top: 10px;
  margin-bottom: 3px;
}
.dp-crosstab-controls select {
  width: 100%;
  font-size: 11.5px;
  padding: 3px 5px;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.dp-crosstab-controls .dp-run-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 6px;
  background: #1a5fbd;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.dp-crosstab-controls .dp-run-btn:hover { background: #1348a0; }

.dp-crosstab-results {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}
.dp-crosstab-results .dp-placeholder {
  color: #aaa;
  font-size: 12px;
  margin-top: 20px;
  text-align: center;
}

/* Stats summary band */
.dp-stat-band {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-bottom: 12px;
  font-size: 11.5px;
}
.dp-stat-item { display: flex; gap: 5px; align-items: baseline; }
.dp-stat-name { color: #666; }
.dp-stat-val  { font-weight: 700; color: #222; }
.dp-stat-sig  { font-size: 10px; font-weight: 700; color: #b30000; }
.dp-stat-note { font-size: 10.5px; color: #999; margin-bottom: 8px; font-style: italic; }

/* Contingency table */
table.dp-ct-table {
  border-collapse: collapse;
  font-size: 11.5px;
  margin-bottom: 10px;
}
table.dp-ct-table th {
  background: #f0f0f0;
  padding: 4px 10px;
  font-weight: 600;
  border: 1px solid #ddd;
  text-align: center;
}
table.dp-ct-table td {
  padding: 4px 10px;
  border: 1px solid #e8e8e8;
  text-align: center;
  min-width: 36px;
}
table.dp-ct-table td.ct-row-header {
  text-align: left;
  font-weight: 600;
  background: #f7f7f7;
  white-space: nowrap;
}
table.dp-ct-table td.ct-total {
  font-weight: 600;
  background: #f5f5f5;
  color: #444;
}
/* Heat intensity — set via background rgba inline */

/* ---------- Tract profile tab ---------- */
.dp-profile-layout {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}
.dp-profile-col {
  flex: 1;
  padding: 12px 14px;
  overflow-y: auto;
  border-right: 1px solid #f0f0f0;
  min-width: 180px;
}
.dp-profile-col:last-child { border-right: none; }

.dp-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 4px;
}
.dp-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 12px;
  border-bottom: 1px solid #f8f8f8;
}
.dp-metric-label { color: #555; }
.dp-metric-value { font-weight: 600; color: #222; }

/* Stacked bar for demographic distributions */
.dp-dist-bar {
  height: 14px;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0 2px;
}
.dp-dist-seg { height: 100%; }

/* Sparkline canvas */
.dp-sparkline-wrap { margin: 8px 0 4px; }
.dp-sparkline-wrap canvas { display: block; }
.dp-sparkline-label {
  font-size: 10px;
  color: #999;
  text-align: right;
  margin-top: 1px;
}
.dp-no-tract {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
  font-size: 13px;
}

/* ---------- Trends tab ---------- */
.dp-trends-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}
.dp-trends-controls {
  flex: 0 0 180px;
  padding: 12px;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.dp-trends-controls label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-top: 10px;
  margin-bottom: 3px;
}
.dp-trends-controls label:first-child { margin-top: 0; }
.dp-trends-controls select {
  width: 100%;
  font-size: 11.5px;
  padding: 3px 5px;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.dp-tr-toggle-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e8e8e8;
}
.dp-tr-toggle-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-size: 11px !important;
  font-weight: 400 !important;
  color: #444 !important;
  cursor: pointer;
  margin: 0 !important;
}
.dp-tr-toggle-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}
.dp-tr-hint {
  font-size: 10px;
  color: #999;
  font-style: italic;
  margin-top: 5px;
  line-height: 1.4;
}
.dp-trends-chart-wrap {
  flex: 1;
  padding: 12px 14px 8px;
  overflow: hidden;
  position: relative;
  min-width: 0;
}
.dp-trends-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Definition tooltips ---------- */
.dp-def-tip {
  cursor: help;
  border-bottom: 1px dotted #999;
  text-decoration: none;
}

/* Glossary section in crosstab controls */
.dp-glossary {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #e8e8e8;
}
.dp-glossary-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 6px;
}
.dp-gloss-term {
  font-size: 10.5px;
  color: #444;
  padding: 2px 0;
  cursor: help;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px dotted transparent;
}
.dp-gloss-term:hover {
  color: #1a5fbd;
  border-bottom-color: #aac;
}
.dp-gloss-q {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ddd;
  color: #666;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Precinct chips in tract profile ---------- */
.dp-precinct-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.dp-precinct-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #c5d0f5;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s, border-color 0.1s;
}
.dp-precinct-chip:hover {
  background: #d4deff;
  border-color: #8fa3f0;
}
.dp-precinct-chip.is-highlighted {
  background: #00e5ff22;
  border-color: #00b8cc;
  font-weight: 700;
  outline: 2px solid #00e5ff;
}
.dp-precinct-code { font-weight: 600; color: #1a3a8f; }
.dp-precinct-share { color: #777; }

/* CV reliability badge in tract table */
.dp-cv-badge {
  font-size: 10px;
  vertical-align: middle;
  cursor: help;
}
