/* css/charts.css
   Styles for bar charts, donut charts, population pyramids,
   comparison panels, and chart widget containers. */

/* ── Bar Chart ─────────────────────────────────────────────────────── */
.wm-bar-chart {
  font-size: 0.8rem;
}
.wm-bar-chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #111827;
}

.wm-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.wm-bar-label {
  flex: 0 0 110px;
  font-size: 0.75rem;
  color: #4b5563;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-bar-track {
  flex: 1;
  height: 18px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
}

.wm-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.wm-bar-value {
  flex: 0 0 65px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

/* Grouped bars (comparison) */
.wm-bar-group {
  margin-bottom: 0.75rem;
}
.wm-bar-group > .wm-bar-label {
  display: block;
  flex: none;
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.wm-bar-group-bars {
  padding-left: 0;
}
.wm-bar-row--grouped {
  margin-bottom: 0.125rem;
}
.wm-bar-row--grouped .wm-bar-track {
  height: 14px;
}

/* Legend */
.wm-bar-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.7rem;
  color: #6b7280;
}
.wm-bar-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.wm-bar-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Donut Chart ───────────────────────────────────────────────────── */
.wm-donut-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wm-donut-svg {
  overflow: visible;
}
.wm-donut-center {
  text-anchor: middle;
  font-weight: 700;
  fill: #111827;
}
.wm-donut-center-label {
  text-anchor: middle;
  font-size: 0.65rem;
  fill: #6b7280;
}
.wm-donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.7rem;
  color: #4b5563;
  justify-content: center;
}
.wm-donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.wm-donut-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Population Pyramid ────────────────────────────────────────────── */
.wm-pyramid {
  font-size: 0.75rem;
}
.wm-pyramid-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2px;
}
.wm-pyramid-label {
  flex: 0 0 60px;
  text-align: center;
  font-size: 0.65rem;
  color: #6b7280;
}
.wm-pyramid-bar-left,
.wm-pyramid-bar-right {
  flex: 1;
  height: 14px;
  position: relative;
}
.wm-pyramid-bar-left {
  display: flex;
  justify-content: flex-end;
}
.wm-pyramid-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Comparison Panel ──────────────────────────────────────────────── */
.wm-compare-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.wm-compare-panel--open {
  transform: translateX(0);
}
.wm-compare-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}
.wm-compare-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.wm-compare-panel-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.7rem;
  color: #9ca3af;
}

/* Compare selection badges */
.wm-compare-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.wm-compare-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 0.75rem;
  color: #1d4ed8;
}
.wm-compare-badge-remove {
  cursor: pointer;
  font-size: 0.65rem;
  color: #6b7280;
  margin-left: 0.25rem;
}
.wm-compare-badge-remove:hover {
  color: #dc2626;
}

/* Stat card grid for comparison — 1 column per geography */
.wm-compare-grid {
  display: grid;
  gap: 0.5rem;
}

/* ── Chart Widget Container ────────────────────────────────────────── */
.wm-chart-widget {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.wm-chart-widget-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0.75rem;
}
