/* =========================================================================
 * mobile-override.css
 * Surcouche mobile pour le framework nicdark (site travaux).
 * - Chargé APRÈS nicdark_responsive.css : ses règles priment.
 * - Aucune modification des CSS d'origine.
 * Breakpoint principal : <= 767px (téléphone portrait + paysage léger)
 *
 * v4.0 — Remplacement de tinynav par un vrai menu drawer latéral (mobile-menu.js).
 *        Les corrections de mise en page desktop/mobile héritées des versions
 *        précédentes sont conservées (logo, grille, tableaux…).
 * ========================================================================= */

/* ------------------------------------------------------------------
 * 1) Masquer tinynav partout
 *    Le <select> est toujours généré si le plugin est chargé, mais on
 *    ne l'utilise plus : le drawer JS prend le relais.
 * ------------------------------------------------------------------ */
select.tinynav,
select.tinynav-ready {
    display: none !important;
}

/* ------------------------------------------------------------------
 * 2) Bouton hamburger (inséré par mobile-menu.js)
 * ------------------------------------------------------------------ */
.mobile-menu-toggle {
    display: none; /* caché par défaut, affiché via media query mobile */
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10000;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #065EC1; /* bleu du site (couleur des liens du menu) */
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease;
}

.mobile-menu-toggle:focus,
.mobile-menu-toggle:hover {
    background: #0549a0;
    outline: none;
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid #ffbf47;
    outline-offset: 2px;
}

.mobile-menu-toggle .bar {
    display: block;
    width: 22px;
    height: 2px;
    margin: 5px auto;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

/* État "ouvert" : les barres forment une croix */
.mobile-menu-toggle.is-open .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-toggle.is-open .bar:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.is-open .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ------------------------------------------------------------------
 * 3) Overlay semi-transparent derrière le drawer
 * ------------------------------------------------------------------ */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
    z-index: 9998;
}

.mobile-menu-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0s linear 0s;
}

/* ------------------------------------------------------------------
 * 4) Drawer latéral (le menu lui-même)
 * ------------------------------------------------------------------ */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(85vw, 340px);
    height: 100vh;
    height: 100dvh;           /* évite les barres mobiles qui masquent le bas */
    background: #ffffff;
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
    overflow: hidden;   /* le scroll est géré par .mmd-body */
}

.mobile-menu-drawer.is-open {
    transform: translateX(0);
}

/* --- En-tête du drawer (titre + croix) --- */
.mobile-menu-drawer .mmd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #065EC1;
    color: #fff;
    flex-shrink: 0;
}

.mobile-menu-drawer .mmd-title {
    font-family: 'Raleway', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.mobile-menu-drawer .mmd-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    padding: 0 6px;
    cursor: pointer;
    border-radius: 6px;
    min-width: 40px;
    min-height: 40px;
}

.mobile-menu-drawer .mmd-close:focus,
.mobile-menu-drawer .mmd-close:hover {
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

/* --- Corps scrollable du drawer --- */
.mobile-menu-drawer .mmd-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

/* --- Sections (recherche / nav principale / nav utilisateur) --- */
.mobile-menu-drawer .mmd-section {
    padding: 8px 0;
    border-bottom: 1px solid #eef1f4;
}

.mobile-menu-drawer .mmd-section:last-child {
    border-bottom: none;
}

/* --- Recherche --- */
.mobile-menu-drawer .mmd-search {
    padding: 12px 14px;
    background: #f7f9fc;
}

.mobile-menu-drawer .mmd-search-form {
    display: flex;
    gap: 6px;
    align-items: stretch;
    width: 100%;
}

.mobile-menu-drawer .mmd-search-form .form-control,
.mobile-menu-drawer .mmd-search-form input[type="text"],
.mobile-menu-drawer .mmd-search-form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;       /* empêche le zoom iOS au focus */
    padding: 8px 10px;
    border: 1px solid #d1d7de;
    border-radius: 6px;
    background: #fff;
}

.mobile-menu-drawer .mmd-search-form .btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 6px;
}

/* --- Liste des entrées (nav principale + nav utilisateur) --- */
.mobile-menu-drawer .mmd-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu-drawer .mmd-item {
    display: block;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #f0f2f5;
}

.mobile-menu-drawer .mmd-item:last-child {
    border-bottom: none;
}

/* --- Ligne principale d'une entrée --- */
.mobile-menu-drawer .mmd-row {
    display: flex;
    align-items: stretch;
    min-height: 48px;   /* cible tactile confortable */
}

.mobile-menu-drawer .mmd-link {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: #065EC1;
    font-family: 'Raleway', sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.3;
}

.mobile-menu-drawer .mmd-link:hover,
.mobile-menu-drawer .mmd-link:focus {
    background: #f4f8fd;
    color: #0549a0;
    outline: none;
}

.mobile-menu-drawer .mmd-link--static {
    color: #2c3e50;
    cursor: default;
}

/* Icônes Open Iconic dans les liens : alignement propre */
.mobile-menu-drawer .mmd-link .oi,
.mobile-menu-drawer .mmd-sublink .oi {
    margin-right: 10px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* --- Bouton d'accordéon pour sous-menu --- */
.mobile-menu-drawer .mmd-sub-toggle {
    flex: 0 0 auto;
    width: 48px;
    min-height: 48px;
    background: transparent;
    border: none;
    border-left: 1px solid #f0f2f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mobile-menu-drawer .mmd-sub-toggle:hover,
.mobile-menu-drawer .mmd-sub-toggle:focus {
    background: #f4f8fd;
    outline: none;
}

.mobile-menu-drawer .mmd-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid #065EC1;
    border-bottom: 2px solid #065EC1;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    margin-top: -3px;
}

.mobile-menu-drawer .mmd-sub-toggle[aria-expanded="true"] .mmd-chevron {
    transform: rotate(-135deg);
    margin-top: 3px;
}

/* --- Sous-liste (niveau 2) --- */
.mobile-menu-drawer .mmd-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f7f9fc;
}

.mobile-menu-drawer .mmd-sublist[hidden] {
    display: none;
}

.mobile-menu-drawer .mmd-subitem {
    border-top: 1px solid #eef1f4;
}

.mobile-menu-drawer .mmd-sublink {
    display: flex;
    align-items: center;
    padding: 11px 18px 11px 36px;
    color: #3a4a5c;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.3;
    min-height: 44px;
}

.mobile-menu-drawer .mmd-sublink:hover,
.mobile-menu-drawer .mmd-sublink:focus {
    background: #e9f0fa;
    color: #065EC1;
    outline: none;
}

/* --- Bloc utilisateur : variante visuelle --- */
.mobile-menu-drawer .mmd-user {
    background: #fafbfc;
}

.mobile-menu-drawer .mmd-user .mmd-link {
    color: #2c3e50;
    font-weight: 500;
    font-size: 15px;
}

/* ------------------------------------------------------------------
 * 5) Media query : activation du menu mobile (<= 767px)
 * ------------------------------------------------------------------ */
@media (max-width: 767px) {

    .mobile-menu-toggle {
        display: block;
    }

    /* --- On masque complètement l'ancien menu desktop --- */
    ul.nicdark_menu,
    nav > ul.nicdark_menu {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* --- On masque aussi la barre du haut (search + navbar-nav) ---
       Elle est désormais intégrée au drawer ; la garder visible ferait
       doublon et casserait le header sur petits écrans. */
    .nicdark_displaynone_responsive {
        display: none !important;
    }

    /* La <nav> wrapper du menu principal ne doit plus imposer un float */
    .nicdark_logo + nav,
    nav {
        float: none !important;
        clear: both;
        width: 100%;
    }

    /* Quand le drawer est ouvert : bloquer le scroll du body dessous */
    body.mobile-menu-open {
        overflow: hidden;
        touch-action: none;
    }

    /* ------------------------------------------------------------------
     * Corrections de mise en page héritées des versions précédentes
     * ------------------------------------------------------------------ */

    /* --- Logo : neutraliser position:absolute forcé par nicdark_shortcodes --- */
    .nicdark_logo {
        float: none !important;
        position: static !important;
        display: block;
        width: auto !important;
        height: auto !important;
        text-align: center;
        margin: 10px auto !important;
        padding: 0 !important;
        clear: both;
    }

    .nicdark_logo img {
        position: static !important;
        width: auto !important;
        max-width: 180px;
        height: auto;
        margin: 0 auto !important;
        display: inline-block;
    }

    /* --- Grilles : empilement forcé --- */
    .grid,
    .grid_2, .grid_3, .grid_4, .grid_5, .grid_6,
    .grid_7, .grid_8, .grid_9, .grid_10, .grid_11, .grid_12 {
        width: 100% !important;
        float: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box;
    }

    .nicdark_container {
        width: 100% !important;
        padding: 0 10px !important;
        box-sizing: border-box;
    }

    /* --- Tableaux : scroll horizontal plutôt que débordement --- */
    .overflow_scroll,
    .nicdark_textevidence {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .nicdark_table {
        min-width: 600px;
    }

    /* --- Typographie lisible --- */
    body {
        font-size: 15px;
    }

    h1, .nicdark_focus h1 {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }

    h2 { font-size: 20px !important; }
    h3 { font-size: 18px !important; }
    h4 { font-size: 16px !important; }

    /* --- Formulaires : pleine largeur et anti-zoom iOS --- */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select:not(.tinynav) {
        font-size: 16px !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* --- Espaces nicdark souvent trop grands --- */
    .nicdark_space100 { height: 40px !important; }
    .nicdark_space50  { height: 25px !important; }
    .nicdark_space40  { height: 20px !important; }

    /* --- Images responsives par défaut --- */
    img {
        max-width: 100%;
        height: auto;
    }

    /* --- Footer pagination : empiler --- */
    footer.footer .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    footer.footer .nav-item {
        width: 100%;
        padding: 4px 0;
    }
}

/* ------------------------------------------------------------------
 * 6) Très petits écrans (<= 380px) : ajustements fins
 * ------------------------------------------------------------------ */
@media (max-width: 380px) {
    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
    }

    .mobile-menu-drawer {
        width: 90vw;
    }

    .nicdark_logo img {
        max-width: 150px !important;
    }

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