/* Flexbox alignment for the cart form */
body form.cart {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    gap: 15px !important;
    width: 100% !important;
}

/* Force all direct children of the cart form to not push each other away */
body form.cart > * {
    margin: 0 !important;
    flex: 0 0 auto !important;
    width: auto !important;
}

/* Remove clearfix pseudo-elements that break flexbox */
body form.cart::before,
body form.cart::after {
    display: none !important;
    content: none !important;
}

body form.cart .custom-price-wrapper {
    margin: 0 !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    align-items: flex-start !important;
    flex: 0 0 auto !important;
    order: -1 !important;
}

body form.cart .custom-price-wrapper label {
    display: block !important;
    font-weight: 600 !important;
    margin-bottom: 5px !important;
    white-space: nowrap !important;
    line-height: 1 !important;
}

body form.cart .custom-price-wrapper input[type="number"] {
    width: 130px !important;
    padding: 0 15px !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    height: 42px !important;
    box-sizing: border-box !important;
    line-height: 42px !important;
    margin: 0 !important;
}

body form.cart .custom-price-wrapper small {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    margin-top: 5px !important;
    color: #888 !important;
    white-space: nowrap !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

/* Fix for Woodmart Add to Cart button and quantity input height */
body form.cart .quantity,
body form.cart .single_add_to_cart_button,
body form.cart .wd-buy-now-btn {
    margin: 0 !important;
    flex: 0 0 auto !important;
    align-self: flex-end !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
}

body form.cart .quantity input[type="button"],
body form.cart .quantity input[type="number"],
body form.cart .single_add_to_cart_button,
body form.cart .wd-buy-now-btn {
    height: 42px !important;
    line-height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body form.cart .single_add_to_cart_button.hgf4u-loaded-card-blocked,
body form.cart .wd-buy-now-btn.hgf4u-loaded-card-blocked,
body form.cart .single_add_to_cart_button:disabled,
body form.cart .wd-buy-now-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* Specific fix for Woodmart quantity buttons which might have internal padding/margins */
body form.cart .quantity {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    border: 1px solid #000 !important;
    border-radius: 40px !important;
    overflow: hidden !important;
    background-color: #fff !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 0 !important;
    margin: 0 !important;
}

body form.cart .quantity input[type="button"] {
    width: 35px !important;
    background: transparent !important;
    border: none !important;
    color: #000 !important;
    font-size: 18px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    box-shadow: none !important;
}

body form.cart .quantity input[type="button"]:hover {
    background-color: #f0f0f0 !important;
}

body form.cart .quantity input[type="number"] {
    width: 40px !important;
    -moz-appearance: textfield;
    appearance: textfield;
    border: none !important;
    border-left: 1px solid #000 !important;
    border-right: 1px solid #000 !important;
    border-radius: 0 !important;
    text-align: center !important;
    color: #000 !important;
    font-size: 16px !important;
    font-weight: bold !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    background: transparent !important;
    box-shadow: none !important;
}

body form.cart .quantity input[type="number"]::-webkit-inner-spin-button,
body form.cart .quantity input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* In case Woodmart wraps the buttons */
body form.cart .woocommerce-variation-add-to-cart,
body form.cart .cart-info {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    gap: 15px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 auto !important;
    width: auto !important;
}

/* Responsive fallback for smaller screens */
@media (max-width: 768px) {
    body form.cart {
        flex-wrap: wrap !important;
    }

    body form.cart .custom-price-wrapper {
        width: 100% !important;
        flex: 1 1 100% !important;
        margin-bottom: 25px !important;
    }
}
