/**
 * Leaflet Map Improvements CSS
 * - Loading animation
 * - Better filter design
 * - Marker hover effects
 */

/* ========================================
   LOADING ANIMATION
   ======================================== */

.cspm-map-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cspm-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #3498db;
    border-radius: 50%;
    animation: cspm-spin 1s linear infinite;
}

@keyframes cspm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cspm-loading-text {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    animation: cspm-pulse 1.5s ease-in-out infinite;
}

@keyframes cspm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   УЛУЧШЕННЫЙ ДИЗАЙН ФИЛЬТРА
   ======================================== */

/* Кнопка фильтра */
div.faceted_search_btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
    padding: 12px 16px !important;
    transition: all 0.3s ease !important;
}

div.faceted_search_btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6) !important;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
}

div.faceted_search_btn img,
div.faceted_search_btn svg {
    filter: brightness(0) invert(1);
}

/* Контейнер фильтра */
div[class^=faceted_search_container] {
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    overflow: hidden !important;
    min-width: 280px !important;
}

/* Заголовок фильтра */
div[class^=faceted_search_container]::before {
    content: 'Фильтр по категориям';
    display: block;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Форма фильтра */
div[class^=faceted_search_container] form.faceted_search_form ul {
    padding: 16px 20px 20px !important;
    margin: 0 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}

/* Прокрутка */
div[class^=faceted_search_container] form.faceted_search_form ul::-webkit-scrollbar {
    width: 8px;
}

div[class^=faceted_search_container] form.faceted_search_form ul::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

div[class^=faceted_search_container] form.faceted_search_form ul::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

div[class^=faceted_search_container] form.faceted_search_form ul::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Элементы списка - базовые стили заменены на улучшенные ниже */

div[class^=faceted_search_container] form.faceted_search_form ul li:first-child {
    padding-top: 10px !important;
}

div[class^=faceted_search_container] form.faceted_search_form ul li:last-child {
    border-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Checkbox стили */
div[class^=faceted_search_container] form.faceted_search_form ul li div[class^=icheckbox_],
div[class^=faceted_search_container] form.faceted_search_form ul li div[class^=iradio_] {
    float: left;
    margin-right: 12px;
}

/* Label стили */
div[class^=faceted_search_container] form.faceted_search_form ul li label {
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #2d3748 !important;
    cursor: pointer !important;
    margin-left: 12px !important;
    line-height: 22px !important;
    transition: color 0.2s ease !important;
}

div[class^=faceted_search_container] form.faceted_search_form ul li:hover label {
    color: #667eea !important;
}

/* ЭЛЕМЕНТЫ СПИСКА - БЕЗ ЧЕКБОКСОВ, ВЫБОР ПО КЛИКУ */
div[class^=faceted_search_container] form.faceted_search_form ul li {
    padding: 14px 18px !important;
    margin-bottom: 8px !important;
    background: #f8f9fa !important;
    border-radius: 10px !important;
    border: 2px solid transparent !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    position: relative !important;
    user-select: none !important;
}

/* HOVER эффект */
div[class^=faceted_search_container] form.faceted_search_form ul li:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%) !important;
    border-color: rgba(102, 126, 234, 0.3) !important;
    transform: translateX(6px) !important;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.1) !important;
}

/* АКТИВНОЕ состояние (выбрано) */
div[class^=faceted_search_container] form.faceted_search_form ul li.cspm-filter-active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%) !important;
    border-color: #667eea !important;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.25) !important;
    transform: translateX(6px) !important;
}

/* Индикатор выбора - галочка */
div[class^=faceted_search_container] form.faceted_search_form ul li.cspm-filter-active::after {
    content: '✓';
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    font-size: 20px;
    font-weight: bold;
    animation: cspm-check-pop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes cspm-check-pop {
    0% {
        transform: translateY(-50%) scale(0);
        opacity: 0;
    }
    50% {
        transform: translateY(-50%) scale(1.3);
    }
    100% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
}

/* Счетчик выбранных */
div[class^=faceted_search_container] form.faceted_search_form::after {
    content: '';
    display: block;
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 13px;
    color: #6c757d;
    text-align: center;
}

/* Mobile responsive */
@media (max-width: 767px) {
    div[class^=faceted_search_container] {
        min-width: 260px !important;
        max-width: calc(100vw - 40px) !important;
    }
    
    div[class^=faceted_search_container] form.faceted_search_form ul {
        max-height: 250px !important;
    }
}

/* ========================================
   МАРКЕРЫ С HOVER ЭФФЕКТОМ
   ======================================== */

.cspm-marker-with-image {
    background: transparent !important;
    border: none !important;
}

.cspm-marker-thumbnail {
    cursor: pointer !important;
    position: relative !important;
}

.cspm-marker-thumbnail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.cspm-marker-thumbnail:hover::after {
    background: rgba(102, 126, 234, 0.2);
}

/* ========================================
   ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ
   ======================================== */

/* Плавная анимация для Leaflet маркеров */
.leaflet-marker-icon {
    transition: transform 0.2s ease !important;
}

/* Улучшенный zoom control */
.cspm_zoom_container {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

div.cspm_zoom_in_control,
div.cspm_zoom_out_control {
    background: white !important;
    transition: all 0.2s ease !important;
}

div.cspm_zoom_in_control:hover,
div.cspm_zoom_out_control:hover {
    background: #f0f0f0 !important;
    transform: scale(1.05) !important;
}

/* Улучшенная тень для карты */
div[id^=codespacing_progress_map_div] {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

/* Прелоадер для lazy load изображений */
.cspm-marker-thumbnail img[loading=\"lazy\"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: cspm-shimmer 1.5s infinite;
}

@keyframes cspm-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Плавное появление карты */
div[id^=codespacing_progress_map_div] {
    animation: cspm-fade-in 0.5s ease-in;
}

@keyframes cspm-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Улучшенный marker cluster */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #667eea !important;
    font-weight: 600 !important;
}
