/**
 * Smooth Animations and Transitions
 * Enhances user experience with fluid animations
 */

/* ========================================
   CART DRAWER ANIMATIONS & STATES
   ======================================== */

/* Cart drawer overlay animations */
.cart-drawer-overlay {
    animation: fadeIn 0.3s ease-out;
}

.cart-drawer-overlay.closing {
    animation: fadeOut 0.3s ease-in;
}

/* Cart item animations */
.cart-item {
    transition: all 0.3s ease;
    position: relative;
}

.cart-item.removing {
    transform: translateX(-100%);
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.cart-item.updating {
    opacity: 0.6;
    pointer-events: none;
}

.cart-item.updating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #7d41f5;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Loading spinner for individual items */
.cart-item.updating .qty-btn,
.cart-item.updating .remove-item {
    opacity: 0.5;
    pointer-events: none;
}

/* Retry button animations */
.retry-update {
    animation: slideInRight 0.3s ease-out;
}

.retry-update:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Focus management styles */
.cart-drawer-overlay:focus {
    outline: none;
}

.cart-drawer-overlay:focus-visible {
    outline: 2px solid #7d41f5;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cart-drawer-overlay {
        background-color: rgba(0, 0, 0, 0.8) !important;
    }
    
    .cart-item.updating::after {
        border-color: #000;
        border-top-color: transparent;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cart-drawer-overlay,
    .cart-item,
    .retry-update {
        animation: none !important;
        transition: none !important;
    }
    
    .cart-item.removing {
        display: none;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

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

/* Slide in from right animation */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Pulse animation for loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Shake animation for error states */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

/* Error state styling */
.cart-item.error {
    animation: shake 0.5s ease-in-out;
    border-left: 3px solid #ef4444;
}

/* Success state styling */
.cart-item.success {
    border-left: 3px solid #10b981;
    transition: border-left-color 0.3s ease;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    .cart-drawer-overlay {
        align-items: flex-end;
    }
    
    .cart-item {
        padding: 12px 0;
    }
    
    .cart-item.updating::after {
        width: 16px;
        height: 16px;
        margin: -8px 0 0 -8px;
    }
    
    .retry-update {
        font-size: 10px;
        padding: 4px 8px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .cart-drawer-overlay {
        background-color: rgba(0, 0, 0, 0.6);
    }
    
    .cart-item.updating::after {
        border-color: #f59e0b;
        border-top-color: transparent;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Focus indicators for keyboard navigation */
.qty-btn:focus,
.remove-item:focus,
.retry-update:focus,
.close-cart-drawer:focus,
.proceed-to-checkout:focus {
    outline: 2px solid #7d41f5;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High contrast focus indicators */
@media (prefers-contrast: high) {
    .qty-btn:focus,
    .remove-item:focus,
    .retry-update:focus,
    .close-cart-drawer:focus,
    .proceed-to-checkout:focus {
        outline: 3px solid #000;
        outline-offset: 1px;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Hardware acceleration for smooth animations */
.cart-drawer-overlay,
.cart-item,
.retry-update {
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Optimize for mobile performance */
@media (max-width: 768px) {
    .cart-drawer-overlay {
        will-change: auto;
    }
}

/* ========================================
   ERROR STATE STYLES
   ======================================== */

.error-content {
    text-align: center;
    padding: 2rem;
}

.error-content svg {
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-content h3 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.error-content p {
    color: #6b7280;
    margin-bottom: 1rem;
}

/* ========================================
   LOADING STATE STYLES
   ======================================== */

.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.loading-content .loader {
    margin-bottom: 1rem;
}

.loading-content p {
    color: #6b7280;
    font-size: 0.875rem;
}

/* ========================================
   SUCCESS STATE STYLES
   ======================================== */

.success-indicator {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    animation: pulse 2s ease-in-out;
}

/* ========================================
   RESPONSIVE DESIGN ENHANCEMENTS
   ======================================== */

@media (max-width: 640px) {
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .cart-item .flex.items-center.space-x-2 {
        width: 100%;
        justify-content: space-between;
    }
    
    .retry-update {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .cart-item {
        gap: 1rem;
    }
    
    .cart-item .flex.items-center.space-x-2 {
        flex-shrink: 0;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .cart-drawer-overlay {
        display: none !important;
    }
    
    .cart-item.updating::after {
        display: none !important;
    }
    
    .retry-update {
        display: none !important;
    }
}

/* Cart drawer animations */
.cart-drawer-overlay {
    animation: fadeIn 0.3s ease-out;
}

.cart-drawer-overlay.closing {
    animation: fadeOut 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Cart item animations */
.cart-item {
    animation: slideInUp 0.3s ease-out;
}

.cart-item.removing {
    animation: slideOutRight 0.3s ease-in;
}

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

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

/* Button hover effects */
.elink-cart-add,
.elink-cart-plus,
.elink-cart-minus,
.qty-btn {
    transition: all 0.2s ease-in-out;
}

/* Quantity controls animation */
.elink-cart-qty {
    animation: expandIn 0.3s ease-out;
}

.elink-cart-qty.hiding {
    animation: shrinkOut 0.3s ease-in;
}

@keyframes expandIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shrinkOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.8);
        opacity: 0;
    }
}

/* Product card hover effects */
.flex-shrink-0 {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

/* Loading state animations */
.btn-loading {
    transition: all 0.2s ease-in-out;
}

.btn-loading .btn-text {
    transition: opacity 0.2s ease-in-out;
}

/* Toast notifications */
.toast-notification {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus states for accessibility */
.elink-cart-add:focus,
.elink-cart-plus:focus,
.elink-cart-minus:focus,
.qty-btn:focus {
    outline: 2px solid #7d41f5;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .cart-drawer-overlay,
    .cart-item,
    .elink-cart-qty,
    .toast-notification {
        animation: none !important;
        transition: none !important;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .cart-drawer-overlay {
        animation-duration: 0.2s;
    }
    
    .cart-item {
        animation-duration: 0.2s;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .elink-cart-add,
    .elink-cart-plus,
    .elink-cart-minus {
        border: 2px solid currentColor;
    }
    
    .btn-loading {
        border: 2px solid currentColor;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .toast-notification {
        filter: brightness(0.9);
    }
} 