/**
 * Стили для кастомного мобильного селектора категорий
 * Применяются только на мобильных устройствах (≤768px)
 */

@media (max-width: 768px) {
    /* Кастомный мобильный селектор */
    .mobile-category-selector {
        position: relative;
        width: 100%;
        max-width: none;
        z-index: 1000;
    }

    /* Заголовок селектора */
    .mobile-select-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.8rem 1.25rem;
        background: white;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
        min-height: 41.6px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .mobile-select-header:hover {
        border-color: #007bff;
        box-shadow: 0 2px 6px rgba(0, 123, 255, 0.15);
    }

    .mobile-select-header:active {
        transform: translateY(1px);
    }

    /* Текст селектора */
    .mobile-select-text {
        font-size: 1rem;
        font-weight: 500;
        color: #495057;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-right: 0.5rem;
        line-height: 1.4;
    }

    /* Стрелка */
    .mobile-select-arrow {
        font-size: 1rem;
        color: #6c757d;
        transition: transform 0.3s ease;
        flex-shrink: 0;
    }

    /* Выпадающий список */
    .mobile-select-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border: 1px solid #e9ecef;
        border-top: none;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        max-height: 300px;
        overflow: hidden;
        z-index: 1001;
        animation: slideDown 0.2s ease;
    }

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

    /* Поиск в выпадающем списке */
    .mobile-select-search {
        padding: 0.75rem;
        border-bottom: 1px solid #e9ecef;
        background: #f8f9fa;
    }

    .mobile-select-search input {
        width: 100%;
        padding: 0.75rem 1rem;
        border: 1px solid #ced4da;
        border-radius: 6px;
        font-size: 0.9rem;
        background: white;
        min-height: 44px;
    }

    .mobile-select-search input:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }

    /* Контейнер опций */
    .mobile-select-options {
        max-height: 250px;
        overflow-y: auto;
        background: white;
    }

    /* Отдельная опция */
    .mobile-select-option {
        padding: 1rem 1.25rem;
        cursor: pointer;
        transition: all 0.2s ease;
        border-bottom: 1px solid #f1f3f4;
        font-size: 0.95rem;
        line-height: 1.4;
        display: flex;
        align-items: center;
        min-height: 52px;
    }

    .mobile-select-option:last-child {
        border-bottom: none;
    }

    .mobile-select-option:hover {
        background: #f8f9fa;
        color: #007bff;
    }

    .mobile-select-option:active {
        background: #e9ecef;
        transform: scale(0.98);
    }

    /* Стили для скроллбара */
    .mobile-select-options::-webkit-scrollbar {
        width: 6px;
    }

    .mobile-select-options::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .mobile-select-options::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .mobile-select-options::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

    /* Состояние открытого селектора */
    .mobile-category-selector.open .mobile-select-header {
        border-color: #007bff;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        box-shadow: 0 2px 6px rgba(0, 123, 255, 0.15);
    }

    .mobile-category-selector.open .mobile-select-arrow {
        transform: rotate(180deg);
    }

    /* Адаптация для очень маленьких экранов */
    @media (max-width: 480px) {
        .mobile-select-header {
            padding: 0.64rem 1rem;
            min-height: 38.4px;
        }

        .mobile-select-text {
            font-size: 0.9rem;
        }

        .mobile-select-arrow {
            font-size: 0.9rem;
        }

        .mobile-select-search {
            padding: 0.75rem;
        }

        .mobile-select-search input {
            padding: 0.6rem 0.8rem;
            font-size: 0.85rem;
        }

        .mobile-select-option {
            padding: 0.8rem 1rem;
            font-size: 0.85rem;
            min-height: 48px;
        }

        .mobile-select-dropdown {
            max-height: 250px;
        }

        .mobile-select-options {
            max-height: 200px;
        }
    }

    /* Анимации для плавного появления */
    .mobile-select-dropdown {
        transform-origin: top;
        animation: dropdownSlide 0.2s ease-out;
    }

    @keyframes dropdownSlide {
        from {
            opacity: 0;
            transform: scaleY(0);
        }
        to {
            opacity: 1;
            transform: scaleY(1);
        }
    }

    /* Стили для активной опции */
    .mobile-select-option.selected {
        background: #e3f2fd;
        color: #1976d2;
        font-weight: 500;
    }

    /* Стили для пустого состояния */
    .mobile-select-options:empty::after {
        content: "Категории не найдены";
        display: block;
        padding: 1rem;
        text-align: center;
        color: #6c757d;
        font-style: italic;
        font-size: 0.85rem;
    }

    /* Улучшенная доступность */
    .mobile-select-header:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }

    .mobile-select-option:focus {
        outline: 2px solid #007bff;
        outline-offset: -2px;
    }
}

/* Скрываем оригинальный селектор на мобильных устройствах */
@media (max-width: 768px) {
    #customKeywordsModal #keywords-category-filter {
        display: none !important;
    }
    
    /* Убираем отступы у контейнера с селекторами */
    #customKeywordsModal .d-flex.flex-wrap {
        gap: 0.5rem !important;
    }
    
    #customKeywordsModal .d-flex.flex-wrap .form-control,
    #customKeywordsModal .d-flex.flex-wrap .mobile-category-selector {
        flex: 1;
        min-width: 0;
    }
} 