/**
 * Global Add-to-Cart UX Enhancement Styles
 * 
 * Styles for loading states, toast notifications, and cart highlight
 */

/* ============================================
   Loading State Styles
   ============================================ */

/**
 * Loading state for add-to-cart buttons
 * Using our custom class "rinno-is-loading" to NOT interfere with WooCommerce "loading" class
 */
.add_to_cart_button.rinno-is-loading,
.single_add_to_cart_button.rinno-is-loading,
.wishlist__add-to-cart.rinno-is-loading {
    position: relative;
    opacity: 0.8;
    /* Do NOT set pointer-events: none - WooCommerce needs to handle the click */
    /* Do NOT set cursor: not-allowed - let WooCommerce handle it */
}

.add_to_cart_button.rinno-is-loading::after,
.single_add_to_cart_button.rinno-is-loading::after,
.wishlist__add-to-cart.rinno-is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: rinno-cart-spinner 0.6s linear infinite;
    pointer-events: none; /* Spinner doesn't block clicks */
}

@keyframes rinno-cart-spinner {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/**
 * Do NOT override WooCommerce "loading" or "added" classes
 * WooCommerce handles these classes - we only add our own "rinno-is-loading"
 */

/**
 * Ensure our loading state doesn't interfere with WooCommerce "added" state
 */
.add_to_cart_button.added.rinno-is-loading,
.single_add_to_cart_button.added.rinno-is-loading {
    /* If WooCommerce added "added" class, remove our loading */
    /* This is handled by JS, but CSS ensures no visual conflict */
}

/* ============================================
   Cart Highlight Animation
   ============================================ */

/**
 * Highlight animation for cart indicator
 */
.indicator.is-cart-highlight {
    animation: rinno-cart-highlight 0.6s ease-in-out;
}

.indicator.is-cart-highlight .indicator__button {
    animation: rinno-cart-pulse 0.6s ease-in-out;
}

@keyframes rinno-cart-highlight {
    0%, 100% {
        transform: scale(1);
        outline: none;
        box-shadow: none;
    }
    50% {
        transform: scale(1.05);
        outline: 2px solid rgba(0, 123, 255, 0.5);
        outline-offset: 4px;
        box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
    }
}

@keyframes rinno-cart-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/**
 * Alternative highlight using box-shadow
 */
.indicator.is-cart-highlight .indicator__area {
    position: relative;
}

.indicator.is-cart-highlight .indicator__area::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.2);
    animation: rinno-cart-ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes rinno-cart-ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* ============================================
   Toast Styles (if not already provided)
   ============================================ */

/**
 * Ensure toast is accessible and visible
 */
.rinno-toast {
    z-index: 9999;
}

/* ============================================
   Accessibility Enhancements
   ============================================ */

/**
 * Screen reader only text
 */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/**
 * Focus styles for add-to-cart buttons
 */
.add_to_cart_button:focus,
.single_add_to_cart_button:focus,
.wishlist__add-to-cart:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/**
 * Focus styles - ensure our loading doesn't break focus
 */
.add_to_cart_button.rinno-is-loading:focus,
.single_add_to_cart_button.rinno-is-loading:focus,
.wishlist__add-to-cart.rinno-is-loading:focus {
    /* Keep focus visible - WooCommerce handles the actual interaction */
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 991.98px) {
    /**
     * Disable dropdown auto-open on mobile
     */
    .indicator.is-cart-highlight .indicator__dropdown {
        /* Mobile dropdowns might behave differently */
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .add_to_cart_button.rinno-is-loading::after,
    .single_add_to_cart_button.rinno-is-loading::after {
        display: none;
    }
    
    .indicator.is-cart-highlight {
        animation: none;
        outline: none;
        box-shadow: none;
    }
}
