/* ============================================================
   КАТАЛОГ — ОБЩИЕ СТИЛИ
   ============================================================ */

:root {
    --green: #2e7d32;
    --green-hover: #1b5e20;
    --green-light: #e8f5e9;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e0e0e0;
    --gray-300: #bdbdbd;
    --gray-400: #9e9e9e;
    --gray-500: #757575;
    --gray-600: #616161;
    --gray-700: #424242;
    --gray-800: #212121;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ===== ОБЩИЕ ===== */
.shop-page .container-fluid {
    max-width: 1440px;
    margin: 0 auto;
    padding: 30px 20px 20px;
}

@media (max-width: 768px) {
    .shop-page .container-fluid {
        padding-top: 15px;
    }
}

/* ===== СЕТКА ТОВАРОВ ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    padding: 0;
    list-style: none;
}

@media (max-width: 1199px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        gap: 12px;
    }
}

/* ===== ПАНЕЛЬ УПРАВЛЕНИЯ ===== */
.catalog-control-panel {
    padding: 12px 0;
}

.sort-select {
    padding: 8px 32px 8px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23424242' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

.view-toggle-buttons {
    display: flex;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #fff;
    color: var(--gray-400);
    border: none;
    border-right: 1px solid var(--gray-200);
    transition: 0.15s;
    text-decoration: none;
}

.view-toggle-btn:last-child {
    border-right: none;
}

.view-toggle-btn:hover {
    color: var(--green);
}

.view-toggle-btn.active {
    background: var(--green);
    color: #fff;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination-section {
    padding: 24px 0 8px;
}

.pagination .page-link {
    border: none;
    color: var(--gray-600);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
}

.pagination .page-link:hover {
    background: var(--green-light);
    color: var(--green);
}

.pagination .active .page-link {
    background: var(--green);
    color: #fff;
}

/* ===== МОБИЛЬНЫЙ ФИЛЬТР ===== */
.mobile-filters-toggle {
    display: none;
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-align: left;
    gap: 10px;
    align-items: center;
}

@media (max-width: 991px) {
    .mobile-filters-toggle {
        display: flex;
    }

    .desktop-sidebar-wrapper {
        display: none;
    }

    .desktop-sidebar-wrapper.open {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 80vh;
        overflow-y: auto;
        background: #fff;
        z-index: 1050;
        padding: 20px;
        border-radius: var(--radius) var(--radius) 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    .filters-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1040;
    }

    .filters-overlay.show {
        display: block;
    }
}

/* ==========================================================================
   1. КОМПАКТНЫЙ САЙДБАР ФИЛЬТРОВ С АККУРАТНЫМ СКРОЛЛОМ
   ========================================================================== */

/* Ограничиваем списки категорий и брендов по высоте */
.filters-sidebar .filter-block-content,
.filters-sidebar .categories-list,
.filters-sidebar .brands-list,
div[id*="filter"] .checkbox-list {
    max-height: 220px !important;
    overflow-y: auto !important;
    padding-right: 8px !important;
    margin-top: 10px !important;
}

/* Изящный тонкий скроллбар для сайдбара (Chrome, Safari, Edge) */
.filters-sidebar *::-webkit-scrollbar,
div[id*="filter"] *::-webkit-scrollbar {
    width: 4px !important;
}

.filters-sidebar *::-webkit-scrollbar-track,
div[id*="filter"] *::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
    border-radius: 10px !important;
}

.filters-sidebar *::-webkit-scrollbar-thumb,
div[id*="filter"] *::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important;
    border-radius: 10px !important;
}

.filters-sidebar *::-webkit-scrollbar-thumb:hover,
div[id*="filter"] *::-webkit-scrollbar-thumb:hover {
    background: #2e7d32 !important; /* Наш фирменный зеленый */
}

/* ==========================================================================
   2. ФИКС ИЗОБРАЖЕНИЙ ТОВАРОВ И ПРОПОРЦИЙ
   ========================================================================== */

.product-image-container {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important; /* Строгий квадрат для всех фото */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    overflow: hidden !important;
}

.product-image-container .product-image,
.product-image-container img {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important; /* Гарантирует отсутствие растягивания и деформации */
    display: block !important;
}

/* ==========================================================================
   3. ВЫРАВНИВАНИЕ СТРОКИ ЦЕН И СКИДОК
   ========================================================================== */

.product-price {
    display: flex !important;
    flex-direction: row !important;
    align-items: baseline !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: auto !important;
}

.product-price .current-price {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
}

.product-price .current-price.discounted {
    color: #b91c1c !important; /* Благородный красный для акционной цены */
}

.product-price .old-price {
    font-size: 0.95rem !important;
    color: #94a3b8 !important;
    text-decoration: line-through !important;
    white-space: nowrap !important;
}

/* ==========================================================================
   ПОЛНЫЙ РЕЙСТАЙЛИНГ КНОПКИ КАТАЛОГА (Убираем "стиль 90-х")
   ========================================================================== */

.btn-catalog-dropdown {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;

    /* СБРОС СИСТЕМНЫХ СТИЛЕЙ БРАУЗЕРА */
    appearance: none !important;
    -webkit-appearance: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;

    /* СОВРЕМЕННЫЙ ДИЗАЙН КНОПКИ */
    padding: 14px 20px !important;
    background-color: #2e7d32 !important; /* Наш благородный зеленый */
    border-radius: 10px !important; /* Аккуратные скругленные углы */
    color: #ffffff !important;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;

    /* Запрещаем тексту переноситься и ломать кнопку */
    white-space: nowrap !important;
    overflow: hidden;
}

/* Эффект при наведении — кнопка становится чуть глубже */
.btn-catalog-dropdown:hover {
    background-color: #1b5e20 !important;
}

/* Мягкий клик */
.btn-catalog-dropdown:active {
    transform: scale(0.98);
}

/* ФИКС СТИЛЕЙ ТЕГА H1 ВНУТРИ КНОПКИ */
.catalog-btn-title {
    /* Полный сброс всех дефолтных стилей заголовка */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;

    /* Шрифтовая пара */
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 15px !important; /* Оптимальный аккуратный размер для кнопки */
    font-weight: 600 !important; /* Приятная полужирность */
    color: #ffffff !important;
    line-height: 1 !important;
    letter-spacing: -0.01em !important;
}

/* Изящная белая стрелочка */
.dropdown-btn-arrow {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin-left: 10px;
    transition: transform 0.2s ease;
}

/* ==========================================================================
   ПОЛНЫЙ ФИКС СОРТИРОВКИ И ПЕРЕКЛЮЧАТЕЛЕЙ ВИДА
   ========================================================================== */

/* Контейнер панели */
.catalog-header-clean {
    width: 100%;
    margin-bottom: 24px;
}

/* Выстраиваем ВСЕ элементы в одну идеальную линию */
.catalog-actions-row-premium {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 0 16px 0;
    /* Вместо пустой рамки делаем изящную разделительную линию снизу */
    border-bottom: 1px solid #e2e8f0;
}

/* Левая часть: сортировка и текст */
.catalog-sorting-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Корректируем надпись "Сортировка:" */
.sorting-label {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #64748b;
    font-weight: 400;
}

/* Делаем сам выпадающий список сортировки аккуратнее */
.sort-select {
    padding: 8px 36px 8px 12px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    color: #0f172a !important;
    background-color: #ffffff !important;
    height: 38px;
    transition: border-color 0.15s ease;
}

.sort-select:focus {
    border-color: #2e7d32 !important;
    outline: none;
}

/* Надпись "Найдено: 700+ товаров" */
.product-count-inline {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #94a3b8; /* Чуть приглушаем, чтобы не спорила с сортировкой */
    margin-left: 8px;
}

/* Правая часть: кнопки переключения сетки */
.view-toggle-buttons {
    display: flex;
    border-radius: 8px !important; /* Скругления как у сортировки */
    border: 1px solid #cbd5e1 !important;
    overflow: hidden;
    height: 38px; /* Выравниваем высоту в один пиксель с сортировкой */
}

.view-toggle-btn {
    width: 38px;
    height: 100%;
    background: #ffffff !important;
    color: #64748b !important;
    border: none !important;
    border-right: 1px solid #cbd5e1 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.view-toggle-btn:last-child {
    border-right: none !important;
}

.view-toggle-btn:hover {
    color: #2e7d32 !important;
    background: #f8fafc !important;
}

/* Стили для активной кнопки (выбранный вид) */
.view-toggle-btn.active {
    background: #2e7d32 !important; /* Фирменный зеленый */
    color: #ffffff !important;
}

/* АДАПТИВ ПОД МОБИЛЬНЫЕ */
@media (max-width: 768px) {
    .catalog-actions-row-premium {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .catalog-sorting-actions {
        width: 100%;
        justify-content: space-between;
    }

    .view-toggle-buttons {
        align-self: flex-end;
    }
}

/* ===== ОПТИМИЗАЦИЯ ВЕРХНЕГО ОТСТУПА СТРАНИЦЫ ===== */
.shop-page .container-fluid {
    max-width: 1440px;
    margin: 0 auto;
    /* Уменьшаем верхний паддинг с 30px до 12px, чтобы подтянуть каталог к хедеру */
    padding: 12px 20px 20px 20px !important;
}

/* Убираем лишние верхние маргины у блоков, которые могут толкать контент вниз */
.desktop-sidebar-wrapper {
    margin-top: 0 !important;
}

.catalog-header-clean {
    width: 100%;
    margin-bottom: 24px;
    /* Убедимся, что у панели сортировки нет верхнего отступа */
    margin-top: 0 !important;
}

/* Выравниваем базовую линию элементов управления */
.catalog-actions-row-premium {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    /* Делаем легкий верхний паддинг в 4px, чтобы сортировка визуально
       встала в один пиксель по высоте с текстом на зеленой кнопке слева */
    padding: 4px 0 16px 0 !important;
    border-bottom: 1px solid #e2e8f0;
}
