/* static/main/css/template-responsive.css */

/* ============================================
   АДАПТИВНОСТЬ (ПЛАНШЕТЫ И ТЕЛЕФОНЫ)
   ============================================ */

@media (max-width: 1024px) {
    .header-top-row {
        gap: 15px;
    }
    .search-bar-wrapper {
        max-width: 400px;
    }
    .user-actions {
        gap: 10px;
    }
    .user-action-item span {
        display: none; /* Скрываем текст под иконками на средних экранах */
    }
    .user-action-item svg {
        margin-bottom: 0; /* Убираем отступ, если нет текста */
    }

    .footer-col {
        min-width: 180px;
        padding-right: 15px;
    }

    /* Адаптация кнопки сортировки */
    .sort-button span {
        display: none;
    }

    .sort-button {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .header-top-row {
        flex-wrap: wrap; /* Разрешаем элементам переноситься на новую строку */
        justify-content: center; /* Центрируем элементы при переносе */
        padding: 10px 20px;
    }

    .logo {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }

    .catalog-button {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }

    .search-bar-wrapper {
        order: 3; /* Перемещаем поиск вниз */
        width: 100%;
        max-width: 100%;
        margin-bottom: 10px;
    }

    .user-actions {
        order: 2; /* Перемещаем действия пользователя */
        width: 100%;
        justify-content: space-around;
        margin-bottom: 10px;
    }

    .user-action-item {
        font-size: 0.7rem;
    }
    .user-action-item span {
        display: block; /* Показываем текст снова, но меньше */
    }
    .user-action-item svg {
        margin-bottom: 4px; /* Возвращаем отступ для текста */
    }

    .header-bottom-row {
        padding: 0.5rem 10px;
    }
    .secondary-nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    .secondary-nav ul li a {
        font-size: 0.8rem;
    }

    .main-content {
        display: block; /* Убираем flex, если сайдбар вынесен */
    }

    .products {
        padding: 15px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Меньше колонок на маленьких экранах */
    }

    /* Адаптивность футера для планшетов */
    .footer-inner {
        flex-direction: column; /* Колонки футера теперь в столбец */
        align-items: center; /* Центрируем содержимое */
        text-align: center;
    }

    .footer-col {
        width: 100%; /* Каждая колонка занимает всю ширину */
        max-width: 300px; /* Ограничиваем ширину для лучшего вида */
        padding-right: 0;
        margin-bottom: 30px;
    }

    .footer-col h3 {
        margin-bottom: 15px;
    }

    .social-links {
        justify-content: center; /* Центрируем иконки */
    }
}

@media (max-width: 480px) {
    .header-top-row {
        padding: 10px;
        gap: 10px;
    }
    .logo {
        font-size: 1.5rem;
    }
    .catalog-button {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    .catalog-button .catalog-icon {
        width: 18px;
        height: 18px;
        margin-right: 5px;
    }
    .search-form {
        height: 35px;
    }
    .search-wrapper {
        height: 100%;
    }
    .sort-button {
        padding: 8px;
    }
    .sort-button svg:first-child {
        width: 14px;
        height: 14px;
    }
    .sort-button svg:last-child {
        width: 10px;
        height: 10px;
    }
    .search-bar-wrapper input[type="text"] {
        font-size: 0.9rem;
    }
    .search-button {
        padding: 0 10px;
    }
    .search-button svg {
        width: 16px;
        height: 16px;
    }
    .user-actions {
        gap: 8px;
    }
    .user-action-item {
        font-size: 0.65rem;
    }
    .user-action-item svg {
        width: 20px;
        height: 20px;
        margin-bottom: 2px;
    }

    .header-bottom-row {
        padding: 0.4rem 5px;
    }
    .secondary-nav ul {
        gap: 10px;
    }
    .secondary-nav ul li a {
        font-size: 0.75rem;
    }

    .products h2 {
        font-size: 1.5rem;
    }

    /* Адаптивность футера для мобильных */
    .footer-new {
        padding-top: 20px;
    }
    .footer-inner {
        padding-bottom: 20px;
    }
    .footer-col {
        margin-bottom: 20px;
    }
    .footer-col h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    .footer-nav-menu a,
    .footer-contacts-col a,
    .footer-contacts-col p,
    .footer-contacts-col .title {
        font-size: 0.9rem;
    }
    .social-links {
        gap: 10px;
    }
    .social-icon {
        width: 28px;
        height: 28px;
    }
    .social-icon img {
        width: 16px;
        height: 16px;
    }
    .footer-bottom-bar {
        padding: 15px 0;
        font-size: 0.75rem;
    }
}

/* ============================================
   ЛИПКОЕ МЕНЮ
   ============================================ */

/* Базовые стили для хедера */
.header {
    background-color: #333;
    color: #fff;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    z-index: 100;
}

/* Липкий хедер при скролле */
.header.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    /* Убираем анимацию, которая может создавать зазор */
    animation: none;
    /* Добавляем аппаратное ускорение */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Альтернативная анимация (без зазоров) */
@keyframes slideDownFixed {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(0);
    }
}

/* Если хотите оставить анимацию, используйте эту версию */
.header.is-sticky.animate {
    animation: slideDownFixed 0.3s ease forwards;
}

/* Компенсация отступа при фиксированном хедере */
body.has-sticky-header {
    padding-top: 100px; /* Установите точную высоту вашего сжатого хедера */
}

/* Скрытие вторичной навигации при липком режиме */
.header.is-sticky .header-bottom-row {
    display: none;
}

/* Плавное появление/исчезновение */
.header-bottom-row {
    transition: all 0.3s ease;
}

.header.is-sticky .header-top-row {
    padding: 8px 20px;
    transition: padding 0.3s ease;
}

.header.is-sticky .logo {
    font-size: 1.4rem;
    transition: font-size 0.3s ease;
}

.header.is-sticky .catalog-button {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.header.is-sticky .search-form {
    height: 36px;
}

/* Убираем возможные зазоры */
.header.is-sticky::before,
.header.is-sticky::after {
    display: none;
}

/* Исправление для body при фиксированном хедере */
body.has-sticky-header {
    margin-top: 0;
    padding-top: 100px;
}

/* Для мобильных устройств */
@media (max-width: 768px) {
    body.has-sticky-header {
        padding-top: 90px;
    }
}

/* ============================================
   МОБИЛЬНАЯ ВЕРСИЯ (ДО 768px) - ИСПРАВЛЕННАЯ
   ============================================ */

/* Скрываем на десктопе */
.mobile-bottom-nav,
.mobile-search-bar {
    display: none;
}

/* Только на телефонах */
@media (max-width: 768px) {
    /* ===== ОТКЛЮЧАЕМ ЛИПКОСТЬ ВЕРХНЕГО МЕНЮ ===== */
    .header.is-sticky {
        position: relative !important;
        top: auto !important;
        animation: none !important;
    }

    body.has-sticky-header {
        padding-top: 0 !important;
    }

    /* ===== НИЖНЕЕ МЕНЮ ===== */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #333;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding: 6px 8px;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #ccc;
        font-size: 10px;
        transition: color 0.2s;
        padding: 4px 0;
        flex: 1;
        text-align: center;
        background: none;
        border: none;
        cursor: pointer;
        position: relative;
    }

    .mobile-nav-item svg {
        width: 22px;
        height: 22px;
        margin-bottom: 3px;
        color: #ccc;
    }

    .mobile-nav-item.active,
    .mobile-nav-item.active svg {
        color: #e44c2c;
    }

    /* Бейдж корзины */
    .mobile-cart-count {
        position: absolute;
        top: -2px;
        right: 18%;
        background: #e44c2c;
        color: white;
        font-size: 9px;
        font-weight: bold;
        min-width: 16px;
        height: 16px;
        border-radius: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    /* ===== ВЫЕЗЖАЮЩИЙ ПОИСК ===== */
    .mobile-search-bar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: #333;
        padding: 10px 15px;
        z-index: 1001;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    .mobile-search-bar.visible {
        transform: translateY(0);
    }

    .mobile-search-form {
        display: flex;
        align-items: center;
        background: #555;
        border-radius: 8px;
        overflow: hidden;
        width: 100%;
    }

    .mobile-search-input {
        flex: 1;
        border: none;
        background: transparent;
        color: white;
        padding: 10px 15px;
        font-size: 14px;
        outline: none;
    }

    .mobile-search-input::placeholder {
        color: #aaa;
    }

    .mobile-search-btn {
        background: #444;
        border: none;
        padding: 0 15px;
        cursor: pointer;
        color: white;
        height: 44px;
    }

    .mobile-search-close {
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        padding: 0 10px;
        display: flex;
        align-items: center;
    }

    /* ===== ХЕДЕР (ТОЛЬКО ЛОГОТИП И НАВИГАЦИЯ) ===== */
    .catalog-button,
    .search-bar-wrapper,
    .user-actions {
        display: none !important;
    }

    .header-top-row {
        display: flex;
        justify-content: center !important;
        padding: 12px 15px;
    }

    .logo {
        font-size: 1.4rem;
        margin-bottom: 0;
        text-align: center;
        width: 100%;
    }

    .header-bottom-row {
        display: block !important;
        background-color: #2a2a2a;
        padding: 8px 15px;
        text-align: center;
    }

    .header-bottom-row .secondary-nav ul {
        display: flex;
        justify-content: center;
        gap: 25px;
        margin: 0;
        padding: 0;
    }

    .header-bottom-row .secondary-nav ul li a {
        font-size: 14px;
        padding: 5px 0;
        color: #ccc;
    }

    /* ===== ВЫПАДАЮЩЕЕ МЕНЮ АККАУНТА НА ТЕЛЕФОНЕ ===== */
    .mobile-nav-item.account-dropdown-trigger {
        position: relative;
    }

    .mobile-account-dropdown {
        position: fixed;
        bottom: 70px;
        right: 10px;
        left: auto;
        background: #1c2127;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        min-width: 200px;
        z-index: 1002;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.2s ease;
        border-top: 3px solid #e44c2c;
    }

    .mobile-account-dropdown.show {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .mobile-account-dropdown ul {
        list-style: none;
        margin: 0;
        padding: 8px 0;
    }

    .mobile-account-dropdown li a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        color: #d0d0d0;
        text-decoration: none;
        font-size: 14px;
        transition: background 0.2s;
    }

    .mobile-account-dropdown li a:hover {
        background: #2d343b;
        color: #fff;
    }

    .mobile-account-dropdown li a svg {
        width: 18px;
        height: 18px;
    }

    /* Затемнение фона при открытом меню */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s;
    }

    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    /* ===== ОТСТУПЫ ===== */
    body {
        padding-bottom: 70px;
    }
}

/* ============================================
   АДАПТИВНЫЙ ФУТЕР ДЛЯ ТЕЛЕФОНОВ
   ============================================ */

@media (max-width: 768px) {
    .footer-new {
        padding-top: 30px;
        margin-top: 30px;
    }

    .footer-inner {
        flex-direction: column !important;
        gap: 25px;
        padding: 0 15px 25px !important;
    }

    /* Каждая колонка футера */
    .footer-col {
        width: 100% !important;
        max-width: none !important;
        min-width: auto !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
        text-align: left;
    }

    /* Заголовки колонок */
    .footer-col h3 {
        font-size: 16px;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 2px solid #e44c2c;
        display: inline-block;
    }

    /* Сетка для навигационных ссылок (2 колонки) */
    .footer-nav-menu ul {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px 15px;
    }

    .footer-nav-menu li {
        margin-bottom: 0;
    }

    .footer-nav-menu a {
        font-size: 13px;
        padding: 4px 0;
        display: inline-block;
    }

    /* Контакты — отдельный блок */
    .footer-contacts-col {
        margin-top: 5px;
    }

    .footer-contacts-col .title {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .footer-tel p {
        margin-bottom: 5px;
    }

    .footer-tel a {
        font-size: 14px;
    }

    .footer-address {
        margin-top: 10px;
    }

    .footer-address p {
        font-size: 13px;
        display: inline-block;
        margin-right: 10px;
    }

    .footer-mail {
        margin-top: 8px;
    }

    .footer-mail a {
        font-size: 13px;
    }

    /* Социальные сети — горизонтально и красиво */
    .footer-social-col {
        text-align: center;
    }

    .footer-social-col h3 {
        display: block;
        text-align: center;
    }

    .social-links {
        display: flex;
        justify-content: center;
        gap: 20px;
        margin-top: 15px;
    }

    .social-icon {
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .social-icon:hover {
        background: #e44c2c;
        transform: translateY(-3px);
    }

    .social-icon img {
        width: 20px;
        height: 20px;
    }

    /* Нижняя полоса */
    .footer-bottom-bar {
        padding: 15px 0;
    }

    .footer-copyright {
        font-size: 11px;
    }
}

/* Очень маленькие экраны (до 480px) */
@media (max-width: 480px) {
    .footer-nav-menu ul {
        gap: 6px 10px;
    }

    .footer-nav-menu a {
        font-size: 12px;
    }

    .social-links {
        gap: 15px;
    }

    .social-icon {
        width: 36px;
        height: 36px;
    }

    .social-icon img {
        width: 18px;
        height: 18px;
    }
}