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

/* Ensure minimum touch target size (44x44px recommended) */
button, 
a.btn, 
input[type="submit"],
input[type="button"],
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Smooth transitions for all interactive elements */
button,
a,
input,
select {
    transition: all 0.2s ease-in-out;
}

/* Active state feedback for buttons */
button:active,
a.btn:active,
.touch-target:active {
    transform: scale(0.97);
}

/* Enhanced quantity controls for mobile */
@media (max-width: 768px) {
    /* Compact quantity controls for product cards */
    .quantity-control {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .quantity-control button {
        font-size: 1.25rem;
        font-weight: bold;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .quantity-control input {
        font-size: 0.875rem;
        font-weight: 600;
        text-align: center;
        user-select: none;
        -webkit-appearance: none;
        -moz-appearance: textfield;
        appearance: textfield;
    }
    
    .quantity-control input::-webkit-outer-spin-button,
    .quantity-control input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        appearance: none;
        margin: 0;
    }

    /* Product card improvements */
    .product-card {
        position: relative;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .product-card:active {
        transform: scale(0.98);
    }
    
    /* Ensure product cards have consistent height */
    .product-card > div:last-child {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .product-card form {
        margin-top: auto;
    }

    /* Larger add to cart buttons */
    .add-to-cart-btn {
        min-height: 48px !important;
        font-size: 1rem !important;
        font-weight: 600;
        padding: 0.875rem 1rem !important;
    }

    /* Cart item controls */
    .cart-item-actions button {
        min-width: 48px;
        min-height: 48px;
    }

    /* Mobile sticky elements */
    .mobile-sticky {
        position: sticky;
        bottom: 5rem; /* Above bottom nav */
        z-index: 30;
    }
}

/* Loading spinner animation */
.loading-spinner {
    border: 3px solid rgba(34, 197, 94, 0.1);
    border-top: 3px solid #22c55e;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
}

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

/* Success feedback animation */
@keyframes successPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.9;
    }
}

.success-pulse {
    animation: successPulse 0.5s ease-in-out;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: #22c55e;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: slideUp 0.3s ease-out;
    min-width: 280px;
    text-align: center;
    font-weight: 500;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.toast.error {
    background: #ef4444;
}

.toast.info {
    background: #3b82f6;
}

/* Ripple effect for buttons */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Pull to refresh indicator */
.pull-to-refresh {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #22c55e;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Enhanced focus states for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #22c55e;
    outline-offset: 2px;
}

/* Safe area padding for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Skeleton loading for images */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Image lazy loading fade in */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Cart badge pulse animation */
.cart-badge-pulse {
    animation: badgePulse 0.5s ease-in-out;
}

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

/* Swipe indicator for mobile carousels */
.swipe-indicator {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.swipe-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s;
}

.swipe-dot.active {
    background: white;
    width: 24px;
    border-radius: 4px;
}

/* Bottom sheet modal for mobile */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 100;
    max-height: 85vh;
    overflow-y: auto;
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 99;
    pointer-events: none;
}

.bottom-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Handle for bottom sheet */
.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0.75rem auto;
}

/* Enhanced card hover/active states */
@media (hover: hover) {
    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    }
}

/* Prevent text selection on buttons */
button,
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Optimize for touch scrolling */
.touch-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Loading state for buttons */
button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

button.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Floating action button - Retiré (bouton flèche verte) */
/*
.fab {
    position: fixed;
    bottom: 6rem;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #22c55e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    z-index: 40;
    transition: all 0.3s;
}

.fab:active {
    transform: scale(0.95);
}

.fab:hover {
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.5);
}
*/

/* Haptic feedback class (requires JS) */
.haptic {
    cursor: pointer;
}
