/**
 * Complete CSS Styling for the [custom_product_list] Shortcode Output
 * Targets the custom HTML structure generated by the PHP function
 * using 'mai-' prefixed classes.
 */

/* Styles for the main WooCommerce wrapper if needed (adjust columns etc.) */
.woocommerce ul.products {
    list-style: none;
    padding: 0;
    margin: 0;
    clear: both;
}

/* Style the standard LI product container generated by WC loop */
.woocommerce ul.products li.product {
    /* Reset theme defaults if necessary */
    padding: 0;
    border: none;
    box-shadow: none;
    background: none;
    text-align: left; /* Or center if preferred */
    margin-bottom: 2em; /* Space between products */
    position: relative; /* For sale flash positioning */
    overflow: visible; /* Allow potential hover effects */
}

/* Inner wrapper for the custom card structure */
.mai-product-card-inner {
    background-color: #ffffff; /* White background for the card */
    border: none; /* Light grey border */
    border-radius: 8px; /* Rounded corners */
    padding: 0; /* Padding inside the card */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* Subtle shadow */
    transition: box-shadow 0.3s ease-in-out, transform 0.3s ease-in-out; /* Smooth transition for hover */
    text-align: center; /* Center align content */
    overflow: hidden; /* Hide overflow */
    display: flex; /* Optional: use flex for layout */
    flex-direction: column; /* Stack elements vertically */
    height: 100%; /* Make card fill the li height if needed */
}

.woocommerce ul.products li.product:hover .mai-product-card-inner {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); /* Slightly larger shadow on hover */
    transform: translateY(-3px); /* Slight lift effect */
}

/* Image Wrapper */
.mai-product-image-wrapper {
    margin-bottom: 1em; /* Space below image */
    position: relative; /* For sale flash positioning */
}

.mai-product-image-wrapper a {
    display: block;
    text-decoration: none;
}

.mai-product-image-wrapper img {
    display: block; /* Remove extra space below image */
    margin: 0 auto; /* Center image */
    max-width: 100%; /* Ensure image is responsive */
    height: auto; /* Maintain aspect ratio */
    border-radius: 4px; /* Slightly rounded corners for image */
}

/* On Sale Badge (targets standard WC class within our structure) */
.mai-product-image-wrapper .onsale {
    position: absolute;
    top: 10px;
    left: 10px; /* Position top-left */
    background-color: #dc3545; /* Red sale badge */
    color: #ffffff;
    padding: 3px 8px;
    font-size: 0.8em;
    font-weight: bold;
    border-radius: 4px;
    z-index: 2; /* Ensure it's above the image */
    line-height: 1.5;
    margin: 0; /* Reset margin */
}


/* Info Wrapper (contains title, rating, bottom section) */
.mai-product-info-wrapper {
    background-color: #fff;
    max-width: 100%;
    flex-grow: 1; /* Allow this section to grow */
    display: flex;
    flex-direction: column;
}

/* Product Title */
.mai-product-title {
    font-size: 1.1em; /* Adjust title size */
    color: #333; /* Darker title color */
    margin: 0 0 0.5em 0; /* Space below title */
    padding: 0;
    font-weight: 600; /* Slightly bolder title */
}

.mai-product-title a {
    text-decoration: none;
    color: inherit;
}

.mai-product-title a:hover {
    color: #5a4b81; /* Example hover color */
}

/* Rating Wrapper */
.mai-product-rating-wrapper {
    margin: 0 auto 0.75em auto; /* Center rating and add space below */
}

/* Target the standard WC star rating within our wrapper */
.mai-product-rating-wrapper .star-rating {
    font-size: 0.9em; /* Adjust rating size if needed */
    /* Inherits WC default styles, add overrides if needed */
}

/* Bottom Section (Add to Cart & Price) */
.mai-product-info-bottom {
    display: flex;
    border: 1px solid #111;
    border-radius: 4px;
    overflow: hidden;
    margin-top: auto; /* Push to bottom when info-wrapper uses flex */
    margin: 1px 1px;
}

/* Add to Cart Box */
.mai-add-to-cart-box {
    flex: 1 1 0; /* Allow flex items to grow and shrink */
    min-width: 0; /* Prevent overflow on smaller screens */
    background: #fff;
    display: flex; /* Use flex for button alignment */
    align-items: stretch; /* Stretch button vertically */
    justify-content: center;
    position: relative; /* For button pseudo-element */
    border: none;
    text-transform: uppercase;
    color: #1a0e2a;
    padding: 0; /* Remove padding, button handles it */
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    border-right: 1px solid #1a0e2a;
}

/* Add to Cart Button */
.mai-add-to-cart-box .mai-button {
    position: relative;
    overflow: hidden;
    padding: 12px 10px; /* Button padding */
    font-family: 'Tajawal', sans-serif; /* Ensure font is loaded */
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    color: #1a0e2a;
    text-align: center;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.3s ease;
    z-index: 1;
    width: 100%; /* Full width of its container */
    height: 100%; /* Full height of its container */
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
}

/* Animated background effect for the button */
.mai-add-to-cart-box .mai-button::after {
    content: '';
    background-color: rgb(56, 33, 81); /* Dark purple background */
    position: absolute;
    top: 0;
    left: 0;
    width: 150%;
    height: 100%;
    z-index: -1; /* Place behind the text */
    transform: rotate3d(0, 0, 1, 10deg) translate3d(-1.2em, 110%, 0); /* Initial off-screen position */
    transform-origin: 0% 100%; /* Rotate from bottom-left */
    transition: transform 0.5s cubic-bezier(0.59, 0.03, 0.2, 1); /* Smooth animation */
}

/* Button hover state */
.mai-add-to-cart-box .mai-button:hover {
    z-index: 3; /* Ensure text stays above background */
    color: #fff !important; /* Change text color on hover */
}

/* Button hover state for the animated background */
.mai-add-to-cart-box .mai-button:hover::after {
    transform: rotate3d(0, 0, 1, 0deg) translate3d(0, 0, 0); /* Animate background into view */
}

/* Styling for 'added' state (targets standard WC class on button/link) */
.mai-add-to-cart-box a.added_to_cart {
    display: inline-block; /* Or block if needed */
    margin-left: 10px; /* Space next to button if needed */
    color: #28a745; /* Green checkmark/text color */
    font-size: 0.9em;
}


/* Price Box */
.mai-price-box {
    flex: 1 1 0; /* Allow flex items to grow and shrink */
    min-width: 0; /* Prevent overflow on smaller screens */
    padding: 4px 0 0 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap; /* Prevent text wrapping */
    position: relative;
    direction: rtl; /* Right-to-left text direction */
    color: #111; /* Text color */
    font-family: "Tajawal", sans-serif;
}

/* Target standard WC price class within our price box */
.mai-price-box .price {
    display: block; /* Make price take full width */
    color: #555; /* Price color */
    font-weight: bold;
    font-size: 1.1em; /* Slightly larger price */
    margin: 0; /* Reset margin */
    padding: 0; /* Reset padding */
    margin-bottom: .5em;
}

.mai-price-box .price ins {
    /* Style for sale price */
    color: #28a745; /* Green for sale price */
    background: none; /* Remove default WC background */
    text-decoration: none;
    font-weight: bold;
}

.mai-price-box .price del {
    /* Style for regular price when on sale */
    opacity: 0.6;
    margin-right: 0.5em;
    font-weight: normal;
    color: #777; /* Lighter color for strikethrough */
}

.mai-price-box .price bdi {
    font-size: 14px;
}

.woocommerce ul.products li.product a.button.mai-button {
    padding: 0;
    margin: 0;
    justify-content: center;
    align-items: center;
    display: flex;
    border: none;
}




/* Ensure Tajawal font is loaded if you use it */
/* @import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@700&display=swap'); */












/* Reset default margins and ensure box-sizing for consistent layout */
.mai-woocommerce.columns-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 equal columns on large screens */
    gap: clamp(16px, 2vw, 20px); /* Responsive gap between products */
    padding: 0;
    margin: 0;
    list-style: none;
    box-sizing: border-box;
    width: 100%;
    max-width: 1400px; /* Prevent overly wide layouts on large screens */
    margin-left: auto;
    margin-right: auto;
}

/* Style each product card for consistent appearance */
.mai-product {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: #fff; /* Ensure background for visibility */
    border: none; /* Subtle border for definition */
    border-radius: 4px; /* Slight rounding for modern look */
    overflow: hidden; /* Prevent content overflow */
    transition: transform 0.2s ease, box-shadow 0.2s ease; /* Smooth hover effect */
    margin-bottom: 20px;
}

/* Hover effect for interactivity */
.mai-product:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Ensure image wrapper maintains aspect ratio and scales properly */
.mai-product-image-wrapper {
    position: relative;
    width: 100%;
     /* aspect-ratio: 1 / 1; Maintain square aspect ratio for images */
    aspect-ratio: 1 / 1.3;
    overflow: hidden;
}

.mai-product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensure images fill the space without distortion */
    display: block;
    transition: transform 0.3s ease; /* Smooth zoom on hover */
}

.mai-product-image-wrapper img:hover {
    transform: scale(1.05); /* Slight zoom effect on hover */
}

/* Style sale badge for visibility */
.mai-product-image-wrapper .onsale {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #d32f2f;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.85em;
    font-weight: bold;
    border-radius: 3px;
    z-index: 1;
}

/* Ensure product info is consistently styled */
.mai-product-info-wrapper {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mai-product-title {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin: 0 0 10px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit title to 2 lines */
    -webkit-box-orient: vertical;
}

.mai-product-title a {
    text-decoration: none;
    color: #333;
}

.mai-product-title a:hover {
    color: #5a4b81;
}

/* Style rating wrapper */
.mai-product-rating-wrapper {
    margin-bottom: 10px;
}

.star-rating {
    font-size: 0.9em;
    color: #f5c518; /* Star color */
}

/* Style price and add-to-cart section */
.mai-product-info-bottom {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.mai-price-box {
    font-size: clamp(0.9rem, 2vw, 1rem);
    color: #333;
}

.mai-price-box del {
    color: #999;
    font-size: 0.9em;
    margin-right: 5px;
}

.mai-price-box ins {
    color: #d32f2f; /* Highlight sale price */
    text-decoration: none;
}

.mai-add-to-cart-box .mai-button {
    display: inline-block;
    padding: 8px 16px;
    background: #5a4b81;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.9em;
    transition: background 0.2s ease;
}

@media only screen and (min-width: 768px) {
    .mai-add-to-cart-box a.button{
        padding: 0;
        display: flex;
        height: 100%;
        align-items: center;
        justify-content: center;
        text-align: center;
        border: none;
        border-right: 1px solid #111;
    }
    
}

.mai-add-to-cart-box .mai-button:hover {
    background: #005177;
}

/* Responsive adjustments */

/* Tablets (up to 1024px): 3 columns */
@media (max-width: 1024px) {
    .mai-woocommerce.columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile (up to 768px): 2 columns */
@media (max-width: 768px) {
    .mai-woocommerce.columns-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(12px, 2vw, 16px);
    }

    .mai-product-title {
        font-size: 1rem;
    }

    .mai-price-box {
        font-size: 0.9rem;
    }

    .mai-add-to-cart-box .mai-button {
        padding: 6px 12px;
        font-size: 0.85em;
    }
}

/* Small mobile devices (up to 480px): 1 column */
@media (max-width: 280px) {
    .mai-woocommerce.columns-4 {
        grid-template-columns: 1fr;
    }

    .mai-product {
        border-radius: 0; /* Simplify for smaller screens */
    }

    .mai-product-info-wrapper {
        padding: 0;
    }
}

/* Accessibility: Ensure focus states are clear */
.mai-product a:focus,
.mai-add-to-cart-box .mai-button:focus {
    outline: 2px solid #5a4b81;
    outline-offset: 2px;
}

/* Fallback for older browsers without CSS Grid support */
@supports not (display: grid) {
    .mai-woocommerce.columns-4 {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .mai-product {
        flex: 0 0 calc(25% - 20px); /* 4 per row with gap */
        margin-bottom: 20px;
    }

    @media (max-width: 1024px) {
        .mai-product {
            flex: 0 0 calc(33.33% - 20px); /* 3 per row */
        }
    }

    @media (max-width: 768px) {
        .mai-product {
            flex: 0 0 calc(50% - 20px); /* 2 per row */
        }
    }

    @media (max-width: 480px) {
        .mai-product {
            flex: 0 0 100%; /* 1 per row */
        }
    }
}








@media only screen and (min-width: 768px) {
    .mai-woocommerce.woocommerce a.button, .mai-woocommerce.woocommerce a.button.alt, .mai-woocommerce.woocommerce button.button, .mai-woocommerce.woocommerce button.button.alt, .mai-woocommerce.woocommerce input.button, .mai-woocommerce.woocommerce #respond input#submit, .woocommerce a.added_to_cart {
        padding: 0;
        min-width: 100%;
        width: 100%;
        line-height: 14px;
        line-height: 14px;
        border: none;
        align-items: center;
        justify-content: center;
        display: flex;
    }
    
    .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit, .woocommerce .added_to_cart, #add_payment_method .wc-proceed-to-checkout a.checkout-button, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button, .woocommerce-checkout .wc-proceed-to-checkout a.checkout-button {
        font-size: 11px;
        padding: 4px 0px;
    }
    
    .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit, .woocommerce .added_to_cart, #add_payment_method .wc-proceed-to-checkout a.checkout-button, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button, .woocommerce-checkout .wc-proceed-to-checkout a.checkout-button {
        font-size: 11px;
        padding: 4px 0px;
    }
}


@media only screen and (min-width: 768px) {
    .mai-woocommerce.woocommerce a.button.added {
        display: none;
    }
    .mai-add-to-cart-box a.mai-button.added {
        display: none;
    }
   .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit, .woocommerce .added_to_cart, #add_payment_method .wc-proceed-to-checkout a.checkout-button, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button, .woocommerce-checkout .wc-proceed-to-checkout a.checkout-button {
        font-size: 11px;
        padding: 4px 0px;
    }
    
    .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit, .woocommerce .added_to_cart, #add_payment_method .wc-proceed-to-checkout a.checkout-button, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button, .woocommerce-checkout .wc-proceed-to-checkout a.checkout-button {
        font-size: 11px;
        padding: 4px 0px;
    }
}
.mai-woocommerce.woocommerce a.button.added {
    display: none;
}

.mai-add-to-cart-box a.mai-button.added {
    display: none;
}





.mai-woocommerce.woocommerce .mai-product a.added_to_cart {
    padding: 0;
    margin: 0;
    border: none;
}











