/* ========================================
   STYLES MOBILES ET ANTI-DÉFILEMENT HORIZONTAL
   Appliqués à toutes les pages du site
   ======================================== */

/* Règles globales pour empêcher le défilement horizontal */
* {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

html {
    overflow-x: hidden !important;
    width: 100% !important;
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Conteneurs principaux */
.main-container,
.container,
.content-wrapper,
.wrapper,
.page-wrapper {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Sections principales */
section,
header,
footer,
nav,
main,
article,
aside,
div[class*="section"],
div[class*="container"] {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* ========================================
   RESPONSIVITÉ POUR PETITS ÉCRANS
   ======================================== */

/* Pour les très petits écrans (380px et moins) */
@media (max-width: 380px) {
    /* Ajustements de padding généraux */
    body {
        font-size: 14px !important;
    }

    .hero-section,
    .section,
    .content-section,
    [class*="section"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Textes et titres */
    h1 {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }

    h2 {
        font-size: 20px !important;
        line-height: 1.2 !important;
    }

    h3 {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }

    h4 {
        font-size: 16px !important;
    }

    p {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }

    /* Boutons */
    .btn,
    button,
    [class*="btn-"],
    input[type="submit"],
    input[type="button"] {
        font-size: 13px !important;
        padding: 10px 16px !important;
        min-height: 40px !important;
    }

    /* Cartes et éléments */
    .card,
    [class*="card"] {
        padding: 16px !important;
        margin-bottom: 12px !important;
    }

    /* Navigation */
    .nav-container,
    nav {
        padding: 8px 12px !important;
    }

    /* Images et médias */
    img, video, iframe, embed, object {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Formulaires */
    input,
    textarea,
    select {
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
}

/* Pour les écrans de 320px (iPhone SE, etc.) */
@media (max-width: 320px) {
    /* Réduction supplémentaire */
    body {
        font-size: 13px !important;
    }

    h1 {
        font-size: 22px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    h3 {
        font-size: 16px !important;
    }

    p {
        font-size: 13px !important;
    }

    /* Boutons encore plus compacts */
    .btn,
    button {
        padding: 8px 12px !important;
        font-size: 12px !important;
        min-height: 36px !important;
    }

    /* Padding minimal */
    .section,
    [class*="section"] {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* Empêcher le défilement horizontal sur mobile */
@media (max-width: 768px) {
    /* Tous les éléments ne doivent pas dépasser la largeur de l'écran */
    * {
        max-width: 100vw !important;
    }

    /* S'assurer que les conteneurs flex ne causent pas de débordement */
    .flex,
    .flex-row,
    .flex-col,
    [class*="flex"],
    .d-flex {
        flex-wrap: wrap !important;
    }

    /* Prévenir le débordement des textes longs */
    p, span, a, li, td, th, div {
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }

    /* Forcer les contenus pré-formatés à respecter les limites */
    pre, code {
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        max-width: 100% !important;
        overflow-x: auto !important;
    }

    /* Cacher la barre de défilement horizontal */
    ::-webkit-scrollbar-horizontal {
        display: none !important;
    }

    /* Forcer les tableaux à être responsive */
    table {
        display: block !important;
        overflow-x: auto !important;
        max-width: 100% !important;
    }

    /* S'assurer que les modales ne dépassent pas */
    .modal,
    .modal-content,
    .modal-dialog,
    .popup,
    [class*="modal"] {
        max-width: calc(100vw - 20px) !important;
        margin: 0 10px !important;
    }

    /* Empêcher les positions absolues de sortir de l'écran */
    [style*="position: absolute"],
    [style*="position:absolute"] {
        max-width: 100vw !important;
    }

    /* Réinitialiser les marges négatives qui pourraient causer des débordements */
    [class*="ml-"],
    [class*="mr-"],
    [style*="margin-left"],
    [style*="margin-right"] {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Fix pour iOS Safari */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    body {
        -webkit-overflow-scrolling: touch !important;
    }

    /* Prevent elastic scroll on iOS */
    html, body {
        position: fixed !important;
        overflow: hidden !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* Allow vertical scroll on main content */
    main, .main-content {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Règles de débogage (à commenter en production) */
/*
* {
    outline: 1px solid red !important;
}
*/