/* Cart Animations CSS */
/* ==================== */

/* Floating Cart Button */
.floating-cart-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2B6233 0%, #3d8b47 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    box-shadow: 0 4px 20px rgba(43, 98, 51, 0.4);
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0) translateY(20px);
    pointer-events: none;
}

.floating-cart-btn.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.floating-cart-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 8px 30px rgba(43, 98, 51, 0.5);
}

.floating-cart-btn i {
    font-size: 24px;
    color: #fff;
}

.floating-cart-btn .cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 24px;
    height: 24px;
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Cart Shake Animation on Add */
.floating-cart-btn.shake {
    animation: cart-shake 0.5s ease-in-out;
}

@keyframes cart-shake {
    0%, 100% { transform: scale(1) rotate(0); }
    20% { transform: scale(1.1) rotate(-10deg); }
    40% { transform: scale(1.1) rotate(10deg); }
    60% { transform: scale(1.1) rotate(-5deg); }
    80% { transform: scale(1.1) rotate(5deg); }
}

/* ==================== */
/* Add to Cart Animation Overlay */
/* ==================== */
.add-to-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.cart-animation-container {
    text-align: center;
    padding: 40px;
}

/* Flying Product Animation */
.flying-product {
    position: fixed;
    z-index: 10000;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
}

.flying-product img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flying-product.animate {
    opacity: 1;
    animation: fly-to-cart 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fly-to-cart {
    0% {
        transform: scale(1) rotate(0);
    }
    50% {
        transform: scale(0.5) rotate(180deg);
    }
    100% {
        transform: scale(0.2) rotate(360deg);
        opacity: 0;
    }
}

/* Success Checkmark Animation */
.add-success-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 10001;
    background: #fff;
    border-radius: 20px;
    padding: 40px 60px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.add-success-animation.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #2B6233 0%, #3d8b47 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: success-pop 0.5s ease-out forwards;
}

.success-checkmark i {
    font-size: 40px;
    color: #fff;
    animation: check-draw 0.4s ease-out 0.2s forwards;
    opacity: 0;
    transform: scale(0);
}

@keyframes success-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes check-draw {
    0% { opacity: 0; transform: scale(0) rotate(-45deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}

.add-success-animation h3 {
    color: #2B6233;
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.add-success-animation p {
    color: #666;
    margin-bottom: 20px;
}

.add-success-animation .btn-view-cart {
    background: linear-gradient(135deg, #2B6233 0%, #3d8b47 100%);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-right: 10px;
}

.add-success-animation .btn-view-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(43, 98, 51, 0.4);
}

.add-success-animation .btn-continue {
    background: transparent;
    color: #666;
    border: 2px solid #ddd;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-success-animation .btn-continue:hover {
    border-color: #2B6233;
    color: #2B6233;
}

/* ==================== */
/* Order Processing Animation */
/* ==================== */
.order-processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.order-processing-overlay.active {
    opacity: 1;
    visibility: visible;
}

.order-animation-stage {
    position: relative;
    width: 300px;
    height: 200px;
    margin-bottom: 30px;
}

/* Packing Box Animation */
.packing-box {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 80px;
    background: #8B4513;
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.packing-box::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -5px;
    right: -5px;
    height: 20px;
    background: #A0522D;
    border-radius: 3px 3px 0 0;
    transform-origin: bottom;
    animation: box-lid 1s ease-in-out 0.5s forwards;
}

.packing-box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #2B6233;
    border-radius: 50%;
    opacity: 0;
    animation: product-drop 0.5s ease-out forwards;
}

@keyframes box-lid {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(-120deg); }
    100% { transform: rotateX(0); }
}

@keyframes product-drop {
    0% { opacity: 1; transform: translate(-50%, -150%); }
    100% { opacity: 1; transform: translate(-50%, -50%); }
}

/* Tape Animation */
.packing-tape {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -100%);
    width: 60px;
    height: 15px;
    background: #ffd700;
    opacity: 0;
    animation: tape-appear 0.3s ease-out 1.8s forwards;
}

@keyframes tape-appear {
    0% { opacity: 0; width: 0; }
    100% { opacity: 1; width: 60px; }
}

/* Delivery Truck Animation */
.delivery-truck {
    position: absolute;
    left: -150px;
    bottom: 20px;
    width: 120px;
    opacity: 0;
    animation: truck-enter 1s ease-out 2.5s forwards;
}

.truck-body {
    position: relative;
    width: 80px;
    height: 50px;
    background: linear-gradient(135deg, #2B6233 0%, #3d8b47 100%);
    border-radius: 5px;
    margin-left: 40px;
}

.truck-body::before {
    content: 'COCONI';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

.truck-cabin {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 35px;
    background: #1e4a24;
    border-radius: 10px 0 0 0;
}

.truck-cabin::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 20px;
    height: 15px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.truck-wheel {
    position: absolute;
    bottom: -10px;
    width: 20px;
    height: 20px;
    background: #333;
    border-radius: 50%;
    border: 3px solid #666;
}

.truck-wheel.front {
    left: 10px;
    animation: wheel-spin 0.5s linear infinite;
}

.truck-wheel.back {
    right: 10px;
    animation: wheel-spin 0.5s linear infinite;
}

@keyframes wheel-spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

@keyframes truck-enter {
    0% {
        left: -150px;
        opacity: 0;
    }
    30% {
        left: 50%;
        opacity: 1;
        transform: translateX(-50%);
    }
    60% {
        left: 50%;
        transform: translateX(-50%);
    }
    100% {
        left: 110%;
        opacity: 1;
    }
}

/* Progress Steps */
.order-progress-steps {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.3;
    transition: all 0.3s ease;
}

.progress-step.active {
    opacity: 1;
}

.progress-step.completed .step-icon {
    background: #2B6233;
    color: #fff;
}

.step-icon {
    width: 50px;
    height: 50px;
    background: #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #666;
    transition: all 0.3s ease;
}

.step-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.order-message {
    font-size: 1.2rem;
    color: #2B6233;
    font-weight: 600;
    margin-bottom: 20px;
    min-height: 30px;
}

/* ==================== */
/* Button Loading States */
/* ==================== */
.btn-add-to-cart.loading,
.place-order-btn.loading {
    position: relative;
    pointer-events: none;
}

.btn-add-to-cart.loading::after,
.place-order-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn-add-to-cart.loading span,
.btn-add-to-cart.loading i,
.place-order-btn.loading span,
.place-order-btn.loading i {
    visibility: hidden;
}

/* Cart Item Added Notification Toast */
.cart-toast {
    position: fixed;
    top: 100px;
    right: 30px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    transform: translateX(150%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 350px;
}

.cart-toast.show {
    transform: translateX(0);
}

.cart-toast-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2B6233 0%, #3d8b47 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-toast-icon i {
    color: #fff;
    font-size: 24px;
}

.cart-toast-content h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 700;
    color: #2B6233;
}

.cart-toast-content p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.cart-toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.cart-toast-close:hover {
    color: #333;
}

/* Confetti Animation for Order Success */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    z-index: 99998;
    pointer-events: none;
}

.confetti.square {
    background: var(--confetti-color);
}

.confetti.circle {
    background: var(--confetti-color);
    border-radius: 50%;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ==================== */
/* Page Loading Animation */
/* ==================== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.page-loader.active {
    opacity: 1;
    visibility: visible;
}

.page-loader-content {
    text-align: center;
}

/* Modern spinner with brand colors */
.page-loader-spinner {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
}

.page-loader-spinner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid #e9ecef;
    border-radius: 50%;
}

.page-loader-spinner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #2B6233;
    border-right-color: #3d8b47;
    border-radius: 50%;
    animation: loader-spin 0.6s linear infinite;
}

@keyframes loader-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress bar at top */
.page-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #2B6233, #3d8b47, #ffc107);
    z-index: 100000;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(43, 98, 51, 0.5);
}

.page-loader-bar.active {
    animation: loader-bar-progress 1.5s ease-out forwards;
}

@keyframes loader-bar-progress {
    0% { width: 0; }
    20% { width: 25%; }
    50% { width: 60%; }
    80% { width: 85%; }
    100% { width: 95%; }
}

.page-loader-bar.complete {
    width: 100%;
    transition: width 0.2s ease;
}

/* Loader text */
.page-loader-text {
    color: #2B6233;
    font-size: 14px;
    font-weight: 600;
    animation: loader-text-pulse 1s ease-in-out infinite;
}

@keyframes loader-text-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Dots animation for text */
.page-loader-dots {
    display: inline-block;
}

.page-loader-dots::after {
    content: '';
    animation: loader-dots 1.5s steps(4) infinite;
}

@keyframes loader-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

/* Quick flash loader for fast pages */
.page-loader-quick {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #2B6233, #3d8b47);
    z-index: 100000;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.15s ease-out;
}

.page-loader-quick.active {
    transform: scaleX(0.3);
}

.page-loader-quick.loading {
    animation: quick-loader 0.8s ease-out forwards;
}

@keyframes quick-loader {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(0.7); }
    100% { transform: scaleX(0.9); }
}

.page-loader-quick.complete {
    transform: scaleX(1);
    transition: transform 0.1s ease-out;
}

.page-loader-quick.fade-out {
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
}

/* Responsive */
@media (max-width: 768px) {
    .floating-cart-btn {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }

    .add-success-animation {
        padding: 30px;
        margin: 20px;
        width: calc(100% - 40px);
    }

    .order-animation-stage {
        transform: scale(0.8);
    }

    .order-progress-steps {
        gap: 15px;
    }

    .step-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .cart-toast {
        right: 15px;
        left: 15px;
        max-width: none;
    }

    .page-loader-spinner {
        width: 50px;
        height: 50px;
    }
}
