/* Современные кастомные модальные окна фильтров */

/* Увеличиваем z-index для SweetAlert, чтобы он появлялся поверх кастомных модальных окон */
.swal2-custom-z-index {
    z-index: 100000 !important;
}

.swal2-custom-z-index .swal2-popup {
    z-index: 100001 !important;
}

.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-modal-container {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    max-width: 352px; /* Увеличено с 320px на 10% */
    width: 88%; /* Увеличено с 80% на 10% */
    max-height: 61.6vh; /* Увеличено с 56vh на 10% */
    overflow: hidden;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px) scale(0.95);
    }
    to {
        transform: translateY(0) scale(1);
    }
}

/* Заголовок модального окна */
.custom-modal-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 0.88rem 1.1rem; /* Увеличено с 0.8rem 1rem на 10% */
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.custom-modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
    pointer-events: none;
}

.custom-modal-title {
    margin: 0;
    font-size: 0.99rem; /* Увеличено с 0.9rem на 10% */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.44rem; /* Увеличено с 0.4rem на 10% */
    position: relative;
    z-index: 1;
}

.custom-modal-title i {
    font-size: 0.99rem; /* Увеличено с 0.9rem на 10% */
    opacity: 0.9;
}

.custom-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 26.4px; /* Увеличено с 24px на 10% */
    height: 26.4px; /* Увеличено с 24px на 10% */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.99rem; /* Увеличено с 0.9rem на 10% */
    font-weight: bold;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.custom-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Тело модального окна */
.custom-modal-body {
    padding: 1.1rem; /* Увеличено с 1rem на 10% */
    flex: 1; /* Растягиваем тело модального окна на всю доступную высоту */
    min-height: 0; /* Позволяет телу сжиматься */
    display: flex; /* Включаем flexbox для правильного распределения пространства */
    flex-direction: column; /* Вертикальное расположение элементов */
    overflow: hidden; /* Убираем прокрутку, так как она будет у внутренних элементов */
}

.custom-modal-body::-webkit-scrollbar {
    width: 6px;
}

.custom-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.custom-modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.custom-modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Поиск в модальном окне */
.search-wrapper {
    margin-bottom: 1.375rem; /* Увеличено с 1.25rem на 10% */
    position: relative;
    flex-shrink: 0; /* Предотвращаем сжатие поиска */
}

.search-wrapper::before {
    content: '🔍';
    position: absolute;
    left: 13.2px; /* Увеличено с 12px на 10% */
    top: 50%;
    transform: translateY(-50%);
    font-size: 15.4px; /* Увеличено с 14px на 10% */
    opacity: 0.6;
    z-index: 2;
    pointer-events: none;
}

.search-wrapper .filter-search {
    border: 2px solid #e9ecef;
    border-radius: 13.2px; /* Увеличено с 12px на 10% */
    padding: 0.825rem 1.1rem 0.825rem 2.75rem; /* Увеличено с 0.75rem 1rem 0.75rem 2.5rem на 10% */
    font-size: 1.045rem; /* Увеличено с 0.95rem на 10% */
    background: #f8f9fa;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.search-wrapper .filter-search:focus {
    border-color: #2c3e50;
    background: white;
    box-shadow: 0 4px 16px rgba(44, 62, 80, 0.15);
    outline: none;
}

.search-wrapper .filter-search::placeholder {
    color: #6c757d;
    opacity: 0.7;
}

/* Контролы фильтра */
.filter-controls {
    margin-bottom: 0.88rem; /* Увеличено с 0.8rem на 10% */
    margin-top: -0.55rem; /* Увеличено с -0.5rem на 10% */
    padding: 0.44rem 0.66rem; /* Увеличено с 0.4rem 0.6rem на 10% */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 6.6px; /* Увеличено с 6px на 10% */
    border: 1px solid #e9ecef;
    flex-shrink: 0; /* Предотвращаем сжатие контролов */
}

.select-all-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-height: 1.2rem;
}

.select-all-checkbox {
    width: 14px;
    height: 14px;
    border: 2px solid #2c3e50;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    appearance: none;
    background: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.select-all-checkbox:checked {
    background: #2c3e50;
    border-color: #2c3e50;
}

.select-all-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 8px;
    font-weight: bold;
}

.select-all-checkbox:indeterminate {
    background: #2c3e50;
    border-color: #2c3e50;
}

.select-all-checkbox:indeterminate::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 2px;
    background: white;
    border-radius: 1px;
}

.select-all-label {
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.2;
}

.selected-count {
    background: #2c3e50;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: auto;
    line-height: 1.2;
}

/* Контейнер элементов фильтра */
.filter-items-container {
    flex: 1; /* Растягиваем контейнер на всю доступную высоту */
    min-height: 0; /* Позволяет контейнеру сжиматься */
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: white;
    display: flex; /* Включаем flexbox */
    flex-direction: column; /* Вертикальное расположение */
    overflow: hidden; /* Убираем прокрутку, так как она будет у внутреннего списка */
}

/* Внутренний список элементов фильтра */
.filter-items-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.filter-items-container::-webkit-scrollbar {
    width: 6px;
}

.filter-items-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.filter-items-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.filter-items-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Элементы фильтра */
.filter-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f8f9fa;
    transition: all 0.2s ease;
    cursor: pointer;
}

.filter-item:last-child {
    border-bottom: none;
}

.filter-item:hover {
    background: #f8f9fa;
    transform: translateX(4px);
}

.filter-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border: 2px solid #2c3e50;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 0.75rem;
    appearance: none;
    background: white;
    transition: all 0.2s ease;
    position: relative;
}

.filter-item input[type="checkbox"]:checked {
    background: #2c3e50;
    border-color: #2c3e50;
}

.filter-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.filter-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
    color: #495057;
    margin: 0;
    user-select: none;
}

/* Индикатор загрузки */
.loading-indicator {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

.loading-indicator .custom-spinner {
    width: 2rem;
    height: 2rem;
    border: 0.2rem solid #e9ecef;
    border-top: 0.2rem solid #2c3e50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Футер модального окна */
.custom-modal-footer {
    padding: 1.1rem 1.375rem; /* Увеличено с 1rem 1.25rem на 10% */
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.66rem; /* Увеличено с 0.6rem на 10% */
    justify-content: flex-end;
    margin-top: auto;
    flex-shrink: 0;
}

.custom-modal-footer .modal-btn {
    padding: 0.55rem 1.1rem; /* Увеличено с 0.5rem 1rem на 10% */
    border-radius: 6.6px; /* Увеличено с 6px на 10% */
    font-weight: 600;
    font-size: 0.935rem; /* Увеличено с 0.85rem на 10% */
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.44rem; /* Увеличено с 0.4rem на 10% */
}

.custom-modal-footer .modal-btn-secondary {
    background: #6c757d;
    color: white;
}

.custom-modal-footer .modal-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.custom-modal-footer .modal-btn-primary {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
}

.custom-modal-footer .modal-btn-primary:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

/* Стили для иконок в кнопках */
.custom-modal-footer .modal-btn i {
    font-size: 0.88rem; /* Увеличено с 0.8rem на 10% */
    opacity: 0.9;
}

/* Адаптивность */
@media (max-width: 768px) {
    .custom-modal-container {
        width: 79.2%; /* Увеличено с 72% на 10% */
        max-height: 39.6vh; /* Увеличено с 36vh на 10% */
        border-radius: 8px;
        margin: 0.6rem;
        display: flex;
        flex-direction: column;
        transform: scale(0.88); /* Увеличено с 0.8 на 10% */
        transform-origin: center center;
    }
    
    .custom-modal-header {
        padding: 0.5rem 0.7rem;
    }
    
    .custom-modal-title {
        font-size: 0.8rem;
    }
    
    .custom-modal-title i {
        font-size: 0.9rem;
    }
    
    .custom-modal-close {
        width: 20px;
        height: 20px;
        font-size: 0.8rem;
    }
    
    .custom-modal-body {
        padding: 0.6rem;
        flex: 1; /* Растягиваем тело модального окна на всю доступную высоту */
        min-height: 0; /* Позволяет телу сжиматься */
        display: flex; /* Включаем flexbox для правильного распределения пространства */
        flex-direction: column; /* Вертикальное расположение элементов */
    }
    
    .search-wrapper {
        margin-bottom: 0.8rem;
        flex-shrink: 0; /* Предотвращаем сжатие поиска */
    }
    
    .search-wrapper .filter-search {
        padding: 0.5rem 0.8rem 0.5rem 1.8rem;
        font-size: 0.8rem;
    }
    
    .search-wrapper::before {
        left: 8px;
        font-size: 10px;
    }
    
    .filter-controls {
        margin-bottom: 0.5rem;
        margin-top: -0.2rem;
        padding: 0.2rem 0.4rem;
        flex-shrink: 0; /* Предотвращаем сжатие контролов */
    }
    
    .select-all-wrapper {
        gap: 0.2rem;
        min-height: 0.8rem;
    }
    
    .select-all-checkbox {
        width: 10px;
        height: 10px;
    }
    
    .select-all-label {
        font-size: 0.75rem;
    }
    
    .selected-count {
        font-size: 0.6rem;
        padding: 0.1rem 0.3rem;
    }
    
    .filter-items-container {
        flex: 1; /* Растягиваем контейнер на всю доступную высоту */
        min-height: 0; /* Позволяет контейнеру сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
        display: flex; /* Включаем flexbox */
        flex-direction: column; /* Вертикальное расположение */
    }
    
    /* Стили для внутреннего списка элементов */
    .filter-items-list {
        flex: 1; /* Растягиваем список на всю доступную высоту контейнера */
        min-height: 0; /* Позволяет списку сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
    }
    
    .filter-item {
        padding: 0.5rem 0.6rem;
    }
    
    .filter-item input[type="checkbox"] {
        width: 12px;
        height: 12px;
        margin-right: 0.5rem;
    }
    
    .filter-item label {
        font-size: 0.8rem;
    }
    
    .custom-modal-footer {
        padding: 0.6rem 0.8rem;
        flex-direction: row;
        gap: 0.4rem;
        justify-content: space-between;
        margin-top: auto;
        flex-shrink: 0;
    }
    
    .custom-modal-footer .modal-btn {
        width: auto;
        flex: 1;
        justify-content: center;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        min-width: 80px;
    }
    
    .custom-modal-footer .modal-btn i {
        font-size: 0.75rem;
    }
    
    .loading-indicator {
        padding: 1.2rem;
    }
    
    .loading-indicator .custom-spinner {
        width: 1.2rem;
        height: 1.2rem;
    }
    
    .loading-indicator p {
        font-size: 0.8rem;
        margin-top: 0.4rem;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .custom-modal-container {
        width: 86.24%; /* Увеличено с 78.4% на 10% */
        max-height: 39.6vh; /* Увеличено с 36vh на 10% */
        margin: 0.4rem;
        border-radius: 6px;
        display: flex;
        flex-direction: column;
        transform: scale(0.88); /* Увеличено с 0.8 на 10% */
        transform-origin: center center;
    }
    
    .custom-modal-header {
        padding: 0.5rem 0.6rem;
    }
    
    .custom-modal-title {
        font-size: 0.85rem;
    }
    
    .custom-modal-body {
        padding: 0.6rem;
        flex: 1; /* Растягиваем тело модального окна на всю доступную высоту */
        min-height: 0; /* Позволяет телу сжиматься */
        display: flex; /* Включаем flexbox для правильного распределения пространства */
        flex-direction: column; /* Вертикальное расположение элементов */
    }
    
    .filter-items-container {
        flex: 1; /* Растягиваем контейнер на всю доступную высоту */
        min-height: 0; /* Позволяет контейнеру сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
        display: flex; /* Включаем flexbox */
        flex-direction: column; /* Вертикальное расположение */
    }
    
    /* Стили для внутреннего списка элементов */
    .filter-items-list {
        flex: 1; /* Растягиваем список на всю доступную высоту контейнера */
        min-height: 0; /* Позволяет списку сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
    }
    
    .filter-item {
        padding: 0.4rem 0.5rem;
    }
    
    .filter-item label {
        font-size: 0.75rem;
    }
    
    .custom-modal-footer {
        padding: 0.5rem 0.6rem;
        flex-direction: row;
        gap: 0.3rem;
        justify-content: space-between;
        margin-top: auto;
        flex-shrink: 0;
    }
    
    .custom-modal-footer .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        flex: 1;
        min-width: 70px;
    }
    
    .custom-modal-footer .btn i {
        font-size: 0.7rem;
    }
}

/* Дополнительные стили для мобильных устройств в портретной ориентации */
@media (max-width: 768px) and (orientation: portrait) {
    .custom-modal-container {
        width: 77%; /* Увеличено с 70% на 10% */
        max-height: 35.2vh; /* Увеличено с 32vh на 10% */
        transform: scale(0.825); /* Увеличено с 0.75 на 10% */
    }
    
    .filter-items-container {
        flex: 1; /* Растягиваем контейнер на всю доступную высоту */
        min-height: 0; /* Позволяет контейнеру сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
        display: flex; /* Включаем flexbox */
        flex-direction: column; /* Вертикальное расположение */
    }
    
    /* Стили для внутреннего списка элементов */
    .filter-items-list {
        flex: 1; /* Растягиваем список на всю доступную высоту контейнера */
        min-height: 0; /* Позволяет списку сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
    }
}

/* Дополнительные стили для очень маленьких экранов в портретной ориентации */
@media (max-width: 480px) and (orientation: portrait) {
    .custom-modal-container {
        width: 82.5%; /* Увеличено с 75% на 10% */
        max-height: 33vh; /* Увеличено с 30vh на 10% */
        transform: scale(0.77); /* Увеличено с 0.7 на 10% */
    }
    
    .filter-items-container {
        flex: 1; /* Растягиваем контейнер на всю доступную высоту */
        min-height: 0; /* Позволяет контейнеру сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
        display: flex; /* Включаем flexbox */
        flex-direction: column; /* Вертикальное расположение */
    }
    
    /* Стили для внутреннего списка элементов */
    .filter-items-list {
        flex: 1; /* Растягиваем список на всю доступную высоту контейнера */
        min-height: 0; /* Позволяет списку сжиматься */
        overflow-y: auto; /* Добавляем прокрутку при необходимости */
    }
}

/* Анимации для элементов */
.filter-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Эффект пульсации для кнопок */
.custom-modal-footer .btn:active {
    transform: scale(0.95);
}

/* Улучшенные состояния фокуса */
.filter-item:focus-within {
    background: #ecf0f1;
    outline: 2px solid #2c3e50;
    outline-offset: -2px;
}

/* Стили для пустого состояния */
.filter-items-container:empty::after {
    content: 'Нет данных для отображения';
    display: block;
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* Стили для премиум-функций */
.premium-icon {
    display: none !important;
}

@keyframes premiumGlow {
    from { text-shadow: none; }
    to { text-shadow: none; }
}

/* Стили для элементов с премиум-функциями */
.filter-item.premium-item::before {
    display: none !important;
    content: none !important;
}

/* Стили для недоступных чекбоксов */
.filter-item input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-item input[type="checkbox"]:disabled + label {
    opacity: 0.7;
    cursor: pointer;
} 