/**
 * Add to Cart Button Widget Styles
 */

/* Wrapper */
.vime-add-to-cart-wrapper {
    display: inline-flex;
    align-items: center;
    width: 100%;
}

/* Button */
.vime-add-to-cart-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.vime-add-to-cart-button:hover {
    text-decoration: none;
}

.vime-button-full-width {
    width: 100%;
}

/* Button content */
.vime-button-text {
    display: inline-block;
}

.vime-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Loading spinner */
.vime-loading-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.vime-add-to-cart-button.loading .vime-button-text,
.vime-add-to-cart-button.loading .vime-button-icon {
    opacity: 0.5;
}

/* Hide WooCommerce default loading spinner on our custom button */
.vime-add-to-cart-button.loading::before,
.vime-add-to-cart-button.loading::after,
.woocommerce .vime-add-to-cart-button.loading::before,
.woocommerce .vime-add-to-cart-button.loading::after,
a.vime-add-to-cart-button.loading::before,
a.vime-add-to-cart-button.loading::after {
    display: none !important;
    content: none !important;
}

/* Prevent any WooCommerce AJAX loading animations on our button */
.vime-add-to-cart-button.loading {
    pointer-events: none;
}

/* Alignment classes */
.elementor-align-left .vime-add-to-cart-wrapper {
    justify-content: flex-start;
}

.elementor-align-center .vime-add-to-cart-wrapper {
    justify-content: center;
}

.elementor-align-right .vime-add-to-cart-wrapper {
    justify-content: flex-end;
}

.elementor-align-justify .vime-add-to-cart-button {
    width: 100%;
}

/* WooCommerce compatibility */
.woocommerce ul.products li.product .vime-add-to-cart-wrapper {
    margin-top: 10px;
}

.woocommerce ul.products li.product .vime-add-to-cart-button {
    margin: 0;
}

/* Responsive */
@media (max-width: 767px) {
    .elementor-mobile-align-left .vime-add-to-cart-wrapper {
        justify-content: flex-start;
    }
    
    .elementor-mobile-align-center .vime-add-to-cart-wrapper {
        justify-content: center;
    }
    
    .elementor-mobile-align-right .vime-add-to-cart-wrapper {
        justify-content: flex-end;
    }
    
    .elementor-mobile-align-justify .vime-add-to-cart-button {
        width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .elementor-tablet-align-left .vime-add-to-cart-wrapper {
        justify-content: flex-start;
    }
    
    .elementor-tablet-align-center .vime-add-to-cart-wrapper {
        justify-content: center;
    }
    
    .elementor-tablet-align-right .vime-add-to-cart-wrapper {
        justify-content: flex-end;
    }
    
    .elementor-tablet-align-justify .vime-add-to-cart-button {
        width: 100%;
    }
}

/* Added to cart animation */
@keyframes added-to-cart {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.vime-add-to-cart-button.added {
    animation: added-to-cart 0.5s ease;
}

/* Disabled state */
.vime-add-to-cart-button.disabled,
.vime-add-to-cart-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hide WooCommerce messages when using this widget */
.woocommerce .vime-add-to-cart-wrapper + .woocommerce-message {
    display: none !important;
}

/* Also hide messages that appear after the product in listings */
.woocommerce ul.products li.product .woocommerce-message {
    display: none !important;
}

/* ============================================
   Quantity Selector Styles
   ============================================ */

/* Quantity Wrapper */
.vime-quantity-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

.vime-quantity-wrapper.inline {
    flex-direction: row;
    gap: 10px;
}

.vime-quantity-wrapper.stacked {
    flex-direction: column;
    align-items: stretch;
}

.vime-quantity-wrapper.stacked .vime-quantity-selector {
    margin-bottom: 10px;
    width: 100%;
    justify-content: center;
}

.vime-quantity-wrapper.stacked .vime-add-to-cart-button {
    width: 100%;
}

/* Quantity Selector Container */
.vime-quantity-selector {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
}

/* Quantity Buttons */
.vime-quantity-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: #666;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

.vime-quantity-btn:hover,
.vime-quantity-btn:active,
.vime-quantity-btn:focus {
    color: #333;
    outline: none;
}

.vime-quantity-btn span {
    display: block;
    line-height: 1;
}

/* Quantity Input - Reset all browser defaults */
.vime-quantity-selector .vime-quantity-input,
.vime-quantity-wrapper .vime-quantity-input,
input.vime-quantity-input,
input[type="number"].vime-quantity-input {
    width: 40px;
    height: 32px;
    padding: 0 2px;
    border: none;
    border-width: 0;
    border-style: none;
    border-color: transparent;
    background: transparent;
    background-color: transparent;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-shadow: none;
}

.vime-quantity-input::-webkit-outer-spin-button,
.vime-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.vime-quantity-input:focus,
.vime-quantity-selector .vime-quantity-input:focus,
input.vime-quantity-input:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* Button takes remaining space in inline mode */
.vime-quantity-wrapper.inline .vime-add-to-cart-button {
    flex: 1;
}

/* Variation Integration States */
.vime-add-to-cart-button.vime-variation-required.vime-no-variation {
    opacity: 0.7;
    cursor: not-allowed;
}

.vime-add-to-cart-button.vime-variation-integration {
    transition: all 0.3s ease;
}

/* Selected variation indicator */
.vime-color-swatch.selected,
.vime-color-swatch.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

/* ============================================
   Match Button Height Option
   ============================================ */

/* When match height is enabled - container stretches, content stays centered */
.vime-quantity-match-height-yes .vime-quantity-wrapper.inline {
    align-items: stretch;
}

.vime-quantity-match-height-yes .vime-quantity-wrapper.inline .vime-quantity-selector {
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 480px) {
    .vime-quantity-wrapper.inline {
        flex-wrap: wrap;
    }

    .vime-quantity-wrapper.inline .vime-quantity-selector {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }

    .vime-quantity-wrapper.inline .vime-add-to-cart-button {
        width: 100%;
        flex: none;
    }

    .vime-quantity-input {
        flex: 1;
        max-width: 100px;
    }
}

