/*
 * RS-TH32 — System-wide Leaflet controls.
 * Zoom lives at bottom-right; layers stay top-right; legends stay bottom-left.
 */

html body .leaflet-container .leaflet-control-zoom {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  margin: 0 .65rem .65rem 0 !important;
  border: 1px solid #64748b !important;
  border-radius: .8rem !important;
  background: #ffffff !important;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .24) !important;
}

html body .leaflet-container .leaflet-control-zoom a,
html body .leaflet-container .leaflet-control-zoom a:link,
html body .leaflet-container .leaflet-control-zoom a:visited {
  display: flex !important;
  width: 2.5rem !important;
  height: 2.5rem !important;
  min-width: 2.5rem !important;
  min-height: 2.5rem !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid #cbd5e1 !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  font-family: Arial, sans-serif !important;
  font-size: 0 !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  text-shadow: none !important;
  opacity: 1 !important;
}

html body .leaflet-container .leaflet-control-zoom-in::before,
html body .leaflet-container .leaflet-control-zoom-out::before {
  display: flex !important;
  width: 100% !important;
  height: 100% !important;
  align-items: center !important;
  justify-content: center !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  font-family: Arial, sans-serif !important;
  font-size: 1.35rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-indent: 0 !important;
  opacity: 1 !important;
}

html body .leaflet-container .leaflet-control-zoom-in::before {
  content: "+" !important;
}

html body .leaflet-container .leaflet-control-zoom-out::before {
  content: "\2212" !important;
}

html body .leaflet-container .leaflet-control-zoom a:last-child {
  border-bottom: 0 !important;
}

html body .leaflet-container .leaflet-control-zoom a:is(:hover, :focus-visible) {
  background: #dcfce7 !important;
  color: #14532d !important;
}

html body .leaflet-container .leaflet-control-zoom a:is(:hover, :focus-visible)::before {
  color: #14532d !important;
  -webkit-text-fill-color: #14532d !important;
}

html body .leaflet-container .leaflet-control-zoom a:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid #22c55e !important;
  outline-offset: -3px !important;
}

html body .leaflet-container .leaflet-control-zoom a.leaflet-disabled {
  background: #e2e8f0 !important;
  color: #64748b !important;
  cursor: not-allowed !important;
}

html body .leaflet-container .leaflet-control-zoom a.leaflet-disabled::before {
  color: #64748b !important;
  -webkit-text-fill-color: #64748b !important;
}

html body .leaflet-container .leaflet-control-layers {
  margin: .65rem .65rem 0 0 !important;
  border-color: #64748b !important;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .22) !important;
}

html body .leaflet-container .leaflet-control-layers-toggle {
  width: 2.75rem !important;
  height: 2.75rem !important;
  min-width: 2.75rem !important;
  min-height: 2.75rem !important;
  background-color: #ffffff !important;
  opacity: 1 !important;
}

html body .leaflet-container .leaflet-control-layers-expanded {
  max-width: min(18rem, calc(100% - 4.5rem)) !important;
  max-height: min(60vh, 24rem) !important;
  overflow: auto !important;
}

html body .leaflet-container :is(.herb-map-legend, .map-legend, [class~="map-legend"]) {
  width: 12rem !important;
  min-width: 11rem !important;
  max-width: min(18rem, calc(100vw - 5rem)) !important;
  margin: 0 0 .65rem .65rem !important;
  padding: .75rem .82rem !important;
  border: 1px solid #64748b !important;
  border-radius: .85rem !important;
  background: rgba(255, 255, 255, .97) !important;
  color: #0f172a !important;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .24) !important;
  backdrop-filter: none !important;
}

html body .leaflet-container .herb-map-legend__title {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  margin-bottom: .4rem !important;
  margin-inline: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #0f172a !important;
  box-shadow: none !important;
  font-size: .8rem !important;
  font-weight: 900 !important;
  line-height: 1.35 !important;
}

html body .leaflet-container .herb-map-legend__item {
  display: flex !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 1.65rem !important;
  align-items: center !important;
  gap: .55rem !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #1e293b !important;
  box-shadow: none !important;
  font-size: .76rem !important;
  font-weight: 650 !important;
  line-height: 1.35 !important;
}

/* Restore semantic swatch colors erased by the legacy legend * rule. */
html body .leaflet-container .herb-map-legend__swatch {
  width: .9rem !important;
  height: .9rem !important;
  flex: 0 0 .9rem !important;
  min-width: .9rem !important;
  max-width: .9rem !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 2px solid #1d4ed8 !important;
  border-radius: 999px !important;
  background: #60a5fa !important;
  -webkit-text-fill-color: initial !important;
  box-shadow: 0 0 0 2px #dbeafe !important;
}

html body .leaflet-container .herb-map-legend__item > span:not(.herb-map-legend__swatch) {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
}

html body .leaflet-container .herb-map-legend__swatch--line {
  height: .28rem !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #2563eb !important;
  box-shadow: none !important;
}

html body .leaflet-container .herb-map-legend__swatch--area {
  border-color: #047857 !important;
  border-radius: .2rem !important;
  background: #6ee7b7 !important;
  box-shadow: 0 0 0 2px #d1fae5 !important;
}

html body .leaflet-container .herb-map-legend__swatch--heat {
  border: 0 !important;
  border-radius: 999px !important;
  background: linear-gradient(90deg, #16a34a 0%, #facc15 52%, #dc2626 100%) !important;
  box-shadow: 0 0 0 1px #64748b !important;
}

html body .leaflet-container .leaflet-control-attribution {
  display: none !important;
}

/* public_map has its own bottom-right “load current area” action. */
html body.page-public-map .public-map .leaflet-control-zoom {
  margin-right: .65rem !important;
  margin-bottom: 4.6rem !important;
}

html body .leaflet-container .leaflet-control-attribution a {
  color: #166534 !important;
  font-weight: 700 !important;
}

html body .leaflet-container :is(.leaflet-popup-content-wrapper, .leaflet-tooltip) {
  border: 1px solid #94a3b8 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .24) !important;
}

@media (max-width: 575.98px) {
  html body .leaflet-container .leaflet-control-zoom {
    margin: 0 .4rem 2rem 0 !important;
  }

  html body.page-public-map .public-map .leaflet-control-zoom {
    margin-right: .65rem !important;
    margin-bottom: 4.25rem !important;
  }

  html body .leaflet-container .leaflet-control-layers {
    margin: .4rem .4rem 0 0 !important;
  }

  html body .leaflet-container .leaflet-control-layers-expanded {
    width: min(14rem, calc(100% - 4.25rem)) !important;
    min-width: 0 !important;
    max-width: calc(100% - 4.25rem) !important;
  }

  html body .leaflet-container :is(.herb-map-legend, .map-legend, [class~="map-legend"]) {
    width: min(10.5rem, calc(100vw - 5rem)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 5rem) !important;
    margin: 0 0 2.2rem .4rem !important;
    padding: .58rem .65rem !important;
  }

  html body .leaflet-container .herb-map-legend__title {
    margin-bottom: .22rem !important;
    font-size: .72rem !important;
  }

  html body .leaflet-container .herb-map-legend__item {
    min-height: 1.38rem !important;
    font-size: .68rem !important;
  }

  html body .leaflet-container .leaflet-control-attribution {
    max-width: calc(100% - 4.5rem) !important;
    font-size: .58rem !important;
  }
}

@media print {
  html body .leaflet-container .leaflet-control-zoom,
  html body .leaflet-container .leaflet-control-layers {
    display: none !important;
  }
}
