/* static/css/mobile.css */


@media (max-width: 991.98px) {
    /* === 1. ГЛОБАЛЬНАЯ НАСТРОЙКА === */
    html, body {
        /* Жестко запрещаем горизонтальный скролл */
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;

        /* Делаем прокрутку плавной, как в приложениях */
        -webkit-overflow-scrolling: touch;

        /* Увеличиваем базовый шрифт для читаемости */
        font-size: 16px;

        /* Добавляем отступ снизу, равный высоте Tab Bar */
        /* 60px (tab bar) + 10px (запас) */
        padding-bottom: 70px;
    }

    /* Универсальное правило для корректного расчета размеров */
    * {
        box-sizing: border-box;
    }

    /* Уменьшаем отступы основного контента на мобильных */
    main.container {
        margin-top: 1.5rem !important; /* Уменьшаем my-5 */
        margin-bottom: 1.5rem !important;
    }


    /* === 2. АДАПТАЦИЯ ХЕДЕРА И ФУТЕРА === */
    /* Скрываем верхнюю инфо-панель хедера */
    header.sticky-top .site-header-top {
        display: none;
    }

    /* В основной навигации скрываем десктопную кнопку корзины */
    header.sticky-top .site-header-main .navbar-collapse .nav-item a.btn {
        display: none;
    }

    /* Скрываем десктопный футер */
    /* СТАЛО (Правильный класс из footer.html) */
    footer.site-footer {
        display: none;
    }

    /* === 3. НИЖНЯЯ ПАНЕЛЬ НАВИГАЦИИ (TAB BAR) === */
    .mobile-tab-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px; /* Стандартная высота */
        background: #ffffff;
        border-top: 1px solid #e0e0e0;
        display: flex;
        justify-content: space-around;
        align-items: stretch; /* Растягиваем итемы на всю высоту */
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .mobile-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1; /* Равномерно делим место */
        font-size: 11px;
        color: #555; /* Чуть темнее для контраста */
        text-decoration: none;
        position: relative; /* Для значка корзины */
        padding-top: 4px;
        line-height: 1.4;
        font-weight: 500;
    }

    .mobile-tab-item i {
        font-size: 20px; /* Размер иконки */
        margin-bottom: 3px;
        width: 24px; /* Фикс ширины иконки */
        text-align: center;
    }

    /* Цвет активной кнопки */
    .mobile-tab-item.active {
        color: #007bff; /* Ваш синий цвет (из Bootstrap) */
    }

    /* Значок на корзине */
    .mobile-cart-badge {
        position: absolute;
        top: 5px; /* Сдвигаем чуть ниже */
        right: calc(50% - 22px); /* Центрируем относительно иконки */
        background: #dc3545; /* Красный (из Bootstrap) */
        color: white;
        font-size: 10px;
        font-weight: bold;
        border-radius: 50%;
        width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
        border: 1px solid white; /* Обводка для читаемости */
    }

    /* === 4. СТРАНИЦА КАТАЛОГА (ТОВАРЫ И ФИЛЬТР) === */
    /* --- Сетка товаров --- */
    /* Оптимизируем саму карточку товара */
    .product-card {
        /* Уменьшаем отступы, чтобы больше влезало */
        padding: 8px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Легкая тень */
    }

    /* СТАЛО (Правильно) */
    .blueprint-card {
        /* Уменьшаем отступы, чтобы больше влезало */
        padding: 8px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Легкая тень */
    }

    .blueprint-card .card-img-top {
        border-radius: 4px; /* Скругляем картинку */
    }

    .blueprint-card .product-card-title { /* Имя класса из вашего product_card.html */
        font-size: 0.9rem; /* Уменьшаем шрифт */
        min-height: 40px; /* Выравниваем высоту названий */
        margin-bottom: 0.25rem;
    }

    .blueprint-card .product-price { /* Имя класса цены */
        font-size: 1rem;
        font-weight: bold;
        margin-bottom: 0.5rem;
    }

    .blueprint-card .btn {
        padding: 0.375rem 0.5rem; /* Уменьшаем кнопки */
        font-size: 0.875rem;
        width: 100%; /* Кнопка на всю ширину */
    }

    /* --- Система фильтров --- */
    /* 1. Скрываем десктопный фильтр (sidebar) */
    .sidebar {
        display: none;
    }

    /* 2. Показываем кнопку-триггер для фильтра */
    .mobile-filter-trigger {
        display: block; /* Показываем этот блок */
        padding: 0 10px 15px 10px; /* Отступы для кнопки */
    }

    #open-filter-btn {
        width: 100%;
        font-weight: 600;
    }

    /* 3. Стилизуем модальное окно (Bottom Sheet) */
    .filter-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 2000;

        /* По умолчанию скрыто и управляется через JS */
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;

        /* Располагаем окно внизу */
        align-items: flex-end;
    }

    .filter-modal-content {
        background: #fff;
        width: 100%;
        max-height: 70vh; /* Не более 85% высоты экрана */
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;

        /* Анимация появления снизу */
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
    }

    .filter-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 15px;
        border-bottom: 1px solid #eee;
    }

    .filter-modal-header h4 {
        margin: 0;
        font-weight: 600;
        font-size: 1.1rem
    }

    .filter-close-btn {
        font-size: 28px;
        font-weight: 300;
        line-height: 1;
        border: none;
        background: none;
        cursor: pointer;
        color: #888;
        padding: 0 5px;
    }

    .filter-modal-body {
        padding: 10px 15px;
        overflow-y: auto; /* Главное - скролл внутри окна! */
    }
   /* === НОВЫЕ СТИЛИ ДЛЯ УПЛОТНЕНИЯ ФИЛЬТРОВ === */
    .filter-modal-body .filter-block {
        margin-bottom: 0.5rem !important; /* Cильно уменьшаем отступ (было 0.75rem) */
    }

    .filter-modal-body .form-label {
        font-size: 0.8rem; /* Уменьшаем шрифт лейбла (было 0.85rem) */
        margin-bottom: 0.2rem; /* Сжимаем отступ под лейблом (было 0.25rem) */
        font-weight: 600;
    }

    .filter-modal-body .form-select,
    .filter-modal-body .form-control {
        font-size: 0.85rem; /* Уменьшаем шрифт в полях ввода (было 0.9rem) */
        padding-top: 0.25rem; /* Делаем поля еще ниже (было 0.3rem) */
        padding-bottom: 0.25rem; /* Делаем поля еще ниже (было 0.3rem) */
    }

    .filter-modal-body .form-check {
        min-height: auto; /* Убираем лишнюю высоту у чекбоксов */
        margin-bottom: 0; /* Убираем отступ у чекбоксов */
    }
    /* === КОНЕЦ НОВЫХ СТИЛЕЙ === */

    .filter-modal-footer {
        display: flex;
        flex-direction: column; /* Кнопки друг под другом */
        gap: 0.5rem; /* Расстояние между кнопками */
        padding: 12px 15px;
        border-top: 1px solid #eee;
        background: #f9f9f9;
    }

    .filter-modal-footer .btn {
        width: 100%; /* Кнопка на всю ширину */
        padding: 0.6rem;
        font-weight: 600;
    }

    /* Класс для показа/скрытия окна (управляется JS) */
    .filter-modal-overlay.show {
        display: flex;
        opacity: 1;
    }

    .filter-modal-overlay.show .filter-modal-content {
        transform: translateY(0);
    }


    /* === 5. КНОПКА "НАВЕРХ" === */
    .scroll-top-btn {
        position: fixed;
        /* 80px - чтобы было ВЫШЕ Tab Bar */
        bottom: 80px;
        right: 20px;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.5);
        color: white;
        border-radius: 50%;
        text-align: center;
        line-height: 44px;
        font-size: 24px;
        z-index: 999;
        cursor: pointer;

        /* Скрыта по умолчанию */
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .scroll-top-btn.show {
        display: block;
        opacity: 1;
    }

    /* ===============================================
    === 6. НОВАЯ ПЛАВАЮЩАЯ КНОПКА ФИЛЬТРА (ДЛЯ HOME.HTML) ===
    ===============================================
    */
    #floating-filter-trigger {
        display: flex; /* Показываем на мобильных */
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 20px;

        bottom: 80px; /* Располагаем на одном уровне с кнопкой "Наверх" */
        z-index: 999; /* Выше контента, ниже модалок */

        width: 50px;
        height: 50px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        font-size: 1.1rem; /* Размер иконки */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    #floating-filter-trigger:hover {
        background: #d35400; /* Цвет из :hover .btn-primary */
    }


    /* ===============================================
    === СТИЛИ ДЛЯ ФИЛЬТРА НА HOME.HTML ===
    ===============================================
    */
    /* ===============================================
    === 1. СТАРЫЙ БЛОК КНОПКИ СКРЫТ ===
    ===============================================
    Мы больше не делаем этот блок "липким",
    а просто скрываем его, так как он заменен
    новой плавающей кнопкой.
    */
    #mobile-filter-toggler-wrapper {
        display: none;
        /*
        position: sticky;
        top: 60px;
        z-index: 998;
        background: #fff;
        padding: 10px;
        margin-left: -10px;
        margin-right: -10px;
        border-bottom: 1px solid #eee;
        */
    }

    #mobile-filter-toggler-wrapper .btn {
        width: 100%;
    }


    /* 2. Превращаем сам блок фильтра
         (который у вас .collapse) во
         всплывающий оверлей.
    */
    /* Делаем блок .collapse невидимым по умолчанию
      и превращаем его в полноэкранный фон-оверлей
    */
    #filter-sidebar-collapse {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 2000;

        /* Скрываем его (Bootstrap класс .collapse делает это) */
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    /* Когда Bootstrap добавляет класс .show, показываем его */
    #filter-sidebar-collapse.show {
        display: block;
        opacity: 1;
    }

    /* 3. Стилизуем саму форму (шторку)
         внутри оверлея
    */
    #filter-sidebar-collapse .category-sidebar {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 85vh; /* Не более 85% высоты экрана */
        background: #fff;
        border-radius: 16px 16px 0 0;

        /* Анимация появления снизу */
        transform: translateY(100%);
        transition: transform 0.3s ease-out;

        /* Важно: добавляем внутренний скролл */
        display: flex;
        flex-direction: column;
    }

    /* При показе "шторка" выезжает */
    #filter-sidebar-collapse.show .category-sidebar {
        transform: translateY(0);
    }

    /* 4. Добавляем "шапку" к шторке,
         которой у вас не было
    */
    #filter-form {
        display: flex;
        flex-direction: column;
        height: 100%; /* Занимаем всю высоту шторки */
        max-height: 85vh;
    }

    /* Заголовок для "шторки" */
    .mobile-filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid #eee;
        font-weight: 600;
        font-size: 1.2rem;
    }

    .mobile-filter-header .close-filter-btn {
        font-size: 28px;
        font-weight: 300;
        line-height: 1;
        border: none;
        background: none;
        cursor: pointer;
        color: #888;
        padding: 0 5px;
    }

    /* Оборачиваем тело фильтра для скролла */
    .mobile-filter-body {
        padding: 15px;
        overflow-y: auto; /* ГЛАВНЫЙ СКРОЛЛ */
    }

    /* === НОВЫЕ СТИЛИ ДЛЯ УПЛОТНЕНИЯ ФИЛЬТРОВ === */
    .mobile-filter-body .filter-block {
        margin-bottom: 0.2rem !important; /* Cильно уменьшаем отступ (было 0.75rem) */
    }

    .mobile-filter-body .form-label {
        font-size: 0.8rem; /* Уменьшаем шрифт лейбла (было 0.85rem) */
        margin-bottom: 0.2rem; /* Сжимаем отступ под лейблом (было 0.25rem) */
        font-weight: 600;
    }

    .mobile-filter-body .form-select,
    .mobile-filter-body .form-control {
        font-size: 0.85rem; /* Уменьшаем шрифт в полях ввода (было 0.9rem) */
        padding-top: 0.25rem; /* Делаем поля еще ниже (было 0.3rem) */
        padding-bottom: 0.25rem; /* Делаем поля еще ниже (было 0.3rem) */
    }

    .mobile-filter-body .form-check {
        min-height: auto; /* Убираем лишнюю высоту у чекбоксов */
        margin-bottom: 0; /* Убираем отступ у чекбоксов */
    }
    /* === КОНЕЦ НОВЫХ СТИЛЕЙ === */
    /* Прибиваем кнопки "Применить/Сброс" к низу шторки */
    .mobile-filter-footer {
        display: flex;
        flex-direction: column; /* Кнопки друг под другом */
        gap: 0.5rem; /* Расстояние между кнопками */
        padding: 12px 15px;
        border-top: 1px solid #eee;
        background: #f9f9f9;
        margin-top: auto; /* Прибивает к низу */
    }

    .mobile-filter-footer .btn {
        width: 100%; /* Кнопка на всю ширину */
        padding: 0.6rem;
        font-weight: 600;
    }

    /* --- Исправление для /catalog/ (category_list.html) --- */
    /* Находим родительский .row и его дочерние колонки */
    .category-list-page .row > .col-lg-4 {
        width: 100% !important; /* Заставляем быть 100% ширины */
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Увеличиваем высоту карточки, чтобы она не выглядела "сплюснутой" */
    .category-card {
        min-height: 100px;
        justify-content: center; /* Центрируем текст */
    }

    .category-card-title {
        font-size: 1.2rem; /* Делаем шрифт чуть крупнее */
    }


    /* ===============================================
       СТИЛИ ДЛЯ ВСПЛЫВАЮЩЕГО МЕНЮ (POP-UP)
       =============================================== */
    /* 1. Стилизуем триггер-кнопку "Меню" (которая .mobile-tab-trigger)
          чтобы она выглядела так же, как и остальные <a>.mobile-tab-item */
    .mobile-tab-trigger {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%; /* Занимаем всю высоту родителя .mobile-tab-item */
        font-size: 11px;
        color: #555;
        text-decoration: none;
        line-height: 1.4;
        font-weight: 500;
        padding-top: 4px;
        /* Убираем подсветку при клике, т.к. меню будет "show" */
        color: #555 !important;
    }

    .mobile-tab-trigger i {
        font-size: 20px;
        margin-bottom: 3px;
        width: 24px;
        text-align: center;
    }

    /* Активная кнопка "Меню" (когда меню открыто) */
    .mobile-tab-trigger[aria-expanded="true"] {
        color: #007bff !important;
    }


    /* 2. Стилизуем само выпадающее меню (.mobile-pop-menu) */
    .mobile-pop-menu {
        /* Позиционирование */
        position: absolute !important; /* !important нужен для перебивки bootstrap */
        bottom: 100% !important; /* Появляется НАД кнопкой */
        left: 5px !important; /* С небольшим отступом от левого края */
        top: auto !important; /* Сбрасываем лишние стили bootstrap */
        transform: none !important; /* Сбрасываем лишние стили bootstrap */

        margin-bottom: 10px !important; /* Отступ от tab bar */

        /* Внешний вид */
        min-width: 200px; /* Задаем ширину */
        background: #ffffff;
        border-radius: 12px;
        border: 1px solid #e0e0e0;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
        padding: 8px 0; /* Внутренние отступы */
    }

    /* 3. Стилизуем пункты меню */
    .mobile-pop-menu .dropdown-item {
        display: flex;
        align-items: center;
        font-size: 1rem; /* 16px */
        font-weight: 500;
        padding: 10px 15px;
        color: #333;
    }

    .mobile-pop-menu .dropdown-item i {
        width: 28px; /* Выравниваем иконки */
        color: #777;
    }

    /* Активный пункт */
    .mobile-pop-menu .dropdown-item.active,
    .mobile-pop-menu .dropdown-item:active {
        color: #007bff;
        background-color: #f0f8ff;
    }

    /* 4. Убираем стрелочку-индикатор у dropup */
    .mobile-tab-trigger::after {
        display: none;
    }
}

