/* Mobile product layout system based on the provided ti.ua mobile reference.
   Catalog remains a 2-column grid. Home/product sections use compact horizontal carousels. */

@media (max-width: 767px) {
    html,
    body { max-width: 100%; overflow-x: hidden; }

    .shell,
    .page-card,
    .catalog-content,
    .home-hero-grid { box-sizing: border-box; max-width: 100%; min-width: 0; }

    .page-card { padding-left: 10px !important; padding-right: 10px !important; }

    .products,
    .products-polished,
    .catalog-products,
    .product,
    .product-card-v2,
    .product-card-v2 * { box-sizing: border-box; min-width: 0; }

    .products:not(.catalog-products),
    .products-polished:not(.catalog-products) {
        display: grid !important;
        grid-auto-flow: column !important;
        grid-auto-columns: clamp(188px, 60vw, 238px) !important;
        grid-template-columns: none !important;
        gap: 8px !important;
        width: auto !important;
        max-width: none !important;
        margin-left: -10px !important;
        margin-right: -10px !important;
        padding: 0 10px 9px !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .products:not(.catalog-products)::-webkit-scrollbar,
    .products-polished:not(.catalog-products)::-webkit-scrollbar { display: none; }

    .products:not(.catalog-products) > *,
    .products-polished:not(.catalog-products) > * { scroll-snap-align: start; }

    .catalog-products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow: visible !important;
    }

    .product,
    .product-card-v2,
    .products .product-card-v2,
    .products-polished .product-card-v2,
    .catalog-products .product-card-v2 {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 312px !important;
        height: auto !important;
        margin: 0 !important;
        padding: 7px !important;
        overflow: hidden !important;
        border-radius: 14px !important;
        background: #fff !important;
        box-shadow: 0 5px 14px rgba(17, 26, 54, .052) !important;
        transform: none !important;
    }

    .catalog-products .product-card-v2 {
        min-height: 274px !important;
        padding: 7px !important;
    }

    .product-card-v2__photo,
    .product .photo,
    .products .product-card-v2__photo,
    .products-polished .product-card-v2__photo,
    .catalog-products .product-card-v2__photo {
        flex: 0 0 auto !important;
        display: grid !important;
        place-items: center !important;
        width: 100% !important;
        aspect-ratio: auto !important;
        height: 164px !important;
        min-height: 164px !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 8px !important;
        overflow: hidden !important;
        border-radius: 12px !important;
        background: #f6f7fb !important;
    }

    .catalog-products .product-card-v2__photo {
        height: 124px !important;
        min-height: 124px !important;
        max-height: none !important;
    }

    .product-card-v2__photo img,
    .product .photo img,
    .products .product-card-v2__photo img,
    .products-polished .product-card-v2__photo img,
    .catalog-products .product-card-v2__photo img {
        display: block !important;
        width: auto !important;
        height: auto !important;
        max-width: 84% !important;
        max-height: 84% !important;
        object-fit: contain !important;
        object-position: center !important;
        transform: none !important;
        margin: auto !important;
    }

    .catalog-products .product-card-v2__photo img {
        max-width: 78% !important;
        max-height: 78% !important;
    }

    .favorite-toggle { top: 8px !important; right: 8px !important; width: 27px !important; height: 27px !important; border-radius: 9px !important; background: rgba(255, 255, 255, .88) !important; font-size: 16px !important; }

    .product-card-v2__body { display: flex !important; flex-direction: column !important; flex: 1 1 auto !important; width: 100% !important; min-width: 0 !important; min-height: 0 !important; padding-top: 5px !important; overflow: visible !important; }

    .product-card-v2__top { display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 3px !important; min-width: 0 !important; }

    .status-inline,
    .product-code {
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 19px !important;
        padding: 3px 5px !important;
        overflow: hidden !important;
        border-radius: 999px !important;
        font-size: 8.8px !important;
        line-height: 1 !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .product-code { flex: 1 1 54px !important; color: #7b8498 !important; font-weight: 900 !important; }

    .product-card-v2__title {
        display: -webkit-box !important;
        min-height: 28px !important;
        margin-top: 4px !important;
        overflow: hidden !important;
        color: #111a36 !important;
        font-size: 12px !important;
        font-weight: 950 !important;
        line-height: 1.08 !important;
        letter-spacing: -.035em !important;
        text-decoration: none !important;
        -webkit-box-orient: vertical !important;
        -webkit-line-clamp: 2 !important;
    }

    .product-card-v2__chips { display: flex !important; flex-wrap: wrap !important; gap: 3px !important; max-height: 36px !important; margin-top: 4px !important; overflow: hidden !important; }

    .product-card-v2__chips span {
        max-width: 100% !important;
        padding: 3px 5px !important;
        overflow: hidden !important;
        border-radius: 999px !important;
        background: #f0f2f6 !important;
        color: #6a7287 !important;
        font-size: 8.8px !important;
        font-weight: 850 !important;
        line-height: 1 !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .product-card-v2__bottom {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 5px !important;
        width: 100% !important;
        min-width: 0 !important;
        margin-top: auto !important;
        padding-top: 6px !important;
    }

    .card-price { min-width: 0 !important; }
    .card-price strong { display: block !important; overflow: hidden !important; color: #111a36 !important; font-size: 13.5px !important; line-height: 1.05 !important; text-overflow: ellipsis !important; white-space: nowrap !important; }

    .product-card-v2__bottom form,
    .product-card-v2__bottom .button,
    .product-card-v2__bottom button.button { width: 100% !important; max-width: 100% !important; }

    .product-card-v2__bottom .button,
    .product-card-v2__bottom button.button { min-height: 31px !important; padding: 0 7px !important; border-radius: 10px !important; font-size: 10.5px !important; white-space: nowrap !important; }

    .quick-actions { width: auto !important; max-width: calc(100vw - 20px) !important; }
}

@media (max-width: 390px) {
    .products:not(.catalog-products),
    .products-polished:not(.catalog-products) { grid-auto-columns: clamp(190px, 66vw, 238px) !important; }

    .catalog-products { gap: 6px !important; }

    .product,
    .product-card-v2,
    .products .product-card-v2,
    .products-polished .product-card-v2,
    .catalog-products .product-card-v2 { min-height: 304px !important; }

    .catalog-products .product-card-v2 { min-height: 270px !important; }
    .catalog-products .product-card-v2__photo {
        height: 118px !important;
        min-height: 118px !important;
        max-height: none !important;
    }
    .catalog-products .product-card-v2__title { font-size: 11.5px !important; min-height: 27px !important; }
    .catalog-products .product-card-v2__chips span { font-size: 8.5px !important; padding: 3px 4px !important; }
    .catalog-products .card-price strong { font-size: 13px !important; }
}