/* Front office styles */

/* ===================================
   Custom Quantity + UOM Component
   =================================== */

/* Container */
.addify-uom-custom-quantity {
    margin: 15px 0;
}

/* Quantity + UOM Wrapper */
.addify-qty-uom-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Custom Quantity Control */
.addify-custom-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid #d6d4d4;
    border-radius: 3px;
    overflow: hidden;
    background: #fff;
}

/* Quantity Buttons */
.addify-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: #f1f1f1;
    color: #232323;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    outline: none;
}

.addify-qty-btn:hover {
    background: #e0e0e0;
    color: #000;
}

.addify-qty-btn:active {
    background: #d0d0d0;
}

.addify-qty-btn:disabled {
    background: #f8f8f8;
    color: #ccc;
    cursor: not-allowed;
}

/* Material Icons in buttons */
.addify-qty-btn .material-icons {
    font-size: 20px;
    line-height: 1;
}

/* Quantity Input */
.addify-qty-input {
    width: 100px;
    height: 40px;
    border: none;
    border-left: 1px solid #d6d4d4;
    border-right: 1px solid #d6d4d4;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #232323;
    padding: 0 8px;
    outline: none;
    appearance: textfield;
    /* Standard property */
    -moz-appearance: textfield;
    /* Firefox */
}

/* Remove spinner in Chrome, Safari, Edge */
.addify-qty-input::-webkit-outer-spin-button,
.addify-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.addify-qty-input:focus {
    border-color: #00aff0;
    box-shadow: 0 0 0 1px #00aff0;
}

/* UOM Selector */
.addify-uom-select {
    height: 40px;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid #d6d4d4;
    border-radius: 3px;
    font-size: 14px;
    color: #232323;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.addify-uom-select:hover {
    border-color: #00aff0;
}

.addify-uom-select:focus {
    outline: none;
    border-color: #00aff0;
    box-shadow: 0 0 0 2px rgba(0, 175, 240, 0.1);
}

/* Single UOM Label (when only one unit available) */
.addify-single-uom-label {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 8px 15px;
    background: #f1f1f1;
    border: 1px solid #d6d4d4;
    border-radius: 3px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
    min-width: 150px;
    justify-content: center;
}

/* Price Display Section */
.addify-uom-price-info {
    margin-top: 12px;
}

.addify-uom-unit-price {
    margin-bottom: 5px;
}

.addify-uom-unit-price .price {
    color: #00aff0;
    font-weight: 600;
    font-size: 1.1em;
}

.addify-uom-unit-price .per-unit {
    color: #777;
    font-size: 0.9em;
    margin-left: 5px;
}

.addify-uom-final-price {
    font-size: 1.3em;
}

.addify-uom-final-price .price {
    color: #00aff0;
    font-weight: bold;
}

/* ===================================
   Legacy UOM Price Display
   =================================== */

/* UOM Price Display */
.addify-uom-price-container {
    margin: 15px 0;
    font-size: 1.1em;
}

/* Hide default PrestaShop price for UOM products */
/* Target the default price block that appears before UOM price container */
.product-prices:has(.addify-uom-price-container) .product-price.h5,
.product-prices:has(.addify-uom-price-container)>.product-price.h5,
.product-prices:has(.addify-uom-price-container) .product-discount,
.product-prices:has(.addify-uom-price-container)>.product-discount {
    display: none !important;
}

/* LISTING PAGE: Hide default regular price and discount for UOM products */
.product-price-and-shipping:has(.addify-uom-price-container) .regular-price,
.product-price-and-shipping:has(.addify-uom-price-container) .discount-amount,
.product-price-and-shipping:has(.addify-uom-price-container) .discount-percentage,
.product-price-and-shipping:has(.addify-uom-price-container) .discount-product,
.product-price-and-shipping:has(.addify-uom-price-container)>span.price {
    display: none !important;
}

/* Alternative selector using adjacent sibling for broader browser support */
.product-price.h5:has(~ .tax-shipping-delivery-label .addify-uom-price-container),
.product-discount:has(~ .tax-shipping-delivery-label .addify-uom-price-container) {
    display: none !important;
}


.addify-uom-unit-price {
    margin-bottom: 8px;
    font-size: 1.3em;
    font-weight: 600;
    color: #00aff0;
}

.addify-uom-unit-price .price {
    color: #00aff0;
    font-weight: bold;
}

.addify-uom-unit-price .per-unit {
    color: #666;
    font-size: 0.9em;
    font-weight: normal;
    margin-left: 5px;
}

.addify-uom-final-price {
    font-size: 1.1em;
}

.addify-uom-final-price .label {
    color: #333;
    margin-right: 5px;
    font-weight: 600;
}

.addify-uom-final-price .price {
    color: #00aff0;
    font-weight: bold;
}

/* UOM Badge - appears next to quantity selector */
.addify-uom-badge {
    display: inline-block;
    padding: 8px 15px;
    margin-left: 8px;
    background: #fff;
    border: 1px solid #d6d4d4;
    border-radius: 3px;
    font-size: 14px;
    color: #666;
    vertical-align: middle;
    min-width: 80px;
    text-align: center;
}

/* Integration with product actions */
.product-add-to-cart .addify-uom-badge {
    margin-left: 10px;
}

/* Fix UOM positioning when "With Add to Cart" is selected */
/* Target multiple possible theme structures */
.product-add-to-cart,
.product-actions,
.product-information .product-actions,
div[id*="product-actions"],
.add-to-cart-wrapper {
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.product-add-to-cart .addify-uom-custom-quantity,
.product-actions .addify-uom-custom-quantity,
.add-to-cart-wrapper .addify-uom-custom-quantity {
    margin: 0;
    display: inline-flex;
    order: 1;
    /* Place after Add to Cart button */
}

/* Ensure Add to Cart button stays first */
.product-add-to-cart .add-to-cart,
.product-add-to-cart button[type="submit"],
.product-actions .add-to-cart,
.product-actions button[type="submit"] {
    order: 0;
}

/* Direct targeting: If UOM appears as a sibling after form elements */
form+.addify-uom-custom-quantity,
.product-add-to-cart>form+.addify-uom-custom-quantity,
button[type="submit"]+.addify-uom-custom-quantity {
    display: inline-flex !important;
    margin-left: 10px;
    vertical-align: middle;
}

/* Make parent container flexible if it contains both button and UOM */
.product-add-to-cart:has(.addify-uom-custom-quantity),
.product-actions:has(.addify-uom-custom-quantity) {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* More aggressive targeting for stubborn themes */
/* Target containers with inline display style attribute - ONLY when display location is 'with_cart' */
/* The UOM will be repositioned by JS, so we hide the original container */
.addify-uom-custom-quantity[data-display-location="with_cart"][style],
.addify-uom-custom-quantity[data-display-location="with_cart"][data-product-id] {
    display: none !important;
}

/* Specifically target UOM when it appears in product-related contexts - ONLY for 'with_cart' mode */
/* For 'after_title' and 'before_cart' modes, keep the UOM visible in its original position */
#product .addify-uom-custom-quantity[data-display-location="with_cart"],
.product-container .addify-uom-custom-quantity[data-display-location="with_cart"],
.product-information .addify-uom-custom-quantity[data-display-location="with_cart"],
main .addify-uom-custom-quantity[data-display-location="with_cart"]:not(.addify-uom-listing) {
    display: none !important;
    /* Hide the empty container after we move its contents */
}

/* Show UOM in its original position for 'before_cart' display mode */
.addify-uom-custom-quantity[data-display-location="before_cart"] {
    display: block !important;
}

/* Ensure the UOM wrapper inside is visible for 'before_cart' mode */
.addify-uom-custom-quantity[data-display-location="before_cart"] .addify-qty-uom-wrapper {
    display: flex !important;
}

/* Styles for UOM displayed after price (in product_price.tpl) */
.addify-uom-after-price {
    display: block !important;
    margin-top: 10px;
}

.addify-uom-after-price .addify-qty-uom-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin-top: 5px;
    flex-wrap: nowrap !important;
}

/* Ensure UOM controls have consistent height and alignment for after_title */
.addify-uom-after-price .addify-custom-qty-control,
.addify-uom-after-price .addify-uom-select,
.addify-uom-after-price .addify-single-uom-label {
    height: 40px !important;
    align-self: center !important;
}

/* Prevent wrapping and ensure inline layout */
.addify-uom-after-price .addify-custom-qty-control {
    flex-shrink: 0 !important;
}

/* Specific margin adjustment for UOM select in "After Product Price" mode ONLY */
.addify-uom-after-price .addify-uom-select,
.addify-uom-after-price #uom-unit-select,
.addify-uom-after-price .addify-single-uom-label {
    flex-shrink: 0 !important;
    min-width: 150px !important;
    margin: -10px 0px 0 0 !important;
    /* Negative top margin to align with quantity controls */
}

.addify-uom-price-container .control-label {
    display: block;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 8px;
    color: #333;
}

/* Force the parent to allow inline children when UOM is present - ONLY for with_cart mode */
/* For before_cart, we want vertical stacking, so we don't apply flex with inline */

/* Ensure the .add div (parent of button) is also flex */
.product-add-to-cart .add {
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    flex-wrap: nowrap !important;
}

/* Override gap to 0 when UOM is in "With Add to Cart" mode */
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="with_cart"]) .add,
.product-add-to-cart:has(.addify-qty-uom-wrapper) .add {
    gap: 0 !important;
}

/* Make product-quantity container inline flex too */
.product-add-to-cart .product-quantity {
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    flex-wrap: wrap;
}

/* CRITICAL FIX: Hide the .qty div completely when UOM is in after_title or with_cart mode */
/* This prevents the hidden quantity input from affecting the flex layout */
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="after_title"]) .product-quantity .qty,
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="with_cart"]) .product-quantity .qty {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: hidden !important;
}

/* Ensure Add to Cart button alignment is clean for after_title and with_cart modes */
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="after_title"]) .product-quantity .add,
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="with_cart"]) .product-quantity .add {
    margin-left: 0 !important;
}

/* Styles for 'before_cart' display mode - UOM should be above Add to Cart */
.addify-uom-custom-quantity[data-display-location="before_cart"] {
    width: 100%;
    margin-bottom: 15px;
}

.addify-uom-custom-quantity[data-display-location="before_cart"] .addify-qty-uom-wrapper {
    display: flex !important;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* When before_cart is used, product-quantity should be in column layout */
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="before_cart"]) .product-quantity {
    flex-direction: column;
    align-items: flex-start !important;
}

/* Move the Add to Cart to a new row when before_cart */
.product-add-to-cart:has(.addify-uom-custom-quantity[data-display-location="before_cart"]) .product-quantity .add {
    width: 100%;
    margin-top: 10px;
}

/* JavaScript-applied class for before_cart vertical layout */
.product-quantity.uom-before-cart-layout {
    flex-direction: column !important;
    align-items: flex-start !important;
}

.product-quantity.uom-before-cart-layout .addify-uom-custom-quantity {
    width: 100%;
    order: 1;
}

.product-quantity.uom-before-cart-layout .qty {
    order: 2;
}

.product-quantity.uom-before-cart-layout .add {
    order: 3;
    width: 100%;
    margin-top: 10px;
}

/* Ensure base quantity text doesn't interfere */
.addify-qty-uom-wrapper+small,
.text-muted.d-block {
    flex-basis: 100% !important;
    margin-top: 5px !important;
}


/* Specific targeting for add to cart and wishlist buttons */
.product-add-to-cart .add,
.product-add-to-cart .btn-primary,
.product-add-to-cart button[data-button-action="add-to-cart"],
.product-add-to-cart .add-to-cart,
.wishlist-button-add,
.wishlist-button-product {
    display: flex !important;
    align-items: center !important;
    margin: 1 !important;
}


/* CRITICAL: Make UOM select dropdown display inline with quantity box */
.addify-uom-select,
#uom-unit-select {
    display: inline-flex !important;
    max-width: 150px !important;
    flex: 0 0 auto !important;
    margin: 0 5px 0 0 !important;
    /* Reduced margin */
    vertical-align: middle !important;
}

/* Ensure the qty-uom-wrapper displays as inline flex */
.addify-qty-uom-wrapper {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    /* Reduced gap */
    flex: 0 0 auto !important;
    margin: 0 5px 0 0 !important;
    /* Added small right margin */
}


/* Make sure all children of the wrapper are inline */
.addify-qty-uom-wrapper>* {
    display: inline-flex !important;
    flex: 0 0 auto !important;
}



/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 768px) {
    .addify-qty-uom-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .addify-custom-qty-control {
        width: 100%;
        justify-content: space-between;
    }

    .addify-qty-input {
        flex: 1;
    }

    .addify-uom-select {
        width: 100%;
    }

    .addify-single-uom-label {
        width: 100%;
        justify-content: center;
    }

    .addify-uom-price-container {
        font-size: 1em;
    }

    .addify-uom-unit-price {
        font-size: 1.2em;
    }

    .addify-uom-badge {
        display: block;
        margin: 10px 0;
        width: 100%;
    }

    /* ULTRA-AGGRESSIVE: Mobile layout fixes for "With Add to Cart" display mode */
    /* Maximum specificity to override all possible theme CSS */

    /* Force .add container to column layout */
    .product-add-to-cart .add,
    .product-add-to-cart .product-quantity .add,
    div.add,
    div.product-add-to-cart div.add,
    .add[style] {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
        flex: 1 1 100% !important;
        align-items: stretch !important;
        flex-basis: 100% !important;
    }

    /* Force all direct children of .add to full width */
    .add>*,
    .product-add-to-cart .add>* {
        width: 100% !important;
        flex: 1 1 100% !important;
        flex-basis: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Force buttons to take full width on mobile */
    .product-add-to-cart .add button,
    .product-add-to-cart .add a,
    .add button,
    .add a,
    .add>button,
    .add>a {
        width: 100% !important;
        flex: 1 1 100% !important;
        flex-basis: 100% !important;
        max-width: 100% !important;
    }

    /* Ensure Add to Cart button takes full width on mobile */
    .product-add-to-cart button[data-button-action="add-to-cart"],
    .product-add-to-cart .add-to-cart,
    .product-add-to-cart .add .add-to-cart,
    button[data-button-action="add-to-cart"],
    .add-to-cart,
    .btn.add-to-cart,
    .add>button[data-button-action="add-to-cart"] {
        width: 100% !important;
        margin: 0 !important;
        flex: 1 1 100% !important;
        flex-basis: 100% !important;
        display: flex !important;
        justify-content: center !important;
        max-width: 100% !important;
    }

    /* Ensure Wishlist button takes full width on mobile - target all possible selectors */
    .wishlist-button-add,
    .wishlist-button-product,
    .add .wishlist-button-add,
    .add .wishlist-button-product,
    .product-add-to-cart .wishlist-button-add,
    .product-add-to-cart .wishlist-button-product,
    a.wishlist-button-add,
    button.wishlist-button-add,
    .wishlist-button-add[class*="wishlist"],
    /* Target wishlist by href or data attributes if needed */
    a[href*="wishlist"],
    button[class*="wishlist"] {
        width: 100% !important;
        margin: 0 !important;
        flex: 1 1 100% !important;
        flex-basis: 100% !important;
        display: flex !important;
        justify-content: center !important;
        max-width: 100% !important;
    }

    /* Allow parent containers to wrap on mobile */
    .product-add-to-cart,
    .product-actions,
    .product-quantity {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    /* UOM wrapper should take full width on mobile */
    .addify-qty-uom-wrapper {
        width: 100% !important;
        margin: 0 0 10px 0 !important;
        flex: 1 1 100% !important;
        flex-basis: 100% !important;
    }

    /* Override inline styles for mobile - with highest specificity */
    .product-add-to-cart[style*="flex"],
    .add[style*="flex"],
    .product-add-to-cart .add[style*="flex"],
    div.add[style*="display"] {
        flex-wrap: wrap !important;
        flex-direction: column !important;
    }

    /* Additional nuclear option - target anything that might be preventing stacking */
    .product-add-to-cart *[class*="btn"],
    .product-add-to-cart *[class*="button"],
    .add *[class*="btn"],
    .add *[class*="button"] {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 991px) {
    .addify-qty-uom-wrapper {
        gap: 8px;
    }

    .addify-uom-select {
        min-width: 130px;
    }
}

/* Force hide original wishlist buttons that were cloned/moved */
.addify-original {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    z-index: -9999 !important;
}