
@media (max-width: 767.98px) and (orientation: portrait) {

    html,
    body {
        height: 100%;
    }

body {
    overflow-x: hidden;
}

    /* Hide desktop-ish toolbar (sorting bar inside cards column) */
    .sticky-toolbar {
        display: none !important;
    }

    /* Topbar */
    #mobile-topbar {
        position: fixed;
        top: 0;
        z-index: 3000;
        display: flex;
        gap: 8px;
        align-items: center;
        padding: 8px 10px;
        background: #fff;
        border-bottom: 1px solid #e9ecef;
    }

    #mobile-topbar #mobile-menu-btn {
        flex: 0 0 auto;
    }

    #mobile-topbar #mobile-sort-select {
        flex: 1 1 auto;
        min-width: 0;
    }

    #mobile-topbar #mobile-filters-btn {
        flex: 0 0 auto;
    }

    /* Active filters row (chips) */
    #mobile-active-filters {
        display: none;
        gap: 8px;
        align-items: center;
        padding: 6px 10px;
        background: #fff;
        border-bottom: 1px solid #f1f3f5;
        overflow-x: auto;
        white-space: nowrap;
        z-index: 1000;
    }

    #mobile-active-filters::-webkit-scrollbar {
        display: none;
    }

    .af-chip {
        border: 1px solid #dee2e6;
        background: #f8f9fa;
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 12px;
        display: inline-flex;
        gap: 6px;
        align-items: center;
        cursor: pointer;
    }

    .af-chip-x {
        font-weight: 700;
        opacity: .7;
    }

    /* Force the results area to become a fixed-height, no-scroll layout */
    .row {
        margin-left: 0;
        margin-right: 0;
    }


    #property-cards {
        order: 2;
        max-height: none !important;
        overflow: hidden !important;
        padding: 0 !important;
    }


    /* BUILDINGS: reorder map & cards */
    #building-cards {
        order: 2;
        max-height: none !important;
        overflow: hidden !important;
    }

    #map-wrapper {
        order: 1;
    }

   #map {
        width: 100%;
    }

    /* Cards area takes ~40-45vh, horizontal snap carousel */
#property-list {
    margin: 0 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    gap: 5px;
    padding: 10px 30px 14px 30px;
    flex: 0 0 auto;
    align-items: stretch;
}
#map-wrapper{
    width:100%;
}

    #property-list::-webkit-scrollbar {
        display: none;
    }

    .mobile-card {
        flex: 0 0 calc(100vw - 60px);
        /* 30px + 30px padding */
        max-width: calc(100vw - 60px);
        scroll-snap-align: center;
        scroll-snap-stop: always;
    }

    /* Make cards fill the carousel height nicely */
    .mobile-card .card {
        height: 100%;
        font-size: 0.8rem;
        display: flex;
        flex-direction: column;
        line-height: 1.25;
    }


    /* Keep gallery visible but not too tall */
    .mobile-card .glide__slide img {
        height: 220px !important;
    }

    /* Loading indicator */
    #loading {
        padding: 10px 0;
    }

    /* Filters form becomes overlay when open */
    #filters-form {
        display: none;
        /* hidden by default on mobile portrait */
    }

    body.mobile-filters-open #filters-form {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 5000;
        margin: 0 !important;
        padding: 70px 12px 90px 12px;
        /* leaves space for overlay header/footer */
        background: #fff;
        overflow-y: auto;
    }

    /* Overlay shell */
    #mobile-filters-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 4800;
        background: rgba(0, 0, 0, 0.45);
    }

    body.mobile-filters-open #mobile-filters-overlay {
        display: block;
    }

    .mfo-panel {
        position: absolute;
        inset: 0;
        background: transparent;
    }

    .mfo-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 5100;
        background: #fff;
        border-bottom: 1px solid #e9ecef;
        padding: 10px 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mfo-title {
        font-weight: 700;
    }

    .mfo-body {
        padding: 0;
    }

    .mfo-footer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 5100;
        background: #fff;
        border-top: 1px solid #e9ecef;
        padding: 10px 12px;
    }

    /* Make Leaflet controls not collide too much */
    .leaflet-top,
    .leaflet-bottom {
        z-index: 2000;
    }

    /* BUILDINGS horizontal carousel */
    /*#building-list {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory;
        gap: 5px;
        padding: 10px 30px 10px 30px;
        height: 40vh;
        -webkit-overflow-scrolling: touch;
    }*/

    #building-list::-webkit-scrollbar {
        display: none;
    }

    #building-list.row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Active filters = second fixed bar */
    #mobile-active-filters {
        position: fixed;
        top: 62px;
        left: 0;
        right: 0;
        display: none;
    }

    body.has-active-filters #mobile-active-filters {
        display: flex;
    }
    
}

@media (max-width: 767.98px) and (orientation: portrait) {
    #building-list {
        height: auto; /* вместо 40vh */
        padding: 10px 30px 14px 30px;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        scroll-snap-type: x mandatory;
        gap: 5px;
        align-items: stretch;
    }

    .mobile-card.building-card {
        flex: 0 0 calc(100vw - 60px);
        max-width: calc(100vw - 60px);
        scroll-snap-align: center;
        scroll-snap-stop: always;
    }

    .mobile-card.building-card .card {
        height: auto; /* позволява на текста да се покаже */
        display: flex;
        flex-direction: column;
    }

    .mobile-card.building-card .glide__slide img {
        height: 220px !important;
        object-fit: cover;
    }
}
/* === Clean mobile hamburger === */
@media (max-width: 767.98px) {

    .navbar-toggler {
        border: none !important;
        box-shadow: none !important;
        padding: 6px 8px;
    }

    .navbar-toggler:focus,
    .navbar-toggler:active {
        outline: none !important;
        box-shadow: none !important;
    }

    .navbar-toggler-icon {
        background-image: var(--bs-navbar-toggler-icon-bg);
        width: 1.6em;
        height: 1.6em;
    }

    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 6000;
    }

    /* компенсация за съдържанието */
    body {
        padding-top: 56px;
        /* височината на navbar */
    }

    .navbar-collapse {
        position: fixed;
        top: 56px;
        /* под navbar */
        left: 0;
        right: 0;
        background: #fff;
        z-index: 5900;
        padding: 12px 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    body.has-active-filters {
        padding-top: 100px;
        /* navbar + active filters */
    }
}

/* === BUILDINGS: active marker (mobile center card) === */
.building-thumb-marker.active,
.building-circle-marker.active {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #d33;
    z-index: 10000 !important;
}

/* ============================
   MOBILE FIX — GLIDE DOTS
   ============================ */
@media (max-width: 767.98px) {

    /* позволяваме dots да излизат над image – само за properties */
    #property-list .glide {
        overflow: visible;
        contain: none !important;
    }

    /* dots позиция – САМО properties */
    #property-list .glide-dots-custom {
        bottom: 10px;
        z-index: 50;
    }
}
