/* Style for the custom download button */
.custom-download-button {
  background: transparent;
  /* Make background transparent */
  border: none;
  /* Remove borders */
  padding: 0;
  /* Remove padding */
  cursor: pointer;
  /* Change cursor to pointer on hover */
}

/* Increase text size in the hover panel (tooltip) */
.leaflet-tooltip {
  font-size: 14px !important;
  line-height: 1.2 !important;
}

/* Collapsible Map Control Styling */
.map-layer-control {
  background-color: white;
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  padding: 5px;
  width: 36px;
  height: 36px;
  overflow: hidden;
  transition: width 0.3s ease, height 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.map-layer-control.expanded {
  width: 200px;
  height: auto;
  padding: 10px;
}

.control-icon {
  width: 26px;
  height: 26px;
  text-align: center;
  margin-bottom: 5px;
  font-size: 18px;
  color: #333;
  flex-shrink: 0;
}

.control-content {
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 5px;
  white-space: nowrap;
  /* Prevent wrapping during transition */
}

.map-layer-control.expanded .control-content {
  opacity: 1;
  white-space: normal;
}

.map-layer-control.expanded .control-icon {
  display: none !important;
}

.map-layer-control .control-content label {
  font-size: 85%;
  /* Reduce text size by 15% */
}

/* Frozen overlay - blocks all interactions during data loading */
.frozen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: none;
  cursor: wait;
}

.frozen-overlay.active {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-end !important;
  padding: 80px 30px 30px 30px !important;
}

.frozen-overlay-content {
  position: relative;
  background: white;
  width: 400px;
  min-height: 200px;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.frozen-overlay-content .spinner-border {
  width: 3rem;
  height: 3rem;
  margin-bottom: 15px;
}

.frozen-overlay-content p {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
}

.frozen-overlay-station {
  font-size: 1.3rem;
  font-weight: bold;
  color: #007bff;
  margin-bottom: 10px;
}

.frozen-overlay-close {
  position: absolute;
  top: 10px;
  right: 15px;
  border: none;
  background: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  line-height: 1;
}

.frozen-overlay-close:hover {
  color: #000;
}

/* Disable pointer events on sidebar when frozen */
body.ui-frozen .bslib-sidebar-layout>.sidebar {
  pointer-events: none;
  opacity: 0.6;
}

body.ui-frozen .navbar {
  pointer-events: none;
  opacity: 0.6;
}

/* Keep the floating panel active for close button */
body.ui-frozen #station_detail_panel {
  pointer-events: auto;
  opacity: 1;
}

div.outer {
  position: relative;
  height: calc(100vh - 100px);
}

#zoom_home_obs_panel {
  z-index: 10 !important;
}

.btn-home {
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  color: #444;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-home:hover {
  background: #f4f4f4;
  color: #000;
}

/* Move plotly modebar to bottom */
.plotly .modebar-container {
  top: auto !important;
  bottom: 10px !important;
}

.plotly .modebar {
  background: rgba(255, 255, 255, 0.9) !important;
  border-radius: 4px;
  padding: 2px 5px;
}


@media (max-width: 768px) {
  .container,
  .container-fluid,
  .container-sm,
  .container-md {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .tab-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .tab-content > .tab-pane > .card,
  .tab-content > .active > .card {
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
  }

  .tab-content > .tab-pane > .card > .card-body,
  .tab-content > .active > .card > .card-body,
  .tab-content > .tab-pane > .card-body,
  .tab-content > .active > .card-body {
    padding: 4px !important;
  }

  .bslib-page-fill,
  .bslib-gap-spacing,
  .bslib-sidebar-layout > .main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .maplibregl-ctrl-top-left .maplibregl-ctrl-group,
  .mapboxgl-ctrl-top-left .mapboxgl-ctrl-group {
    display: none !important;
  }

  .map-layer-control {
    display: none !important;
  }

  .plotly .modebar-container {
    display: none !important;
  }

  .js-plotly-plot .annotation {
    display: none !important;
  }

  .frozen-overlay.active {
    padding: 60px 10px 10px 10px !important;
    justify-content: center !important;
  }

  .frozen-overlay-content {
    width: 90% !important;
    max-width: 350px;
    min-height: 150px;
    padding: 20px;
  }

  div.outer {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
  }

  #zoom_home_panel {
    top: 60px !important;
  }

  #fullscreen_toggle {
    display: none !important;
  }

  .row.g-3 {
    --bs-gutter-x: 0.25rem;
    --bs-gutter-y: 0.5rem;
    padding: 2px !important;
  }

  .col-12.col-lg-6 {
    padding-left: 2px !important;
    padding-right: 2px !important;
  }

  .col-12.col-lg-6 .plotly {
    min-height: 280px;
    height: 45vw !important;
    max-height: 360px;
  }

  .navbar-nav .nav-link {
    font-size: 0.8rem !important;
    padding: 0.4rem 0.5rem !important;
  }

  .datepicker {
    width: 100% !important;
    max-width: 300px;
  }

  .dataTables_wrapper {
    font-size: 0.8rem !important;
  }

  .dataTables_wrapper th {
    font-size: 0.75rem !important;
  }

  .btn-home {
    width: 44px;
    height: 44px;
  }

  .station-header-body {
    padding: 12px;
  }

  .station-header-row {
    row-gap: 10px;
  }

  .station-header-actions {
    justify-content: stretch;
  }

  .station-header-actions .btn {
    width: 100%;
  }

  .maplibregl-popup,
  .mapboxgl-popup {
    max-width: calc(100vw - 12px) !important;
  }

  .maplibregl-popup-content,
  .mapboxgl-popup-content {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 90px);
    padding: 12px;
    overflow-y: auto;
  }

  .station-map-popup {
    max-width: 100%;
    font-size: 16px !important;
    line-height: 1.25;
  }
}

/* Data Info Box Styling */
.data-info-box {
  background-color: #f8f9fa;
  border-left: 4px solid #007bff;
  padding: 12px;
  border-radius: 0 6px 6px 0;
  margin: 15px 0;
  font-size: 0.9rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.data-info-title {
  font-weight: 700;
  color: #495057;
  margin-bottom: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-info-item {
  color: #6c757d;
  margin-bottom: 2px;
}

.fw-bold {
  color: #343a40;
}

/* --- Summary Cards (Glassmorphism) --- */
.summary-cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 10px;
  margin-bottom: 5px;
}

.summary-cards-header {
  width: 100%;
  font-size: 0.75rem;
  font-weight: bold;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-left: 0.25rem;
  margin-bottom: -0.5rem;
}

.glass-card {
  flex: 1 1 calc(20% - 1rem); /* 5 cols by default */
  min-width: 180px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.glass-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.glass-card-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.glass-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glass-card-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 0.1rem;
}

.glass-card-subtext {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.25rem;
  line-height: 1.2;
}

/* Color variations for glass cards */
.glass-card.card-red { background: rgba(254, 242, 242, 0.5); border-color: rgba(254, 226, 226, 0.5); }
.glass-card.card-red .glass-card-icon { color: #ef4444; background: rgba(254, 226, 226, 0.5); }

.glass-card.card-blue { background: rgba(239, 246, 255, 0.5); border-color: rgba(219, 234, 254, 0.5); }
.glass-card.card-blue .glass-card-icon { color: #3b82f6; background: rgba(219, 234, 254, 0.5); }

.glass-card.card-emerald { background: rgba(236, 253, 245, 0.5); border-color: rgba(209, 250, 229, 0.5); }
.glass-card.card-emerald .glass-card-icon { color: #10b981; background: rgba(209, 250, 229, 0.5); }

.glass-card.card-cyan { background: rgba(236, 254, 255, 0.5); border-color: rgba(207, 250, 254, 0.5); }
.glass-card.card-cyan .glass-card-icon { color: #06b6d4; background: rgba(207, 250, 254, 0.5); }

.glass-card.card-purple { background: rgba(250, 245, 255, 0.5); border-color: rgba(243, 232, 255, 0.5); }
.glass-card.card-purple .glass-card-icon { color: #a855f7; background: rgba(243, 232, 255, 0.5); }

.glass-card.card-sky { background: rgba(240, 249, 255, 0.5); border-color: rgba(224, 242, 254, 0.5); }
.glass-card.card-sky .glass-card-icon { color: #38bdf8; background: rgba(224, 242, 254, 0.5); }

.glass-card.card-amber { background: rgba(255, 251, 235, 0.5); border-color: rgba(254, 243, 199, 0.5); }
.glass-card.card-amber .glass-card-icon { color: #f59e0b; background: rgba(254, 243, 199, 0.5); }

.glass-card.card-pink { background: rgba(253, 242, 248, 0.5); border-color: rgba(252, 231, 243, 0.5); }
.glass-card.card-pink .glass-card-icon { color: #ec4899; background: rgba(252, 231, 243, 0.5); }

.glass-card.card-slate { background: rgba(248, 250, 252, 0.5); border-color: rgba(241, 245, 249, 0.5); }
.glass-card.card-slate .glass-card-icon { color: #64748b; background: rgba(241, 245, 249, 0.5); }

@media (max-width: 991px) {
  .glass-card {
    flex: 1 1 calc(33.333% - 1rem);
  }
}
@media (max-width: 767px) {
  .glass-card {
    flex: 1 1 calc(50% - 1rem);
  }
}
@media (max-width: 480px) {
  .glass-card {
    flex: 1 1 100%;
  }
}

/* Floating station selection badge / chip */
.station-floating-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 9999px;
  padding: 6px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
  pointer-events: auto;
  transition: all 0.2s ease;
}

.station-floating-chip:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  border-color: #cbd5e1;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.chip-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-chip-clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  line-height: 1.2;
}

.btn-chip-clear:hover {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.chip-kbd {
  font-family: inherit;
  font-size: 0.6875rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.sidebar-station-active-card {
  margin-top: 10px;
  padding: 10px 12px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #dc2626;
  border-radius: 6px;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
  line-height: 1.2;
}

/* --- Resolution & Trend Scale Selector Grid (DWD Model) --- */
.btn-group-container-sw,
#data_resolution.btn-group-container-sw,
#data_resolution .btn-group-container-sw,
#data_resolution .btn-group-vertical,
#trend_scale.btn-group-container-sw,
#trend_scale .btn-group-container-sw,
#trend_scale .btn-group-vertical {
  display: grid !important;
  grid-template-columns: 1fr 1fr 1fr !important;
  gap: 5px;
  width: 100%;
}

.btn-group-container-sw > .btn-group,
#data_resolution .btn-group,
#trend_scale .btn-group {
  width: 100% !important;
  margin: 0 !important;
}

.btn-group-container-sw .btn,
#data_resolution .btn,
#trend_scale .btn {
  width: 100% !important;
  margin: 0 !important;
  border-radius: 6px !important;
  font-size: 0.78rem !important;
  padding: 6px 2px !important;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.btn-group-container-sw .btn.active,
#data_resolution .btn.active,
#trend_scale .btn.active,
#data_resolution .btn:has(input:checked),
#trend_scale .btn:has(input:checked) {
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.35) !important;
  font-weight: 700 !important;
  filter: brightness(0.92);
}

/* Trend Year Range Slider Styling */
#trend_year_range .irs-bar {
  background: #2563eb !important;
}
#trend_year_range .irs-from,
#trend_year_range .irs-to,
#trend_year_range .irs-single {
  background: #1d4ed8 !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}


/* --- Station Header Card (DWD Model) --- */
.station-header-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.station-header-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.station-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.station-header-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.station-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #64748b;
}

.station-header-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.station-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Responsive 2-column plot grid height constraint */
@media (max-width: 991px) {
  .col-12.col-lg-6 {
    margin-bottom: 1rem;
  }
}

/* --- Sidebar Station Inventory Counter Card --- */
.sidebar-station-counter-card {
  margin: 6px 0 12px 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.95) 0%, rgba(240, 249, 255, 0.85) 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease-in-out;
}

.sidebar-station-counter-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}

.sidebar-station-counter-card .counter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-station-counter-card .counter-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.83rem;
  color: #1e3a8a;
}

.sidebar-station-counter-card .counter-badge {
  font-size: 0.80rem;
  font-weight: 700;
  padding: 3px 9px;
  letter-spacing: 0.01em;
}

.sidebar-station-counter-card .counter-subtext {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 4px;
  line-height: 1.3;
}