/* Animations pour le panier */

/* Animation du badge du panier */
@keyframes cartBadgePulse {
    0% { 
        transform: scale(0); 
        opacity: 0;
    }
    50% { 
        transform: scale(1.3); 
        opacity: 1;
    }
    100% { 
        transform: scale(1); 
        opacity: 1;
    }
}

.cart-badge-pulse {
    animation: cartBadgePulse 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Animation de l'icône du panier */
@keyframes cartIconBounce {
    0%, 100% { 
        transform: scale(1) rotate(0deg); 
    }
    25% { 
        transform: scale(1.1) rotate(-5deg); 
    }
    50% { 
        transform: scale(1.15) rotate(0deg); 
    }
    75% { 
        transform: scale(1.1) rotate(5deg); 
    }
}

.cart-icon-bounce {
    animation: cartIconBounce 0.8s ease-in-out;
}

/* Animation d'entrée de l'aperçu du panier */
@keyframes cartPreviewEnter {
    0% { 
        opacity: 0; 
        transform: scale(0.8) translateY(-20px); 
        filter: blur(4px);
    }
    100% { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
        filter: blur(0px);
    }
}

.cart-preview-enter {
    animation: cartPreviewEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Animation d'entrée des articles du panier */
@keyframes cartItemEnter {
    0% { 
        opacity: 0; 
        transform: translateX(-30px) scale(0.9); 
    }
    100% { 
        opacity: 1; 
        transform: translateX(0) scale(1); 
    }
}

.cart-item-enter {
    animation: cartItemEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Animation du bouton "Ajouter au panier" */
@keyframes addToCartSuccess {
    0% { 
        transform: scale(1); 
        background-color: #059669;
    }
    50% { 
        transform: scale(1.05); 
        background-color: #10b981;
    }
    100% { 
        transform: scale(1); 
        background-color: #10b981;
    }
}

.add-to-cart-success {
    animation: addToCartSuccess 0.6s ease-in-out;
}

/* Animation des notifications toast */
@keyframes toastSlideIn {
    0% { 
        transform: translateX(100%); 
        opacity: 0;
    }
    100% { 
        transform: translateX(0); 
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% { 
        transform: translateX(0); 
        opacity: 1;
    }
    100% { 
        transform: translateX(100%); 
        opacity: 0;
    }
}

.toast-notification {
    animation: toastSlideIn 0.3s ease-out;
}

.toast-notification.sliding-out {
    animation: toastSlideOut 0.3s ease-in;
}

/* Effet de survol amélioré pour l'icône du panier */
#cartIcon:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

#cartIcon:hover i {
    transform: rotate(-10deg);
    transition: transform 0.3s ease;
}

/* Animation de chargement pour l'aperçu du panier */
@keyframes cartPreviewLoading {
    0% { 
        transform: rotate(0deg); 
    }
    100% { 
        transform: rotate(360deg); 
    }
}

.cart-preview-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: cartPreviewLoading 1s linear infinite;
}

/* Effet de pulsation pour le badge quand il y a des articles */
.cart-badge-has-items {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: cartBadgePulse 2s infinite;
}

@keyframes cartBadgePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Animation pour les images des produits dans l'aperçu */
.cart-preview-image {
    transition: transform 0.3s ease, filter 0.3s ease;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.cart-preview-image:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.cart-preview-image img {
    transition: transform 0.3s ease, filter 0.3s ease;
}

.cart-preview-image:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.cart-preview-image .fas.fa-box {
    color: #9ca3af;
    transition: color 0.3s ease;
}

.cart-preview-image:hover .fas.fa-box {
    color: #6b7280;
}

/* Effet de focus amélioré pour l'accessibilité */
#cartIcon:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Animation de transition pour les changements de quantité */
.cart-quantity-change {
    transition: all 0.3s ease;
}

.cart-quantity-change.updating {
    opacity: 0.7;
    transform: scale(0.95);
}

/* Responsive design pour l'aperçu du panier */
@media (max-width: 768px) {
    #cartPreview {
        width: 90vw;
        max-width: 350px;
        right: 5vw;
    }
    
    .cart-preview-enter {
        animation-duration: 0.3s;
    }
}

/* Animation de succès pour l'ajout au panier */
@keyframes addToCartSuccess {
    0% {
        background-color: #059669;
        transform: scale(1);
    }
    50% {
        background-color: #10b981;
        transform: scale(1.05);
    }
    100% {
        background-color: #10b981;
        transform: scale(1);
    }
}

.add-to-cart-success {
    animation: addToCartSuccess 0.6s ease-in-out;
}

/* Effet de particules pour l'ajout au panier */
@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.5);
    }
}

.cart-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: #10b981;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1s ease-out forwards;
}

/* Cart Modal Animations */
@keyframes cartModalEnter {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes cartModalExit {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

.cart-modal-enter {
    animation: cartModalEnter 0.3s ease-out;
}

.cart-modal-exit {
    animation: cartModalExit 0.3s ease-in;
}

/* Modal overlay animations */
@keyframes modalOverlayEnter {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes modalOverlayExit {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

#cartModalOverlay:not(.hidden) {
    animation: modalOverlayEnter 0.3s ease-out;
}

#cartModalOverlay.cart-modal-exit {
    animation: modalOverlayExit 0.3s ease-in;
}

/* Cart modal content animations */
.cart-item-enter {
    animation: cartItemEnter 0.4s ease-out;
}

.cart-item-exit {
    animation: cartItemExit 0.3s ease-in;
}

@keyframes cartItemExit {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-30px) scale(0.9);
    }
}

/* Loading animation for cart modal */
.cart-loading {
    animation: cartLoading 1.5s ease-in-out infinite;
}

@keyframes cartLoading {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Cart Modal Image Styles */
.cart-item .flex-shrink-0 img {
    transition: transform 0.3s ease, filter 0.3s ease;
    display: block;
}

.cart-item .flex-shrink-0 img:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.cart-item .flex-shrink-0 .bg-gray-200 {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.cart-item .flex-shrink-0 .fas.fa-box {
    color: #9ca3af;
    transition: color 0.3s ease;
}

.cart-item:hover .flex-shrink-0 .fas.fa-box {
    color: #6b7280;
}

/* Ensure proper image display */
.cart-item .flex-shrink-0 .w-20 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fallback styling */
.cart-item .flex-shrink-0 .w-20 .bg-gray-200 {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

/* Image loading animation */
.cart-item .flex-shrink-0 {
    position: relative;
}

.cart-item .flex-shrink-0::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: imageShimmer 1.5s infinite;
    z-index: 1;
    opacity: 0;
}

.cart-item .flex-shrink-0 img:not([src*="placeholder"]) {
    opacity: 0;
    animation: imageFadeIn 0.5s ease-in forwards;
}

@keyframes imageShimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes imageFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive image sizing for cart modal */
@media (max-width: 768px) {
    .cart-item .flex-shrink-0 .w-20 {
        width: 3rem;
        height: 3rem;
    }
}

@media (max-width: 640px) {
    .cart-item .flex-shrink-0 .w-20 {
        width: 2.5rem;
        height: 2.5rem;
    }
}
