/* ============================================
   RESPONSIVE.CSS - Адаптивный дизайн Zoo Simba
   ============================================ */

/* ============================================
   TYPOGRAPHY - Плавное масштабирование
   ============================================ */

h1, h2, h3, h4, h5, h6 { margin: 0; }
h1 { font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.2; font-weight: 600; }
h2 { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.3; }
h3 { font-size: clamp(1.1rem, 3vw, 1.5rem); }
h4, h5, h6 { font-size: clamp(0.9rem, 2.5vw, 1.2rem); }
p, body { font-size: clamp(0.85rem, 2vw, 1rem); line-height: 1.6; }
small { font-size: clamp(0.75rem, 1.5vw, 0.9rem); }

/* ============================================
   GRID & LAYOUT
   ============================================ */

@media (max-width: 1024px) {
    /* Предотвращение горизонтального скролла при свайпе */
    body {
        overflow-x: hidden;
    }

    .catalog-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100vh;
        overflow-y: auto;
        background: white;
        z-index: 1000;
        transition: left 0.3s ease;
        
    }

    .catalog-sidebar.open {
        left: 0 !important;
    }

    /* Предотвращение горизонтального скролла при открытом sidebar */
    body.filters-open {
        overflow: hidden;
        width: 100vw;
        max-width: 100%;
    }

    /* Кнопка фильтра - видима только на мобильном */
    .filters-toggle-btn {
        display: block;
        width: 100%;
        padding: clamp(12px, 3vw, 16px);
        margin-bottom: 20px;
        background: white;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        font-size: clamp(0.9rem, 2vw, 1rem);
        font-weight: 600;
        color: var(--text-dark);
        cursor: pointer;
        transition: all 0.3s;
        position: relative;
    }

    .filters-toggle-btn:hover {
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

    .filters-toggle-btn i {
        margin-right: 8px;
    }

    .filters-active-count {
        display: none;
        margin-left: 6px;
        padding: 3px 7px;
        background: linear-gradient(135deg, #ff6b6b, #ff5252);
        color: white;
        border-radius: 14px;
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1;
        box-shadow: 0 2px 6px rgba(255, 82, 82, 0.3);
        transition: all 0.2s ease;
    }

    .filters-toggle-btn:hover .filters-active-count {
        transform: scale(1.1);
        box-shadow: 0 3px 8px rgba(255, 82, 82, 0.4);
    }

    /* Overlay для фильтров */
    .filters-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        transition: opacity 0.3s ease;
        opacity: 0;
    }

    .filters-overlay.active {
        display: block !important;
        opacity: 1 !important;
    }

    .filters-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: clamp(16px, 3vw, 24px);
        border-bottom: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1001;
    }

    .filters-header h3 {
        margin: 0;
        font-size: clamp(1rem, 2.5vw, 1.2rem);
    }

    .filters-close-btn {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #666;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filters-close-btn:hover {
        color: #000;
    }

    .nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: clamp(16px, 3vw, 24px);
        border-bottom: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1001;
    }

    .nav-header h3 {
        margin: 0;
        font-size: clamp(1rem, 2.5vw, 1.2rem);
    }

    .nav-close-btn {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #666;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-close-btn:hover {
        color: #000;
    }

    .filters-overlay.active { z-index: 0; }

    .main-nav a {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .main-nav a i {
        margin-right: 8px;
    }

    .catalog-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 849px) {
    #catalog-columns-menu {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        display: flex !important;
        flex-direction: column !important;
        /* flex-wrap: wrap !important; */
        z-index: auto !important;

        /* Анимация закрытия */
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
        transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.4s ease,
                    padding 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .main-nav .has-dropdown:hover #catalog-columns-menu {
        transform: none !important;

        /* Анимация открытия */
        max-height: 100vh !important;
        opacity: 1 !important;
    }

    .dropdown-column {
        width: 100% !important;
        margin: 0 !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;

        /* Плавное появление элементов */
        animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
    }

    .dropdown-column:nth-child(1) { animation-delay: 0.05s !important; }
    .dropdown-column:nth-child(2) { animation-delay: 0.1s !important; }
    .dropdown-column:nth-child(3) { animation-delay: 0.15s !important; }
    .dropdown-column:nth-child(4) { animation-delay: 0.2s !important; }

    @keyframes slideInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}



@media (max-width: 1024px) {
    .products-grid { grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 1.5vw, 16px); }
}

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

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

/* ============================================
   FOOTER & SIMILAR PRODUCTS
   ============================================ */

/* ============================================
   IMAGES
   ============================================ */

.product-image { aspect-ratio: 1; overflow: hidden; }
.product-image img { width: 100%; height: 100%; object-fit: contain; }

.main-image { aspect-ratio: 1; overflow: hidden; }
.main-image img { width: 100%; height: 100%; object-fit: contain; }

.thumbnail { aspect-ratio: 1; overflow: hidden; }
.thumbnail img { width: 100%; height: 100%; object-fit: contain; }

.banners-carousel { aspect-ratio: 16 / 5.5; }

@media (max-width: 1450px) {
    .banners-carousel { aspect-ratio: 16 / 7; }
}

@media (max-width: 768px) {
    .banners-carousel { aspect-ratio: 16 / 9; }
}

/* ============================================
   CONTAINER & SPACING
   ============================================ */

.container { padding: 0 clamp(10px, 2vw, 20px); }
section { padding: clamp(30px, 5vw, 80px) 0; }

/* ============================================
   BUTTONS & FORMS
   ============================================ */

button, .btn {
    padding: clamp(8px, 1.5vw, 12px) clamp(16px, 2vw, 24px);
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    border-radius: 6px;
    transition: all 0.3s ease;
}

input, textarea, select {
    padding: clamp(8px, 1.5vw, 12px) clamp(12px, 2vw, 16px);
    font-size: clamp(0.85rem, 2vw, 1rem);
    border-radius: 6px;
}

/* ============================================
   RESPONSIVE IMAGES FALLBACK
   ============================================ */

img[src="undefined"] { src: url('/assets/images/no-image.svg'); }

/* ============================================
   HEADER - CENTER ALIGNED
   ============================================ */

.header-top .container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: clamp(12px, 2vw, 20px);
}

.header-contacts {
    display: flex;
    gap: clamp(10px, 1.5vw, 16px);
    align-items: center;
    flex-wrap: wrap;
}

.header-user {
    display: flex;
    gap: clamp(10px, 1.5vw, 16px);
    align-items: center;
}

.logo-img { max-height: clamp(40px, 8vw, 70px); }

/* ============================================
   MOBILE ADAPTATIONS
   ============================================ */

@media (max-width: 1450px) {
    h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
    h2 { font-size: clamp(1.2rem, 3vw, 1.8rem); }
}


@media (max-width: 1024px) {
    .header {
        position: static;
    }

    .header-top { flex-direction: column; }
    .header-top .container { display: flex; flex-direction: column; gap: 0; }

    .header-contacts,
    .email-link {
        display: none;
    }
}

@media (max-width: 700px) {
    .header-contacts { flex-direction: column; }
}

@media (max-width: 768px) {
    .header-top { flex-direction: column; }
    .header-top .container { display: flex; flex-direction: column; gap: 0; }

    .product-actions { grid-template-columns: 1fr; }
    /* .thumbnails остаётся flex с horizontal scroll */

    .pagination { flex-wrap: wrap; gap: clamp(8px, 1vw, 12px); }
}

/* Attribute names остаются 200px везде, кроме мобильных 480px */

@media (max-width: 568px) {
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .category-card p { display: none; }
    .products-grid { grid-template-columns: repeat(2, 1fr); }
    /* .thumbnails остаётся flex с horizontal scroll */
    .header-contacts { flex-direction: column; }

    /* Product description mobile - aggressive spacing reset */
    .tab-content {
        padding: 0 !important;
    }

    .tab-content * {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .product-attributes {
        margin-bottom: 12px !important;
    }

    h3 {
        text-align: center !important;
    }

    .product-attributes h3 {
        margin-bottom: 10px !important;
        font-size: clamp(0.8rem, 2vw, 0.95rem);
    }

    .tab-content > h3 {
        margin: 12px 0 8px 0 !important;
        font-size: clamp(0.8rem, 2vw, 0.95rem);
    }

    .tab-content > p {
        margin: 0 0 8px 0 !important;
        line-height: 1.4;
        font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    }

    .attribute-item {
        display: flex;
        padding: 8px 0 !important;
        margin: 0 !important;
        border-bottom: 1px solid var(--border-color);
        align-items: center;
        gap: 8px;
    }

    .attribute-name {
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 0 !important;
        font-weight: 700;
        font-size: clamp(0.75rem, 1.5vw, 0.85rem);
        white-space: nowrap;
    }

    .attribute-name::after {
        content: "" !important;
    }

    .attribute-value {
        color: var(--text-light);
        font-size: clamp(0.75rem, 1.5vw, 0.85rem);
        margin: 0 !important;
        padding: 0 !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    .review-form {
        margin-top: 12px !important;
    }

    .review-form h3 {
        margin: 0 0 10px 0 !important;
    }

    .review-list .review-item {
        margin-bottom: 12px !important;
    }
}

/* При экране больше 850px показать основное меню */
@media (min-width: 850px) {
    .main-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 6px;
    }

    .main-nav a i {
        margin-right: 0;
    }

    .nav-close-btn,
    .nav-header {
        display: none !important;
    }

    .main-nav {
        position: static !important;
        background: transparent !important;
        box-shadow: none !important;
        display: block !important;
    }
}

/* Скрыть гамбургер на 850px и выше */
@media (min-width: 850px) {
    #mobile-menu-toggle {
        display: none !important;
    }
}

/* При экране больше 1024px скрыть кнопку фильтров и overlay */
@media (min-width: 1025px) {
    .filters-toggle-btn,
    .filters-overlay,
    .filters-close-btn,
    .filters-header {
        display: none !important;
    }

    .catalog-sidebar {
        position: static !important;
        height: auto !important;
    }
}

/* При экране больше 1200px убрать вертикальное меню */
@media (min-width: 1200px) {
    .main-nav a {
        flex-direction: row !important;
        text-align: left;
    }

    .main-nav a i {
        margin-right: 8px;
    }
}

/* Product page: цены слева только от 1025px */
@media (min-width: 1025px) {
    .product-price-block {
        align-items: flex-start !important;
    }
}


/* Features grid - 4 столбца на больших экранах */
@media (min-width: 1400px) {
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Популярные товары - минимум на мобильных */
@media (max-width: 768px) {
    .featured-products .products-grid {
        gap: 8px;
    }

    .featured-products .product-card {
        border-radius: 8px;
        min-width: unset !important;
        max-width: 160px !important;
        margin: 0 auto;
    }

    .featured-products .product-image {
        max-height: 150px;
    }

    .featured-products .product-info {
        padding: 8px;
    }

    .featured-products .product-name {
        font-size: 0.7rem;
        line-height: 1.2;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        margin-bottom: 4px;
    }

    .featured-products .product-price {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }

    .featured-products .product-actions {
        padding: 4px 8px;
    }

    .featured-products .btn {
        padding: 6px 8px !important;
        font-size: 0.65rem !important;
        height: auto !important;
        min-height: 28px !important;
    }

    .featured-products .btn i {
        font-size: 0.8rem !important;
    }
}

/* Header-main на мобильных (до 1000px) */
@media (max-width: 999px) {
    .header-main {
        padding: 12px 0 !important;
    }

    .header-main .container {
        flex-wrap: wrap;
        gap: 12px;
    }

    .logo {
        flex-shrink: 0;
        order: 1;
    }

    .logo-img {
        height: 50px !important;
        width: auto;
    }

    .mobile-menu-toggle {
        display: flex !important;
        position: fixed !important;
        top: 25px !important;
        right: 20px !important;
        z-index: 999 !important;
        order: unset;
        margin-left: unset;
        background: linear-gradient(135deg, #f39c12, #e67e22) !important;
        color: white !important;
        border-radius: 8px !important;
        padding: 0 !important;
        width: 25px !important;
        height: 26px !important;
        justify-content: center !important;
        align-items: center !important;
        box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3) !important;
        border: none !important;
        font-size: 1.2rem !important;
        transition: all 0.3s ease !important;
    }

    .mobile-menu-toggle.scrolled-down {
        width: 37px !important;
        height: 39px !important;
        font-size: 1.8rem !important;
        box-shadow: 0 6px 20px rgba(243, 156, 18, 0.5) !important;
    }

    .header-actions {
        flex-shrink: 0;
        order: 2;
        gap: 12px;
        justify-content: flex-end;
        margin-left: auto;
    }

    .search-form {
        flex: 1 1 100% !important;
        order: 3;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .header-action {
        font-size: 1.3rem !important;
    }

    .cart-total {
        display: none !important;
    }
}

/* Dropdown меню на мобильных */
@media (max-width: 768px) {
    #catalog-columns-menu {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        max-width: 95vw !important;
        width: 95vw !important;
        left: 50% !important;
        transform: translate(-50%, -10px) !important;
    }

    .dropdown-column {
        width: 100% !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 12px 15px !important;
    }

    .dropdown-column:last-child {
        border-bottom: none !important;
    }

    .column-title {
        font-size: 0.85rem !important;
        padding-bottom: 8px !important;
        margin-bottom: 8px !important;
    }

    .column-link {
        font-size: 0.8rem !important;
        padding: 6px 0 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }
}
