/* ============================================================
   MAP STYLES — InsightWorkspace Mapv2
   Leaflet overrides, layer styles, county labels, legend
   ============================================================ */

/* ── Leaflet Base Overrides (ReSHAPE) ── */
.leaflet-container {
  background: var(--color-gray-200);
  font-family: var(--font-sans);
}

.leaflet-interactive:hover {
  cursor: pointer;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
  border: 1px solid var(--color-border) !important;
  color: var(--color-text-secondary) !important;
  font-family: var(--font-sans) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--color-bg-secondary) !important;
  color: var(--color-text-primary) !important;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  color: var(--color-text-tertiary) !important;
}

/* ── County Floating Labels ── */
.county-label-wrapper {
  pointer-events: auto;
}

.county-label {
  background: #1a1f2e;
  border-radius: 10px;
  padding: 8px 12px;
  color: #fff;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border: 1px solid rgba(255,255,255,0.06);
  min-width: 140px;
}

.county-label:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.county-label.selected {
  background: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25), 0 4px 16px rgba(0,67,131,0.5);
}

.county-label.compare-1 {
  background: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25), 0 4px 16px rgba(0,67,131,0.5);
}

.county-label.compare-2 {
  background: var(--color-positive);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25), 0 4px 16px rgba(0,0,0,0.3);
}

.county-label__name {
  font-weight: var(--font-bold);
  font-size: 13px;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.county-label__stats {
  display: flex;
  gap: 6px;
  align-items: center;
}

.county-label__stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.county-label__stat-icon {
  display: inline-flex;
  align-items: center;
  opacity: 0.65;
}

.county-label__stat-icon svg {
  width: 12px;
  height: 12px;
}

.county-label__stat-val {
  font-weight: var(--font-semi);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.county-label__stat-divider {
  display: block;
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.15);
  flex: 0 0 auto;
  margin: 0 2px;
}

.county-label__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: 0 0 16px;
}

.county-label__badge svg {
  width: 10px;
  height: 10px;
}

.county-label__badge--up   { background: #22c55e; }
.county-label__badge--down { background: #ef4444; }

/* ── GeoJSON Layer Styles ── */
/* Applied via Leaflet path options, these just set defaults */
.leaflet-overlay-pane path {
  transition: fill-opacity 0.15s ease, stroke-width 0.15s ease;
}

/* ── Coverage Heatmap Legend (Training mode) ── */
.heatmap-legend {
  position: absolute;
  bottom: 60px;
  right: var(--space-4);
  z-index: var(--z-map-overlay);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-md);
  min-width: 160px;
}

.heatmap-legend__title {
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.heatmap-legend__gradient {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--heat-low), var(--heat-mid), var(--heat-high));
  margin-bottom: var(--space-1);
}

.heatmap-legend__labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-gray-500);
}

/* General layer legend */
.layer-legend {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-map-overlay);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-md);
}

.layer-legend__title {
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.legend-swatch {
  width: 18px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 auto;
}

/* ── Map Metric Pop-over (on hover) ── */
.map-popover {
  background: var(--color-gray-900);
  color: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-xl);
  font-size: var(--text-sm);
  pointer-events: none;
  min-width: 200px;
  position: absolute;
  z-index: var(--z-tooltip);
  transform: translate(-50%, calc(-100% - 12px));
}

.map-popover::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--color-gray-900);
}

.map-popover__header {
  font-weight: var(--font-semi);
  font-size: var(--text-md);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: var(--space-1);
}

.map-popover__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: 2px 0;
}

.map-popover__key   { color: var(--color-gray-400); font-size: var(--text-xs); }
.map-popover__val   { font-weight: var(--font-semi); }
.map-popover__val.up   { color: var(--color-success-300); }
.map-popover__val.down { color: var(--color-danger-300); }

/* ── Compare Region Highlight ── */
.compare-badge {
  position: absolute;
  z-index: var(--z-map-overlay);
  top: var(--space-3);
  right: var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.compare-badge__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.compare-badge__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.compare-badge__dot--1 { background: var(--color-primary); }
.compare-badge__dot--2 { background: var(--color-positive); }

.compare-badge__name {
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}
