/* Plan 20 (2026-09-16) - agent B. Heatmaps page styling, layered on top of
   the shared frontend/css/styles.css (variables, header, body:has(#map)
   flex layout) which this file does not modify. Keeps the page native next
   to the sales map: same --bg/--panel-bg/--text/--border/--brand tokens. */

#heatmap-panel {
  flex: 0 0 340px;
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.9rem;
}

.hm-mock-banner {
  background: var(--orange);
  color: #1a1a1a;
  font-weight: 600;
  font-size: 0.78rem;
  text-align: center;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
}

.hm-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hm-section-title {
  font-weight: bold;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--neutral, #7f8c8d);
}

/* 2026-09-17 (Adnan's request): each layer checkbox now owns its own
   metric row directly beneath it (indented), instead of a shared METRIC
   block. .hm-layer-item groups a layer's checkbox with its metric row;
   a thin divider + spacing separates the four groups. */
.hm-layer-list {
  display: flex;
  flex-direction: column;
}

.hm-layer-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0;
}

.hm-layer-item + .hm-layer-item {
  border-top: 1px solid var(--border);
}

.hm-layer-item:first-child {
  padding-top: 0;
}

.hm-layer-item:last-child {
  padding-bottom: 0;
}

.hm-layer-item > label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.hm-metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-left: 1.6rem;
}

/* Without this, the `hidden` attribute JS toggles (updateMetricVisibility()
   in heatmaps.js) loses to this class's own `display: flex` in the cascade
   (author-origin beats user-agent-origin regardless of specificity), so an
   unchecked layer's metric row stayed visible - this is what let all four
   metric rows show at once under the old standalone METRIC block. */
.hm-metric-row[hidden] {
  display: none;
}

.hm-metric-row label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.hm-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hm-search-box {
  position: relative;
}

.hm-search-box input[type='text'] {
  width: 100%;
}

.hm-search-results {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.hm-search-results:empty {
  border: none;
}

.hm-search-results li {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hm-search-results li:last-child {
  border-bottom: none;
}

.hm-search-results li:hover {
  background: var(--bg);
}

.hm-search-kind {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-contrast);
  flex: 0 0 auto;
}

.hm-hint {
  margin-top: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: var(--error);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.3;
}

.hm-legend {
  font-size: 0.82rem;
}

/* Stacked legends (Plan 20 v2, 2026-09-16) - one block per active layer,
   in selection order. */
.hm-legend-block {
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.hm-legend-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.hm-legend-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.hm-legend-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

.hm-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--neutral, #7f8c8d);
  line-height: 1.5;
}

.hm-loading {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

.hm-loading[hidden] {
  display: none;
}

/* Cell popup, matches the sales map's .cell-popup convention. */
.hm-cell-popup {
  font-size: 0.85rem;
  min-width: 190px;
}

.hm-cell-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.6rem;
  margin: 0.3rem 0 0;
}

.hm-cell-popup dt {
  font-weight: bold;
}

.hm-cell-popup dd {
  margin: 0;
}

.hm-site-label {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  opacity: 0.9;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.hm-imsi-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3388ff;
  border: 1px solid #ffffff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
}

.hm-search-highlight {
  animation: hm-pulse 1.4s ease-out 2;
}

@keyframes hm-pulse {
  0% {
    stroke-width: 6;
    stroke-opacity: 1;
  }
  100% {
    stroke-width: 1;
    stroke-opacity: 0.3;
  }
}

@media (max-width: 768px) {
  #heatmap-panel {
    flex: 0 0 auto;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
