/**
 * Cart Animations CSS
 * Mobile-first approach (70% mobile users)
 */

/* ==============================================
   FLYING CART ANIMATION
   ============================================== */

.flying-cart-icon {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ==============================================
   CART BOUNCE ANIMATION
   ============================================== */

.cart-bounce-animation {
    animation: cartBounce 0.6s ease !important;
}

@keyframes cartBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(0.9); }
    75% { transform: scale(1.15); }
}

/* ==============================================
   ROTATE LOADER ANIMATION
   ============================================== */

.rotate-animation {
    display: inline-block;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==============================================
   CART BADGE (in header)
   ============================================== */

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ==============================================
   STICKY CART BAR (Mobile-first)
   ============================================== */

.sticky-cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-top: 2px solid #667eea;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    padding: 12px 15px;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sticky-cart-bar.show {
    transform: translateY(0);
}

.sticky-cart-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.sticky-cart-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.sticky-cart-info i {
    font-size: 20px;
    color: #667eea;
}

.sticky-cart-info span {
    font-size: 14px;
}

/* Desktop optimization */
@media (min-width: 768px) {
    .sticky-cart-bar {
        padding: 15px 0;
    }
    
    .sticky-cart-content {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 15px;
    }
    
    .sticky-cart-info span {
        font-size: 15px;
    }
}

/* ==============================================
   PROGRESS BAR (Discount motivation)
   ============================================== */

.cart-discount-progress {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.progress-text {
    margin-bottom: 12px;
    font-size: 14px;
    color: #2c3e50;
    text-align: center;
}

.progress-text strong {
    color: #667eea;
    font-weight: 700;
}

.progress-text i {
    font-size: 18px;
    vertical-align: middle;
    margin-right: 5px;
}

.discount-progress {
    height: 12px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.discount-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.discount-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Success state */
.cart-discount-progress.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.cart-discount-progress.success .progress-text {
    color: #155724;
    font-weight: 600;
}

.cart-discount-progress.success .discount-progress-bar {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
}

/* Mobile optimization */
@media (max-width: 767px) {
    .cart-discount-progress {
        padding: 15px;
        border-radius: 8px;
    }
    
    .progress-text {
        font-size: 13px;
    }
    
    .discount-progress {
        height: 10px;
    }
}

/* ==============================================
   CART SIDEBAR (Desktop only)
   ============================================== */

@media (min-width: 768px) {
    #cartSidebar {
        position: fixed;
        right: -420px;
        top: 0;
        width: 400px;
        height: 100vh;
        background: white;
        box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 9999;
        overflow-y: auto;
    }
    
    #cartSidebar.open {
        right: 0;
    }
    
    #cartOverlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s ease;
        z-index: 9998;
    }
    
    #cartOverlay.show {
        opacity: 1;
        visibility: visible;
    }
}

/* Mobile: sidebar as bottom sheet */
@media (max-width: 767px) {
    #cartSidebar {
        position: fixed;
        bottom: -100%;
        left: 0;
        right: 0;
        width: 100%;
        height: 80vh;
        max-height: 600px;
        background: white;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 9999;
        overflow-y: auto;
    }
    
    #cartSidebar.open {
        bottom: 0;
    }
    
    /* Mobile handle */
    #cartSidebar::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #e0e0e0;
        border-radius: 2px;
    }
}

/* ==============================================
   MINI CART PREVIEW (Desktop only)
   ============================================== */

@media (min-width: 768px) {
    .cart-dropdown {
        position: absolute;
        top: 100%;
        right: 0;
        width: 350px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        margin-top: 10px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        z-index: 1000;
    }
    
    .top-bar-item:hover .cart-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .cart-dropdown-header {
        padding: 15px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .cart-dropdown-header h5 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
    }
    
    .cart-dropdown-body {
        max-height: 300px;
        overflow-y: auto;
        padding: 10px;
    }
    
    .cart-dropdown-footer {
        padding: 15px;
        border-top: 1px solid #f0f0f0;
    }
    
    .cart-dropdown-footer .cart-total {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
    }
}

/* ==============================================
   RESPONSIVE UTILITIES
   ============================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 768px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ==============================================
   BUTTON ANIMATIONS
   ============================================== */

.btn-cart, .btn-success {
    transition: all 0.3s ease;
}

.btn-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3) !important;
}

/* ==============================================
   LOADING STATES
   ============================================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rotate 0.8s linear infinite;
}

/* ==============================================
   ACCESSIBILITY
   ============================================== */

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for keyboard navigation */
.btn-cart:focus,
.btn-success:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

