/* View Toggle Buttons */
.search-results__view-container {
    display: none; /* Hide the original container */
}

/* Move toggle buttons to header */
.search-results-header .search-results__view-toggle {
    display: flex;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 100px;
    width: fit-content;
    border: 1px solid #D7D7D7;
    margin: 0;
    height: fit-content;
    align-self: center;
}

/* Target specifically the search results header row */
.search-results__header-row {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.search-results__header-row .page-title {
    margin: 0;
    flex-shrink: 0;
}

.search-results__controls-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

@media (max-width: 767px) {
    .search-results__header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .search-results__controls-wrapper {
        margin-left: 0;
        gap: 8px;
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .search-results__controls-wrapper .filter {
        max-width: 170px;
        width: 100%;
    }

    .search-results__view-toggle {
        max-width: 180px;
        width: 100%;
    }

    /* Hide desktop sort button and show mobile refine */
    .button.hollow.dark.button-short.hide-for-small-only {
        display: none;
    }
    
    .button.button-blue.expanded.show-for-small-only {
        margin: 0;
        height: 100%;
    }
    
    .show-for-small-only.mobile-save-search {
        padding: 10px 10px 0;
        display: flex;
        gap: 10px;
        align-items: center;
        justify-content: space-between;
    }

    .show-for-small-only.mobile-save-search .icon.icon_elegant.icon-save {
        color: rgb(203, 74, 54);
    }

    .show-for-small-only.mobile-save-search > a {
        order: 2;
    }

    .show-for-small-only.mobile-save-search .tabs-title {
        order: 1;
    }

    .show-for-small-only.mobile-save-search .tabs-title {
        list-style: none;
        margin: 0;
        border: none;
    }
    
    .show-for-small-only.mobile-save-search .tabs-title:after,
    .show-for-small-only.mobile-save-search .tabs-title:before {
        display: none;
    }

    .show-for-small-only.mobile-save-search .tabs-title a {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 12px;
        color: #333;
        text-decoration: none;
        font-size: 16px;
        margin-bottom: 12px;
        border: none;
    }

    .show-for-small-only.mobile-save-search .tabs-title a svg {
        width: 12px;
        height: 12px;
        fill: currentColor;
    }

    /* Create stacking contexts for the entire header area */
    .search-results-header {
        position: relative;
        z-index: 20000 !important;
    }

    /* Mobile save search container */
    .show-for-small-only.mobile-save-search {
        position: relative;
        z-index: 20000 !important;
    }

    /* Ensure dropdown is above map */
    .dropdown-pane#sort-results-by-2 {
        position: absolute !important;
        z-index: 30000 !important;
    }

    /* Mobile sort button */
    .tabs-title.show-for-small-only {
        display: flex;
        align-items: center;
    }

    .tabs-title.show-for-small-only a {
        padding: 12px;
        color: #333;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 5px;
    }
}

.search-results__view-toggle {
    display: flex;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 100px;
    width: 100%;
    max-width: 180px;
    border: 1px solid #D7D7D7;
}

.search-results__view-toggle .search-results__view-button {
    flex: 1;
    text-align: center;
    min-width: unset;
}

.search-results__view-button {
    padding: 8px 24px;
    border: none;
    background: transparent;
    color: #666;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 100px;
    font-size: 14px;
    min-width: 80px;
}

@media (max-width: 767px) {
    .search-results__view-button {
        padding: 8px 12px;
        min-width: unset;
        width: 100%;
        font-size: 13px;
    }

    .search-results__view-toggle {
        width: 100%;
        max-width: none;
    }
}

.search-results__view-button:hover {
    background: #0f284c;
    color: #fff;

}

.search-results__view-button--active {
    background: #0f284c;
    color: #fff;
}

/* Search Results Layout */
.search-results__content {
    display: flex;
    flex-direction: row-reverse; /* Map on the right */
    height: 66.666rem;
    max-width: 100%; /* 1140px converted to rem */
    margin: 0 auto;
    gap: 16px;
    padding: 0 16px;
    
    @media (max-width: 767px) {
      flex-direction: column;
      height: auto;
      min-height: 100vh;
      padding: 0 8px;
      gap: 8px;
    }
}

/* Map view (default) */
.search-results__content--map-active .property-search-map {
    position: relative;
    width: calc(60% - 24px);
    display: block;
    margin-top: 6px;
    margin-right: 20px;

    @media (max-width: 1526px) {
        width: calc(50% - 16px);
    };

    @media (max-width: 1280px) {
      width: calc(60% - 24px);
    }

    @media (max-width: 767px) {
      width: 100%;
      margin-right: 0;
      height: 400px; /* Fixed height for mobile map */
    }
}

.search-results__content--map-active .search-results__listings {
    width: calc(40% - 32px);
    height: 100%;
    overflow-y: auto;

    @media (max-width: 1526px) {
      width: calc(50% - 32px);
    };

    @media (max-width: 1280px) {
      width: calc(40% - 32px);
    }

    @media (max-width: 767px) {
      width: 100%;
      padding: 0;
      margin-top: 16px;
    }
}

/* Adjust grid columns when map is active */
.search-results__content--map-active .search-results__listings .row.medium-up-3 {
    display: flex;
    flex-wrap: wrap;
}

.search-results__content--map-active .search-results__listings .row.medium-up-3 > .column {
    width: 50%;
    flex: none !important;

    @media (max-width: 1280px) {
      width: 100%;
    }
}

/* Keep original 3-column layout when map is hidden */
.search-results__content:not(.search-results__content--map-active) .search-results__listings {
    width: 100%;
}

.search-results__content:not(.search-results__content--map-active) .search-results__listings .row.medium-up-3,
.search-results__content:not(.search-results__content--map-active) .search-results__listings .row.xlarge-up-4 {
    width: 100% !important;
    max-width: 100% !important;
}

.search-results__content:not(.search-results__content--map-active) .search-results__listings .row.medium-up-3 > .column {
    width: calc(33.333% - 16px) !important;
    flex: none !important;

    @media (max-width: 767px) {
      width: 100% !important;
    }
}

/* Listings-only view */
.search-results__content:not(.search-results__content--map-active) .property-search-map {
    display: none;
}

.search-results__content:not(.search-results__content--map-active) .search-results__listings {
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

#map-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Map Controls - More styled version from base */
.property-search-map-controls {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 401;
}

.property-search-map-control {
  background-color: #fff;
  border: 0;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0,0,0,.1);
  cursor: pointer;
  display: block;
  height: 29px;
  margin: 0 0 10px;
  padding: 0;
  position: relative;
  width: 29px;
}

/* Markers - Base styles */
.map__marker {
    padding: .125rem .6875rem .0625rem;
    border-radius: 100px;
    font-size: .875rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    border: 2px solid #e7c046;
    color: #fff;
    margin: 0;
    height: 27px;
}

/* Base marker arrows */
.map__marker::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 11px 9px 0 9px;
    border-color: #e7c046 transparent transparent transparent;
}

.map__marker::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 6px 0 6px;
}

/* Color variations */
.map__marker--dark-blue {
    background: #422;
}
.map__marker--dark-blue::after {
    border-color: #422 transparent transparent transparent;
}

.map__marker--blue {
    background: #2654a1;
}
.map__marker--blue::after {
    border-color: #2654a1 transparent transparent transparent;
}

.map__marker--new {
    background: #d63f3a;
}
.map__marker--new::after {
    border-color: #d63f3a transparent transparent transparent;
}

.map__marker--orange {
    background: #d9620a;
}
.map__marker--orange::after {
    border-color: #d9620a transparent transparent transparent;
}

.map__marker--white {
    background: #fff;
    color: #422;
}
.map__marker--white::after {
    border-color: #fff transparent transparent transparent;
}

/* Hover state for markers */
.map__marker.map__marker--hover {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #e7c046 !important;
}

.map__marker.map__marker--hover::after {
    border-top-color: #e7c046 !important;
}

/* Make sure hover state overrides all color variations */
.map__marker--dark-blue.map__marker--hover,
.map__marker--blue.map__marker--hover,
.map__marker--new.map__marker--hover,
.map__marker--orange.map__marker--hover,
.map__marker--white.map__marker--hover {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #e7c046 !important;
}

.map__marker--dark-blue.map__marker--hover::after,
.map__marker--blue.map__marker--hover::after,
.map__marker--new.map__marker--hover::after,
.map__marker--orange.map__marker--hover::after,
.map__marker--white.map__marker--hover::after {
    border-top-color: #e7c046 !important;
}

/* Info Window (Popup) - More detailed styling from base */
.property-search-map-info-window {
    background: #fff;
    color: #333;
    font-family: 'Lato', sans-serif;
}

/* Override Leaflet's default popup styles */
.leaflet-popup-content {
    margin: 0 !important;
    width: 400px !important;
    box-shadow: 0 3px 14px rgba(0,0,0,.4);
    padding: 8px 6px 8px 6px;

    @media (max-width: 767px) {
      width: 360px !important;
    }
}

.leaflet-popup-content-wrapper {
    padding: 0 !important;
    border-radius: 3px !important;
}

.leaflet-popup-close-button+.leaflet-popup-content-wrapper .leaflet-popup-content {
  padding-top: 8px
}

.property-search-map-info-window__wrapper {
    width: 390.94px;
    height: 138px;
    overflow: hidden;
}

.property-search-map-info-window a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
}

.property-search-map-info-window__image {
    background-position: center;
    background-size: cover;
    width: 138px;
    height: 138px;
    flex-shrink: 0;
}

.property-search-map-info-window__content {
    padding: 12px;
    text-align: left;
    flex: 1;
    min-width: 0; /* This prevents flex items from overflowing */
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 138px); /* Subtract image width */
}

.property-search-map-info-window__price {
    color: #0084aa;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    margin: 0;
}

.property-search-map-info-window__address {
    color: #4d4d4d;
    font-size: 14.4px;
    /* line-height: 0.3; */
    margin: 0;
}

.property-search-map-info-window__location {
    color: #4d4d4d;
    font-size: 14.4px;
    /* line-height: 1.3; */
    margin-top: -12px;

}

.property-search-map-info-window__features {
    color: #4d4d4d;
    font-size: 16px;
    margin-bottom: 6px;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    span {
      margin-right: 10px;
    }
}

.property-search-map-info-window__features .feature {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.property-search-map-info-window__features .feature strong {
    color: #333;
}

.property-search-map-info-window__features .feature {
    display: flex;
    align-items: center;
    gap: 4px;

}

.property-search-map-info-window__features .feature strong {
    color: #333;
}