/* ========================================
   Toast Notifications System
   ======================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    min-width: 320px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    pointer-events: all;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.toast.hiding {
    animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@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;
    }
}

.toast-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.toast.success .toast-icon {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #ffffff;
}

.toast.error .toast-icon {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #ffffff;
}

.toast.info .toast-icon {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: #ffffff;
}

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast-title {
    font-size: 15px;
    font-weight: 700;
    color: #2f3658;
    margin: 0;
    line-height: 1.3;
}

.toast-message {
    font-size: 13px;
    color: #97abc5;
    margin: 0;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #97abc5;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.toast-close:hover {
    background: #f8f8f8;
    color: #2f3658;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #FDB913, #F6BA1A);
    width: 100%;
    transform-origin: left;
    animation: progressBar 3s linear forwards;
}

@keyframes progressBar {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* ========================================
   Cart Badge Animation
   ======================================== */

.nav-cart-badge,
.floating-cart-badge {
    animation: badgePop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

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

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

/* ========================================
   Add to Cart Button Animation
   ======================================== */

.cart-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.cart-btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.cart-btn-success {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    animation: successPulse 0.6s ease;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ========================================
   Product Flying Animation
   ======================================== */

.product-flying {
    position: fixed;
    z-index: 99998;
    pointer-events: none;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    animation: flyToCart 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

@keyframes flyToCart {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: scale(0.2);
    }
}

/* ========================================
   Cart Modal Enhancements
   ======================================== */

.cart-item-enter {
    animation: itemSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes itemSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cart-item-remove {
    animation: itemSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes itemSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ========================================
   Quantity Update Animation
   ======================================== */

.qty-updating {
    animation: qtyPulse 0.3s ease;
}

@keyframes qtyPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
    
    .product-flying {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .toast {
        padding: 12px 16px;
    }
    
    .toast-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .toast-title {
        font-size: 14px;
    }
    
    .toast-message {
        font-size: 12px;
    }
}

/* ========================================
   Accessibility
   ======================================== */

.toast:focus-within {
    outline: 3px solid rgba(253, 185, 19, 0.5);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .product-flying,
    .cart-btn-success,
    .cart-icon-shake,
    .nav-cart-badge,
    .floating-cart-badge {
        animation: none !important;
    }
}
