/* Product Catalog Fixes for Grid Alignment and Hover Issues */

/* Ensure consistent initial state for all product items */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 30px;
    contain: layout style paint;
    -webkit-contain: layout style paint;
    position: relative;
    z-index: 1;
}

/* Fix for the last item alignment issue */
.product-grid .product-item {
    transform: translateY(0) !important;
    opacity: 1 !important;
    will-change: transform, box-shadow;
    -webkit-transform: translateY(0) !important;
    -webkit-will-change: transform, box-shadow;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

/* Ensure all product items have the same initial state */
.product-grid .product-item:last-child {
    transform: translate3d(0, 0, 0) !important;
    -webkit-transform: translate3d(0, 0, 0) !important;
}

/* Set hover state explicitly */
.product-grid .product-item:hover {
    transform: translateY(-5px) !important;
    -webkit-transform: translateY(-5px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
}

/* Fix overlay rendering */
.product-grid .product-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.product-grid .product-item:hover .product-overlay {
    opacity: 1 !important;
}

/* Fix Safari and Firefox rendering issues */
@supports (-webkit-touch-callout: none) {
    .product-grid .product-item {
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
    }

    .product-grid .product-item:hover {
        transform: translate3d(0, -5px, 0) !important;
        -webkit-transform: translate3d(0, -5px, 0) !important;
    }
}

/* Fix for Firefox */
@-moz-document url-prefix() {
    .product-grid .product-item {
        transform: translateZ(0) !important;
    }

    .product-grid .product-item:hover {
        transform: translate3d(0, -5px, 0) !important;
    }
}

/* Improve image rendering */
.product-image-container {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.product-image {
    object-fit: cover;
    font-family: "object-fit: cover;"; /* For IE polyfill */
    background-color: #f8f9fa;
}

/* Fix for responsive grid on various screen sizes */
@media (max-width: 768px) {
    .product-grid .product-item:last-child {
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
    }
}
