/* ensure html/body take full height */
html, body {
    height: 100%;
    margin: 0;
}

/* main container flex behavior if needed */
.main {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* force map to fill remaining space */
#vehicle-map {
    flex: 1;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    min-height: 0; /* critical inside flex containers */
    position: relative;
}

/* Base popup */
.custom-popup .mapboxgl-popup-content {
  max-width: 380px;
  max-height: none;            /* ← allow full height */
  box-sizing: border-box;
  padding: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
  border-radius: 10px;
}

/* Keep the entire popup non-interactive so hover state belongs to the marker */
.custom-popup .mapboxgl-popup-content,
.custom-popup .mapboxgl-popup-tip {
  pointer-events: none;
}

/* Header: icon + address (address can wrap to multiple lines) */
.custom-popup .popup-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}
.custom-popup .popup-pin { flex: 0 0 auto; line-height: 1; font-size: 16px; margin-top: 2px; }
.custom-popup .popup-address { font-weight: 600; line-height: 1.3; white-space: normal; min-width: 0; }

/* Vehicles: no internal scrolling; full list visible */
.custom-popup .popup-vehicles, #location-details-overlay {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: none;            /* ← remove scroll limit */
  overflow: visible;           /* ← no scrollbars */
  min-width: 0;
}

/* Row layout */
.vehicle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.06);
}

/* Thumbnail: fixed column; never cropped */
.custom-popup img.vehicle-image {
  flex: 0 0 92px;              /* fixed column width */
  width: 92px;
  height: 60px;
  object-fit: contain;         /* ← prevent cutting off wide images */
  background: #fff;            /* subtle letterbox if aspect differs */
  border-radius: 6px;
  display: block;
}

/* Text block */
.custom-popup .vehicle-meta { flex: 1 1 auto; min-width: 0; }
.custom-popup .vehicle-meta .name {
  line-height: 1.25;
  white-space: normal;         /* wrap instead of ellipsis */
  margin-bottom: 2px;
}
.custom-popup .vehicle-meta .muted { font-size: 12px; color: #6c757d; }

.location-details-overlay {
  position: absolute;
  left: 30px;
  bottom: 30px;

  width: 390px;
  max-width: calc(100% - 60px);
  max-height: calc(100vh - var(--navbar-height) - 80px);
  overflow-y: auto;

  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  z-index: 500;
  box-shadow: 0 6px 26px rgba(0,0,0,0.16);

  padding: 0.75rem;

  /* Requested font stack */
  font-family: -apple-system, BlinkMacSystemFont,
               "SF Pro Text", "SF Pro Display",
               "Inter", "InterVariable",
               "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif !important;

  opacity: 0;
  transform: translateY(12px) scale(0.96);
  visibility: hidden;

  transition:
    opacity 240ms ease,
    transform 240ms ease,
    visibility 0ms linear 240ms;   /* Wait to hide until fade finishes */

  min-width: 0;

  /* Prevent overflow issues in Bootstrap flex layouts */
  min-width: 0;
}

.location-details-overlay.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition:
    opacity 240ms ease,
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0ms;                /* Visible immediately */
}

.location-details-overlay #overlay-vehicles-container {
  display: flex;
  flex-direction: column;
  gap: 8px;

  /* Limit container to ~45% of viewport height (subtract any header height if set)
     so the parent overlay won't exceed ~40-50% of the page. */
  max-height: calc(45vh - 1.5rem);

  /* Allow scrolling inside the vehicles list when content exceeds the max height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  min-width: 0;
}

/* Tighter list group spacing */
.location-details-overlay .vehicle-row {
  display: flex;
  gap: 6px;
}

.location-details-overlay .vehicle-image {
  margin-top: 8px;
  flex: 0 0 92px;              /* fixed column width */
  width: 92px;
  height: auto;
  object-fit: contain;
}

.location-details-overlay #overlay-subtitle {
  font-size: 0.8rem;
}

.vehicle-additional-details {
  margin-right: 15px;
}

/* Map Filter Panel */
.map-filter-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 300px;
  max-width: calc(100% - 40px);
  max-height: calc(100vh - var(--navbar-height) - 80px);
  overflow: visible;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  z-index: 500;
  font-family: -apple-system, BlinkMacSystemFont,
               "SF Pro Text", "SF Pro Display",
               "Inter", "InterVariable",
               "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif !important;
}

.map-filter-panel h6 {
  font-size: 0.85rem;
  color: #333;
}

#map-filter-toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.7rem;
}

#map-filter-toggle-icon.rotated {
  transform: rotate(180deg);
}

.map-filter-groups {
  transition: height 0.3s ease;
  margin-top: 0.75rem;
  padding-right: 0.5rem;
  max-height: calc(100vh - var(--navbar-height) - 200px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling for filter groups */
.map-filter-groups::-webkit-scrollbar {
  width: 6px;
}

.map-filter-groups::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.map-filter-groups::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.map-filter-groups::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

#toggle-map-filters {
  color: inherit;
  transition: opacity 0.2s ease;
}

#toggle-map-filters:hover {
  opacity: 0.8;
}

#map-results-count {
  font-size: 0.65rem;
  white-space: nowrap;
}

#clear-map-filters {
  border-radius: 50px;
  transition: all 0.2s ease;
  font-size: 0.65rem !important;
}

#clear-map-filters:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Smaller filter pills for map */
.map-filter-panel .filter-pill {
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  border-width: 1px;
}

.map-filter-panel .filter-label {
  font-size: 0.75rem;
  font-weight: 600;
}

.map-filter-panel .filter-group {
  margin-bottom: 0.75rem;
}

.map-filter-panel .pills-container {
  gap: 0.4rem;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .location-details-overlay {
    left: 12px;
    right: 12px;
    bottom: 16px;
    width: auto;
    max-height: calc(100vh - var(--navbar-height) - 100px);
  }

  .map-filter-panel {
    top: 12px;
    left: 12px;
    right: 60px; /* Leave space for Mapbox controls */
    width: auto;
    max-width: none;
  }

  .map-filter-groups {
    max-height: 50vh; /* Fixed height that's more reliable on mobile */
  }

  .map-filter-panel .filter-pill {
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
  }

  .map-filter-panel .filter-label {
    font-size: 0.7rem;
  }

  .map-filter-panel .filter-group {
    margin-bottom: 0.5rem;
  }

  .map-filter-panel h6 {
    font-size: 0.8rem;
  }
}

.nav-apps * {
  font-size: 0.75rem;
}

.location-details-overlay .vehicle-row {
  transition: transform 0.2s ease;
}

.location-details-overlay .vehicle-row:hover {
  transform: translateY(-2px);
}