/* ============================================================
   Wetterstationen-Komponente
   Ausgelagertes CSS für Marker, Tooltip, Popup, Legende, Chart
   ============================================================ */

:root {
  --wetter-ms-petrol: #005b79;
  --wetter-ms-gruen: #aab315;
  --wetter-ms-blau: #0094d3;
  --wetter-ms-muted: #687782;
  --wetter-ms-text: #1f2933;
  --wetter-ms-card: #ffffff;
}

/* ============================================================
   Permanente Tooltip-Beschriftung auf der Karte
   ============================================================ */

.station-custom-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;

  font-weight: 850;
  font-size: 12px;
  line-height: 1;
  color: #111111;
  opacity: 1 !important;

  white-space: nowrap;
  text-align: center;

  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.95),
     1px -1px 0 rgba(255, 255, 255, 0.95),
    -1px  1px 0 rgba(255, 255, 255, 0.95),
     1px  1px 0 rgba(255, 255, 255, 0.95),
     0  2px 3px rgba(255, 255, 255, 0.95),
     0  1px 2px rgba(0, 0, 0, 0.25);
}

.station-custom-tooltip::before {
  display: none !important;
}

/* ============================================================
   SVG-Marker
   ============================================================ */

.station-div-icon {
  background: transparent !important;
  border: none !important;
}

.station-marker-icon {
  display: block;
  width: var(--icon-size);
  height: var(--icon-size);
  color: #3f3f3f;
}

.station-marker-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  filter:
    drop-shadow(0 0 1.5px rgba(255, 255, 255, 1))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.72))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.30));
}

/* ============================================================
   Qualitäts-Badges
   ============================================================ */

.quality-flag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  width: fit-content;
  margin-top: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
  white-space: normal;
}

.quality-flag.plausible {
  color: #005b79;
  background: rgba(170, 179, 21, 0.20);
}

.quality-flag.warning {
  color: #5d3b00;
  background: rgba(242, 140, 0, 0.22);
}

.quality-flag.limited {
  color: #4b5563;
  background: rgba(104, 119, 130, 0.16);
}

.quality-flag.empty {
  color: #687782;
  background: rgba(104, 119, 130, 0.12);
}

.quality-flag-detail {
  display: block;
  margin-top: 4px;
  font-size: 9.5px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--ms-muted);
}

.station-popup-metric .quality-flag-detail:empty {
  display: none;
}

@media (max-width: 500px) {
  .station-popup-metric .quality-flag-detail {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 2px;
  }
}

/* ============================================================
   Leaflet Popup nur für Wetterstationen
   ============================================================ */

.station-leaflet-popup .leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
  overflow: visible !important;
}

.station-leaflet-popup .leaflet-popup-content-wrapper {
  border-radius: 18px !important;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0, 91, 121, 0.22) !important;
}

.station-leaflet-popup .leaflet-popup-tip {
  box-shadow: 0 8px 18px rgba(0, 91, 121, 0.18) !important;
}

.station-leaflet-popup .station-popup {
  max-height: min(680px, calc(100dvh - 120px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: auto;
}

.station-leaflet-popup .station-popup::-webkit-scrollbar {
  width: 8px;
}

.station-leaflet-popup .station-popup::-webkit-scrollbar-track {
  background: rgba(0, 91, 121, 0.06);
}

.station-leaflet-popup .station-popup::-webkit-scrollbar-thumb {
  background: rgba(0, 91, 121, 0.35);
  border-radius: 999px;
}

.station-leaflet-popup .station-popup::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 91, 121, 0.55);
}

.station-leaflet-popup .leaflet-popup-close-button {
  color: #000000 !important;
  opacity: 1 !important;
  background: transparent !important;
  box-shadow: none !important;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.9) !important;
  font-size: 20px !important;
  font-weight: 900 !important;
  width: 20px !important;
  height: 20px !important;
  line-height: 20px !important;
  top: 6px !important;
  right: 6px !important;
  z-index: 9999 !important;
}

.station-leaflet-popup .leaflet-popup-close-button:hover,
.station-leaflet-popup .leaflet-popup-close-button:focus {
  color: #000000 !important;
  background: transparent !important;
}

/* ============================================================
   Popup-Inhalt
   ============================================================ */

.station-popup {
  width: 410px;
  max-width: 84vw;
  font-family: Arial, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--wetter-ms-text);
  background: var(--wetter-ms-card);
}

.station-popup-header {
  position: relative;
  overflow: hidden;
  padding: 12px 16px 10px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--wetter-ms-petrol), #003f55);
}

.station-popup-header::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -46px;
  width: 100px;
  height: 100px;
  border-radius: 999px;
  background: var(--wetter-ms-gruen);
  opacity: 0.9;
}

.station-popup-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 800;
  padding-right: 72px;
}

.station-popup-time {
  position: relative;
  z-index: 1;
  margin-top: 5px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.84);
}

.station-popup-live-line {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.station-popup-live {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.station-popup-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--wetter-ms-gruen);
  box-shadow: 0 0 0 4px rgba(170, 179, 21, 0.25);
}

.station-popup-live-line .station-button {
  min-height: 0;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 1.1;
  box-shadow: none;
}

.station-popup-body {
  padding: 14px 16px 16px;
  background:
    radial-gradient(circle at top left, rgba(0, 148, 211, 0.11), transparent 220px),
    #ffffff;
}

/* ============================================================
   Messwert-Cards
   ============================================================ */

.station-popup-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.station-popup-metric {
  min-width: 0;
  padding: 10px 9px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(0, 91, 121, 0.13);
  box-shadow: 0 6px 18px rgba(0, 91, 121, 0.08);
}

.station-popup-metric.temperature {
  border-top: 5px solid var(--wetter-ms-blau);
}

.station-popup-metric.global {
  border-top: 5px solid var(--wetter-ms-gruen);
}

.station-popup-metric.humidity {
  border-top: 5px solid var(--wetter-ms-petrol);
}

.station-popup-metric-value-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.station-popup-metric-value-row .quality-flag {
  margin-top: 0;
}

.station-popup-metric-value-row .quality-flag-detail {
  flex-basis: 100%;
}


.station-popup-metric-value {
  display: block;
  font-size: 18px;
  line-height: 1.05;
  font-weight: 850;
  color: var(--wetter-ms-petrol);
  white-space: nowrap;
}

.station-popup-metric-value.unavailable {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 850;
  color: var(--wetter-ms-muted);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.station-popup-metric-label {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--wetter-ms-muted);
}

.station-popup-metric-label-long {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

/* ============================================================
   Buttons
   ============================================================ */

.station-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 10px;
  padding: 7px 11px;
  background: var(--wetter-ms-petrol);
  color: #ffffff !important;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  line-height: 1.2;
  border: 1px solid var(--wetter-ms-petrol);
  box-shadow: 0 4px 12px rgba(0, 91, 121, 0.20);
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.station-button:hover,
.station-button:focus,
.station-button:active {
  background: var(--wetter-ms-gruen);
  border-color: var(--wetter-ms-gruen);
  color: #000000 !important;
  transform: translateY(-1px);
}

.station-button:active {
  transform: translateY(0);
}

/* ============================================================
   Chart im Popup
   ============================================================ */

.station-popup-chart-card {
  padding: 12px 12px 10px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(0, 91, 121, 0.13);
  box-shadow: 0 8px 22px rgba(0, 91, 121, 0.08);
}

.station-popup-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.station-popup-chart-title {
  margin: 0;
  font-size: 13px;
  font-weight: 850;
  color: var(--wetter-ms-petrol);
}

.station-popup-chart-subtitle {
  font-size: 10.5px;
  color: var(--wetter-ms-muted);
  text-align: right;
}

.station-popup-chart-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 10px;
  border-bottom: 1px solid rgba(0, 91, 121, 0.12);
}

.station-chart-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--wetter-ms-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
  padding: 7px 2px 8px;
  margin: 0;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.station-chart-tab:hover,
.station-chart-tab:focus {
  color: var(--wetter-ms-petrol);
}

.station-chart-tab.active {
  color: var(--tab-color);
  border-bottom-color: var(--tab-color);
}

.station-chart-tab.temperature {
  --tab-color: var(--wetter-ms-blau);
}

.station-chart-tab.humidity {
  --tab-color: var(--wetter-ms-petrol);
}

.station-chart-tab.global {
  --tab-color: var(--wetter-ms-gruen);
}

.station-chart-tab.is-hidden {
  display: none !important;
}

.station-popup-chart-wrap {
  width: 100%;
  height: 230px;
}

.station-popup-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.station-popup-refresh {
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--wetter-ms-muted);
}

/* ============================================================
   Legende
   ============================================================ */

#wetterstationen-legend {
  font-family: Arial, sans-serif;
}

.wetterstationen-legend-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: #000000;
}

.wetterstationen-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.25;
  color: #000000;
}

.wetterstationen-legend-icon {
  display: inline-flex;
  width: 26px;
  min-width: 26px;
  justify-content: center;
  align-items: center;
}

.wetterstationen-legend-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--wetter-ms-muted);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 500px) {
  .station-popup {
    width: 84vw;
  }

  .station-popup-metrics {
    grid-template-columns: 1fr;
  }

  .station-popup-metric {
    display: block;
    min-width: 0;
    overflow: visible;
  }

  .station-popup-metric-label {
    display: block;
    margin-top: 0;
    margin-bottom: 4px;
  }

  .station-popup-metric-value-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
  }

  .station-popup-metric-value-row .station-popup-metric-value {
    flex: 0 0 auto;
  }

  .station-popup-metric-value-row .quality-flag {
    margin-top: 0;
    justify-self: start;
    font-size: 10px;
    padding: 4px 7px;
    white-space: normal;
    max-width: 150px;
  }

  .station-popup-metric-value-row .quality-flag-detail {
    flex-basis: 100%;
    margin-top: 2px;
  }

  .station-popup-metric.global.global-unavailable {
    display: block;
    min-width: 0;
    overflow: visible;
  }

  .station-popup-metric.global.global-unavailable .station-popup-metric-value.unavailable {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
  }

  .station-popup-metric-label-long {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }

  .station-popup-chart-wrap {
    height: 250px;
  }

  .station-popup-chart-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .station-popup-chart-subtitle {
    text-align: left;
  }
}