/* Optimisations mobiles pour RoadMatch */

/* Variables CSS pour une meilleure cohérence */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

/* Améliorations tactiles pour mobile */
@media (max-width: 768px) {
    /* Augmenter la taille des zones cliquables */
    button, .btn, [onclick] {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }
    
    /* Améliorer la lisibilité sur petit écran */
    body {
        font-size: 16px;
        line-height: 1.5;
    }
    
    /* Navigation mobile optimisée */
    .md\\:hidden {
        display: block !important;
    }
    
    .hidden {
        display: none !important;
    }
    
    /* Cards plus compactes sur mobile */
    .card-shadow {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    /* Formulaires mobile-friendly */
    input, textarea, select {
        font-size: 16px; /* Éviter le zoom sur iOS */
        padding: 12px 16px;
    }
    
    /* Messages et notifications adaptées */
    .fixed.top-4.right-4 {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    /* Chat mobile optimisé */
    #chatSection .lg\\:col-span-2 {
        grid-column: span 1;
    }
    
    #messagesContainer {
        height: 50vh;
        min-height: 300px;
    }
    
    /* Cartes de matches plus grandes sur mobile */
    #newMatchesList .grid,
    #allMatchesList .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Amélioration des modals sur mobile */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* Tracking interface mobile */
    .grid.md\\:grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    #map {
        height: 200px;
        margin-bottom: 1rem;
    }
    
    /* Amélioration de l'accessibilité tactile */
    .space-x-4 > * + * {
        margin-left: 0.5rem;
    }
    
    .space-y-4 > * + * {
        margin-top: 1rem;
    }
}

/* Optimisations pour très petits écrans */
@media (max-width: 480px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .text-4xl {
        font-size: 2rem;
        line-height: 2.5rem;
    }
    
    .text-6xl {
        font-size: 2.5rem;
        line-height: 3rem;
    }
    
    /* Réduire l'espacement sur très petits écrans */
    .py-8 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }
    
    .mb-12 {
        margin-bottom: 2rem;
    }
    
    /* Ajustements pour les cartes de profil */
    .w-20.h-20 {
        width: 4rem;
        height: 4rem;
    }
    
    .w-16.h-16 {
        width: 3.5rem;
        height: 3.5rem;
    }
}

/* Animations et transitions optimisées */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mode sombre (si supporté par le système) */
@media (prefers-color-scheme: dark) {
    .dark-mode-support {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-300: #6b7280;
        --gray-400: #9ca3af;
        --gray-500: #d1d5db;
        --gray-600: #e5e7eb;
        --gray-700: #f3f4f6;
        --gray-800: #f9fafb;
        --gray-900: #ffffff;
    }
}

/* Améliorations pour les gestes tactiles */
.swipe-container {
    touch-action: pan-x;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}

.swipe-item {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* Feedback tactile amélioré */
.btn-haptic {
    position: relative;
    overflow: hidden;
}

.btn-haptic::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn-haptic:active::after {
    width: 300px;
    height: 300px;
}

/* Optimisations pour les performances */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

.scroll-optimized {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Indicateurs de chargement mobile */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Amélioration des zones de drop sur mobile */
.drop-zone {
    min-height: 120px;
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: var(--gray-50);
}

/* Status bar et safe area pour iOS */
@supports (padding-top: env(safe-area-inset-top)) {
    .ios-safe-top {
        padding-top: env(safe-area-inset-top);
    }
    
    .ios-safe-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Optimisations pour Android */
.android-optimized {
    tap-highlight-color: transparent;
    -webkit-tap-highlight-color: transparent;
}

/* Pull-to-refresh indication */
.pull-to-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Floating action button pour actions rapides */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    z-index: 40;
    transition: all 0.3s ease;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Améliorations pour la géolocalisation */
.location-accuracy-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.accuracy-high { color: var(--success-color); }
.accuracy-medium { color: var(--warning-color); }
.accuracy-low { color: var(--danger-color); }

/* Indicateurs de connectivité */
.connection-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

.connection-dot.offline {
    background: var(--danger-color);
    animation: none;
}

/* Améliorations pour le chat mobile */
.message-input-container {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

.message-bubble {
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Optimisations pour les images de profil */
.profile-image {
    object-fit: cover;
    object-position: center;
    background: var(--gray-200);
}

.profile-image-loading {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 2s infinite;
}

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

/* Améliorations pour l'accessibilité */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Améliorations pour les performances de scroll */
.virtual-scroll {
    contain: layout style paint;
    content-visibility: auto;
}

/* Responsive typography */
.text-responsive {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
}

.heading-responsive {
    font-size: clamp(1.5rem, 5vw, 3rem);
}

/* Optimisations pour PWA */
.pwa-install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 1rem;
    z-index: 50;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-prompt.show {
    transform: translateY(0);
}