/* ============================================================================
   COLISBLED - MOBILE FIRST CORE STYLESHEET
   Correction complète du responsive design avec approche mobile-first stricte
   ============================================================================ */

/* ===========================================
   1. RESET ET PRÉVENTION DES DÉBORDEMENTS
   =========================================== */

/* Reset universel avec box-sizing pour éviter les débordements */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Empêche le tap highlight sur mobile */
    -webkit-tap-highlight-color: transparent;
}

/* Configuration HTML de base */
html {
    /* Taille de police de base pour mobile */
    font-size: 16px;
    /* Empêche le zoom automatique sur iOS lors du focus des inputs */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Scroll fluide */
    scroll-behavior: smooth;
    /* Anti-aliasing pour une meilleure lisibilité */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* CRUCIAL: Empêche le débordement horizontal */
    overflow-x: hidden;
    width: 100%;
}

/* Configuration Body - MOBILE FIRST */
body {
    /* Empêche absolument tout débordement horizontal */
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
    
    /* Typographie mobile optimale */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #1e293b;
    background: #f8fafc;
    
    /* Améliore le rendu du texte sur mobile */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* ===========================================
   2. CONTENEURS RESPONSIVE MOBILE-FIRST
   =========================================== */

/* Tous les conteneurs doivent respecter la largeur de l'écran */
.container,
.container-fluid,
.modern-container,
[class*="container"] {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    /* Padding mobile minimal mais confortable */
    padding-left: 1rem;
    padding-right: 1rem;
    /* Empêche tout débordement */
    overflow-x: hidden;
}

/* Tablette: plus d'espace */
@media (min-width: 640px) {
    .container,
    .container-fluid,
    .modern-container,
    [class*="container"] {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Desktop: padding optimal */
@media (min-width: 1024px) {
    .container,
    .container-fluid,
    .modern-container,
    [class*="container"] {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Container avec largeur maximale pour grands écrans */
@media (min-width: 1280px) {
    .container,
    .modern-container {
        max-width: 1280px;
    }
}

/* ===========================================
   3. GRILLES ET LAYOUTS RESPONSIVE
   =========================================== */

/* Grille mobile-first: 1 colonne par défaut */
.responsive-grid,
.modern-grid,
[class*="grid"] {
    display: grid;
    width: 100%;
    gap: 1rem;
    /* Mobile: toujours 1 colonne par défaut */
    grid-template-columns: 1fr;
}

/* Tablette: 2 colonnes */
@media (min-width: 640px) {
    .responsive-grid-2,
    .modern-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .responsive-grid,
    .modern-grid {
        gap: 1.5rem;
    }
}

/* Desktop: 3-4 colonnes selon le contexte */
@media (min-width: 1024px) {
    .responsive-grid-3,
    .modern-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .responsive-grid-4,
    .modern-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .responsive-grid,
    .modern-grid {
        gap: 2rem;
    }
}

/* Layout flexbox mobile-first */
.flex-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

@media (min-width: 768px) {
    .flex-mobile {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* ===========================================
   4. IMAGES ET MÉDIAS RESPONSIVE
   =========================================== */

/* Toutes les images doivent être responsive */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Iframe et embeds responsive */
iframe,
embed,
object {
    max-width: 100%;
}

/* Container pour aspect ratio des vidéos */
.video-responsive {
    position: relative;
    padding-bottom: 56.25%; /* ratio 16:9 */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive object,
.video-responsive embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ===========================================
   5. TYPOGRAPHIE MOBILE-FIRST
   =========================================== */

/* Titres responsive avec clamp() */
h1, .h1 {
    font-size: clamp(1.75rem, 5vw + 0.5rem, 3rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    color: #0f172a;
}

h2, .h2 {
    font-size: clamp(1.5rem, 4vw + 0.5rem, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.875rem;
    color: #1e293b;
}

h3, .h3 {
    font-size: clamp(1.25rem, 3vw + 0.5rem, 2rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    color: #1e293b;
}

h4, .h4 {
    font-size: clamp(1.125rem, 2.5vw + 0.5rem, 1.75rem);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.625rem;
}

h5, .h5 {
    font-size: clamp(1rem, 2vw + 0.5rem, 1.5rem);
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

h6, .h6 {
    font-size: clamp(0.875rem, 1.5vw + 0.5rem, 1.25rem);
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

/* Paragraphes adaptés mobile */
p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* ===========================================
   6. FORMULAIRES MOBILE-OPTIMIZED
   =========================================== */

/* Inputs optimisés pour mobile */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    /* 16px minimum pour éviter le zoom automatique sur iOS */
    font-size: 16px;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: white;
    color: #1e293b;
    transition: all 0.2s ease;
    /* Supprime les styles natifs */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Focus états */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Textarea spécifique */
textarea {
    min-height: 120px;
    resize: vertical;
}

/* Labels mobiles */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #475569;
}

/* Form groups */
.form-group {
    margin-bottom: 1.25rem;
    width: 100%;
}

/* ===========================================
   7. BOUTONS MOBILE-FIRST
   =========================================== */

/* Boutons optimisés tactile */
button,
.btn,
[type="button"],
[type="submit"],
[type="reset"] {
    /* Taille minimum pour le tactile (44x44px recommandé) */
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Bouton mobile: pleine largeur par défaut */
    width: 100%;
}

/* Desktop: width auto */
@media (min-width: 768px) {
    button,
    .btn,
    [type="button"],
    [type="submit"],
    [type="reset"] {
        width: auto;
    }
}

/* Effet tactile */
button:active,
.btn:active {
    transform: scale(0.98);
}

/* ===========================================
   8. CARTES RESPONSIVE
   =========================================== */

.card,
.modern-card,
.gp-card,
.trip-card,
.reservation-card {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    width: 100%;
    /* Empêche le débordement du contenu */
    overflow: hidden;
    transition: all 0.2s ease;
}

@media (min-width: 640px) {
    .card,
    .modern-card,
    .gp-card,
    .trip-card,
    .reservation-card {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .card,
    .modern-card,
    .gp-card,
    .trip-card,
    .reservation-card {
        padding: 2rem;
    }
}

/* ===========================================
   9. NAVIGATION MOBILE
   =========================================== */

/* Navbar sticky optimisée */
.navbar,
nav[role="navigation"] {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    /* Effet de flou pour modernité */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Menu mobile: hamburger spacing */
.navbar-toggler {
    /* Zone tactile minimum */
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
}

/* Menu déroulant mobile */
.navbar-collapse {
    width: 100%;
}

@media (max-width: 991px) {
    .navbar-collapse {
        background: white;
        border-radius: 0.75rem;
        margin-top: 1rem;
        padding: 1rem;
        box-shadow: 0 10px 40px -5px rgba(0, 0, 0, 0.15);
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem;
        width: 100%;
        text-align: left;
    }
}

/* ===========================================
   10. TABLEAUX RESPONSIVE
   =========================================== */

/* Wrapper pour scroll horizontal sur mobile */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Table mobile */
table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

/* Version mobile: cartes au lieu de tableau */
@media (max-width: 767px) {
    .table-mobile-cards table,
    .table-mobile-cards thead,
    .table-mobile-cards tbody,
    .table-mobile-cards th,
    .table-mobile-cards td,
    .table-mobile-cards tr {
        display: block;
    }
    
    .table-mobile-cards thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-mobile-cards tr {
        margin-bottom: 1rem;
        background: white;
        border-radius: 0.5rem;
        padding: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .table-mobile-cards td {
        border: none;
        position: relative;
        padding-left: 40%;
    }
    
    .table-mobile-cards td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        font-weight: 600;
        color: #64748b;
    }
}

/* ===========================================
   11. MODALES MOBILE
   =========================================== */

.modal-mobile {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content-mobile {
    background: white;
    margin: 1rem;
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 100%;
}

@media (min-width: 640px) {
    .modal-content-mobile {
        margin: 2rem auto;
        max-width: 600px;
    }
}

/* ===========================================
   12. ESPACEMENTS MOBILE-FIRST
   =========================================== */

/* Section padding adaptatif */
.section-mobile {
    padding: 2rem 0;
}

@media (min-width: 640px) {
    .section-mobile {
        padding: 3rem 0;
    }
}

@media (min-width: 1024px) {
    .section-mobile {
        padding: 5rem 0;
    }
}

/* ===========================================
   13. UTILITAIRES ANTI-DÉBORDEMENT
   =========================================== */

/* Force la limitation de largeur */
.w-full {
    width: 100%;
}

.max-w-full {
    max-width: 100%;
}

/* Empêche débordements */
.no-overflow {
    overflow: hidden;
}

.no-overflow-x {
    overflow-x: hidden;
}

.no-overflow-y {
    overflow-y: hidden;
}

/* Scroll uniquement si nécessaire */
.overflow-auto {
    overflow: auto;
}

/* Word break pour éviter débordement du texte */
.break-word {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ===========================================
   14. PERFORMANCE MOBILE
   =========================================== */

/* Optimisation du rendu */
.gpu-accelerate {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Smooth scrolling touch */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ===========================================
   15. CORRECTIONS SPÉCIFIQUES iOS
   =========================================== */

/* Empêche le zoom sur double-tap iOS */
* {
    touch-action: manipulation;
}

/* Fix iOS input shadow */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0.5rem;
}

/* Fix iOS button */
button,
input[type="button"],
input[type="submit"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0.5rem;
}

/* ===========================================
   16. PRINT STYLES
   =========================================== */

@media print {
    body {
        background: white;
        color: black;
    }
    
    .no-print,
    nav,
    .navbar,
    footer,
    button,
    .btn {
        display: none !important;
    }
}

/* ===========================================
   17. ACCESSIBILITÉ MOBILE
   =========================================== */

/* Focus visible amélioré */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Cacher visuellement mais garder pour screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Zone tactile minimum respectée */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

/* ===========================================
   18. CORRECTIONS FINALES
   =========================================== */

/* Empêche le body de scroller horizontalement sur TOUS les appareils */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Correction pour les éléments position absolute qui débordent */
[style*="absolute"],
.position-absolute {
    max-width: 100%;
}

/* Correction Bootstrap responsive */
.row {
    margin-left: 0;
    margin-right: 0;
}

.col,
[class*="col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* S'assurer que rien ne dépasse */
* {
    max-width: 100%;
}

/* Exception pour images avec ratio */
img {
    max-width: 100%;
    height: auto;
}
