/* =========================================
   1. ОСНОВНОЙ КОНТЕЙНЕР КАРТЫ
   ========================================= */
main {
    padding: 0 !important;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

#map-container {
    position: relative;
    width: 100%;
    /* Высота карты = Высота экрана минус высота хедера */
    height: calc(100vh - var(--header-height));
    z-index: 1;
    background-color: #eef2f5;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: filter 0.3s;
}

/* =========================================
   2. ПАНЕЛЬ УПРАВЛЕНИЯ (ПОИСК И ФИЛЬТРЫ)
   ========================================= */
.map-controls-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    width: 340px;
    max-width: calc(100% - 40px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* Пропускаем клики мимо контейнера */
}

/* --- Карточка ПОИСКА (остается с фоном) --- */
.control-card {
    pointer-events: auto; /* Возвращаем клики элементам */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.control-card.search-card:focus-within {
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.15);
}

.search-group {
    display: flex;
    align-items: center;
    height: 48px;
    width: 100%;
}

.search-group input {
    border: none;
    background: transparent !important;
    padding-left: 20px;
    flex-grow: 1;
    height: 100%;
    outline: none;
    font-size: 0.95rem;
    color: #333;
}

.search-group button {
    background: transparent;
    border: none;
    padding: 0 20px;
    height: 100%;
    color: var(--primary-color);
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.search-group button:hover {
    transform: scale(1.1);
}

/* --- Контейнер ФИЛЬТРОВ (теперь прозрачный везде) --- */
.filters-card {
    /* Убираем фон и тени, делаем прозрачным */
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 5px 0 0 0; /* Небольшой отступ от поиска */
    pointer-events: none; /* Клик проходит сквозь пустое место */
}

/* Скрываем заголовок "ФИЛЬТРЫ", он не нужен без плашки */
.filters-card h6 {
    display: none;
}

/* Контейнер для кнопок-чипсов */
.filter-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    pointer-events: auto; /* Возвращаем клики самим кнопкам */
}

/* Стиль чекбокса как кнопки (Chip) */
.filter-chip-wrapper {
    position: relative;
    cursor: pointer;
    flex-shrink: 0; 
}

.filter-chip-wrapper input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.filter-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* Фон самой кнопки */
    background: #ffffff; 
    padding: 8px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Легкая тень для кнопки */
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    user-select: none;
    white-space: nowrap;
}

/* Состояние: Активен */
.filter-chip-wrapper input:checked + .filter-chip-label {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
    padding-right: 16px;
    border-color: transparent;
}

.filter-chip-label i {
    font-size: 1rem;
}

/* =========================================
   3. КНОПКИ ДЕЙСТВИЙ
   ========================================= */
.map-action-buttons {
    position: absolute;
    bottom: 40px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
    transition: bottom 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.action-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    border: none;
    font-size: 1.5rem;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.action-btn:hover { transform: scale(1.1); }
.action-btn:active { transform: scale(0.95); }

.action-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.4);
}

/* =========================================
   4. МОБИЛЬНАЯ ШТОРКА
   ========================================= */
#mobile-bottom-sheet {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #ffffff;
    z-index: 1050;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -5px 30px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    visibility: hidden;
}

#mobile-bottom-sheet.active {
    transform: translateY(0);
    visibility: visible;
}

.sheet-handle-bar {
    width: 100%; height: 28px;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; flex-shrink: 0; padding-top: 10px;
}

.sheet-handle {
    width: 40px; height: 5px;
    background: #e0e0e0; border-radius: 10px;
}

.sheet-content {
    padding: 0 20px 30px 20px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sheet-content::-webkit-scrollbar { display: none; }

.sheet-close-btn {
    position: absolute; top: 15px; right: 15px;
    background: #f1f3f5; border: none;
    width: 32px; height: 32px; border-radius: 50%;
    color: #555; z-index: 2;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

.toilet-details-view { font-family: 'Montserrat', sans-serif; }

/* =========================================
   5. LEAFLET OVERRIDES
   ========================================= */
.leaflet-right .leaflet-control-zoom {
    margin-right: 20px !important; margin-top: 20px !important;
    border: none !important; box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    border-radius: 12px !important;
}
.leaflet-control-zoom a {
    width: 40px !important; height: 40px !important; line-height: 40px !important;
    color: #333 !important; border-radius: 0 !important; background: white !important;
}
.leaflet-control-zoom a:first-child { border-radius: 12px 12px 0 0 !important; border-bottom: 1px solid #eee !important; }
.leaflet-control-zoom a:last-child { border-radius: 0 0 12px 12px !important; }

.leaflet-popup-content-wrapper {
    border-radius: 16px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
    padding: 0 !important; overflow: hidden;
}
.leaflet-popup-content { margin: 15px !important; width: 280px !important; }
.leaflet-popup-close-button { top: 10px !important; right: 10px !important; color: #999 !important; font-size: 20px !important; }

/* =========================================
   6. MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 768px) {
    /* Панель управления на всю ширину */
    .map-controls-overlay {
        top: 10px;
        left: 0; right: 0;
        width: 100%;
        padding: 0 15px; /* Отступы по краям экрана */
        max-width: none;
        gap: 10px;
    }
    
    .filters-card {
        padding-top: 0;
        overflow: visible;
    }
    
    /* Горизонтальный скролл для фильтров (Chips) */
    .filter-chips-container {
        display: flex;
        flex-wrap: wrap !important; /* На мобильных тоже переносим */
        justify-content: flex-start;
        gap: 8px;
    }
    
    .filter-chip-label {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    /* КНОПКИ ДЕЙСТВИЙ */
    .map-action-buttons {
        bottom: 90px;
        right: 15px;
        flex-direction: column;
        gap: 15px;
        z-index: 1040;
    }
    
    body.sheet-open .map-action-buttons {
        opacity: 0; 
        pointer-events: none;
        transition: opacity 0.2s;
    }

    .leaflet-control-zoom { display: none !important; }
}

/* =========================================
   7. DARK MODE SUPPORT
   ========================================= */
[data-bs-theme="dark"] #map-container { background-color: #121212; }
[data-bs-theme="dark"] .leaflet-layer,
[data-bs-theme="dark"] .leaflet-control-attribution { filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%); }

[data-bs-theme="dark"] .control-card {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] #mobile-bottom-sheet,
[data-bs-theme="dark"] .leaflet-popup-content-wrapper {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .search-group input { color: #fff; }
[data-bs-theme="dark"] .search-group button { color: #fff; }

[data-bs-theme="dark"] .filter-chip-label {
    background: #2c2c2c;
    color: #bbb;
    border-color: #444;
}
[data-bs-theme="dark"] .filter-chip-wrapper input:checked + .filter-chip-label {
    background: var(--primary-color);
    color: white;
    border-color: transparent;
}

[data-bs-theme="dark"] .sheet-handle { background: #444; }
[data-bs-theme="dark"] .sheet-close-btn { background: #333; color: #fff; }
[data-bs-theme="dark"] .toilet-details-view .text-dark { color: #fff !important; }
[data-bs-theme="dark"] .toilet-details-view .text-muted { color: #aaa !important; }
[data-bs-theme="dark"] .toilet-details-view .text-secondary { color: #ccc !important; }
[data-bs-theme="dark"] .toilet-details-view .bg-light { background-color: #252525 !important; border-color: #333 !important; }
[data-bs-theme="dark"] .toilet-details-view .btn-light { background-color: #333; border-color: #444; color: #fff; }
[data-bs-theme="dark"] .action-btn { background: #333; color: #fff; }
[data-bs-theme="dark"] .action-btn.primary { background: var(--primary-gradient); color: white; }
[data-bs-theme="dark"] .leaflet-popup-tip { background: #333; }