/* Full-bleed map page under the top nav */
body:has(.map-page) {
  overflow: hidden;
}

body:has(.map-page) .page-content {
  padding: 0;
  height: calc(100vh - 52px);
  max-width: none;
}

body:has(.map-page-public) .page-content {
  height: 100vh;
}

.map-public-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 8px;
  background: #f7f8fb;
  border-bottom: 1px solid #d8dce3;
}

.map-public-banner h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.map-public-banner p {
  margin: 0;
}

.map-public-login {
  flex: 0 0 auto;
  align-self: center;
  text-decoration: none;
  border: 1px solid #c5cad3;
  border-radius: 6px;
  padding: 8px 12px;
  color: #222;
  background: #fff;
}

.map-public-login:hover {
  background: #eef1f6;
}

body:has(.map-page-public) .page-content {
  display: flex;
  flex-direction: column;
}

body:has(.map-page-public) .map-page-public {
  flex: 1 1 auto;
  min-height: 0;
}

.map-page {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
  min-height: 0;
}

.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  background: #fff;
  border-right: 1px solid #d8dce3;
  padding: 10px 12px 16px;
}

.map-panel {
  border-bottom: 1px solid #e6e8ee;
  padding: 10px 0 12px;
}

.map-panel:last-child {
  border-bottom: 0;
}

.map-panel h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5a6472;
}

.map-filters-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.map-filters-toggle-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5a6472;
  font-weight: 700;
}

.map-filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #6f1d3d;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.map-filters-badge[hidden] {
  display: none;
}

.map-filters-chevron {
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #5a6472;
  transition: transform 0.15s ease;
}

.map-filters-panel:not([data-collapsed="true"]) .map-filters-chevron {
  transform: rotate(180deg);
}

.map-filters-body {
  margin-top: 8px;
}

.map-filters-body[hidden] {
  display: none;
}

.map-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
}

.map-field span {
  color: #444;
}

.map-field select,
.map-field input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #c9ced6;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}

.map-filters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.map-export-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid #6f1d3d;
  border-radius: 4px;
  background: #fff;
  color: #6f1d3d;
  cursor: pointer;
  text-align: left;
}

.map-export-btn:hover {
  background: #f7eef1;
}

.map-export-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.map-filter-actions button,
.map-toolbar button,
.map-selection-header button {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid #6f1d3d;
  border-radius: 4px;
  background: #6f1d3d;
  color: #fff;
  cursor: pointer;
}

.map-filter-actions .secondary-btn,
.map-toolbar .secondary-btn,
.map-selection-header .secondary-btn {
  background: #fff;
  color: #6f1d3d;
}

.map-filter-actions button:disabled,
.map-toolbar button:disabled,
.map-selection-header button:disabled {
  opacity: 0.5;
  cursor: default;
}

.map-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  max-height: 180px;
  overflow: auto;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
}

.map-legend-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-legend-count {
  color: #777;
  font-size: 12px;
}

.map-stats {
  margin: 8px 0 0;
  font-size: 12px;
}

.map-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.map-selection-header h2 {
  margin: 0;
}

.map-selection-hint {
  margin: 0 0 8px;
  font-size: 12px;
}

.map-selection-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
}

.map-selection-list li {
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

.map-selection-list a {
  color: #6f1d3d;
  text-decoration: none;
  font-weight: 600;
}

.map-selection-list a:hover {
  text-decoration: underline;
}

.map-field-checkboxes {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
}

.map-field-checkboxes > span {
  display: block;
  margin-bottom: 6px;
  color: #444;
  text-align: left;
  width: 100%;
}

.map-checkbox-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  margin: 0;
  padding: 0;
}

.map-checkbox-row {
  display: grid;
  grid-template-columns: 16px 12px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  justify-content: start;
}

.map-checkbox-row input {
  margin: 0;
  width: 14px;
  height: 14px;
  justify-self: start;
}

.map-checkbox-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
  justify-self: start;
}

.map-selection-meta {
  display: block;
  color: #666;
  font-size: 12px;
  margin-top: 2px;
}

.map-selection-result-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  margin-right: 6px;
  vertical-align: -1px;
}

.map-result-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: baseline;
}

.map-popup-subtests {
  margin: 4px 0 6px;
  padding-left: 16px;
  list-style: disc;
}

.map-popup-subtests li {
  margin: 2px 0;
}

.map-popup-subtest-name {
  font-weight: 600;
}

.map-cluster-wrapper {
  background: transparent;
  border: 0;
}

.map-cluster-icon {
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.map-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid #d8dce3;
  flex-wrap: wrap;
}

.map-time-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.map-time-intervals {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
}

.map-time-intervals input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid #c9ced6;
  border-radius: 4px;
  font-size: 13px;
}

.map-time-range {
  min-width: 190px;
  font-size: 12px;
  white-space: nowrap;
}

.map-status {
  margin-left: auto;
  font-size: 12px;
}

#map-canvas {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #e8ecf1;
}

.map-marker-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.muted {
  color: #777;
}

@media (max-width: 900px) {
  .map-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .map-sidebar {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid #d8dce3;
  }
}
