/**
 * OloEle Property Map — Styles
 * Dynamic values via CSS custom properties set on .oloele-pms wrapper.
 */

/* ── Elementor full-width compatibility ──
   In a Full Width section these wrappers can stay narrower than the section
   unless width is stated; min-width:0 keeps the grid from overflowing. */
.elementor-widget-oloele-property-map,
.elementor-widget-oloele-property-map > .elementor-widget-container {
    width: 100%;
    min-width: 0;
}

/* ── Layout ── */
.oloele-pms {
    display: grid;
    grid-template-columns: var(--oloele-map-cols, 50% 1fr);
    height: var(--oloele-height, 700px);
    width: 100%;
    min-width: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
}

/* ── Map panel ── */
.oloele-pms .pms-map-panel {
    position: relative;
    order: var(--oloele-map-order, 1);
    z-index: 1;
}
.oloele-pms .pms-map {
    width: 100%; height: 100%;
}
.oloele-pms .pms-fullscreen-btn {
    position: absolute; top: 10px; right: 10px; z-index: 1000;
    width: 34px; height: 34px; background: #fff;
    border: 2px solid rgba(0,0,0,0.2); border-radius: 4px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.oloele-pms .pms-fullscreen-btn:hover { background: #f4f4f4; }

/* ── Fullscreen ── */
/* Without these the container keeps its fixed --oloele-height in fullscreen, so
   the map fills the screen width but not the height and Leaflet tiles break up
   into a "puzzle". Forcing full viewport size + invalidateSize() (JS) fixes it. */
.oloele-pms:fullscreen,
.oloele-pms:-webkit-full-screen {
    width: 100vw !important; height: 100vh !important; border-radius: 0;
}
.oloele-pms:fullscreen .pms-map-panel,
.oloele-pms:-webkit-full-screen .pms-map-panel { height: 100% !important; }
.oloele-pms:fullscreen .pms-results-panel,
.oloele-pms:-webkit-full-screen .pms-results-panel { height: 100% !important; }

/* ── Results panel ── */
.oloele-pms .pms-results-panel {
    order: var(--oloele-results-order, 2);
    display: flex; flex-direction: column; overflow: hidden; background: #FAFBFC;
    position: relative; z-index: 2;
}

/* ── Filters ── */
.oloele-pms .pms-filters {
    padding: 16px 20px; background: #fff;
    border-bottom: 1px solid #E5E7EB;
    overflow: visible; flex-shrink: 0;
    position: relative; z-index: 3;
}
/* Ensure Elementor doesn't block interactive elements */
.oloele-pms .pms-filters select,
.oloele-pms .pms-filters input,
.oloele-pms .pms-filters button,
.oloele-pms .pms-results-header select,
.oloele-pms .pms-results-header button,
.oloele-pms .pms-pagination button {
    pointer-events: auto !important;
    cursor: pointer;
}
.oloele-pms .pms-filters-grid {
    display: grid;
    grid-template-columns: repeat(var(--oloele-filter-cols, 2), 1fr);
    gap: 10px;
}
.oloele-pms .pms-filter-group {
    display: flex; flex-direction: column; gap: 3px;
}
.oloele-pms .pms-filter-group--full {
    grid-column: 1 / -1;
}
.oloele-pms .pms-filter-label {
    font-size: 11px; font-weight: 600; color: #6B7280;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.oloele-pms .pms-filter-input,
.oloele-pms .pms-filter-select {
    padding: 8px 10px; border: 1px solid #D1D5DB; border-radius: 6px;
    font-size: 13px; color: #374151; background: #fff;
    width: 100%; box-sizing: border-box; font-family: inherit;
    transition: border-color 0.15s;
}
.oloele-pms .pms-filter-input:focus,
.oloele-pms .pms-filter-select:focus {
    outline: none; border-color: var(--oloele-color, #2563EB);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--oloele-color, #2563EB) 13%, transparent);
}

/* ── Range wrap ── */
.oloele-pms .pms-range-wrap {
    display: flex; align-items: center; gap: 8px;
}
.oloele-pms .pms-range-wrap input[type="number"] { width: 100%; min-width: 0; }
.oloele-pms .pms-range-sep { color: #9CA3AF; font-size: 13px; flex-shrink: 0; }

/* ── Radius slider ── */
.oloele-pms .pms-radius-wrap {
    display: flex; align-items: center; gap: 8px;
}
.oloele-pms .pms-radius-wrap input[type="range"] {
    flex: 1; accent-color: var(--oloele-color, #2563EB); height: 4px;
}
.oloele-pms .pms-radius-val {
    font-size: 12px; font-weight: 600; color: #374151; min-width: 40px; text-align: right;
}

/* ── Actions bar ── */
.oloele-pms .pms-actions {
    display: flex; gap: 8px; margin-top: 12px; align-items: center;
}
.oloele-pms .pms-btn-search {
    flex: 1; padding: 10px 16px;
    background: var(--oloele-btn-bg, #2563EB);
    color: var(--oloele-btn-color, #fff);
    border: none; border-radius: 6px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: opacity 0.2s; font-family: inherit;
}
.oloele-pms .pms-btn-search:hover { opacity: 0.88; }
.oloele-pms .pms-btn-reset {
    padding: 10px 14px; background: transparent; color: #6B7280;
    border: 1px solid #D1D5DB; border-radius: 6px; font-size: 13px;
    cursor: pointer; transition: background 0.15s; font-family: inherit;
}
.oloele-pms .pms-btn-reset:hover { background: #F3F4F6; }

/* ── Results header ── */
.oloele-pms .pms-results-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px; background: #fff;
    border-bottom: 1px solid #E5E7EB; flex-shrink: 0; gap: 8px; flex-wrap: wrap;
}
.oloele-pms .pms-results-count { font-size: 13px; font-weight: 600; color: #374151; }
.oloele-pms .pms-results-count strong { color: var(--oloele-color, #2563EB); }
.oloele-pms .pms-sort-wrap { display: flex; align-items: center; gap: 8px; }
.oloele-pms .pms-sort-select {
    padding: 5px 8px; border: 1px solid #D1D5DB; border-radius: 4px;
    font-size: 12px; color: #374151; background: #fff; font-family: inherit;
}
.oloele-pms .pms-view-toggles { display: flex; gap: 2px; }
.oloele-pms .pms-view-btn {
    width: 30px; height: 30px; border: 1px solid #D1D5DB; background: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    padding: 0; color: #9CA3AF; transition: background 0.15s, color 0.15s;
}
.oloele-pms .pms-view-btn:first-child { border-radius: 4px 0 0 4px; }
.oloele-pms .pms-view-btn:last-child  { border-radius: 0 4px 4px 0; }
.oloele-pms .pms-view-btn.is-active {
    background: var(--oloele-color, #2563EB);
    border-color: var(--oloele-color, #2563EB);
    color: #fff;
}

/* ── Results list ── */
.oloele-pms .pms-results-list {
    flex: 1; overflow-y: auto; padding: 12px 16px;
}

/* ── Card (list view) ── */
.oloele-pms .pms-card {
    display: grid; grid-template-columns: var(--oloele-card-img-cols, 38%) 1fr;
    border: 1px solid #E5E7EB;
    border-radius: var(--oloele-card-radius, 8px);
    overflow: hidden;
    max-height: var(--oloele-card-maxh, none);
    background: #fff; margin-bottom: 10px;
    transition: box-shadow 0.2s, transform 0.15s;
    cursor: pointer; text-decoration: none; color: inherit;
}
.oloele-pms .pms-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px);
}
.oloele-pms .pms-card.is-highlighted {
    box-shadow: 0 0 0 2px var(--oloele-color, #2563EB), 0 4px 12px rgba(0,0,0,0.1);
}

/* ── Card (grid view) ── */
.oloele-pms .pms-results-list.pms-grid-view {
    display: grid;
    grid-template-columns: repeat(var(--oloele-grid-cols, 2), 1fr);
    gap: 10px; padding: 12px 16px; align-content: start;
}
.oloele-pms .pms-results-list.pms-grid-view .pms-card {
    display: flex; flex-direction: column;
    margin-bottom: 0; position: relative; min-height: 220px;
}
.oloele-pms .pms-results-list.pms-grid-view .pms-card-img {
    position: absolute; inset: 0; height: 100%;
}
.oloele-pms .pms-results-list.pms-grid-view .pms-card-body {
    position: relative; z-index: 2; margin-top: auto;
    background: linear-gradient(0deg, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.45) 70%, transparent 100%);
    padding: 40px 12px 10px;
    border-radius: 0 0 var(--oloele-card-radius, 8px) var(--oloele-card-radius, 8px);
}
.oloele-pms .pms-results-list.pms-grid-view .pms-card-title { color: #fff; font-size: 13px; }
.oloele-pms .pms-results-list.pms-grid-view .pms-card-address { color: rgba(255,255,255,0.8); }
.oloele-pms .pms-results-list.pms-grid-view .pms-card-address svg { stroke: rgba(255,255,255,0.7); }
.oloele-pms .pms-results-list.pms-grid-view .pms-card-specs { color: rgba(255,255,255,0.85); }
.oloele-pms .pms-results-list.pms-grid-view .pms-card-specs svg { stroke: rgba(255,255,255,0.7); }
.oloele-pms .pms-results-list.pms-grid-view .pms-card-price { color: #fff; }

/* ── Card image ── */
.oloele-pms .pms-card-img {
    position: relative; overflow: hidden; background: #E5E7EB;
    min-height: 110px; height: var(--oloele-card-imgh, auto);
}
.oloele-pms .pms-card-img img {
    width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s;
}
.oloele-pms .pms-card:hover .pms-card-img img { transform: scale(1.05); }
.oloele-pms .pms-card-img-ph {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #9CA3AF;
}
.oloele-pms .pms-card-labels {
    display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 2px;
}
.oloele-pms .pms-card-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 100px; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px; color: #fff;
}
.oloele-pms .pms-card-badge--sale  { background: #059669; }
.oloele-pms .pms-card-badge--rent  { background: #D97706; }
.oloele-pms .pms-card-badge--label { background: #DC2626; }
.oloele-pms .pms-card-expand {
    position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
    background: rgba(0,0,0,0.45); border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.oloele-pms .pms-card:hover .pms-card-expand { opacity: 1; }

/* ── Card body ── */
.oloele-pms .pms-card-body {
    padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.oloele-pms .pms-card-title {
    font-size: 14px; font-weight: 700; color: #1F2937; margin: 0;
    text-transform: uppercase; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oloele-pms .pms-card-address {
    font-size: 12px; color: #6B7280; display: flex; align-items: center; gap: 3px; margin: 0;
}
.oloele-pms .pms-card-specs {
    display: flex; gap: 10px; font-size: 11px; color: #6B7280; flex-wrap: wrap; margin-top: 4px;
}
.oloele-pms .pms-card-specs span {
    display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.oloele-pms .pms-card-price {
    font-size: 16px; font-weight: 700; color: var(--oloele-color, #2563EB);
    margin-top: auto; padding-top: 4px; text-align: right;
}

/* ── Pagination ── */
.oloele-pms .pms-pagination {
    display: flex; justify-content: center; align-items: center; gap: 8px;
    padding: 10px 20px; background: #fff; border-top: 1px solid #E5E7EB; flex-shrink: 0;
}
.oloele-pms .pms-page-btn {
    padding: 6px 14px; border: 1px solid #D1D5DB; border-radius: 4px;
    background: #fff; color: #374151; font-size: 13px; cursor: pointer;
    font-family: inherit; transition: background 0.15s;
}
.oloele-pms .pms-page-btn:hover { background: #F3F4F6; }
.oloele-pms .pms-page-btn:disabled { opacity: 0.4; cursor: default; }
.oloele-pms .pms-page-info { font-size: 12px; color: #6B7280; }

/* ── No results ── */
.oloele-pms .pms-no-results {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px; color: #9CA3AF; text-align: center; gap: 8px;
}
.oloele-pms .pms-no-results-title { font-size: 15px; font-weight: 600; color: #6B7280; }

/* ── Autocomplete ── */
.oloele-pms .pms-autocomplete-wrap { position: relative; }
.oloele-pms .pms-autocomplete-list {
    display: none; position: absolute; z-index: 1000; top: 100%; left: 0; right: 0;
    margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff;
    border: 1px solid #D1D5DB; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12); max-height: 220px; overflow-y: auto;
}
.oloele-pms .pms-autocomplete-list.is-open { display: block; }
.oloele-pms .pms-ac-item {
    padding: 8px 12px; font-size: 13px; color: #374151; cursor: pointer;
    display: flex; align-items: flex-start; gap: 8px; line-height: 1.35;
}
.oloele-pms .pms-ac-item:hover,
.oloele-pms .pms-ac-item.is-active { background: #F3F4F6; }
.oloele-pms .pms-ac-item svg { flex-shrink: 0; margin-top: 2px; color: #9CA3AF; }

/* ── Leaflet popup override (global — popups render outside the widget wrapper) ── */
.pms-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    min-width: 220px; max-width: 280px; padding: 4px;
}
.pms-popup img {
    width: 100%; height: 120px; object-fit: cover;
    border-radius: 6px; margin-bottom: 8px; display: block;
}
.pms-popup h4 {
    margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #1F2937;
    line-height: 1.3; word-wrap: break-word;
}
.pms-popup .pms-popup-specs {
    font-size: 12px; color: #6B7280; margin: 4px 0 6px;
}
.pms-popup .pms-popup-price {
    font-size: 16px; font-weight: 700; color: #2563EB; margin: 0 0 8px;
}
.pms-popup a.pms-popup-link {
    display: inline-block; padding: 6px 14px; background: #2563EB;
    color: #fff; border-radius: 6px; font-size: 12px; font-weight: 600;
    text-decoration: none; transition: opacity 0.2s;
}
.pms-popup a.pms-popup-link:hover { opacity: 0.85; }
.leaflet-popup-content { margin: 8px 10px; }

/* ── Marker cluster color override ── */
.oloele-pms .marker-cluster-small { background-color: color-mix(in srgb, var(--oloele-color, #2563EB) 20%, transparent); }
.oloele-pms .marker-cluster-small div { background-color: var(--oloele-color, #2563EB); color: #fff; }
.oloele-pms .marker-cluster-medium { background-color: color-mix(in srgb, var(--oloele-color, #2563EB) 27%, transparent); }
.oloele-pms .marker-cluster-medium div { background-color: var(--oloele-color, #2563EB); color: #fff; }
.oloele-pms .marker-cluster-large { background-color: color-mix(in srgb, var(--oloele-color, #2563EB) 33%, transparent); }
.oloele-pms .marker-cluster-large div { background-color: var(--oloele-color, #2563EB); color: #fff; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .oloele-pms { grid-template-columns: 1fr; height: auto; }
    .oloele-pms .pms-map-panel { order: 1 !important; height: 350px; }
    /* No fixed height + overflow here: it cropped the filters (from Min/Max down)
       when they stacked. The panel now grows to fit; only the results list keeps
       an internal scroll so the page stays manageable. */
    .oloele-pms .pms-results-panel { order: 2 !important; height: auto; overflow: visible; }
    .oloele-pms .pms-results-list { flex: none; max-height: 60vh; }
    .oloele-pms .pms-results-list.pms-grid-view { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    /* Keep two filter columns on mobile (cap at 2 even if the desktop setting is
       higher). Full-width rows and the Min/Max range fields span the whole width
       so they never get squeezed. */
    .oloele-pms .pms-filters-grid { grid-template-columns: repeat(2, 1fr); }
    .oloele-pms .pms-filter-group--range { grid-column: 1 / -1; }
    /* Stacked card: the "max card height" setting is a budget for the side-by-side
       layout, where photo and text share it. Once they stack, the photo alone can
       use it all and overflow:hidden crops the entire body — so drop the cap.
       position:relative makes the card the anchor for the labels below. */
    .oloele-pms .pms-card {
        grid-template-columns: 1fr;
        max-height: none;
        position: relative;
    }
    .oloele-pms .pms-card-img { height: 160px; }
    /* Stacked layout only: labels move onto the photo, the way property portals
       show them. On desktop they stay in the flow above the title. */
    .oloele-pms .pms-card-labels {
        position: absolute;
        top: 8px;
        left: 8px;
        z-index: 2;
        margin-bottom: 0;
    }
}
