/* ========================================================
   General Visual Enhancements
   ======================================================== */

/* Blurry horizontal separator */
.hr-blurry-custom {
  all: unset;
  display: block;
  height: 1px;
  width: 100%;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 1px;
  margin: 16px 0;
}

/* Checkbox and radio label improvements */
.form-check .form-check-label::after,
input[type="checkbox"]+label::after,
input[type="radio"]+label::after {
  content: none !important;
}

.form-check .form-check-label,
input[type="checkbox"]+label,
input[type="radio"]+label {
  font-weight: normal !important;
}

.form-group .form-check {
  padding-left: 2.0rem;
}

/* ========================================================
   Map Container and Layout (Abertos Geomap Wrapper)
   ======================================================== */

/* Main wrapper */
.abertos_geomap-wrapper {
  margin-top: 5vh;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 90vh;
  max-height: 90vh;
  gap: 10px;
  visibility: hidden;
}

@media (min-aspect-ratio: 16/9) {
  .abertos_geomap-wrapper {
    width: 90vw;
    margin-left: auto;
    margin-right: auto;
  }
}

.abertos_geomap-wrapper.ready {
  visibility: visible;
}

.map-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #007bc4;
  border-top: 4px solid transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.abertos_geomap-wrapper.no-filters .filter-panel {
  display: none;
}

.abertos_geomap-wrapper.no-filters .map-container {
  flex: 1 1 100%;
}

/* Map container */
.map-container {
  flex: 1;
  position: relative;
}

#geomap-map-container {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background-color: #e0eaf0;
}

/* ========================================================
   Leaflet Toolbar and Controls Styling
   ======================================================== */

/* Toolbar container */
.leaflet-bar {
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
  overflow: hidden;
}

/* Toolbar buttons */
.leaflet-bar a {
  background-color: #fff;
  border-bottom: 1px solid #ccc;
  width: 40px;
  height: 40px;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #333;
  font-size: 20px;
  font-weight: bold;
  transition: background-color 0.3s, box-shadow 0.3s;
}

/* Remove bottom border from last button */
.leaflet-bar a:last-child {
  border-bottom: none;
}

/* Hover effect for toolbar buttons */
.leaflet-bar a:hover {
  background-color: #f3f4f6;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

/* Fullscreen button adjustments */
.leaflet-control-fullscreen-button {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaflet-touch .leaflet-control-fullscreen a {
  background-position: 3px 4px !important;
}

.leaflet-touch.leaflet-fullscreen-on .leaflet-control-fullscreen a {
  background-position: 3px -23px !important;
}

/* Basemap selector adjustments */
.leaflet-control-layers {
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-layers label {
  font-weight: normal;
  font-size: 0.7rem;
}

.leaflet-control label::after {
  content: none !important;
}

/* ========================================================
   Leaflet Popup (Executive Card Style)
   ======================================================== */

/* Popup wrapper */
.leaflet-popup-content-wrapper {
  --primary-color: #007bc4;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --highlight-bg: #f8fafc;

  width: 280px;
  min-width: 260px;
  background: white;
  border: 0px solid #e0e0e0;
  border-left: 4px solid var(--primary-color);
  border-radius: 5px;
  padding: 12px 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

/* Decorative top gradient bar */
.leaflet-popup-content-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color) 0%, #60a5fa 100%);
}

/* Reset popup content */
.leaflet-popup-content {
  padding: 0 !important;
  margin: 0;
}

/* General map font */
.leaflet-container,
.leaflet-popup-content,
.leaflet-control {
  font-family: 'Xunta Sans', Arial, Helvetica, sans-serif;
}

/* Popup Header (title and subtitle) */
.map-card-header {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.map-card-location-marker {
  flex-shrink: 0;
  color: var(--primary-color);
  margin-top: 2px;
}

.map-card-header-text {
  flex: 1;
}

.map-card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.map-card-subtitle {
  margin: 6px 0 0 !important;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: normal;
  line-height: 1.1;
}

.map-card-subtitle {
  margin: 6px 0 0 !important;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.map-card-data-value {
  max-width: 50%;
  min-width: max-content;
}

/* awesome adjustment */
.awesome-marker i {
  margin-top: 12px !important;
}

/* Popup dividers */
.map-card-divider {
  height: 1px;
  background: var(--border-color);
  margin: 10px 0 20px;
}

.map-card-divider-thin {
  height: 1px;
  background: #f1f5f9;
  margin: 6px 0;
  opacity: 0.6;
}

/* Popup Body */
.map-card-body {
  display: grid;
  gap: 10px;
}

.map-card-data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  line-height: 1.2;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.map-card-data-text {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
}

.map-card-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 10px 0 4px;
  text-transform: none;
  letter-spacing: 0.2px;
}

.map-card-data-row.highlighted {
  background: var(--highlight-bg);
  margin: -4px -12px;
  padding: 4px 12px;
  border-radius: 5px;
}

.map-card-data-row.status-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

/* Labels and Values inside Popup */
.map-card-data-label {
  color: var(--text-secondary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-card-data-value {
  color: var(--text-primary);
  font-weight: 600;
  flex: 0 0 auto;
  max-width: 50%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: right;
  min-width: max-content;
}

/* Status badges */
.map-card-status-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  white-space: normal;
  overflow-wrap: anywhere;
}

.map-card-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  color: #007bc4;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.7rem;
  font-weight: 600;
}

.map-card-status-dot {
  display: block;
  width: 8px;
  height: 8px;
  background: #007bc4;
  border-radius: 50%;
}

/* Different badge colors */
.map-card-status-badge.green {
  background: #e6f4ea;
  color: #28a745;
}

.map-card-status-badge.green .map-card-status-dot {
  background: #28a745;
}

.map-card-status-badge.yellow {
  background: #fff8e6;
  color: #efa500;
}

.map-card-status-badge.yellow .map-card-status-dot {
  background: #efa500;
}

.map-card-status-badge.red {
  background: #ffe6ef;
  color: #F5105E;
}

.map-card-status-badge.red .map-card-status-dot {
  background: #F5105E;
}

/* Popup Footer */
.map-card-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.map-card-footer-content {
  font-size: 0.7rem;
  color: #94a3b8;
  font-style: italic;
  line-height: 1.2;
  display: block;
}

/* ========================================================
   Filter Panel Styling (Compact)
   ======================================================== */

/* Filter panel base */
.filter-panel {
  flex: 0 0 20%;
  max-width: 400px;
  max-height: 90vh;
  min-width: 250px;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 7px;
  box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.05);
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  font-size: 0.9em;
  transition: max-height 0.4s ease, opacity 0.4s ease, padding 0.4s ease, margin 0.4s ease;
}


/* Header/title of the filter panel */
.panel-title {
  font-size: 14px;
  /* Slightly larger for emphasis */
  font-weight: 600;
  /* Semi-bold for visual hierarchy */
  margin-bottom: 10px;
  /* Spacing from next element */
  border-bottom: 1px solid #e0e0e0;
  /* Light gray separator line */
  padding-bottom: 6px;
  /* Padding below text */
  color: #333;
  /* Dark gray for contrast */
}

/* Each filter block wrapper */
.filter-group {
  margin-bottom: 10px;
  /* Space between filter groups */
  padding-bottom: 6px;
}

/* Label for each selector */
.filter-group label {
  display: block;
  /* Takes full line */
  font-size: 0.88rem;
  /* Small and subtle */
  font-weight: 600;
  /* Medium boldness */
  margin-bottom: 4px;
  /* Tight space to select element */
  color: #555;
  /* Medium gray for labels */
}

/* ========================================================
   Filter Panel Styling (Consolidated and Polished)
   ======================================================== */

/* Filter Panel Container */
.filter-panel {
  background: white;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #007bc4;
  position: relative;
  border-radius: 5px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  /* Enable vertical scroll if content exceeds max height */
  overflow-y: auto;
  max-height: 90vh;
  scroll-behavior: smooth;

  /* Scrollbar styling for modern browsers */
  scrollbar-width: thin;
  /* Firefox */
  scrollbar-color: #cbd5e1 #f8fafc;
}

/* Decorative top gradient bar */
.filter-panel::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #007bc4 0%, #60a5fa 100%);
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

/* Scrollbar styling for WebKit-based browsers */
.filter-panel::-webkit-scrollbar {
  width: 6px;
}

.filter-panel::-webkit-scrollbar-track {
  background: #f8fafc;
  /* Light gray background */
  border-radius: 4px;
}

.filter-panel::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  /* Subtle medium gray */
  border-radius: 4px;
}

/* Panel Title */
.filter-panel h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e293b;
}

/* Filter Container */
#filters-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Filter Inputs and Selects */
#filters-container input[type="text"],
#filters-container input[type="number"],
#filters-container select {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 5px;
}

select option:checked,
select option:focus,
select option:hover {
  background-color: #007bc4;
  color: white;
}

/* Checkbox Wrapper */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  min-width: 0;
}

/* Checkbox Styling */
.checkbox-wrapper input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: #007bc4;
  margin: 0 0 0 3%;
}

/* Checkbox Label Styling */
.checkbox-wrapper label {
  flex: 1 1 auto;
  min-width: 0;
  flex: 1;
  font-size: 0.85rem;
  color: #1e293b;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* Range Styling */
.range-value {
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #1e293b;
  font-weight: 500;
}

input[type="range"].filter-control {
  width: 100%;
}

/* Reset Filters Button */
#reset-filters {
  margin-top: 20px;
  background: #007bc4;
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
  transition: background 0.3s ease;
  display: block;
  /* Ensure block-level layout */
  max-width: 100%;
  /* Prevent overflow due to padding */
  box-sizing: border-box;
  /* Padding + border count within width */
  flex-shrink: 0;
  /* Prevents the button from collapsing */
}

/* Reset Filters Button Hover */
.filter-button:hover,
.filter-button:focus {
  background: #005a91;
}

/* JSON editor */
.jsoneditor-menu {
  background-color: #007bc4;
  border-bottom: 1px solid #007bc4;
}

/* ----------------------------------------
   noUiSlider Custom Styles for Range Filter
   ---------------------------------------- */

/* noUiSlider Styling */
#range-value {
  height: 12px;
  margin-top: 8px;
}

#range-value .noUi-connect {
  background: #007bc4;
}

#range-value .noUi-handle {
  height: 20px;
  width: 20px;
  top: -5px;
  right: -10px;
  border-radius: 12px;
}

#range-value .noUi-handle::before,
#range-value .noUi-handle::after {
  display: none !important;
}

.range-value {
  margin-top: 3px;
  margin-left: 5px;
  font-size: 0.7rem;
}

/* Only showing tooltips when sliding handles */

#range-value .noUi-tooltip {
  display: none;
}

#range-value .noUi-active .noUi-tooltip {
  display: block;
  z-index: 1000 !important;
  position: absolute !important;
}

body.vertical-mode .abertos_geomap-wrapper {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0vh;
  min-height: 100vh;
  height: auto;
  max-height: none;
}

/* ========================================================
   Responsive vertical mode (portrait or tall layout)
   Applied when JS adds .vertical-mode to the <body>
   ======================================================== */

body.vertical-mode .filter-panel {
  width: 100%;
  max-width: 100%;
  min-height: 60px;
  max-height: 100vh;
  margin: 0;
  flex: none;
  overflow: visible;
  height: auto;
  padding: 15px;
  box-sizing: border-box;
  flex: 0 0 auto;
  overflow-y: auto;
}

body.vertical-mode #filters-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.vertical-mode .filter-group {
  width: 100%;
}

body.vertical-mode #filters-container input[type="text"],
body.vertical-mode #filters-container input[type="number"],
body.vertical-mode #filters-container select {
  width: 100%;
  min-width: 0;
}

body.vertical-mode .map-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 95vh;
  min-height: 280px;
}

body.vertical-mode #geomap-map-container {
  height: 100% !important;
}


@media (max-width: 480px) {
  .map-container {
    aspect-ratio: 4 / 6;
  }

}

/* Large screens adjustments */
@media (min-width: 1600px) {
  .filter-panel {
    flex: 0 0 15%;
    max-width: 300px;
  }

  .panel-title {
    font-size: 15px;
  }

  .filter-group label {
    font-size: 13vx;
  }

  .filter-group select {
    font-size: 13vx;
  }


  .filter-group label {
    font-size: 15px;
  }

  .filter-group select {
    font-size: 13vx;
  }

}

/* Filter panel header with title and hamburger */
.filter-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-family: 'Xunta Sans', Arial, Helvetica, sans-serif;
}

/* Title styling */
.filter-panel-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

/* Hamburger button style */
.filter-panel-toggle {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  cursor: pointer;
  display: none;
  /* Hidden by default (desktop) */
  align-items: center;
  justify-content: center;
  margin-top: -6px;
}

.filter-panel-toggle {
  display: flex;
}

body.vertical-mode .filter-panel.collapsed {
  padding-bottom: 0 !important;
  padding-top: 10px;
  max-height: 60px !important;
  overflow: hidden;
  transition: max-height 0.1s ease, padding 0.3s ease;
}

/* Hide filters and reset button when collapsed */
body.vertical-mode .filter-panel.collapsed #filters-container,
body.vertical-mode .filter-panel.collapsed #reset-filters {
  display: none;
}


/* Show panel toggle when not vertical */
body.vertical-mode .filter-panel-toggle {
  display: flex;
}

/* Hide panel toggle when not vertical */
body:not(.vertical-mode) .filter-panel-toggle {
  display: none !important;
}

.filter-panel h2 {
  margin-top: 8px;
}

.filter-panel .collapsed-content {
  display: none;
}
