/* Casa Moldova 1.6.6.5: parallel, reversible map list/detail UX experiment. */

.re-map-ux-switch {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 5px 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--re-border, #dce5e8);
    background: #f8fafc;
}

.re-map-ux-switch-label {
    color: var(--re-text, #17212b);
    font-size: 12px;
    font-weight: 800;
}

.re-map-ux-switch-buttons {
    justify-self: end;
    display: inline-flex;
    padding: 2px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
}

.re-map-ux-switch-buttons button {
    min-height: 34px;
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    color: #475569;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.re-map-ux-switch-buttons button.is-active,
.re-map-ux-switch-buttons button[aria-pressed="true"] {
    color: #fff;
    background: var(--re-brand, #064da1);
    box-shadow: 0 3px 9px rgba(15, 23, 42, .14);
}

.re-map-ux-switch-buttons button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--re-brand, #064da1) 28%, transparent);
    outline-offset: 2px;
}

.re-map-ux-switch small {
    grid-column: 1 / -1;
    color: #64748b;
    font-size: 10px;
    line-height: 1.25;
}

.re-list-view-label {
    display: none;
}

.re-map-app.is-ux-optimized .re-list-view-toggle {
    width: auto;
    min-width: 92px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 12px;
    border-color: color-mix(in srgb, var(--re-brand, #064da1) 22%, #dbe4ea);
}

.re-map-app.is-ux-optimized .re-list-view-label {
    display: inline;
    font-size: 12px;
    font-weight: 800;
}

.re-map-app.is-ux-optimized .re-list-view-toggle[aria-pressed="true"] {
    color: #fff;
    background: var(--re-brand, #064da1);
}

.re-map-app.is-ux-optimized .re-card {
    cursor: pointer;
    scroll-margin-top: 84px;
}

.re-map-app.is-ux-optimized .re-card:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--re-brand, #064da1) 34%, transparent);
    outline-offset: 3px;
}

.re-map-app.is-ux-optimized .re-selected-back {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 46px;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid #dbe4ea;
    border-radius: 12px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 5px 18px rgba(15, 23, 42, .09);
    backdrop-filter: blur(10px);
}

/* Normal website mode: the document owns scrolling. The map stays available
 * as a sticky comparison surface, while list and details no longer create a
 * second narrow scrollbar inside the page. */
@media (min-width: 901px) {
    body.bodywebpage-map .re-map-content-embed.is-ux-optimized .re-map-layout {
        height: auto !important;
        min-height: calc(100dvh - var(--estate-header-height, 72px)) !important;
        align-items: start !important;
        overflow: visible !important;
    }

    body.bodywebpage-map .re-map-content-embed.is-ux-optimized .re-map-panel {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        align-self: start !important;
    }

    body.bodywebpage-map .re-map-content-embed.is-ux-optimized .re-card-list,
    body.bodywebpage-map .re-map-content-embed.is-ux-optimized .re-selected-detail-slot {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        overscroll-behavior: auto !important;
    }

    body.bodywebpage-map .re-map-content-embed.is-ux-optimized .re-map-stage {
        position: sticky !important;
        top: var(--estate-header-height, 72px) !important;
        height: calc(100dvh - var(--estate-header-height, 72px)) !important;
        min-height: 580px !important;
        max-height: calc(100dvh - var(--estate-header-height, 72px)) !important;
        align-self: start !important;
    }

    .re-map-content-embed.is-ux-optimized.has-selected-property .re-results-summary {
        display: none !important;
    }

    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-map-layout {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-map-stage {
        display: none !important;
    }

    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-map-panel {
        width: min(100%, 1120px) !important;
        margin: 0 auto !important;
    }

    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-card-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-card-placeholder,
    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-map-list-ad-slot,
    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-map-list-footer,
    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-card-pagination {
        grid-column: 1 / -1;
    }
}

/* Fullscreen remains a workspace with one explicit, easy-to-hit scrollbar. */
.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-card-list,
.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-selected-detail-slot {
    scrollbar-width: auto;
    scrollbar-color: color-mix(in srgb, var(--re-brand, #064da1) 70%, #64748b) #e8eef2;
    scrollbar-gutter: stable;
}

.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-card-list::-webkit-scrollbar,
.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-selected-detail-slot::-webkit-scrollbar {
    width: 14px;
}

.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-card-list::-webkit-scrollbar-thumb,
.re-map-app.is-ux-optimized.is-map-workspace-fullscreen .re-selected-detail-slot::-webkit-scrollbar-thumb {
    min-height: 48px;
    border: 3px solid #e8eef2;
    border-radius: 999px;
    background: color-mix(in srgb, var(--re-brand, #064da1) 70%, #64748b);
}

@media (max-width: 900px) {
    .re-map-app.is-ux-optimized .re-map-panel,
    .re-map-app.is-ux-optimized .re-card-list,
    .re-map-app.is-ux-optimized .re-selected-detail-slot {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .re-map-app.is-ux-optimized.is-ux-list-view .re-map-stage {
        display: none !important;
    }

    .re-map-app.is-ux-optimized.is-ux-list-view .re-map-panel {
        width: 100% !important;
    }
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
    .re-map-ux-switch {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 9px 12px;
    }

    .re-map-ux-switch-label,
    .re-map-ux-switch small {
        text-align: center;
    }

    .re-map-ux-switch-buttons {
        justify-self: stretch;
        width: 100%;
    }

    .re-map-ux-switch-buttons button {
        flex: 1;
        min-height: 44px;
    }

    .re-map-app.is-ux-optimized #re-map > .re-mobile-property-sheet.is-open.is-expanded:not([hidden]) {
        position: fixed !important;
        inset: 0 !important;
        z-index: 10000 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: max(56px, env(safe-area-inset-top)) 0 env(safe-area-inset-bottom) !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: #fff !important;
        box-shadow: none !important;
        overflow: hidden !important;
    }

    .re-map-app.is-ux-optimized #re-map > .re-mobile-property-sheet.is-expanded .re-mobile-property-sheet-content {
        height: calc(100dvh - max(56px, env(safe-area-inset-top)) - env(safe-area-inset-bottom)) !important;
        max-height: none !important;
        padding: 0 0 28px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .re-map-app.is-ux-optimized #re-map > .re-mobile-property-sheet.is-expanded .re-mobile-property-sheet-expand {
        position: absolute !important;
        top: max(6px, env(safe-area-inset-top)) !important;
        left: 12px !important;
        right: 62px !important;
        height: 44px !important;
        justify-content: flex-start !important;
        color: var(--re-brand, #064da1) !important;
        font-size: 13px !important;
    }

    .re-map-app.is-ux-optimized #re-map > .re-mobile-property-sheet.is-expanded .re-mobile-property-sheet-expand-label {
        display: inline !important;
    }

    .re-map-app.is-ux-optimized #re-map > .re-mobile-property-sheet.is-expanded .re-mobile-property-sheet-close {
        position: absolute !important;
        top: max(6px, env(safe-area-inset-top)) !important;
        right: 8px !important;
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
    }
}

html.re-optimized-detail-open,
body.re-optimized-detail-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

@media (max-width: 620px) {
    .re-map-app.is-ux-optimized .re-list-view-toggle {
        min-width: 44px;
        padding: 8px 10px;
    }
}

@media (max-width: 520px) {
    .re-map-content-embed.is-ux-optimized.is-ux-list-view .re-card-list {
        display: flex !important;
        flex-direction: column !important;
    }
}
