/*
 * Custom Product Card Styles
 */

/* Flexbox grid setup */
.woocommerce ul.products {
    display: flex;
    flex-wrap: wrap;
}

.custom-product-card {
    list-style: none;
    margin-bottom: 30px;
    padding: 0; /* Remove padding from the grid item */
    display: flex; /* Make the li a flex item to stretch its content */
    flex-direction: column;
}

.custom-product-card .card-inner {
    position: relative;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    transition: box-shadow 0.3s ease-in-out;
    height: 100%; /* Ensures cards in a row have the same height */
    display: flex;
    flex-direction: column;
}

.custom-product-card:hover .card-inner {
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.custom-product-card .product-details-wrapper {
    flex-grow: 1; /* This makes the wrapper grow, pushing the button to the bottom */
}

.custom-product-card .product-type-tag {
    position: absolute;
    top: -10px;
    left: -10px;
    background-color: #e8f0e9;
    color: #0a4729;
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.custom-product-card .product-image-wrapper {
    margin-bottom: 20px;
}

.custom-product-card .product-image-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.custom-product-card .certifications {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.custom-product-card .certification-badge {
    background-color: #0a4729;
    color: #fff;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.custom-product-card .woocommerce-loop-product__title {
    font-size: 24px;
    color: #0a4729;
    margin-bottom: 10px;
    line-height: 1.25em; /* Set a consistent line height */
    min-height: 2.5em; /* min-height for 2 lines (2 * 1.25em) */

    /* Truncate text to 2 lines with ellipsis */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Number of lines to show */
    -webkit-box-orient: vertical;
}

.custom-product-card .woocommerce-loop-product__title a {
    text-decoration: none;
    color: inherit;
}

.custom-product-card .product-short-description {
    color: #555;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.custom-product-card .view-details-button {
    background-color: #f58220;
    color: #fff;
    border-radius: 25px;
    padding: 12px 30px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.custom-product-card .view-details-button:hover {
    background-color: #e07010;
}

.custom-product-card .view-details-button .arrow {
    margin-left: 5px;
    transition: transform 0.3s ease;
}

.custom-product-card .view-details-button:hover .arrow {
    transform: translateX(5px);
}

/*
 * Force 4-column grid layout using flexbox
 */
.woocommerce ul.products.columns-4 li.product {
    width: 22.05%; 
    margin: 0 3.8% 2.992em 0;
}

.woocommerce ul.products li.product.last {
    margin-right: 0;
}

/* We don't need float/clear with flexbox */
.woocommerce ul.products li.product.first {
    clear: none;
}

/*
 * Overrides for Related Products section
 */
.related.products .custom-product-card .card-inner {
    background: none;
    border: none;
    padding: 0;
    text-align: left;
}

.related.products .custom-product-card:hover .card-inner {
    box-shadow: none;
}

.related.products .custom-product-card .product-type-tag,
.related.products .custom-product-card .certifications {
    display: none;
}

.related.products .custom-product-card .woocommerce-loop-product__title {
    font-size: 18px; /* Smaller font for related products */
    line-height: 1.3em;
    min-height: 2.6em; /* for 2 lines */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.related.products .custom-product-card .view-details-button {
    background-color: #8a9a5b; /* Olive green color from image */
    text-align: center;
    display: inline-block;
    width: auto;
}

.related.products .custom-product-card .view-details-button:hover {
    background-color: #78864a;
}