/**
 * Исправление стилей каталога Food Union
 * Улучшает отображение и функциональность
 */

/* Индикатор загрузки */
#catalog-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    z-index: 9999;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Сообщение об ошибке */
#catalog-error {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff4444;
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    z-index: 9999;
    max-width: 300px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.3s ease-out;
}

/* Анимация появления ошибки справа */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Стили для загрузки */
.searchandfilter.sf-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.searchandfilter.sf-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
}

.searchandfilter.sf-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
}

/* Анимация спиннера */
@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Кнопка "Загрузить еще" */
.load-more-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 186, 0.3);
}

.load-more-btn:hover:not(:disabled) {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.4);
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Статус загрузки */
.load-more-status {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
    font-style: italic;
}

/* Счетчик результатов */
.results-count {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 10px 15px;
    margin: 20px 0;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.results-count-number {
    font-weight: bold;
    color: #007cba;
}

/* Улучшения для фильтров */
.searchandfilter {
    position: relative;
}

.searchandfilter .sf-field-container {
    margin-bottom: 20px;
}

.searchandfilter .sf-field-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

/* Чекбоксы */
.searchandfilter input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.searchandfilter input[type="checkbox"]:checked + label {
    color: #007cba;
    font-weight: 600;
}

/* Радио кнопки */
.searchandfilter input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.searchandfilter input[type="radio"]:checked + label {
    color: #007cba;
    font-weight: 600;
}

/* Активные опции */
.searchandfilter .active-filter {
    background: rgba(0, 124, 186, 0.1);
    border-left: 3px solid #007cba;
    padding-left: 10px;
}

/* Блоки результатов */
.searchandfilter-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.searchandfilter-results .result {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.searchandfilter-results .result:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Wishlist кнопки */
.add-to-wishlist {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-to-wishlist:hover {
    background: #ff5252;
    transform: scale(1.05);
}

.add-to-wishlist.active {
    background: #4caf50;
}

/* Пагинация */
.sf-pagination {
    margin-top: 30px;
    text-align: center;
}

.sf-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}

.sf-pagination .page-numbers:hover,
.sf-pagination .page-numbers.current {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Кнопка сброса фильтров */
.filter-clear-btn,
.sf-reset {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.filter-clear-btn:hover,
.sf-reset:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Сообщение "нет результатов" */
.searchandfilter-results .no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    grid-column: 1 / -1;
}

/* Селекты */
.searchandfilter select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.searchandfilter select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Range слайдеры */
.searchandfilter input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

.searchandfilter .sf-range-inputs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.searchandfilter .sf-range-inputs input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* Поиск */
.searchandfilter input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.searchandfilter input[type="text"]:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Аккордеон */
.accordion-item {
    border: 1px solid #e9ecef;
    border-radius: 5px;
    margin-bottom: 10px;
    overflow: hidden;
}

.accordion-header {
    background: #f8f9fa;
    padding: 15px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    transition: background 0.3s ease;
    border: none;
    width: 100%;
    text-align: left;
}

.accordion-header:hover {
    background: #e9ecef;
}

.accordion-item.active .accordion-header {
    background: #007cba;
    color: white;
}

.accordion-content {
    padding: 15px;
    background: white;
    display: none;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.searchandfilter-results .result {
    animation: fadeIn 0.3s ease-out;
}

/* Адаптивность */
@media (max-width: 768px) {
    .searchandfilter-results {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .load-more-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .accordion-header {
        padding: 12px;
        font-size: 14px;
    }
    
    .accordion-content {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .searchandfilter-results {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .load-more-btn {
        width: 100%;
        padding: 12px;
    }
    
    .results-count {
        margin: 15px 0;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Скрываем элементы "больше товаров нет" */
.load-more-container.hidden,
.load-more-status.hidden {
    display: none !important;
}

/* Стили для неактивных фильтров */
.searchandfilter.sf-loading input,
.searchandfilter.sf-loading select,
.searchandfilter.sf-loading button {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* Стили для активных фильтров */
.searchandfilter:not(.sf-loading) input,
.searchandfilter:not(.sf-loading) select,
.searchandfilter:not(.sf-loading) button {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

/* Индикатор загрузки для фильтров */
.searchandfilter.sf-loading .sf-field-container {
    position: relative;
}

.searchandfilter.sf-loading .sf-field-container::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 124, 186, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 1002;
}

/* ПРИНУДИТЕЛЬНОЕ отключение стилей Search & Filter Pro для аккордеонов */
.searchandfilter .accordion-item,
.searchandfilter .accordion-header,
.searchandfilter .accordion-content {
    /* Сбрасываем все стили S&F */
    all: unset !important;
    box-sizing: border-box !important;
}

/* Принудительно отключаем стили S&F */
.sf-field-container .accordion-item,
.sf-field-container .accordion-header,
.sf-field-container .accordion-content {
    all: unset !important;
    box-sizing: border-box !important;
}

/* Исправление аккордеонов фильтров */
.searchandfilter .accordion-item {
    border: 1px solid #e0e0e0 !important;
    margin-bottom: 10px !important;
    border-radius: 5px !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    display: block !important;
}

.searchandfilter .accordion-item:hover {
    border-color: #007cba !important;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.1) !important;
}

.searchandfilter .accordion-header {
    background: #f8f9fa !important;
    padding: 15px 20px !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    display: block !important;
    width: 100% !important;
    text-align: left !important;
}

.searchandfilter .accordion-header:hover {
    background: #e9ecef !important;
}

.searchandfilter .accordion-header:active {
    background: #dee2e6 !important;
}

.searchandfilter .accordion-item.active .accordion-header {
    background: #007cba !important;
    color: white !important;
}

.searchandfilter .accordion-title {
    font-weight: 600 !important;
    font-size: 16px !important;
    margin: 0 !important;
    display: block !important;
}

.searchandfilter .accordion-content {
    display: none !important;
    padding: 20px !important;
    background: white !important;
    border-top: 1px solid #e0e0e0 !important;
    width: 100% !important;
}

.searchandfilter .accordion-item.active .accordion-content {
    display: block !important;
}

/* Индикатор состояния аккордеона */
.searchandfilter .accordion-header::after {
    content: '▼' !important;
    position: absolute !important;
    right: 20px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    transition: transform 0.3s ease !important;
    font-size: 12px !important;
    color: #666 !important;
}

.searchandfilter .accordion-item.active .accordion-header::after {
    transform: translateY(-50%) rotate(180deg) !important;
    color: white !important;
}

/* Стили для содержимого аккордеона */
.searchandfilter .accordion-content .sf-field-container {
    margin-bottom: 15px !important;
}

.searchandfilter .accordion-content .sf-field-container:last-child {
    margin-bottom: 0 !important;
}

/* Стили для чекбоксов в аккордеонах */
.searchandfilter .accordion-content input[type="checkbox"] {
    margin-right: 8px !important;
}

.searchandfilter .accordion-content label {
    display: block !important;
    margin-bottom: 8px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    color: #333 !important;
}

.searchandfilter .accordion-content label:hover {
    color: #007cba !important;
}

/* Стили для селектов в аккордеонах */
.searchandfilter .accordion-content select {
    width: 100% !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
}

.searchandfilter .accordion-content select:focus {
    border-color: #007cba !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2) !important;
}

/* ПРЕДОТВРАЩАЕМ автоматическое закрытие аккордеонов */
.searchandfilter .accordion-content {
    /* Принудительно показываем содержимое активного аккордеона */
    display: none !important;
}

.searchandfilter .accordion-item.active .accordion-content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Принудительно скрываем неактивные */
.searchandfilter .accordion-item:not(.active) .accordion-content {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

/* Анимация для аккордеонов */
.searchandfilter .accordion-content {
    max-height: 0 !important;
    overflow: hidden !important;
    transition: max-height 0.3s ease, padding 0.3s ease !important;
}

.searchandfilter .accordion-item.active .accordion-content {
    max-height: 1000px !important;
    padding: 20px !important;
}
