/* HWD mobile fix v2 — 03.05.2026
   Safe mobile overrides for oct_remarket. Desktop is not changed. */

@media (max-width: 767.98px) {
    /* ===== CATEGORY: product grid ===== */
    #product-category .rm-category-products {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
        margin-left: -5px !important;
        margin-right: -5px !important;
    }

    #product-category .rm-category-products > .product-layout,
    #product-category .rm-category-products > .rm-module-col {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
        padding: 5px !important;
        margin: 0 !important;
    }

    #product-category .rm-category-products .rm-module-item {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        border: 1px solid #edf0f4 !important;
        border-radius: 10px !important;
        overflow: hidden !important;
        box-shadow: none !important;
    }

    /* Critical reset: the theme makes image/caption 50% wide on mobile.
       For a 2-column catalog card they must be 100% width and natural height. */
    #product-category .rm-category-products .rm-module-img,
    #product-category .rm-category-products .rm-module-caption {
        flex: 0 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        border-right: 0 !important;
        position: relative !important;
    }

    #product-category .rm-category-products .rm-module-img {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }

    #product-category .rm-category-products .rm-module-img > a {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        aspect-ratio: 1 / 1 !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #fafafa !important;
    }

    #product-category .rm-category-products .rm-module-img > a img,
    #product-category .rm-category-products .rm-module-img img.img-fluid,
    #product-category .rm-category-products .rm-module-img img.oct-lazy {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        object-fit: contain !important;
        display: block !important;
    }

    /* Hide side quick-action buttons on product cards: eye, wishlist, compare. */
    #product-category .rm-category-products .rm-module-buttons {
        display: none !important;
        visibility: hidden !important;
    }

    /* Admin product edit pencil: visible only to admin, but it blocks the mobile card. */
    #product-category .rm-category-products .oct-product-edit,
    #product-category .rm-category-products .oct-product-edit-link,
    #product-category .rm-category-products .product-edit,
    #product-category .rm-category-products .admin-edit,
    #product-category .rm-category-products a[href*="route=catalog/product/edit"] {
        display: none !important;
    }

    /* Stickers: compact and max 2 visible. */
    #product-category .rm-category-products .rm-module-stickers {
        position: absolute !important;
        top: 6px !important;
        left: 6px !important;
        right: 6px !important;
        z-index: 3 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
        pointer-events: none !important;
    }

    #product-category .rm-category-products .rm-module-stickers-sticker {
        max-width: 92% !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 4px 8px !important;
        border-radius: 3px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    #product-category .rm-category-products .rm-module-stickers-sticker:nth-child(n+3) {
        display: none !important;
    }

    #product-category .rm-category-products .rm-module-rating {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        min-height: 18px !important;
        margin: 5px 8px 0 !important;
        gap: 4px !important;
    }

    #product-category .rm-category-products .rm-module-rating-stars {
        display: flex !important;
        align-items: center !important;
        transform: scale(.86) !important;
        transform-origin: left center !important;
    }

    #product-category .rm-category-products .rm-module-rating-star:not(:last-child) {
        margin-right: 2px !important;
    }

    #product-category .rm-category-products .rm-module-reviews {
        display: flex !important;
        align-items: center !important;
        padding-left: 0 !important;
        margin-left: 2px !important;
        color: #8b93a1 !important;
        font-size: 11px !important;
        line-height: 1 !important;
    }

    #product-category .rm-category-products .rm-module-reviews img {
        width: 10px !important;
        height: 10px !important;
        margin-right: 3px !important;
    }

    #product-category .rm-category-products .rm-module-caption {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 0 !important;
        padding: 6px 8px 10px !important;
        margin: 0 !important;
        background: #fff !important;
        overflow: visible !important;
    }

    #product-category .rm-category-products .rm-module-title {
        display: block !important;
        min-height: 36px !important;
        margin: 0 0 5px !important;
        padding: 0 !important;
    }

    #product-category .rm-category-products .rm-module-title a {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        color: #222 !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1.28 !important;
        text-decoration: none !important;
    }

    #product-category .rm-category-products .rm-module-stock {
        align-self: flex-start !important;
        display: inline-flex !important;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 0 5px !important;
        padding: 3px 6px !important;
        border-radius: 6px !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }

    #product-category .rm-category-products .rm-category-product-model {
        display: block !important;
        margin: 0 0 5px !important;
        color: #7f8793 !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    #product-category .rm-category-products .rm-module-attr,
    #product-category .rm-category-products .rm-module-description,
    #product-category .rm-category-products .price-tax {
        display: none !important;
    }

    #product-category .rm-category-products .rm-module-price-box {
        display: flex !important;
        flex-direction: column !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #product-category .rm-category-products .rm-module-price-top {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        margin: 0 0 3px !important;
        min-height: 16px !important;
    }

    #product-category .rm-category-products .rm-module-price-old {
        padding-right: 0 !important;
        color: #8a8f99 !important;
        font-size: 12px !important;
        line-height: 1.1 !important;
        text-decoration: line-through !important;
    }

    #product-category .rm-category-products .rm-module-sticker-discount {
        height: auto !important;
        min-width: 0 !important;
        padding: 3px 7px !important;
        border-radius: 5px !important;
        font-size: 10px !important;
        line-height: 1.1 !important;
    }

    #product-category .rm-category-products .rm-module-price-bottom {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        margin: 0 !important;
        flex-grow: 0 !important;
    }

    #product-category .rm-category-products .rm-module-price {
        display: block !important;
        margin: 0 !important;
        color: #1f2328 !important;
        font-size: 19px !important;
        font-weight: 800 !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
    }

    #product-category .rm-category-products .rm-cart-btn {
        display: flex !important;
        width: 100% !important;
        min-width: 0 !important;
        height: 42px !important;
        min-height: 42px !important;
        margin: 0 !important;
        padding: 0 8px !important;
        border-radius: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        line-height: 1 !important;
    }

    #product-category .rm-category-products .rm-cart-btn .rm-btn-text {
        display: inline !important;
        color: #fff !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
    }

    #product-category .rm-category-products .rm-cart-btn-icon {
        flex: 0 0 auto !important;
    }

    /* Sort block: compact. */
    #product-category .rm-category-sort {
        margin-bottom: 8px !important;
    }

    #product-category .rm-category-sort-select {
        height: 40px !important;
        border-radius: 10px !important;
        font-size: 14px !important;
    }

    /* ===== PRODUCT PAGE ===== */
    #product-product .rm-product-title {
        width: 100% !important;
        padding: 0 !important;
        margin: 8px 0 8px !important;
    }

    #product-product .rm-product-title h1 {
        color: #222 !important;
        font-size: 22px !important;
        font-weight: 500 !important;
        line-height: 1.25 !important;
        margin: 0 !important;
    }

    #product-product #oct-tabs .nav-link {
        min-height: 40px !important;
        padding: 7px 4px !important;
        font-size: 13px !important;
        line-height: 1.15 !important;
    }

    #product-product .rm-product-mobile-fixed {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 10005 !important;
        min-height: 66px !important;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
        background: #fff !important;
        border-top: 1px solid #e8edf3 !important;
        box-shadow: 0 -4px 18px rgba(20, 28, 40, .12) !important;
        gap: 10px !important;
    }

    #product-product .rm-product-mobile-fixed-price-new {
        color: #1f2328 !important;
        font-size: 20px !important;
        font-weight: 800 !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
    }

    #product-product .hwd-fixed-buy-btn {
        width: 100% !important;
        max-width: 190px !important;
        height: 48px !important;
        min-height: 48px !important;
        margin: 0 !important;
        padding: 0 14px !important;
        border-radius: 10px !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        box-shadow: none !important;
    }

    /* Mobile: remove floating feedback button so it does not cover products. */
    #rm_fixed_contact_button,
    #rm_fixed_contact_substrate {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .hwd-mobile-bar {
        height: 62px !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        z-index: 1000 !important;
    }

    .hwd-mobile-item {
        min-height: 62px !important;
        font-size: 11px !important;
        text-decoration: none !important;
    }

    .hwd-mobile-item i {
        font-size: 19px !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    #product-category .rm-category-products > .product-layout,
    #product-category .rm-category-products > .rm-module-col {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }
}

/* HWD mobile fix v4 — прибираємо проміжок між мобільним header і вкладками товару */
@media (max-width: 767.98px) {
    /* row-padding-top у темі додавав зайву відстань над блоком: Опис / Характеристики / Відгуки */
    html body #product-product .row-padding-top.rm-product-tabs,
    html body #product-product .rm-product-tabs {
        position: sticky !important;
        top: 66px !important;
        z-index: 1001 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        background: #fff !important;
        border-top: 0 !important;
        box-shadow: none !important;
    }

    html body #product-product .rm-product-tabs .col-12 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    html body #product-product #oct-tabs {
        margin-top: 0 !important;
        padding-top: 0 !important;
        border-top: 0 !important;
    }

    html body #product-product #oct-tabs .nav-link {
        min-height: 42px !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
    }
}
