/**
 * AutoMatch Pro - WooCommerce Optimization Styles
 * Prevents visual glitches and improves user experience
 */

/* Prevent infinite loading states */
.woocommerce-checkout-review-order-table.processing,
.woocommerce-checkout-review-order-table .woocommerce-checkout-review-order.processing {
    opacity: 0.7;
    pointer-events: none;
}

/* Optimize add to cart button loading state */
.single_add_to_cart_button.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.single_add_to_cart_button.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

/* Checkout form optimization */
form.checkout.processing {
    opacity: 0.8;
    pointer-events: none;
}

form.checkout .woocommerce-checkout-place-order.processing {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Hide cart page elements if accessed */
body.woocommerce-cart .woocommerce-cart-form,
body.woocommerce-cart .cart-collaterals {
    display: none;
}

body.woocommerce-cart .woocommerce-info {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
    text-align: center;
}

/* Loading animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state styling */
.woocommerce-error,
.woocommerce-message,
.woocommerce-info {
    margin: 15px 0;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid;
}

.woocommerce-error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.woocommerce-message {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.woocommerce-info {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

/* Responsive optimizations */
@media (max-width: 768px) {
    .single_add_to_cart_button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
    
    .woocommerce-checkout-review-order-table {
        font-size: 14px;
    }
}

/* Prevent cart page flash */
.woocommerce-cart .entry-content {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Smooth transitions */
.woocommerce-checkout-review-order-table,
form.checkout,
.single_add_to_cart_button {
    transition: opacity 0.3s ease;
}
