/**
 * Improved Add to Cart Button Spinner
 * 
 * This file contains styles for an improved loading spinner and button animations
 * for the add to cart buttons in the Belvedo theme.
 */

/* Button Loading State */
.add_to_cart_button.loading,
.single_add_to_cart_button.loading {
    position: relative;
    color: transparent !important;
    transition: all 0.3s ease;
}

/* Text change animation */
.add_to_cart_button,
.single_add_to_cart_button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Success state */
.add_to_cart_button.added::before,
.single_add_to_cart_button.added::before {
    content: "✓ Dodano";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

/* Loading Spinner - Modern Circle Animation */
.add_to_cart_button.loading::after,
.single_add_to_cart_button.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: mc-spin 0.8s infinite linear;
    box-sizing: border-box;
}

/* Loading Text */
.add_to_cart_button.loading::before,
.single_add_to_cart_button.loading::before {
    content: "Dodawanie...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: transparent;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
}

/* Spinner Animation */
@keyframes mc-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Button Hover Effects */
.add_to_cart_button:hover,
.single_add_to_cart_button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.add_to_cart_button:active,
.single_add_to_cart_button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Pulse Animation for Added State */
.add_to_cart_button.added,
.single_add_to_cart_button.added {
    animation: mc-pulse 0.5s;
}

@keyframes mc-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Ensure the button has enough width for the spinner and text */
.single_add_to_cart_button,
.add_to_cart_button {
    min-width: 150px;
    position: relative;
}

/* Make sure the spinner is visible on all button colors */
.add_to_cart_button.loading::after,
.single_add_to_cart_button.loading::after {
    z-index: 10;
}