/* Property map listing — Airbnb-style split layout */

@media (min-width: 992px) {
    .properties-listing-page--map .properties-listing {
        max-width: none;
        padding-left: 0;
        padding-right: 0;
    }
}

.properties-listing-page--map .properties-listing__breadcrumb,
.properties-listing-page--map .properties-listing__intro,
.properties-listing-page--map .properties-filter-bar,
.properties-listing-page--map .properties-listing__toolbar {
    padding-left: max(1rem, calc((min(100vw, 100%) - 1400px) / 2 + 1rem));
    padding-right: max(1rem, calc((min(100vw, 100%) - 1400px) / 2 + 1rem));
}

.properties-map-layout {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-height: calc(100vh - var(--properties-map-top-offset, 220px));
    border-top: 1px solid #e2e8f0;
    max-width: 100%;
}

.properties-list-panel {
    flex: 0 0 58%;
    max-width: 58%;
    min-width: 0;
    padding: 15px max(1rem, calc((min(100vw, 100%) - 1400px) / 2 + 1rem)) 2.5rem;
    overflow-x: clip;
}

.properties-list-panel .properties-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.properties-listing-page--map .properties-filter-bar .properties-listing__toolbar {
    width: 100%;
    flex-basis: 100%;
    margin: 0.75rem 0 0;
    padding-bottom: 0;
    border-bottom: none;
}

.properties-list-panel .properties-pagination {
    margin-top: 0.5rem;
    padding-bottom: 1rem;
}

.properties-map-panel {
    flex: 0 0 42%;
    max-width: 42%;
    position: sticky;
    top: var(--properties-map-sticky-top, 0);
    align-self: flex-start;
    height: calc(100vh - var(--properties-map-top-offset, 220px));
    z-index: 20;
    padding-top: 10px;
}

.properties-map-panel__inner {
    position: relative;
    width: 100%;
    height: 100%;
    background: #e8eef4;
}

.properties-map-canvas {
    width: 100%;
    height: 100%;
}

/* Price pins — estilo pill (Airbnb / Idealista) */
.property-price-marker {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #ffffff;
    color: #222222;
    border-radius: 999px;
    padding: 8px 13px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-body, system-ui, -apple-system, sans-serif);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.14),
        0 8px 22px rgba(0, 0, 0, 0.12);
    transform: translateY(0) scale(1);
    transition:
        transform 180ms ease,
        box-shadow 180ms ease,
        background 180ms ease,
        color 180ms ease,
        border-color 180ms ease;
}

.property-price-marker:hover,
.property-price-marker.is-active {
    background: #222222;
    color: #ffffff;
    border-color: #222222;
    transform: translateY(-2px) scale(1.08);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.22),
        0 16px 38px rgba(0, 0, 0, 0.22);
    z-index: 10;
}

.property-price-marker span {
    display: block;
}

.mapboxgl-marker:has(.property-price-marker.is-active),
.mapboxgl-marker:has(.property-price-marker:hover) {
    z-index: 10 !important;
}

.properties-map-panel .mapboxgl-ctrl-bottom-right,
.properties-map-panel .mapboxgl-ctrl-bottom-left {
    margin-bottom: 1rem;
}

/* Price pins (HTML markers) */
.property-price-marker {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #ffffff;
    color: #222222;
    border-radius: 999px;
    padding: 8px 13px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.14),
        0 8px 22px rgba(0, 0, 0, 0.12);
    transform: translateY(0) scale(1);
    transition:
        transform 180ms ease,
        box-shadow 180ms ease,
        background 180ms ease,
        color 180ms ease,
        border-color 180ms ease;
    font-family: var(--font-body, 'Fira Sans', system-ui, sans-serif);
}

.property-price-marker:hover,
.property-price-marker.is-active {
    background: #222222;
    color: #ffffff;
    border-color: #222222;
    transform: translateY(-2px) scale(1.08);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.22),
        0 16px 38px rgba(0, 0, 0, 0.22);
    z-index: 10;
}

.property-price-marker span {
    display: block;
}

.mapboxgl-marker:has(.property-price-marker.is-active) {
    z-index: 10 !important;
}

.search-this-area-btn {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 0.6rem 1.15rem;
    border: none;
    border-radius: 999px;
    background: #fff;
    color: var(--text, #0f172a);
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.search-this-area-btn:hover {
    transform: translateX(-50%) translateY(-1px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.search-this-area-btn[hidden] {
    display: none !important;
}

.properties-map-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    background: rgba(248, 250, 252, 0.88);
    z-index: 4;
    pointer-events: none;
}

.properties-map-overlay[hidden] {
    display: none !important;
}

.properties-map-overlay--error {
    pointer-events: auto;
}

.properties-map-overlay__spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid #cbd5e1;
    border-top-color: var(--primary, #1e40af);
    border-radius: 50%;
    animation: property-map-spin 0.7s linear infinite;
}

@keyframes property-map-spin {
    to { transform: rotate(360deg); }
}

.properties-map-overlay p {
    margin: 0;
    color: #64748b;
    font-size: 0.9375rem;
}

.properties-map-overlay__retry {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    background: #fff;
    cursor: pointer;
    font-size: 0.875rem;
}

.properties-map-fab,
.properties-list-fab {
    display: none;
}

.property-card.is-map-active {
    box-shadow: 0 0 0 2px var(--primary, #1e40af), 0 16px 40px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.properties-list-root.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Mapbox popup */
.property-map-popup .mapboxgl-popup-content {
    padding: 0;
    border-radius: 0.85rem;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    min-width: 240px;
    max-width: 280px;
}

.property-map-popup .mapboxgl-popup-close-button {
    font-size: 1.25rem;
    padding: 0.35rem 0.5rem;
    color: #fff;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.property-map-popup-card {
    display: block;
    color: inherit;
    text-decoration: none;
}

.property-map-popup-card__media {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f1f5f9;
}

.property-map-popup-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.property-map-popup-card__body {
    padding: 0.85rem 1rem 1rem;
}

.property-map-popup-card__price {
    display: block;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text, #0f172a);
    margin-bottom: 0.25rem;
}

.property-map-popup-card__title {
    margin: 0 0 0.35rem;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.property-map-popup-card__location {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    color: #64748b;
}

.property-map-popup-card__features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 0 0 0.5rem;
    padding: 0;
    list-style: none;
    font-size: 0.75rem;
    color: #475569;
}

.property-map-popup-card__ref {
    font-size: 0.6875rem;
    color: #94a3b8;
    letter-spacing: 0.03em;
}

.property-map-popup-card__cta {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary, #1e40af);
}

.property-map-popup-card:hover .property-map-popup-card__cta {
    text-decoration: underline;
}

/* Mobile — ocultar controlos desktop */
@media (max-width: 991.98px) {
    .properties-map-close-btn,
    .properties-map-toggle-btn--show {
        display: none !important;
    }

    /* Gutter no main.container; filhos sem padding horizontal extra */
    .properties-listing-page--map .properties-listing__breadcrumb,
    .properties-listing-page--map .properties-listing__intro,
    .properties-listing-page--map .properties-filter-bar,
    .properties-listing-page--map .properties-listing__toolbar {
        padding-left: 0;
        padding-right: 0;
    }

    .properties-listing-page--map main.properties-listing.container {
        max-width: 100%;
        padding-inline: var(--tenant-mobile-gutter, 1.125rem);
    }

    .properties-listing-page--map .marketplace-sticky-shell .marketplace-header.container {
        padding-inline: var(--tenant-mobile-gutter, 1.125rem);
    }

    .properties-map-layout {
        flex-direction: column;
        min-height: 0;
        border-top: none;
        max-width: 100%;
        overflow-x: clip;
    }

    .properties-list-panel {
        flex: 1 1 auto;
        max-width: 100%;
        width: 100%;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
        overflow-x: clip;
    }

    .properties-list-panel .properties-grid {
        grid-template-columns: 1fr;
    }

    .properties-map-panel {
        display: none;
        position: fixed;
        inset: 0;
        flex: none;
        max-width: none;
        width: 100%;
        height: 100%;
        z-index: 200;
        top: 0;
    }

    .properties-listing-page--map.is-map-open .properties-map-panel {
        display: block;
    }

    .properties-listing-page--map.is-map-open {
        overflow: hidden;
    }

    .properties-map-fab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        position: fixed;
        bottom: 1.25rem;
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100% - 2rem);
        z-index: 150;
        padding: 0.85rem 1.35rem;
        border: none;
        border-radius: 999px;
        background: var(--text, #0f172a);
        color: #fff;
        font-size: 0.9375rem;
        font-weight: 600;
        box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
        cursor: pointer;
    }

    .properties-map-fab svg {
        width: 1.125rem;
        height: 1.125rem;
    }

    .properties-list-fab {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 210;
        padding: 0.55rem 0.95rem;
        border: none;
        border-radius: 999px;
        background: #fff;
        color: var(--text, #0f172a);
        font-size: 0.875rem;
        font-weight: 600;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
        cursor: pointer;
    }

    .properties-listing-page--map.is-map-open .properties-map-fab {
        display: none;
    }

    .properties-list-fab[hidden] {
        display: none !important;
    }

    .properties-list-fab svg {
        width: 1rem;
        height: 1rem;
    }
}

@media (min-width: 992px) {
    .properties-listing-page--map .properties-listing__toolbar {
        margin-bottom: 0.75rem;
    }

    .properties-map-close-btn {
        position: absolute;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 6;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.5rem 0.85rem;
        border: none;
        border-radius: 999px;
        background: #fff;
        color: var(--text, #0f172a);
        font-size: 0.8125rem;
        font-weight: 600;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
        transition: background 0.2s ease, box-shadow 0.2s ease;
    }

    .properties-map-close-btn svg {
        width: 1rem;
        height: 1rem;
    }

    .properties-map-close-btn:hover {
        background: #f8fafc;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.16);
    }

    .properties-map-toggle-btn--show {
        display: none;
        align-items: center;
        gap: 0.45rem;
        margin-bottom: 1rem;
        padding: 0.55rem 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: #fff;
        color: var(--text, #0f172a);
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    .properties-map-toggle-btn--show svg {
        width: 1rem;
        height: 1rem;
    }

    .properties-map-toggle-btn--show:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-map-panel {
        display: none;
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-list-panel {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-map-layout {
        min-height: 0;
        border-top: none;
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-list-panel .properties-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-map-toggle-btn--show {
        display: inline-flex;
    }

    .properties-listing-page--map.is-desktop-map-collapsed .properties-map-close-btn {
        display: none;
    }
}

@media (min-width: 992px) and (max-width: 1280px) {
    .properties-listing-page--map.is-desktop-map-collapsed .properties-list-panel .properties-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1281px) {
    .properties-listing-page--map.is-desktop-map-collapsed .properties-list-panel .properties-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
