/* RESO Property Search — Listing Display Styles */

/* ── Grid layout ──────────────────────────────────────────────────────────── */

.reso-listings-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

/* Column variants */
.reso-listings-grid.reso-grid--1col { grid-template-columns: 1fr; }
.reso-listings-grid.reso-grid--2col { grid-template-columns: repeat(2, 1fr); }
.reso-listings-grid.reso-grid--3col { grid-template-columns: repeat(3, 1fr); }
.reso-listings-grid.reso-grid--4col { grid-template-columns: repeat(4, 1fr); }

/* List view overrides */
.reso-listings-grid.reso-view-list {
    grid-template-columns: 1fr;
    gap: 12px;
}

/* ── Listing Card ────────────────────────────────────────────────────────── */

.reso-listing-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.reso-listing-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

/* ── Card Media / Carousel ────────────────────────────────────────────────── */

.reso-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #f0f0f0;
    overflow: hidden;
    flex-shrink: 0;
}

.reso-card-media .splide {
    height: 100%;
}

.reso-card-media .splide__track,
.reso-card-media .splide__list,
.reso-card-media .splide__slide {
    height: 100%;
}

.reso-card-media .splide__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reso-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #eee;
    color: #aaa;
    font-size: 0.85em;
    font-style: italic;
}

.reso-no-photo--thumb {
    width: 120px;
    height: 90px;
}

.reso-no-photo--large {
    height: 320px;
    font-size: 1em;
}

/* ── Card Content Sections ────────────────────────────────────────────────── */

.reso-card-content {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reso-card-header,
.reso-card-body,
.reso-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: baseline;
}

.reso-card-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.82em;
    color: #666;
}

/* ── Field layout within sections ────────────────────────────────────────── */

.reso-field {
    display: flex;
    flex-direction: column;
}

.reso-field--full  { flex: 1 1 100%;  min-width: 100%; }
.reso-field--half  { flex: 1 1 45%;   min-width: 80px; }
.reso-field--third { flex: 1 1 28%;   min-width: 60px; }

.reso-field-label {
    font-size: 0.72em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.reso-field-value {
    font-size: 0.92em;
    color: #23282d;
    font-weight: 500;
    line-height: 1.3;
}

.reso-price {
    font-size: 1.3em;
    font-weight: 700;
    color: #0073aa;
    line-height: 1;
}

/* ── Status Badges ────────────────────────────────────────────────────────── */

.reso-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    background: #e0e0e0;
    color: #555;
}

.reso-status--active             { background: #d4edda; color: #155724; }
.reso-status--pending            { background: #fff3cd; color: #856404; }
.reso-status--active-under-contract { background: #ffeeba; color: #7d5a00; }
.reso-status--closed             { background: #e2e3e5; color: #383d41; }
.reso-status--sold               { background: #e2e3e5; color: #383d41; }
.reso-status--withdrawn          { background: #f8d7da; color: #721c24; }
.reso-status--expired            { background: #f8d7da; color: #721c24; }
.reso-status--coming-soon        { background: #cce5ff; color: #004085; }

/* ── CTA Button ───────────────────────────────────────────────────────────── */

.reso-card-cta {
    margin-top: 10px;
}

.reso-cta-btn {
    display: inline-block;
    background: #0073aa;
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    padding: 8px 18px;
    font-size: 0.88em;
    font-weight: 600;
    transition: background 0.15s;
    cursor: pointer;
}

.reso-cta-btn:hover {
    background: #005177;
}

.reso-cta-btn--large {
    padding: 12px 28px;
    font-size: 1em;
}
.reso-cta-btn--row {
    padding: 5px 12px;
    font-size: 0.82em;
}

/* ── Card Expand Detail ────────────────────────────────────────────────────── */

.reso-card-expand-detail {
    border-top: 1px solid #eee;
    margin: 8px -16px -16px;
    padding: 14px 16px 16px;
    background: #f9f9f9;
}

/* ── List Row ────────────────────────────────────────────────────────────── */

.reso-listing-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 16px;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.reso-listing-row:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.reso-row-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: 4px;
    overflow: hidden;
    background: #eee;
}

.reso-row-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reso-row-content {
    flex: 1;
    min-width: 0;
}

.reso-row-address {
    font-size: 1em;
    font-weight: 600;
    margin: 4px 0 2px;
    color: #23282d;
}

.reso-row-price {
    font-size: 1.1em;
    font-weight: 700;
    color: #0073aa;
    margin-right: 12px;
}

.reso-row-location {
    color: #666;
    font-size: 0.85em;
    margin: 0 0 6px;
}

.reso-row-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.reso-row-stat .reso-field-label {
    font-size: 0.72em;
    color: #888;
    margin-right: 3px;
}

.reso-row-stat .reso-field-value {
    font-size: 0.88em;
    color: #444;
}

/* ── Results Toolbar ──────────────────────────────────────────────────────── */

.reso-results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.reso-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reso-sort-control label {
    font-size: 0.88em;
    color: #555;
    margin-right: 5px;
}

.reso-sort-select {
    font-size: 0.88em;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

/* ── View Toggle ──────────────────────────────────────────────────────────── */

.reso-view-toggle {
    display: flex;
    gap: 4px;
}

.reso-view-btn {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 8px;
    cursor: pointer;
    color: #666;
    transition: background 0.1s, color 0.1s;
    line-height: 1;
}

.reso-view-btn--active,
.reso-view-btn:hover {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

.reso-pagination {
    display: flex;
    justify-content: center;
    margin: 20px 0 8px;
}

.reso-page-list {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.reso-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.reso-page-btn--active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
    font-weight: 700;
}

.reso-page-btn:hover:not(.reso-page-btn--active) {
    background: #f0f0f0;
}

/* ── No results ───────────────────────────────────────────────────────────── */

.reso-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 1em;
}

/* ── Empty state (results page with no search yet) ─────────────────────── */

.reso-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}
.reso-empty-state-message {
    font-size: 1.1em;
    margin-bottom: 16px;
}
.reso-empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
}
.reso-empty-state-btn:hover {
    background: #005a87;
}
.reso-empty-state-btn svg {
    fill: currentColor;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */

body.reso-modal-open {
    overflow: hidden;
}

.reso-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.reso-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    cursor: pointer;
}

.reso-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 10px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.reso-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.reso-modal-close:hover {
    background: rgba(0,0,0,0.85);
}

.reso-modal-media {
    width: 100%;
    max-height: 380px;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.reso-modal-media .splide {
    max-height: 380px;
}

.reso-modal-media .splide__slide img {
    width: 100%;
    height: 380px;
    object-fit: cover;
}

.reso-modal-content {
    padding: 20px 24px 24px;
}

.reso-modal-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.reso-modal-price {
    font-size: 1.6em;
    font-weight: 700;
    color: #0073aa;
}

.reso-modal-address {
    font-size: 1.15em;
    margin: 0 0 16px;
    color: #23282d;
}

.reso-modal-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.reso-modal-cta {
    margin-top: 18px;
}

/* ── Detail page ──────────────────────────────────────────────────────────── */

.reso-detail-page-wrap {
    padding: 20px 0;
}

.reso-detail-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.reso-detail-back {
    margin-bottom: 16px;
}

.reso-detail-back a {
    color: #0073aa;
    text-decoration: none;
}

.reso-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

.reso-detail-carousel .splide__slide img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 8px;
}

.reso-detail-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.reso-detail-price {
    font-size: 2em;
    font-weight: 700;
    color: #0073aa;
}

.reso-detail-address {
    font-size: 1.4em;
    margin: 0 0 4px;
}

.reso-detail-city {
    display: block;
    font-size: 0.7em;
    font-weight: 400;
    color: #666;
    margin-top: 2px;
}

.reso-detail-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.reso-detail-field {
    display: flex;
    flex-direction: column;
}

.reso-detail-group-heading {
    width: 100%;
    font-size: 0.95em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
    margin: 16px 0 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}
.reso-detail-group-heading:first-child {
    margin-top: 0;
}

.reso-detail-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    width: 100%;
}

.reso-detail-cta {
    margin-top: 20px;
}

/* ── Debug JSON ───────────────────────────────────────────────────────────── */

.reso-debug-json {
    margin-top: 20px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media ( max-width: 900px ) {
    .reso-listings-grid.reso-grid--4col { grid-template-columns: repeat(2, 1fr); }
    .reso-listings-grid.reso-grid--3col { grid-template-columns: repeat(2, 1fr); }
    .reso-detail-layout { grid-template-columns: 1fr; }
}

@media ( max-width: 600px ) {
    .reso-listings-grid.reso-grid--2col,
    .reso-listings-grid.reso-grid--3col,
    .reso-listings-grid.reso-grid--4col { grid-template-columns: 1fr; }
    .reso-row-thumb { width: 80px; height: 65px; }
    .reso-modal-dialog { max-height: 95vh; }
    .reso-modal-media .splide__slide img { height: 220px; }
}

/* ── Map view ────────────────────────────────────────────────────────────── */

/* Wrapper that contains the map + slide-in sidebar. overflow:hidden clips the
   sidebar shadow so it doesn't bleed into the page when the sidebar is closed. */
.reso-map-area {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    margin-bottom: 24px;
}

.reso-map-container {
    width: 100%;
    height: 540px;
    border: 1px solid #ddd;
    overflow: hidden;
    /* border-radius and margin-bottom moved to .reso-map-area */
}

@media ( max-width: 600px ) {
    .reso-map-container { height: 380px; }
}

/* Leaflet popup content */
.reso-map-popup {
    min-width: 160px;
    font-family: inherit;
    font-size: 0.88em;
    line-height: 1.4;
}
.reso-map-price {
    font-size: 1.05em;
    color: #0073aa;
}
.reso-map-addr  { margin: 4px 0 0; font-weight: 600; }
.reso-map-city  { margin: 2px 0 0; color: #555; }
.reso-map-stats { margin: 4px 0 0; color: #444; }
/* Map popup thumbnail */
.reso-map-popup-photo {
    margin-bottom: 7px;
}
.reso-map-popup-photo img {
    width: 100%;
    max-width: 220px;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.reso-map-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.reso-map-view-btn,
.reso-map-detail-btn {
    font-size: 0.82em !important;
    padding: 3px 10px !important;
    text-decoration: none;
    display: inline-block;
}

/* ── Map loading overlay ──────────────────────────────────────────────────── */

/* Shown while _fetchAllMapMarkers() is in-flight; hidden on completion */
.reso-map-loading {
    position: absolute;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
    border-radius: inherit;
}
.reso-map-loading-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(0, 115, 170, 0.25);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: reso-map-spin 0.7s linear infinite;
}
@keyframes reso-map-spin {
    to { transform: rotate(360deg); }
}

/* ── Leaflet colored map markers ─────────────────────────────────────────── */

/* Override Leaflet's default divIcon wrapper so we get a clean pin shape */
.reso-marker {
    background: transparent !important;
    border: none !important;
}

/* Rotated rounded square = teardrop pin */
.reso-marker::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50% 50% 50% 0;
    transform: rotate( -45deg );
    box-shadow: 0 1px 4px rgba(0,0,0,.35);
    margin: -1px 0 0 -1px;
}

.reso-marker--green::before  { background: #22a14b; border: 2px solid #18833b; }
.reso-marker--orange::before { background: #f0820d; border: 2px solid #c96800; }
.reso-marker--red::before    { background: #d63232; border: 2px solid #aa1c1c; }
.reso-marker--blue::before   { background: #2271b1; border: 2px solid #135e96; }

/* ── Card / Row action buttons (Quick View + Detail View) ─────────────────── */

.reso-card-actions,
.reso-row-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px 10px;
    flex-wrap: wrap;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
}
.reso-row-actions {
    padding: 6px 0 0;
    border-top: none;
    margin-top: 8px;
}

/* Quick View button */
.reso-btn-quickview {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.reso-btn-quickview:hover,
.reso-btn-quickview:focus {
    background: #005f8a;
    color: #fff;
    outline: none;
}

/* Detail View button / link */
.reso-btn-detail {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: transparent;
    color: #0073aa;
    border: 1px solid #0073aa;
    border-radius: 4px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.reso-btn-detail:hover,
.reso-btn-detail:focus {
    background: #0073aa;
    color: #fff;
    outline: none;
}

/* Modal "Detail View" button — full-width, larger */
.reso-modal-detail-link {
    padding: 12px 0 4px;
}
.reso-modal-detail-btn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    padding: 10px 20px;
    background: transparent;
    color: #0073aa;
    border: 2px solid #0073aa;
    border-radius: 5px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    box-sizing: border-box;
}
.reso-modal-detail-btn:hover,
.reso-modal-detail-btn:focus {
    background: #0073aa;
    color: #fff;
    outline: none;
}

/* ── Map view — filter sidebar toggle button ─────────────────────────────── */

#reso-map-filter-toggle,
.reso-map-filter-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    transition: background 0.15s, color 0.15s;
    color: #23282d;
}

#reso-map-filter-toggle:hover,
.reso-map-filter-toggle:hover {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ── Map view — slide-in filter sidebar ─────────────────────────────────── */

.reso-map-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    border-right: 1px solid #ddd;
    box-shadow: 4px 0 16px rgba(0,0,0,0.18);
    z-index: 1001;
    transform: translateX( -110% );
    transition: transform 0.28s ease;
    overflow-y: auto;
    pointer-events: none;
}

/* .reso-map-area (the wrapper) is the positioned ancestor for the sidebar.
   .reso-map-container keeps position:relative for the Leaflet toolbar button. */
.reso-map-container {
    position: relative;
}

.reso-map-sidebar.reso-map-sidebar--open {
    transform: translateX( 0 );
    pointer-events: all;
}

.reso-map-sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.reso-map-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.reso-map-sidebar-title {
    font-weight: 700;
    font-size: 1rem;
}

.reso-map-sidebar-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.reso-map-sidebar-close:hover {
    color: #000;
}

.reso-map-sidebar-body {
    padding: 16px;
    flex: 1;
}

/* ── Map view — viewport-filtered list below map ─────────────────────────── */

.reso-map-list {
    margin-top: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.reso-map-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    background: #f7f8f9;
    border-bottom: 1px solid #e0e0e0;
}

.reso-map-list-count {
    font-size: 0.88em;
    color: #555;
    font-weight: 600;
}

.reso-map-list-pagination {
    /* Reuses .reso-page-list / .reso-page-btn styles */
}

.reso-map-list-pagination .reso-page-list {
    flex-wrap: nowrap;
}

.reso-map-list-pagination .reso-page-btn {
    min-width: 30px;
    height: 28px;
    font-size: 0.8em;
    padding: 0 6px;
}

.reso-map-list-items {
    background: #fff;
}

/* Map list rows: compact variant of .reso-listing-row */
.reso-map-list-items .reso-listing-row {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 0;
    padding: 10px 14px;
}

.reso-map-list-items .reso-listing-row:last-child {
    border-bottom: none;
}

/* ── Leaflet marker cluster overrides ─────────────────────────────────────── */

/* Make cluster icons blend with the site palette */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(0, 115, 170, 0.25) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: rgba(0, 115, 170, 0.55) !important;
    color: #fff !important;
    font-size: 0.78em;
    font-weight: 700;
}
