/* ========================================
   ГЛОБАЛЬНОЕ ИСПРАВЛЕНИЕ МОБИЛЬНОЙ ВЕРСИИ
   Убираем горизонтальную прокрутку везде
   Унифицируем отступы
   ======================================== */

/* БАЗОВЫЕ ПРАВИЛА - УБИРАЕМ OVERFLOW */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* Все элементы не должны вылезать за экран */
* {
    max-width: 100%;
}

/* Все контейнеры и секции */
section,
div,
article,
main,
header,
footer,
nav {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ========================================
   ЕДИНЫЕ ОТСТУПЫ ДЛЯ МОБИЛЬНОЙ ВЕРСИИ
   ======================================== */

/* ДЕСКТОП - оставляем как есть */
@media (min-width: 769px) {
    .luxury-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 3rem;
    }

    .luxury-container-wide {
        max-width: 1440px;
        margin: 0 auto;
        padding: 0 3rem;
    }
}

/* ПЛАНШЕТ - средние отступы */
@media (max-width: 768px) and (min-width: 481px) {
    .luxury-container,
    .luxury-container-wide {
        padding: 0 1.5rem !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Все секции с паддингом */
    section,
    main {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* Контейнеры внутри секций - убираем двойной padding */
    section .luxury-container,
    section .luxury-container-wide,
    main .luxury-container,
    main .luxury-container-wide {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* МОБИЛЬНЫЙ - одинаковые отступы 1rem (16px) */
@media (max-width: 480px) {
    /* ГЛАВНЫЙ КОНТЕЙНЕР */
    .luxury-container,
    .luxury-container-wide {
        padding: 0 1rem !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Все секции с единым паддингом */
    section,
    main,
    article {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        box-sizing: border-box !important;
    }

    /* Контейнеры внутри секций - убираем двойной padding */
    section .luxury-container,
    section .luxury-container-wide,
    main .luxury-container,
    main .luxury-container-wide,
    article .luxury-container,
    article .luxury-container-wide {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Хедер и футер - тоже 1rem */
    header,
    .luxury-header,
    .luxury-header-container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    footer,
    .luxury-footer {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Контейнеры внутри хедера/футера */
    header .luxury-container,
    footer .luxury-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* ========================================
   ИСПРАВЛЕНИЕ ПРОБЛЕМНЫХ ЭЛЕМЕНТОВ
   ======================================== */

/* Изображения и медиа */
img,
video,
iframe,
svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Таблицы */
table {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
}

/* Формы */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea,
select {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Кнопки */
button,
.luxury-btn-primary,
.luxury-btn-secondary,
.btn {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Карточки */
.product-card,
.collection-card,
.category-visual-card {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Сетки */
.products-grid,
.categories-grid,
[style*="display: grid"],
[style*="display: flex"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ========================================
   СПЕЦИФИЧНЫЕ ИСПРАВЛЕНИЯ ДЛЯ СТРАНИЦ
   ======================================== */

/* HERO секции - убираем overflow */
.luxury-hero,
.catalog-hero,
.about-hero {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

/* Breadcrumbs */
.breadcrumbs {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

.breadcrumbs ol {
    flex-wrap: wrap !important;
}

/* Фильтры */
.catalog-filters,
.filter-select,
.price-range-slider {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Пагинация */
.pagination {
    max-width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}

/* Корзина */
.cart-items,
.cart-item {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Checkout форма */
.checkout-form {
    max-width: 100% !important;
}

/* ========================================
   МОБИЛЬНЫЕ УТИЛИТЫ
   ======================================== */

@media (max-width: 480px) {
    /* Скрыть на мобильных */
    .mobile-hide {
        display: none !important;
    }

    /* Текст по центру на мобильных */
    .mobile-center {
        text-align: center !important;
    }

    /* Полная ширина на мобильных */
    .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Стек на мобильных (колонка) */
    .mobile-stack {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Убрать gap на мобильных */
    .mobile-no-gap {
        gap: 0 !important;
    }

    /* Уменьшить gap на мобильных */
    .mobile-small-gap {
        gap: 0.5rem !important;
    }
}

/* ========================================
   ИСПРАВЛЕНИЕ INLINE СТИЛЕЙ
   ======================================== */

/* Любые элементы с фиксированной шириной больше экрана */
@media (max-width: 480px) {
    [style*="width: 1200px"],
    [style*="width: 1440px"],
    [style*="width: 100vw"],
    [style*="min-width: 1200px"],
    [style*="min-width: 1440px"] {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    /* Padding которые слишком большие */
    [style*="padding: 6rem"],
    [style*="padding: 4rem"] {
        padding: 2rem 1rem !important;
    }

    [style*="padding: 3rem"] {
        padding: 1.5rem 1rem !important;
    }

    /* Margin которые слишком большие */
    [style*="margin: 4rem"],
    [style*="margin: 3rem"] {
        margin: 1.5rem 0 !important;
    }

    /* Gap слишком большой */
    [style*="gap: 3rem"],
    [style*="gap: 4rem"],
    [style*="gap: 6rem"] {
        gap: 1rem !important;
    }
}

/* ========================================
   ФИКСЫ ДЛЯ SVG И ИКОНОК
   ======================================== */

/* SVG не должны вызывать overflow */
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Декоративные SVG паттерны */
[style*="background-image: url('data:image/svg+xml"] {
    background-size: contain !important;
}

/* ========================================
   АНТИOVERFLOW - ПОСЛЕДНЯЯ ЛИНИЯ ОБОРОНЫ
   ======================================== */

/* Если что-то все равно вылезает - режем! */
@media (max-width: 480px) {
    body > * {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Все прямые дети body */
    body > section,
    body > main,
    body > header,
    body > footer,
    body > div {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
}

/* ========================================
   МОБИЛЬНЫЙ КАТАЛОГ - ИСПРАВЛЕНИЯ КЛИКАБЕЛЬНОСТИ
   ======================================== */

@media (max-width: 768px) {
    /* Все интерактивные элементы должны работать на касание */
    .product-card,
    .product-card > a,
    .category-visual-card,
    .category-visual-card > a,
    button,
    .luxury-btn-primary,
    .luxury-btn-secondary,
    .add-to-cart-btn,
    .quick-view-btn,
    .wishlist-btn,
    .compare-btn {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(184, 134, 11, 0.1) !important;
        cursor: pointer !important;
    }

    /* Убираем pointer-events: none с интерактивных элементов */
    .product-card,
    .product-card *:not(.product-image::before):not([style*="pointer-events: none"]),
    .category-visual-card,
    .category-visual-card * {
        pointer-events: auto !important;
    }

    /* Карточки товаров на мобильных - полностью кликабельные */
    .product-card {
        position: relative !important;
        z-index: 1 !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }

    .product-card > a {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 2 !important;
        position: relative !important;
    }

    /* Карточки категорий - кликабельные */
    .category-visual-card {
        position: relative !important;
        z-index: 1 !important;
        cursor: pointer !important;
    }

    .category-visual-card > a,
    .category-visual-card a {
        z-index: 2 !important;
        position: relative !important;
    }

    /* Убираем трансформации которые могут мешать кликам */
    .product-card:active,
    .category-visual-card:active {
        transform: scale(0.98) !important;
    }

    /* Модальное окно - полностью кликабельное */
    #productModal {
        touch-action: manipulation !important;
        z-index: 99999 !important;
    }

    #productModal * {
        pointer-events: auto !important;
    }

    /* Кнопки в модальном окне */
    #productModal button,
    #productModal .add-to-cart-btn,
    #productModal .close-modal {
        touch-action: manipulation !important;
        cursor: pointer !important;
        z-index: 100 !important;
    }
}

@media (max-width: 480px) {
    /* На совсем маленьких экранах увеличиваем область клика */
    .product-card,
    .category-visual-card,
    button,
    a {
        min-height: 44px !important; /* iOS рекомендация для касаний */
        min-width: 44px !important;
    }

    /* Карточки товаров - увеличить для удобства */
    .product-card {
        min-height: 110px !important;
    }

    /* Убираем все overlay которые могут блокировать клики */
    .product-card::before,
    .product-card::after,
    .category-visual-card::before,
    .category-visual-card::after {
        pointer-events: none !important;
    }

    /* Градиентные overlay - не должны блокировать */
    [style*="position: absolute"][style*="background: linear-gradient"],
    [style*="position: absolute"][style*="background: radial-gradient"] {
        pointer-events: none !important;
    }

    /* Все ссылки и кнопки кликабельны */
    a, button, .btn, [role="button"] {
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }
}

/* ========================================
   DEBUG - раскомментировать для отладки
   ======================================== */

/*
@media (max-width: 480px) {
    * {
        outline: 1px solid rgba(255, 0, 0, 0.1) !important;
    }

    [style*="width: "],
    [style*="min-width: "],
    [style*="padding: "],
    [style*="margin: "] {
        outline: 2px solid red !important;
    }
}
*/
