/* --- Box Product Card Design --- */

/* The Loop Item Container (Targeting Elementor Container) */
.box-product-card-container {
    border: 1px solid #E5E5E5; 
    background-color: #F4F4F4; 
    transition: border-color 0.3s ease;
    height: auto; /* Changed from 100% to auto to allow expansion */
    min-height: 100%;
    display: flex;
    flex-direction: column;
    /* Ensure form overflow is visible */
    overflow: visible !important; 
    position: relative;
}
.box-product-card-container:hover {
    border-color: #000; /* Darker border on hover */
}

/* --- IMAGE WIDGET --- */
.box-card-image-wrapper {
    position: relative;
    width: 100%;
    /* Separator line between image and text */
    border-bottom: 1px solid #E5E5E5; 
    background-color: #F4F4F4; /* Matches card */
}

.box-img-link {
    display: block;
    width: 100%;
}

.box-img-ratio {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Default Square */
    overflow: hidden;
}

.box-img-ratio img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: contain; /* Keep product ratio intact inside square */
    transition: opacity 0.4s ease;
}

.box-img-ratio img.box-product-image-placeholder {
    width: 42%;
    height: 42%;
    opacity: 0.05;
    mix-blend-mode: multiply;
}

/* Hover Swap Logic */
.img-hover { opacity: 0; z-index: 2; }
.img-main { z-index: 1; }

.box-card-image-wrapper:hover .img-hover { opacity: 1; }


/* --- INFO WIDGET --- */
.box-card-info {
   padding: 15px 20px!important;
    display: flex!important;
    flex-direction: column!important;
    gap: 4px!important;
    font-family: var(--e-global-typography-primary-font-family), "AeonikPro", Sans-serif;
    font-size: 16px!important;
    border-top:1px solid #E5E5E5;
    flex-grow: 1; /* Allow to fill space */
}

/* Top Row: Title + Price */
.info-row-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.box-card-info [type=button], [type=submit], button {padding:0!important}
.p-title {
    font-size: 16px;
    text-transform: uppercase;
    color: #000;
    text-decoration: none;
    font-weight: 400;
    line-height: 1.3;
    flex: 1;
}
.p-price {
    font-size: 16px;
    color: #000;
    text-align: right;
    white-space: nowrap;
    font-weight: 400;
}
/* WooCommerce Price cleanup */
.p-price del { display: none; } /* Hide old price if on sale to keep clean? Or style it */
.p-price ins { text-decoration: none; }

/* Bottom Row: Brand */
.info-row-bot {
    display: flex;
}
.p-brand {
    font-size: 16px;
    text-transform: uppercase;
    color: #000; /* Grey text for brand */
    letter-spacing: 0.5px;
}


/* =======================================================
   ELEMENTOR FLEXBOX CONTAINER MOBILE OVERRIDE (Max 1024px)
   ======================================================= */
@media (max-width: 1024px) {
    
    /* 1. FORCE THE 2-COLUMN GRID */
    .elementor-loop-container,
    ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 2. THE MAIN CARD (Targeting your e-con Flexbox container) */
    .box-product-card-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important; 
        border: 1px solid #E5E5E5 !important;
        background-color: #F2F2F2 !important;
        overflow: hidden !important; 
        padding: 0 !important;
        gap: 0 !important;
    }

    /* 3. THE IMAGE WIDGET (Bypassing Elementor Wrappers) */
    .elementor-widget-box_product_image_hover {
        order: 1 !important; 
        width: 100% !important;
        background-color: #F4F4F4 !important; 
        border-bottom: 1px solid #E5E5E5 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Pass the width safely through Elementor's invisible middle wrappers */
    .elementor-widget-box_product_image_hover .elementor-widget-container,
    .box-card-image-wrapper,
    .box-img-link {
        width: 100% !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
    }

    /* THE INDESTRUCTIBLE SQUARE HACK (Applied directly to the inner box) */
    .box-img-ratio {
        width: 100% !important;
        height: 0 !important; 
        padding-bottom: 100% !important; /* Forces perfect 1:1 Square */
        display: block !important;
        position: relative !important;
        overflow: hidden !important;
        margin: 0 !important;
    }

    /* Locks the image tightly inside the square */
    .box-img-ratio img {
        position: absolute !important;
        top: 0 !important; 
        left: 0 !important;
        width: 100% !important; 
        height: 100% !important;
        object-fit: contain !important; 
        mix-blend-mode: multiply; 
        transform: none !important; /* Kills the desktop centering bug */
    }

    /* 4. THE TEXT WIDGET */
    .elementor-widget-box_product_title_cat,
    .box-card-info {
        order: 2 !important; 
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding: 5px !important; /* Tweaked padding to match mockup */
        width: 100% !important;
        flex-grow: 1 !important; /* Allows the box to stretch */
        box-sizing: border-box !important;
        background: #F2F2F2 !important;
        margin: 0 !important;
        border-top: none !important;
    }
   /* 5. REORDER TEXT ELEMENTS (Title -> Brand -> Price/Quote) */
    
    /* "Unzip" only the top and bottom rows, keeping .p-actions intact! */
    .info-row-top,
    .info-row-bot {
        display: contents !important; 
    }

    /* 1st: The Title */
    .p-title {
        order: 1 !important;
        padding-bottom: 2px !important; 
        font-size: 13px !important;
        text-align: left !important;
        white-space: normal !important; 
        word-wrap: break-word !important;
        width: 100% !important;
        line-height: 1.4 !important;
        color: #000 !important;
        margin: 0 !important;
    }

    /* 2nd: The Brand */
    .p-brand {
        order: 2 !important;
        text-transform: uppercase !important;
        font-size: 13px !important;
        text-align: left !important;
        white-space: normal !important; 
        width: 100% !important;
        line-height: 1.4 !important;
        color: #000 !important;
        margin: 0 !important;
    }

    /* 3rd: The Price or "Request a Quote" */
    .p-actions,
    .p-price {
        order: 3 !important;
        display: block !important; 
        margin-top: auto !important; /* CRITICAL: Snaps it to the bottom! */
        padding-top: 15px !important; 
        width: 100% !important;
        font-size: 13px !important;
        color: #000 !important;
        text-align: left !important;
        white-space: normal !important; 
        margin-bottom: 0 !important;
    }

    /* Underline the Request a Quote link */
    .p-actions a,
    .box-trigger-quote.text-mode {
        text-decoration: underline !important;
        text-transform: uppercase !important;
    }
    
    /* Ensure actual prices don't get underlined */
    .p-price {
        text-decoration: none !important;
    }
    /* 6. HIDE UTILITY BUTTONS */
    .elementor-widget-box_product_title_cat [type="button"],
    .elementor-widget-box_product_title_cat [type="submit"],
    .elementor-widget-box_product_title_cat button {
        display: none !important;
    }
	/* 1. Force the Quote Trigger Text to stay visible */
    .elementor-widget-box_product_title_cat .box-trigger-quote,
    .box-product-card-container .box-trigger-quote {
        display: inline-block !important;
    }

    /* 2. Ensure the actual "Send Request" button inside the form doesn't get hidden */
    .elementor-widget-box_product_title_cat .box-quote-submit,
    .box-product-card-container .box-quote-submit {
        display: inline-block !important;
    }
}