/**
 * ÉLYSIUM - Cart Animations
 * Animations CSS avancées pour le système de panier
 */

/* ============================================
   ANIMATIONS GÉNÉRALES
   ============================================ */

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade Out Animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Slide In From Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide Out To Right */
@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* Scale Pulse */
@keyframes scalePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Spin */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   CART ITEM ANIMATIONS
   ============================================ */

/* Cart Item Entry Animation */
.cart-item {
    animation: slideInRight 0.3s ease-out;
    transition: all 0.3s ease;
}

/* Cart Item Hover Effect */
.cart-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
    transform: translateX(-2px);
}

/* Cart Item Removing */
.cart-item.removing {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Cart Item Image Hover */
.cart-item-image {
    overflow: hidden;
    transition: transform 0.3s ease;
}

.cart-item:hover .cart-item-image img {
    transform: scale(1.1);
}

/* ============================================
   BUTTON ANIMATIONS
   ============================================ */

/* Add to Cart Button */
.add-to-cart-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.add-to-cart-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.add-to-cart-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Button Success State */
.add-to-cart-btn.success {
    animation: scalePulse 0.5s ease;
}

/* Quantity Buttons */
.quantity-btn-modal {
    transition: all 0.2s ease;
}

.quantity-btn-modal:hover {
    transform: scale(1.1);
}

.quantity-btn-modal:active {
    transform: scale(0.95);
}

/* Cart Button Badge Pulse */
.badge {
    animation: scalePulse 0.5s ease;
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Loading Spinner */
.cart-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading for Cart Items */
.cart-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading Overlay */
.cart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MODAL ANIMATIONS
   ============================================ */

/* Cart Modal Entry */
.cart-modal {
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-modal.active {
    animation: slideInRight 0.3s ease-out;
}

/* Overlay Fade */
.overlay {
    transition: opacity 0.3s ease;
}

/* ============================================
   TOAST ANIMATIONS
   ============================================ */

/* Toast Entry */
.toast {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    animation: slideInRight 0.3s ease-out;
}

/* ============================================
   CART COUNT BADGE ANIMATIONS
   ============================================ */

/* Badge Update Animation */
#cartCount {
    transition: all 0.3s ease;
}

#cartCount.updating {
    animation: scalePulse 0.5s ease;
}

/* ============================================
   OPTIMISTIC UI ANIMATIONS
   ============================================ */

/* Item Being Added */
.cart-item.optimistic {
    opacity: 0.6;
    position: relative;
}

.cart-item.optimistic::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shimmer 1s infinite;
}

/* Item Confirmed */
.cart-item.confirmed {
    animation: scalePulse 0.3s ease;
}

/* ============================================
   EMPTY CART STATE
   ============================================ */

.cart-empty {
    animation: fadeIn 0.5s ease-out;
}

.cart-empty-icon {
    animation: scalePulse 2s ease-in-out infinite;
}

/* ============================================
   RESPONSIVE ANIMATIONS
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .cart-item {
        animation-duration: 0.2s;
    }

    .cart-modal.active {
        animation-duration: 0.2s;
    }
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Price Update Flash */
.price-flash {
    animation: priceFlash 0.5s ease;
}

@keyframes priceFlash {
    0%, 100% { color: inherit; }
    50% { color: #10b981; transform: scale(1.1); }
}

/* Quantity Change Feedback */
.quantity-display {
    transition: all 0.2s ease;
}

.quantity-display.changing {
    color: #dc2626;
    font-weight: 700;
    animation: scalePulse 0.3s ease;
}

/* Remove Button Hover */
.cart-item-remove {
    transition: all 0.2s ease;
}

.cart-item-remove:hover {
    transform: scale(1.2) rotate(10deg);
    color: #dc2626;
}
