/* === Map View Layout === */
.cfm-wrap {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    grid-template-rows: 1fr;
    gap: 20px;
    align-items: stretch;
    height: 100vh;
    font-family: inherit;
    box-sizing: border-box;
}

/* --- Sidebar --- */
.cfm-sidebar {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 24px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.05);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    box-sizing: border-box;
}

.cfm-sidebar .cf-filter-group {
    flex: unset;
    width: 100%;
}

.cfm-sidebar .cf-select-wrap {
    width: 100%;
}

.cfm-sidebar .cf-select {
    width: 100%;
    box-sizing: border-box;
}

.cfm-sidebar .cf-reset-btn {
    width: 100%;
    text-align: center;
}

.cfm-count {
    font-size: 12px;
    color: #888;
    text-align: center;
    min-height: 16px;
}

/* --- Map container --- */
.cfm-wrap .leaflet-top,
.cfm-wrap .leaflet-bottom {
    z-index: 400;
}

.cfm-map-container {
    position: relative;
    border-radius: 16px;
    z-index: 1;
    overflow: visible;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,.05);
    height: 100%;
}

#cfm-map {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
}

.cfm-map-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* --- List panel --- */
.cfm-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

/* Prevent cards from shrinking to fit the container — show full card, let container scroll */
.cfm-list .cf-card {
    flex-shrink: 0;
}

.cfm-list::-webkit-scrollbar { width: 4px; }
.cfm-list::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 2px; }
.cfm-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* --- "Детальніше" link inside list card --- */
.cfm-card-link,
.cfm-card-link:visited {
    display: inline-block;
    margin-top: 4px;
    background: #ff8300;
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none !important;
    transition: background .15s;
    align-self: flex-start;
}

.cfm-card-link:hover {
    background: #d96e00;
    color: #fff !important;
    text-decoration: none !important;
}

/* cfm-list-card: card inside list panel (click pans map) */
.cfm-list-card {
    cursor: pointer;
}

.cfm-list-card--active {
    border-color: #ff8300 !important;
    box-shadow: 0 0 0 3px rgba(255,131,0,.15) !important;
}

/* --- List item (legacy, kept for safety) --- */
.cfm-list-item {
    display: flex;
    gap: 12px;
    background: #fff;
    border: 1.5px solid #e8e8e8;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    text-decoration: none;
    color: inherit;
}

.cfm-list-item:hover {
    border-color: #bbb;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.cfm-list-item--active {
    border-color: #ff8300;
    box-shadow: 0 0 0 3px rgba(255,131,0,.15);
}

.cfm-list-item__thumb {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.cfm-list-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cfm-list-item__thumb--placeholder {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #e8e8e8, #d8d8d8);
    border-radius: 8px;
    flex-shrink: 0;
}

.cfm-list-item__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.cfm-list-item__title {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cfm-list-item__desc {
    font-size: 11px;
    color: #888;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Google Maps InfoWindow: scrollable when tall --- */
.gm-style-iw-d {
    overflow-y: auto !important;
    max-height: 320px !important;
    scrollbar-width: none !important;
}
.gm-style-iw-d::-webkit-scrollbar {
    display: none !important;
}
.gm-style-iw {
    padding: 0 !important;
    overflow: hidden !important;
}
.gm-style-iw-c {
    padding: 0 !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,.18) !important;
    max-height: none !important;
    overflow: hidden !important;
}
/* Close button — overlays on top-right of the image */
.gm-style-iw-c button.gm-ui-hover-effect {
    top: 6px !important;
    right: 6px !important;
    width: 26px !important;
    height: 26px !important;
    background: rgba(0,0,0,.45) !important;
    border-radius: 50% !important;
    opacity: 1 !important;
}
.gm-style-iw-c button.gm-ui-hover-effect span {
    width: 14px !important;
    height: 14px !important;
    margin: 6px !important;
    filter: invert(1) !important;
}
.gm-style-iw-t::after {
    display: none;
}

/* --- Google Maps InfoWindow overrides --- */
.gm-style .gm-style-iw-chr {
    display: none !important;
}
.gm-style .gm-style-iw {
    padding: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0,0,0,.18) !important;
    max-height: none !important;
}
.gm-style .gm-style-iw-d {
    overflow-y: auto !important;
    max-height: 320px !important;
    scrollbar-width: none !important;
}
.gm-style .gm-style-iw-d::-webkit-scrollbar {
    display: none !important;
}
.gm-style .gm-style-iw-tc {
    display: none !important;
}

/* Custom close button inside Google Maps popup */
.cfm-popup {
    position: relative;
}
.cfm-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #1a1a1a;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    z-index: 10;
    transition: background .15s;
}
.cfm-popup__close:hover {
    background: #ff8300;
}

/* --- Leaflet popup close button --- */
.cfm-leaflet-popup .leaflet-popup-close-button {
    width: 24px;
    height: 24px;
    background: #1a1a1a !important;
    color: #fff !important;
    border-radius: 50%;
    border: 2px solid #fff !important;
    top: 12px !important;
    right: -10px !important;
    font-size: 16px !important;
    line-height: 20px !important;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    z-index: 10;
}

.cfm-leaflet-popup .leaflet-popup-close-button:hover {
    background: #ff8300 !important;
    color: #fff !important;
}

/* --- Leaflet popup overrides --- */
.cfm-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    border: none;
}

.cfm-leaflet-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 260px !important;
}

.cfm-leaflet-popup .leaflet-popup-tip-container {
    display: none;
}

.cfm-popup {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
}

.cfm-popup__img {
    width: 100% !important;
    height: 150px !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

.cfm-popup__img--placeholder {
    width: 100%;
    height: 150px;
    background: linear-gradient(135deg, #e8e8e8, #d8d8d8);
}

.cfm-popup__body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cfm-popup__title {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
}

.cfm-popup__desc {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cfm-popup__address {
    font-size: 11px;
    color: #999;
    margin: 0;
}

.cfm-popup__btn,
.cfm-popup__btn:visited {
    display: inline-block;
    margin-top: 6px;
    background: #ff8300;
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none !important;
    transition: background .15s;
    align-self: flex-start;
}

.cfm-popup__btn:hover,
.cfm-popup__btn:focus {
    background: #d96e00;
    color: #fff !important;
    text-decoration: none !important;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .cfm-wrap {
        grid-template-columns: 220px 1fr 260px;
        gap: 14px;
    }
}

@media (max-width: 768px) {
    .cfm-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
    }
    #cfm-map {
        height: 400px;
    }
    .cfm-map-container {
        height: auto;
    }
    .cfm-list {
        height: 400px;
    }
}

/* === Footer Map === */
.cfm-footer-wrap {
    width: 100%;
    height: 300px;
    position: relative;
}

#cfm-footer-map {
    width: 100%;
    height: 100%;
}
