/* ==========================================================================
   UNIFIED PRODUCT CARD & GRID SYSTEM
   Loaded on every page that displays product cards (index, all_material,
   products related-items, search, wishlist) so the structure, spacing and
   responsive behaviour is IDENTICAL everywhere.

   Rule: Desktop = 4 columns | Mobile (<=768px) = 2 columns
   ========================================================================== */

/* ---------- 1. Grid containers (every page's product list, whatever
   class/id it happens to use) ---------- */
.homepage-products,
#main-collection-product-grid,
.search-product-grid,
.products-carousel .productListing,
.products-carousel ul,
#wishlist-grid,
ul.productGrid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 20px !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

@media (max-width: 768px) {
    .homepage-products,
    #main-collection-product-grid,
    .search-product-grid,
    .products-carousel .productListing,
    .products-carousel ul,
    #wishlist-grid,
    ul.productGrid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
}

/* Keep "no products found" / empty-state messages spanning the full grid */
li.product-empty-state {
    grid-column: 1 / -1 !important;
}

/* ---------- 2. Reset grid-item box model so legacy per-page rules
   (inline-block, extra padding, fixed heights) can never break the grid ---------- */
.homepage-products > li.product,
#main-collection-product-grid > li.product,
.search-product-grid > li.product,
.products-carousel .productListing > li.product,
#wishlist-grid > li.product,
ul.productGrid > li.product {
    display: block !important;
    vertical-align: initial !important;
    padding: 0 !important;
    margin: 0 !important;
    width: auto !important;
    max-width: none !important;
}
.homepage-products > li.product-empty-state,
#main-collection-product-grid > li.product-empty-state {
    padding: 0 !important;
}

/* ---------- 3. Unified card component ---------- */
.product-item {
    width: 100%;
    height: 100%;
    display: flex;
    box-sizing: border-box;
}
.product-item .card {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid #f0f0f0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.product-item:hover .card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}
.product-item .card-product,
.product-item .card-product__wrapper {
    position: relative;
    width: 100%;
}

/* Media / image box - identical square ratio everywhere */
.product-item .card-media--portrait {
    position: relative !important;
    padding-bottom: 100% !important;
    height: 0 !important;
    max-height: none !important;
    overflow: hidden;
    background: #f8f8f8;
    margin-top: 0 !important;
}
.product-item .card-media--portrait img {
    position: absolute !important;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover !important;
    padding: 0 !important;
    transition: transform 0.5s ease;
}
.product-item .card-media:hover img { transform: scale(1.06); }
.product-item .card-media .hover-image { display: none !important; }

/* Info / text block */
.product-item .card-information {
    background: #ffffff;
    padding: 15px !important;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.product-item .card-information__wrapper {
    text-align: left;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}
.product-item .card-information__wrapper .rating-stars {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px !important;
    line-height: 1 !important;
}
.product-item .card-information__wrapper .rating-stars .stars {
    font-size: 16px !important;
    letter-spacing: 1px;
    line-height: 1 !important;
    white-space: nowrap;
}
/* Black stars everywhere: filled = solid black, empty = black outline on white */
.product-item .card-information__wrapper .rating-stars .star-filled {
    color: #000000 !important;
}
.product-item .card-information__wrapper .rating-stars .star-empty {
    color: #000000 !important;
}
.product-item .card-information__wrapper .rating-stars .rating-text {
    font-size: 12px !important;
    color: #666 !important;
    line-height: 1 !important;
    font-weight: 500;
}
.product-item .card-title {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
    margin: 4px 0 8px !important;
    font-weight: 500;
    text-decoration: none;
    color: #333;
    font-size: 15px !important;
    line-height: 1.15 !important;
}
.product-item .pro-price {
    display: block !important;
    color: #d40000 !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    margin-top: auto !important;
    margin-bottom: 12px !important;
}
.product-item .card-action {
    width: 100%;
    margin-top: 0 !important;
}
.product-item .btn-view-product-card {
    display: block !important;
    text-align: center;
    background: #0A1128;
    color: #fff !important;
    padding: 10px !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px !important;
    font-weight: 600;
    width: 100%;
    box-sizing: border-box;
    border: none;
    cursor: pointer;
    opacity: 1 !important;
    visibility: visible !important;
    transition: background 0.25s ease, transform 0.25s ease;
}
.product-item .btn-view-product-card:hover {
    background: #E4212A;
    transform: translateY(-2px);
}

/* Featured / sale badges - identical everywhere */
.product-item .featured-badge {
    position: absolute; top: 10px; left: 10px;
    background: #f5b342; color: #fff;
    padding: 4px 12px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    z-index: 5; box-shadow: 0 2px 8px rgba(245, 179, 66, 0.3);
}

/* ---------- 4. Mobile polish (<=768px) so the 2-column layout stays
   readable and consistent across every page ---------- */
@media (max-width: 768px) {
    .product-item .card-information { padding: 10px !important; }
    .product-item .card-information__wrapper .rating-stars .stars {
        font-size: 13px !important;
    }
    .product-item .card-information__wrapper .rating-stars .rating-text {
        font-size: 11px !important;
    }
    .product-item .card-title {
        font-size: 12px !important;
        min-height: 2.4em;
        margin: 2px 0 6px !important;
    }
    .product-item .pro-price {
        font-size: 13px !important;
        margin-bottom: 8px !important;
    }
    .product-item .btn-view-product-card {
        font-size: 12px !important;
        padding: 8px 5px !important;
    }
}
