/* ==========================================================================
   Alloy WPL Listings UI
   Scoped to .alloy-wpl-* — no !important required.
   Foundation grid classes (wpl-small-up-*, wpl-large-up-*) no longer appear
   in markup because the template overrides replace the WPL listview wrapper.
   ========================================================================== */

body.wpl_property_listing #wpl_property_listing_container :is(h1, h2, h3, h4, h5, h6),
body.wpl_profile_listing #wpl_profile_listing_container :is(h1, h2, h3, h4, h5, h6) {
    color: var(--brand-secondary);
    font-family: var(--heading-font);
}
/* --------------------------------------------------------------------------
   Map view fallback: if map panel isn't rendered, keep list full-width.
   Keys off the class controlled by our adapter, not WPL's view class.
   -------------------------------------------------------------------------- */
body.wpl_property_listing #wpl_property_listing_container.alloy-map-active
  .wpl_property_listing_list_view_container {
    float: none;
    width: 100%;
    height: auto;
    margin: 1.5rem 0 2.5rem;
    box-shadow: none;
}


/* --------------------------------------------------------------------------
   Reset WPL's .wpl-column overrides inside Alloy containers.
   WPL's frontend.css forces: float:left !important; width:33% !important;
   padding:10px 0 10px 10px !important — these fight CSS Grid sizing.
   Float is ignored in grid, but width/padding need explicit reset.
   -------------------------------------------------------------------------- */
.alloy-wpl-listing-container .wpl-column,
.alloy-wpl-listing-container .wpl-columns {
    width: auto !important;
    padding: 0 !important;
    float: none !important;
    clear: none !important;
}

/* --------------------------------------------------------------------------
   Toolbar (sort bar + view switcher)
   -------------------------------------------------------------------------- */
.alloy-wpl-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 1rem 0 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid #e5e7eb;
}

.alloy-wpl-toolbar-left,
.alloy-wpl-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
}

/* Sort label + native select */
.alloy-wpl-sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* UHM: hide sort controls in listings tool. */
body.wpl_property_listing .alloy-wpl-sort {
    display: none;
}

.alloy-wpl-sort-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.alloy-wpl-sort select.wpl_plist_sort {
    min-height: 2.5rem;
    min-width: 12rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
    cursor: pointer;
}

/* Currency / unit switcher */
.alloy-wpl-unit-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* UHM: hide unit switcher (m / ft dropdown) in listings toolbar. */
body.wpl_property_listing .alloy-wpl-unit-switcher {
    display: none;
}

.alloy-wpl-unit-switcher .wpl_unit_switcher_activity {
    font-family: inherit;
    font-size: 0.875rem;
}

.alloy-wpl-unit-switcher .wpl_unit_switcher_activity select {
    min-height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
}

.alloy-wpl-unit-switcher .chosen-container {
    min-width: 5.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.alloy-wpl-unit-switcher .chosen-container-single .chosen-single {
    min-height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: none;
    line-height: 2.375rem;
    padding-left: 0.75rem;
}

.alloy-wpl-unit-switcher .chosen-container-single .chosen-single span {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    color: #111827;
    padding-right: 1rem;
}

.alloy-wpl-unit-switcher .chosen-container .chosen-search {
    display: none;
}

.alloy-wpl-unit-switcher .chosen-container .chosen-results {
    margin: 0;
    padding: 0;
    list-style: none;
}

.alloy-wpl-unit-switcher .chosen-container .chosen-drop,
.alloy-wpl-unit-switcher .chosen-container .chosen-results li {
    font-family: inherit;
    font-size: 0.875rem;
}

.alloy-wpl-unit-switcher .chosen-container .chosen-results li::before {
    content: none;
    display: none;
}

/* Utility action buttons */
.alloy-wpl-action-btn a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #fff;
    text-decoration: none;
    transition: border-color 120ms, background 120ms, color 120ms;
}

.alloy-wpl-action-btn a:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: #f0f9ff;
}

/* --------------------------------------------------------------------------
   View Switcher (Grid / List / Map toggle)
   -------------------------------------------------------------------------- */
.alloy-wpl-view-switcher {
    display: inline-flex;
    gap: 2px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    padding: 3px;
}

.alloy-wpl-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 0.4375rem;
    cursor: pointer;
    line-height: 1;
    transition: background 120ms, color 120ms, box-shadow 120ms;
    white-space: nowrap;
}

.alloy-wpl-view-btn:hover {
    color: #111827;
    background: #e5e7eb;
}

.alloy-wpl-view-btn.active {
    background: #fff;
    color: var(--brand-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.alloy-wpl-view-btn svg {
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Listing grid container
   Grid view: CSS Grid driven by --alloy-cols-* custom properties.
   List view: single column, cards go horizontal.
   -------------------------------------------------------------------------- */
.alloy-wpl-listing-container {
    width: 100%;
}

/* --- Grid view (default) --- */
.alloy-wpl-listing-container[data-view="grid"] {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(var(--alloy-cols-mobile, 1), minmax(0, 1fr));
}

@media (min-width: 640px) {
    .alloy-wpl-listing-container[data-view="grid"] {
        grid-template-columns: repeat(var(--alloy-cols-tablet, 2), minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .alloy-wpl-listing-container[data-view="grid"] {
        grid-template-columns: repeat(var(--alloy-cols-desktop, 3), minmax(0, 1fr));
    }
}

/* --- List view --- */
.alloy-wpl-listing-container[data-view="list"] {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Expand the card to horizontal layout in list mode */
.alloy-wpl-listing-container[data-view="list"] .wpl-column {
    width: 100%;
}

.alloy-wpl-listing-container[data-view="list"] .alloy-card-listing > a {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.alloy-wpl-listing-container[data-view="list"] .alloy-card-listing > a > *:first-child {
    /* Image wrapper */
    flex: 0 0 220px;
    aspect-ratio: unset;
    min-height: 160px;
    max-height: 240px;
}

@media (min-width: 480px) {
    .alloy-wpl-listing-container[data-view="list"] .alloy-card-listing > a > *:first-child {
        flex-basis: 280px;
    }
}

.alloy-wpl-listing-container[data-view="list"] .alloy-card-listing > a > *:last-child {
    /* Body wrapper */
    flex: 1 1 0;
    min-width: 0;
}

/* Profile cards: keep a vertical media stack (image on top, text below). */
.alloy-wpl-listing-container--profiles .alloy-card-profile > a > .p-5 > .flex.items-center.gap-4 {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.alloy-wpl-listing-container--profiles .alloy-card-profile > a > .p-5 > .flex.items-center.gap-4 img {
    width: 200px;
    height: 200px;
    object-fit: contain !important;
    object-position: center;
    background: #fff;
    border-radius: 0;
}

@media (max-width: 767px) {
    .alloy-wpl-listing-container--profiles .alloy-card-profile > a > .p-5 > .flex.items-center.gap-4 img {
        width: 120px;
        height: 120px;
    }
}

.alloy-wpl-listing-container--profiles .alloy-card-profile dd {
    overflow-wrap: anywhere;
}

/* UHM: list view currently duplicates grid value; hide any residual list toggles. */
.alloy-wpl-view-btn[data-view="list"] {
    display: none;
}

/* Profile listing search filters */
body.wpl_profile_listing .wpl_plisting_top_sidebar_container .wpl_search_from_box input[type="text"],
body.wpl_profile_listing .wpl_plisting_top_sidebar_container .wpl_search_from_box select {
    min-height: 2.5rem;
    min-width: 11rem;
}

body.wpl_profile_listing .wpl_plisting_top_sidebar_container .wpl_search_from_box input::placeholder {
    white-space: nowrap;
}

/* Elite Agents: keep the first location prompt on one line by widening field 1. */
@media (min-width: 1024px) {
    body.wpl_profile_listing [id^="wpl_default_search_"] .alloy-wpl-search-shell {
        flex-wrap: nowrap;
    }

    body.wpl_profile_listing [id^="wpl_default_search_"] [id*="_search_field_container_41"] {
        flex: 0 1 34rem;
        min-width: 34rem;
        max-width: 40rem;
    }

    body.wpl_profile_listing [id^="wpl_default_search_"] [id*="_search_field_container_911"] {
        width: 100%;
        flex: 1 1 56%;
        min-width: 520px;
        max-width: none;
    }

    body.wpl_profile_listing [id^="wpl_default_search_"] [id*="_advancedlocationtextsearch"] {
        white-space: nowrap;
        text-overflow: clip;
        overflow: visible;
        padding-right: 1.25rem;
    }
}

/* --- Map view — single column, compact list-style cards --- */
.alloy-wpl-listing-container[data-view="map"] {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Horizontal card layout in map view (same as list view) */
.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing > a {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing > a > *:first-child {
    flex: 0 0 160px;
    aspect-ratio: unset;
    min-height: 120px;
    max-height: 180px;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing > a > *:last-child {
    flex: 1 1 0;
    min-width: 0;
}

/* Compact card body in map view — override p-4 / text-lg / text-base */
.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing > a > div.space-y-2 {
    padding: 0.375rem 0.5rem;
    gap: 0.125rem;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing h3 {
    font-size: 0.8125rem;
    line-height: 1.3;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing p {
    font-size: 0.75rem;
    line-height: 1.3;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Google Map — hide by default, reveal + rearrange in map view.
   Scoped to `.alloy-wpl-managed` (added by JS only on pages with our switcher)
   so these rules don't affect other WPL instances (e.g. homepage search widget).
   `alloy-map-active` is toggled on #wpl_property_listing_container by JS.
   Do not rely on WPL's `.wpl-property-listing-mapview` class because it can
   persist across view changes depending on plugin state/template.
   -------------------------------------------------------------------------- */

/* Hide the WPL Google Map only on managed listing pages (not homepage) */
#wpl_property_listing_container.alloy-wpl-managed .wpl_googlemap_plisting {
    display: none;
}

/* First-paint guard: when saved view is map, keep legacy-positioned map hidden
   until the Alloy adapter restores layout classes. */
html.alloy-pre-map-view #wpl_property_listing_container .wpl_googlemap_container.wpl_googlemap_plisting {
    visibility: hidden !important;
}

/* Map view: side-by-side layout within the existing content width */
#wpl_property_listing_container.alloy-map-active {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
}

/* Align map-view toolbar spacing with grid/list view */
body.wpl_property_listing #wpl_property_listing_container.alloy-map-active .alloy-wpl-toolbar {
    max-width: var(--container-content, 1280px);
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
}

body.wpl_property_listing #wpl_property_listing_container.alloy-map-active .wpl_search_from_box {
    width: 100%;
    max-width: none;
    margin: 0.875rem auto 1rem;
    padding: 0 0 1rem;
    border-bottom: 1px solid #e5e7eb;
}

body.wpl_property_listing #wpl_property_listing_container.alloy-map-active {
    margin-top: 0.875rem;
    padding-top: 0;
}

body.wpl_property_listing #wpl_property_listing_container.alloy-map-active .wpl_googlemap_container,
body.wpl_property_listing #wpl_property_listing_container.alloy-map-active .wpl_property_listing_list_view_container {
    margin-top: 0;
}

/* Toolbar promoted to direct child of outerEl — span full width above map + listings */
#wpl_property_listing_container.alloy-map-active > .alloy-wpl-toolbar {
    flex: 0 0 100%;
    margin-bottom: 0;
}

#wpl_property_listing_container.alloy-map-active .wpl_googlemap_plisting {
    display: block;
    flex: 0 0 55%;
    position: sticky;
    top: 1rem;
    margin-top: 0;
    border-radius: 0.75rem;
    overflow: hidden;
}

#wpl_property_listing_container.alloy-map-active .wpl_googlemap_container.wpl_googlemap_plisting {
    /* Override WPL legacy mapview rule: position:absolute !important; height:90vh !important */
    position: sticky !important;
    top: 1rem;
    bottom: auto;
    float: none;
    width: auto;
    height: auto !important;
    max-height: none !important;
    margin: 0;
    padding: 0;
}

#wpl_property_listing_container.alloy-map-active .wpl_googlemap_container {
    margin-top: 0;
}

/* Force the map canvas to fill the sticky container */
#wpl_property_listing_container.alloy-map-active .wpl_map_canvas {
    height: calc(100vh - 120px) !important;
}

/* Listings panel: scrollable, toolbar is no longer inside */
#wpl_property_listing_container.alloy-map-active .wpl_property_listing_list_view_container {
    flex: 1 1 0;
    min-width: 0;
    float: none;
    width: auto;
    height: auto;
    margin: 0;
    box-shadow: none;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

/* Search sidebar sits between map and listings in the DOM — keep visible in map view */
#wpl_property_listing_container.alloy-map-active .wpl_plisting_top_sidebar_container {
    display: block;
    flex: 0 0 100%;
    order: -1;
    align-self: stretch;
    width: 100%;
    max-width: none;
    margin: 0 auto;
}

/* Override WPL mapview search-width collapse (display:table; margin:auto). */
#wpl_property_listing_container.wpl-property-listing-mapview [id*='wpl_searchwidget_'] {
    display: block;
    margin: 0;
    width: 100%;
}

#wpl_property_listing_container.alloy-map-active :is(#wpl_default_search_7, [id^="wpl_default_search_"]) .alloy-wpl-search-shell {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
}


/* --------------------------------------------------------------------------
   Card micro-interactions (shared, no !important)
   -------------------------------------------------------------------------- */
.alloy-card-listing,
.alloy-card-profile {
    height: 100%;
    transition: box-shadow 160ms ease, transform 160ms ease;
}

.alloy-card-listing:hover,
.alloy-card-profile:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

.alloy-card-listing a,
.alloy-card-profile a {
    color: inherit;
    text-decoration: none;
}

/* Keep listing thumbnails uniform in grid cards without stretching photos. */
.alloy-wpl-listing-container[data-view="grid"] .alloy-card-listing .alloy-card-media-wrap {
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.alloy-wpl-listing-container[data-view="grid"] .alloy-card-listing .alloy-card-media-wrap > .relative {
    height: 100%;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing .alloy-card-media-wrap {
    aspect-ratio: 2 / 3;
    overflow: hidden;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing .alloy-card-media-wrap > .relative {
    height: 100%;
}

.alloy-wpl-listing-container[data-view="map"] .alloy-card-listing .alloy-card-media-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.alloy-wpl-listing-container[data-view="grid"] .alloy-card-listing .alloy-card-media-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* --------------------------------------------------------------------------
   Pagination
   Matches alloy-core pill style: border-radius 9999px, brand-primary border.
   -------------------------------------------------------------------------- */
.alloy-wpl-pagination {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.875rem;
    border-top: 1px solid #e5e7eb;
}

.alloy-wpl-pagination .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Belt-and-suspenders bullet removal — source may be WPL, Divi, or prose utilities */
.alloy-wpl-pagination .pagination,
.alloy-wpl-pagination .pagination li {
    list-style: none !important;
    list-style-type: none !important;
}

.alloy-wpl-pagination .pagination li::marker,
.alloy-wpl-pagination .pagination li::before {
    display: none !important;
    content: none !important;
}

/* display:flex on <li> suppresses the list-item marker in flex context */
.alloy-wpl-pagination .pagination li {
    display: flex;
    margin: 0;
    padding: 0;
}

.alloy-wpl-pagination .pagination a,
.alloy-wpl-pagination .pagination li > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--brand-primary);
    border-radius: 9999px;
    background: #fff;
    color: var(--brand-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--poppins-font);
    line-height: 1;
    text-decoration: none;
    transition: border-color 120ms, background 120ms, color 120ms;
}

/* Ellipsis — no border, transparent background */
.alloy-wpl-pagination .pagination li > span {
    border-color: transparent;
    background: transparent;
    min-width: auto;
    padding-inline: 0.375rem;
}

.alloy-wpl-pagination .pagination a:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.alloy-wpl-pagination .pagination .active a {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: #fff;
}

.alloy-wpl-pagination .pagination .disabled a {
    opacity: 0.4;
    pointer-events: none;
}

/* Total results count */
.alloy-wpl-pagination .wpl_total_result {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Per-page selector */
.alloy-wpl-pagination .wpl_page_size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    float: none;
    margin: 0;
}

.alloy-wpl-pagination .wpl_page_size_title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.alloy-wpl-pagination .wpl_page_size_options {
    min-height: 2.5rem;
    width: auto !important;
    min-width: 4.5rem;
    border: 1px solid var(--brand-primary);
    border-radius: 9999px;
    background: #fff;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
    cursor: pointer;
}

/* Legacy selector kept for any WPL widget that still writes the old class */
.wpl_pagination_container {
    margin-top: 1.5rem;
}

/* ==========================================================================
   Listing Card Image Chrome
   Carousel buttons, favorite badge, photo count.
   ========================================================================== */

/* Prev / Next arrow buttons — white circles, always visible */
.alloy-card-carousel-btn {
    position: absolute;
    top: 50%;
    z-index: 30;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.85);
    color: #374151;
    cursor: pointer;
    transition: background 150ms ease;
    line-height: 1;
}

.alloy-card-carousel-btn:hover,
.alloy-card-carousel-btn:focus-visible {
    background: #fff;
}

.alloy-card-carousel-btn--prev { left: 0.5rem; }
.alloy-card-carousel-btn--next { right: 0.5rem; }

/* Photo count pill — bottom-right */
.alloy-card-photo-count {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 30;
    font-size: 0.75rem;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 9999px;
    padding: 0.1875rem 0.5rem;
    pointer-events: none;
}

/* Favorite button — top-right inside image area */
.alloy-card-favorite {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 30;
}

/* UHM: hide non-functional favorite heart on listing cards. */
body.wpl_property_listing .alloy-card-favorite {
    display: none;
}

.alloy-card-favorite-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.85);
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    transition: background 120ms, color 120ms;
}

.alloy-card-favorite-btn:hover {
    background: #fff;
    color: #ef4444;
}
