/**
 * Advanced Cart Animations for SquareWOO Theme
 * Modern ve etkileyici sepete ekleme animasyonları
 * Version: 1.0
 * Author: SquarePancake
 */

/* CSS Variables for consistent theming */
:root {
    --primary-gradient: linear-gradient(135deg, #F67280 0%, #C06C84 100%);
    --success-color: #10B981;
    --success-gradient: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --animation-duration: 2s;
    --animation-timing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --bounce-timing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ==========================================
   FLYING CART ANIMATION SYSTEM
   ========================================== */

/* Ürün resmi için flying animation container */
.flying-cart-item {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    transition: none;
    opacity: 0;
}

.flying-cart-item img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(246, 114, 128, 0.3);
    border: 2px solid white;
}

/* Flying animation keyframes */
@keyframes flyToCart {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.8) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) rotate(360deg);
    }
}

.flying-cart-item.animate {
    animation: flyToCart var(--animation-duration) var(--animation-timing) forwards;
}

/* ==========================================
   ENHANCED CART ICON ANIMATIONS
   ========================================== */

/* Cart icon container */
.cart-icon-container {
    position: relative;
    display: inline-block;
}

/* Improved cart shake animation */
@keyframes advancedCartShake {
    0%, 100% { 
        transform: translateX(0) rotate(0deg) scale(1); 
    }
    10% { 
        transform: translateX(-3px) rotate(-2deg) scale(1.05); 
    }
    20% { 
        transform: translateX(3px) rotate(2deg) scale(1.1); 
    }
    30% { 
        transform: translateX(-2px) rotate(-1deg) scale(1.05); 
    }
    40% { 
        transform: translateX(2px) rotate(1deg) scale(1.1); 
    }
    50% { 
        transform: translateX(-1px) rotate(0deg) scale(1.15); 
    }
    60% { 
        transform: translateX(1px) rotate(1deg) scale(1.1); 
    }
    70% { 
        transform: translateX(-1px) rotate(-1deg) scale(1.05); 
    }
    80% { 
        transform: translateX(1px) rotate(0deg) scale(1.02); 
    }
    90% { 
        transform: translateX(0) rotate(0deg) scale(1.01); 
    }
}

.cart-icon-shake {
    animation: advancedCartShake 0.8s ease-in-out;
}

/* Cart count badge animation */
@keyframes cartCountPop {
    0% { 
        transform: scale(0.5) rotate(-180deg);
        opacity: 0;
    }
    50% { 
        transform: scale(1.2) rotate(-90deg);
        opacity: 0.8;
    }
    100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.cart-count-animate {
    animation: cartCountPop 0.5s var(--bounce-timing);
}

/* ==========================================
   PRODUCT CARD HOVER ANIMATIONS
   ========================================== */

/* Add to cart button enhanced animations */
.ajax_add_to_cart,
.single_add_to_cart_button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--animation-timing);
}

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

.ajax_add_to_cart:hover::before,
.single_add_to_cart_button:hover::before {
    width: 300px;
    height: 300px;
}

/* Button click ripple effect */
@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

.button-ripple {
    position: relative;
    overflow: hidden;
}

.button-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 0.6s linear;
}

/* ==========================================
   ENHANCED LOADING ANIMATIONS
   ========================================== */

/* Improved loading spinner */
@keyframes modernSpin {
    0% { 
        transform: rotate(0deg) scale(1);
        border-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.3) #ffffff rgba(255, 255, 255, 0.3);
    }
    50% { 
        transform: rotate(180deg) scale(1.1);
        border-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.1) #ffffff rgba(255, 255, 255, 0.1);
    }
    100% { 
        transform: rotate(360deg) scale(1);
        border-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.3) #ffffff rgba(255, 255, 255, 0.3);
    }
}

.ajax_add_to_cart.loading::after,
.single_add_to_cart_button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    animation: modernSpin 1s ease-in-out infinite;
}

/* Pulse loading effect for button text */
@keyframes pulseText {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.ajax_add_to_cart.loading,
.single_add_to_cart_button.loading {
    animation: pulseText 1.5s ease-in-out infinite;
}

/* ==========================================
   SUCCESS FEEDBACK ANIMATIONS
   ========================================== */

/* Success checkmark animation */
@keyframes drawCheck {
    0% { stroke-dashoffset: 100; }
    100% { stroke-dashoffset: 0; }
}

.success-checkmark {
    width: 24px;
    height: 24px;
    stroke: var(--success-color);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawCheck 0.6s ease-out forwards;
}

/* Button success state */
.button-success {
    background: var(--success-gradient) !important;
    color: white !important;
    transform: scale(1.05);
    transition: all 0.3s var(--bounce-timing);
}

/* ==========================================
   ENHANCED NOTIFICATION ANIMATIONS
   ========================================== */

/* Improved notification appearance */
@keyframes notificationSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateX(-10px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.cart-notification.active {
    animation: notificationSlideIn 0.5s var(--bounce-timing);
}

/* Notification exit animation */
@keyframes notificationSlideOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
}

.cart-notification.hiding {
    animation: notificationSlideOut 0.3s ease-in forwards;
}

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

/* Quantity input animations */
.quantity-input {
    transition: all 0.2s ease;
}

.quantity-input:focus {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(246, 114, 128, 0.2);
}


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

@media (max-width: 768px) {
    /* Reduce animation intensity on mobile */
    .flying-cart-item img {
        width: 70px;
        height: 70px;
    }
    
    .product-card:hover {
        transform: translateY(-2px);
    }
    
    /* Slower animations on mobile for better visibility */
    :root {
        --animation-duration: 1.0s;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Respect user's motion preferences */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================
   MOBILE BOTTOM BAR
   ========================================== */

/* Mobile fixed bottom bar for single product */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
}

@media (max-width: 768px) {
    .mobile-bottom-bar {
        display: block;
    }
}

.mobile-bottom-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

.mobile-price-section {
    flex: 1;
}

.mobile-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-text);
    line-height: 1.2;
}

.mobile-price-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 2px;
}

.mobile-cart-section {
    flex: 0 0 auto;
    margin-left: 15px;
}

.mobile-add-to-cart-btn {
    /* background previously used primary gradient; update to theme green for consistency */
    background: var(--bg-blue-squarepancake);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(246, 114, 128, 0.3);
    min-width: 140px;
    justify-content: center;
}

.mobile-add-to-cart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(246, 114, 128, 0.4);
}

.mobile-add-to-cart-btn:active {
    transform: translateY(0);
}

.mobile-add-to-cart-btn svg {
    flex-shrink: 0;
}

/* ==========================================
   CART DRAWER ANIMATIONS
   ========================================== */

/* Enhanced cart drawer animations */
.cart-drawer {
    transition: transform 0.4s var(--animation-timing);
}

.cart-drawer.opening {
    animation: slideInRight 0.4s var(--animation-timing);
}

@keyframes slideInRight {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}


/* ==========================================
   WISHLIST INTEGRATION ANIMATIONS
   ========================================== */

.wishlist-icon {
    transition: all 0.3s ease;
}

.wishlist-icon:hover {
    transform: scale(1.2);
    color: #e74c3c;
}

.wishlist-icon.added {
    animation: heartBeat 0.6s ease-in-out;
    color: #e74c3c;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1.1); }
    75% { transform: scale(1.25); }
    100% { transform: scale(1); }
}
