/* ============================================
   ADD TO CART NOTIFICATIONS & ANIMATIONS
   Industry-standard visual feedback for cart actions
   ============================================ */

/* Toast Notification Container */
.cart-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

/* Toast Notification */
.cart-toast {
    background: #fff;
    border-left: 4px solid #28a745;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 16px 20px;
    min-width: 320px;
    max-width: 400px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    animation: slideInRight 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.cart-toast.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Toast with product image */
.cart-toast-with-image {
    gap: 15px;
}

.cart-toast-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background: #f5f5f5;
    flex-shrink: 0;
}

/* Toast Icon */
.cart-toast-icon {
    width: 36px;
    height: 36px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Toast Content */
.cart-toast-content {
    flex: 1;
}

.cart-toast-title {
    font-weight: 600;
    font-size: 15px;
    color: #2d3748;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.cart-toast-message {
    font-size: 13px;
    color: #718096;
    margin: 0;
    line-height: 1.4;
}

.cart-toast-product-name {
    font-size: 13px;
    color: #2d3748;
    margin: 4px 0 0 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Toast Actions */
.cart-toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.cart-toast-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.cart-toast-btn-primary {
    background: #007bff;
    color: white;
}

.cart-toast-btn-primary:hover {
    background: #0056b3;
    color: white;
}

.cart-toast-btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.cart-toast-btn-secondary:hover {
    background: #cbd5e0;
}

/* Toast Close Button */
.cart-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.cart-toast-close:hover {
    color: #4a5568;
}

/* Progress Bar */
.cart-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #28a745;
    animation: progressBar 3s linear forwards;
}

/* Cart Icon Animations */
.cart-icon-wrapper {
    position: relative;
    display: inline-block;
}

/* Bounce Animation */
@keyframes cartBounce {
    0%, 100% { transform: scale(1); }
    10% { transform: scale(0.9); }
    30% { transform: scale(1.15); }
    50% { transform: scale(1.05); }
    70% { transform: scale(1.1); }
}

.cart-bounce {
    animation: cartBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Cart Count Badge Animation */
@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.cart-count {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-count-pulse {
    animation: badgePulse 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Flying Cart Animation (optional advanced effect) */
@keyframes flyToCart {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(var(--fly-x), var(--fly-y)) scale(0.5);
    }
    100% {
        opacity: 0;
        transform: translate(var(--fly-x), var(--fly-y)) scale(0.2);
    }
}

.flying-item {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    animation: flyToCart 0.8s cubic-bezier(0.5, 0, 0.5, 1) forwards;
}

/* Toast Animations */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes progressBar {
    from { width: 100%; }
    to { width: 0%; }
}

/* Loading State for Add to Cart Button */
.pd-add-to-cart.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.pd-add-to-cart.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* Success State for Add to Cart Button */
.pd-add-to-cart.success {
    background: #28a745;
    border-color: #28a745;
}

.pd-add-to-cart.success i {
    animation: checkMark 0.5s ease;
}

@keyframes checkMark {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .cart-toast-container {
        right: 10px;
        left: 10px;
        top: 70px;
    }
    
    .cart-toast {
        min-width: auto;
        max-width: 100%;
        padding: 12px 16px;
    }
    
    .cart-toast-image {
        width: 50px;
        height: 50px;
    }
    
    .cart-toast-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .cart-toast-title {
        font-size: 14px;
    }
    
    .cart-toast-message,
    .cart-toast-product-name {
        font-size: 12px;
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    .cart-toast {
        background: #2d3748;
        border-left-color: #48bb78;
    }
    
    .cart-toast-title {
        color: #f7fafc;
    }
    
    .cart-toast-message,
    .cart-toast-product-name {
        color: #cbd5e0;
    }
    
    .cart-toast-btn-secondary {
        background: #4a5568;
        color: #f7fafc;
    }
    
    .cart-toast-btn-secondary:hover {
        background: #718096;
    }
}
