/* --- Main Layout --- */
.market-map-wrapper {
  position: relative;
  background-color: #f8f8f8;
  font-family: Roboto, sans-serif;
}

.map-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: #e9e9e9; /* Set background color */
  position: relative; /* Establish stacking context */
  z-index: 20; /* Ensure it's above content by default */
}

.filter-item-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-item {
  display: flex;
}

.map-content-area {
  display: flex;
  gap: 20px;
  z-index: 100;
}

.property-cards-container {
  width: 525px;
  flex-shrink: 0;
  height: 700px;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  position: relative; /* Establish stacking context for the container */
}

.property-cards-container.active {
  display: block;
}

.property-cards-container.has-hovered-card {
  z-index: 30; /* Elevate container above filters when a card is hovered */
}

.map-render-area {
  flex-grow: 1;
  background-color: #e9e9e9;
  transition: opacity 0.3s ease-in-out;
}

/* --- Individual Property Card Styling --- */
.property-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 15px 10px;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  position: relative; /* Needed for z-index to work */
}

.property-card.highlight {
  border-color: #a2ad00;
  box-shadow: 0 4px 12px rgba(162, 173, 0, 0.5);
  transform: translateY(-5px);
  z-index: 10; /* Bring card to front */
}

@media (hover: hover) {
  .property-card:hover {
    border-color: #a2ad00;
    box-shadow: 0 4px 12px rgba(162, 173, 0, 0.5);
    transform: translateY(-5px);
    z-index: 10; /* Bring card to front */
  }

  .filter-button:hover {
    background-color: #13294b;
    color: #fff;
  }
}

.property-card-image {
  width: 180px;
  height: 120px;
  flex-shrink: 0;
  background-color: #f0f0f0;
  position: relative;
  z-index: 2;
}

.property-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.property-card-info {
  position: relative;
  z-index: 2;
}

.property-card-info h3 {
  margin: 0 0 4px 0;
  font-size: 20px;
  color: #13294b;
  line-height: 1.1;
  font-weight: 600;
}

.property-card-info .location {
  font-size: 16px;
  color: #00b0ca;
  margin-bottom: 8px;
}

.property-card-info .square-footage {
  font-size: 14px;
  color: #54595f;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

.property-card-amenities {
  display: flex;
  gap: 12px;
}

.property-card-amenities img {
  height: 24px;
  width: auto;
}

/* --- Filter Controls Styling --- */
.map-filter-control {
  background-color: #fff;
  border: 1px solid #13294b;
  border-radius: 20px;
  padding: 0 15px !important;
  font-weight: 700 !important;
  color: #13294b;
  font-size: 16px !important;
  text-transform: uppercase;
  height: 40px;
  box-sizing: border-box;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#market-select.map-filter-control {
  width: 200px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2313294B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 1em;
  padding-right: 40px !important;
  justify-content: flex-start;
}
.filter-button.map-filter-control {
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.filter-button.active {
  background-color: #a2ad00;
  border-color: #a2ad00;
  color: #fff;
}

#autocomplete-container {
  position: relative;
  align-items: center;
}
#property-search-input.map-filter-control {
  width: 240px;
  padding-right: 40px !important;
  border-radius: 20px;
}
#property-search-input::placeholder {
  color: #13294b;
  opacity: 1;
}
.search-icon {
  position: absolute;
  right: 15px;
  color: #13294b;
  cursor: pointer;
}

/* --- No Results Message Styling --- */
.no-results-message {
  display: none; /* Hidden by default */
  color: #54595f;
  font-style: italic;
}

/* --- Autocomplete Styling --- */
.autocomplete-items {
  position: absolute;
  border: 1px solid #d4d4d4;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #fff;
  border-radius: 4px;
  margin-top: 2px;
}
.autocomplete-item {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #e9e9e9;
}
.autocomplete-item:last-child {
  border-bottom: none;
}
.autocomplete-item:hover {
  background-color: #f0f0f0;
}

/* --- Custom Infowindow (Tooltip) Styling --- */
.gm-style-iw-c {
  padding: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 7px 1px rgba(0, 0, 0, 0.2);
}
.gm-style-iw-d {
  overflow: hidden !important;
}
.gm-style .gm-style-iw-t::after {
  display: none;
}
.gm-style-iw-c button[aria-label="Close"] {
  /* Hides Google's default close button */
  display: none !important;
}
.custom-infowindow {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 15px;
  max-width: 400px; /* Increased width by 25% */
  font-family: Roboto, sans-serif;
  color: #333;
}
.infowindow-image {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}
.infowindow-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.infowindow-text strong {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2; /* Tightened line spacing */
  color: #13294b;
  display: block;
  margin-bottom: 2px; /* Tightened spacing */
}
.infowindow-text p {
  font-size: 14px;
  line-height: 1.3; /* Tightened line spacing */
  margin: 0;
}
.infowindow-text .tooltip-sqft {
  font-size: 14px;
  line-height: 1.3; /* Tightened line spacing */
  color: #54595f;
  margin: 4px 0; /* Tightened spacing */
}
.tooltip-amenities {
  display: flex;
  gap: 8px;
  margin-top: 8px; /* Tightened spacing */
}
.tooltip-amenities img {
  height: 28px;
  width: auto;
}

/* --- Property Details Blade Styling --- */
.property-details-blade {
  background-color: #f8f8f8;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out,
    padding 0.5s ease-in-out;
  display: flex;
  gap: 40px;
  position: relative;
  justify-content: center;
  align-items: flex-start;
}
.property-details-blade.active {
  max-height: 1000px;
  opacity: 1;
  padding: 60px 40px;
  margin-top: 20px;
  border-top: 1px solid #e0e0e0;
}
.blade-image {
  width: 680px;
  flex-shrink: 0;
}
.blade-image img {
  width: 100%;
  height: auto;
  display: block;
}
.blade-content {
  width: 550px;
  flex-shrink: 0;
}
.blade-content h2 {
  color: #13294b;
  margin: 0;
  font-size: 56px;
  font-weight: 300;
  line-height: 56px;
  text-transform: uppercase;
}
.blade-content .address {
  margin: 0 0 20px 0;
  color: #00549f;
  font-size: 20px;
  font-weight: 400;
  line-height: 22px;
  font-family: Roboto, sans-serif;
}
.blade-content .square-footage {
  font-size: 20px;
  color: #54595f;
  margin: -10px 0 20px 0;
  font-weight: 500;
  line-height: 1.3;
}
.blade-content .amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 0 0 20px 0;
}
.blade-content .amenities img {
  height: 40px;
}
.blade-content .overview {
  font-size: 16px;
  line-height: 1.6;
  margin: 0 0 30px 0;
  color: #54595f;
}
.blade-ctas {
  display: flex;
  gap: 15px;
}
.blade-ctas a {
  display: inline-block;
  padding: 10px 25px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: bold;
  text-transform: uppercase;
}
.blade-ctas .contact-us {
  background-color: #fff;
  border: 1px solid #13294b;
  color: #13294b;
}
.blade-ctas .view-property {
  background-color: #13294b;
  border: 1px solid #13294b;
  color: #fff;
}

.blade-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 45px;
  height: 45px;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  font-size: 30px;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10;
}

/* --- New Blade Image Gallery Styles --- */
.blade-image {
  position: relative;
  overflow: hidden;
  background-color: #e9e9e9;
}

.blade-main-image {
  width: 100%;
  height: auto;
  aspect-ratio: 20 / 9; /* Wider ratio to make image shorter */
  object-fit: cover;
  display: block;
}

.blade-thumbnails-container {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.blade-thumbnails-container .blade-thumbnail {
  width: calc((100% - 20px) / 3); /* Explicitly calculate width */
  height: auto;
  aspect-ratio: 20 / 9; /* Match main image aspect ratio */
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  opacity: 0.7;
  box-sizing: border-box; /* Ensures border is included in width calculation */
}

.blade-thumbnail.active {
  border-color: #00b0ca;
  opacity: 1;
}

@media (hover: hover) {
  .blade-close-btn:hover {
    background-color: #00b0ca !important;
    color: #fff;
    border-color: #00b0ca;
  }
}
/* --- End New Blade Carousel Styles --- */

.amenity-icon-wrapper {
  position: relative;
  display: inline-block;
  z-index: 1;
}
.amenity-icon-wrapper .tooltip {
  visibility: hidden;
  width: 250px;
  background-color: #000;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 9999;
  bottom: 125%;
  left: 50%;
  margin-left: -125px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.amenity-icon-wrapper .tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #000 transparent transparent transparent;
}
.amenity-icon-wrapper:hover .tooltip {
  visibility: visible;
  opacity: 1;
}
.tooltip h4 {
  margin: 0 0 5px 0;
  font-size: 14px;
  font-weight: bold;
  border-bottom: 1px solid #555;
  padding-bottom: 5px;
  text-transform: uppercase;
}
.tooltip div {
  font-size: 13px;
  line-height: 1.3;
  white-space: normal;
}
.tooltip div br {
  content: " ";
  display: block;
  margin-bottom: -8px;
}
.tooltip ul {
  margin: 0;
  padding-left: 15px;
  list-style-type: disc;
}
.tooltip li {
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.3;
}

body.modal-open {
  overflow: hidden;
}
.mpm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.mpm-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}
.mpm-modal-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.mpm-modal-close,
.mpm-modal-nav {
  position: absolute;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  user-select: none;
  z-index: 1001;
}
.mpm-modal-close {
  top: -45px;
  right: 0;
  width: 40px;
  height: 40px;
  font-size: 25px;
  background-color: rgba(0, 0, 0, 0.4);
  color: #fff;
}
.mpm-modal-nav {
  top: 50%;
  width: 75px;
  height: 75px;
  font-size: 54px;
  background-color: #fff;
  color: #555;
}
.mpm-modal-nav.disabled {
  display: none;
}
.mpm-modal-nav.prev {
  left: 0;
  transform: translate(-50%, -50%);
}
.mpm-modal-nav.next {
  right: 0;
  transform: translate(50%, -50%);
}
.mpm-modal-nav:focus {
  background-color: #fff !important;
  color: #555 !important;
  outline: none;
}
.mpm-modal-close:hover,
.mpm-modal-nav:hover {
  background-color: #00b0ca !important;
  color: #fff !important;
}

@media (min-width: 1440px) {
  .property-cards-container {
    width: 656px; /* Approx 25% wider */
  }
}

/* --- Mobile Responsive Styles --- */
@media (max-width: 768px) {
  .map-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    padding: 20px 20px 20px 20px; /* Add top and bottom padding */
  }

  .filter-item-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }

  /* Reduce gap between toggles and search field */
  .filter-item-group .filter-toggle {
    margin-bottom: 0;
  }

  /* Ensure search field has no top margin */
  .filter-item.filter-search {
    margin-top: 0;
  }

  /* Make Market Select full-width on its own line */
  .filter-item-group .filter-item:first-child {
    flex-basis: 100%;
  }

  /* Make the two toggles share the next line */
  .filter-item-group .filter-item:not(:first-child) {
    flex-grow: 1;
    flex-basis: 0; /* This makes them equal width */
  }

  .filter-item-group .filter-toggle {
    flex-grow: 1;
    flex-basis: 0;
  }

  .filter-item-group .filter-error-container {
    flex-basis: 100%;
    text-align: center;
    margin-top: 0; /* Remove margin since error only appears exceptionally */
  }

  /* Ensure all controls fill their container */
  .map-filter-control {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* Center justify text in market select dropdown on mobile */
  #market-select.map-filter-control {
    text-align: center;
    justify-content: center !important;
  }

  /* Center justify text in search input on mobile */
  #property-search-input.map-filter-control {
    text-align: center;
  }

  .search-icon {
    display: none;
  }

  #property-search-input {
    display: block;
  }

  .map-content-area {
    flex-direction: column;
  }

  .property-cards-container {
    width: 100%;
    max-height: none; /* Let it grow as needed on mobile */
    height: auto; /* Override desktop height */
    order: 2;
  }

  .map-render-area {
    height: 40vh;
    order: 1;
    transition: height 0.4s ease-in-out; /* Smooth transition for height changes */
  }

  .market-map-wrapper.all-properties-mobile-view .map-render-area {
    height: 30vh; /* Reduce map height for All Properties view on mobile */
  }

  .property-details-blade {
    transition: transform 0.4s ease-in-out;
    transform: translateY(100%);
  }

  .property-details-blade.active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    z-index: 10000;
    overflow-y: auto;
    flex-direction: column;
    transform: translateY(0);
    padding: 40px 20px;
    box-sizing: border-box;
  }

  .property-details-blade .blade-image,
  .property-details-blade .blade-content {
    width: 100%;
    max-width: 100%;
  }

  .property-details-blade .blade-content h2 {
    font-size: 32px;
    line-height: 1.2;
  }

  .property-details-blade .blade-close-btn {
    top: 20px;
    right: 25px;
    z-index: 10001;
  }

  .blade-ctas {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .filter-item-group {
    margin-bottom: -10px;
  }
  .filter-item-group .filter-item:not(:first-child) {
    flex-basis: 100%;
  }
}
