/* Menu bas mobile en une seule rangée : les entrées au-delà de 4 passent
   dans le panneau « Plus » (voir js/menu-mobile.js). Inactif en desktop. */

@media (max-width: 767px) {
    .sp-menu-wrapper ul.sidebar-menu {
        flex-wrap: nowrap;
    }
    .sp-menu-wrapper ul.sidebar-menu > li > a {
        white-space: nowrap;
    }

    .sp-menu-plus-panel {
        display: none;
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        margin: 0;
        padding: 12px 10px calc(12px + env(safe-area-inset-bottom, 0px));
        list-style: none;
        background: #fff;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.12);
        grid-template-columns: repeat(3, 1fr);
        grid-gap: 4px;
    }
    .sp-menu-plus-panel.ouvert {
        display: grid;
    }
    .sp-menu-plus-panel > li {
        padding: 0;
    }
    .sp-menu-plus-panel > li > a {
        display: flex;
        flex-direction: column;
        align-items: center;
        grid-row-gap: 6px;
        padding: 12px 5px;
        font-size: 12px;
        color: inherit;
    }
}

/* Fil d'ariane mobile : masqué historiquement sous 768px, ce qui laissait
   les pages profondes sans retour. On le réaffiche sous forme de lien
   retour vers le niveau parent (avant-dernier maillon du fil). */
@media (max-width: 767px) {
    ul.breadcrumb {
        display: block !important;
        background: #fff;
        padding: 4px 15px;
        /* bande blanche de bord à bord, quel que soit le padding du conteneur */
        margin: 0 calc(50% - 50vw) 10px;
    }
    ul.breadcrumb > li {
        display: none;
    }
    ul.breadcrumb > li:nth-last-child(2) {
        display: inline-block;
    }
    ul.breadcrumb > li:nth-last-child(2)::before {
        content: none;
    }
    /* Gabarit strictement identique au .btn du front (relevé sur Didacticiel :
       12px/400, padding 13px 18px, rayon 15px, fond #f4f4f4) */
    ul.breadcrumb > li:nth-last-child(2) a {
        display: inline-flex;
        align-items: center;
        font-size: 12px;
        font-weight: 400;
        line-height: normal;
        color: #333;
        background: #f4f4f4;
        border-radius: 15px;
        padding: 0 18px;
        height: 43px; /* hauteur exacte des .btn du front (Didacticiel) */
        box-sizing: border-box;
    }
    /* Chevron (pas de flèche) : tracé CSS net à toutes les densités d'écran */
    ul.breadcrumb > li:nth-last-child(2) a::before {
        content: "";
        display: inline-block;
        width: 8px;
        height: 8px;
        border-left: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        margin-right: 9px;
    }
}

/* Compte sur mobile : société affichée sous le nom dans l'en-tête, et panneau
   de compte (tap sur le nom) avec le sélecteur de société quand le compte en
   a plusieurs, puis la déconnexion. Le desktop a son propre menu d'en-tête. */

@media (max-width: 767px) {
    .sp-header .user-avatar {
        flex-wrap: wrap;
        align-content: center;
        justify-content: flex-end;
        max-width: 46%;
        min-height: 44px;
    }
    .sp-header .user-avatar > span {
        flex: 0 1 auto;
        white-space: nowrap;
    }
    .sp-header .user-avatar > span.user-avatar-societe {
        flex: 0 0 100%;
        margin: 2px 0 0;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: right;
        font-size: 11px;
        font-weight: 400;
        line-height: 1.2;
        color: #5F6E6F;
    }
    /* Chevron : la société se change d'ici. Placé hors du texte, il reste
       visible quand un nom long est coupé par des points de suspension. */
    .sp-header .user-avatar > span.user-avatar-societe--choix {
        position: relative;
        padding-right: 14px;
    }
    .sp-header .user-avatar > span.user-avatar-societe--choix::after {
        content: '';
        position: absolute;
        right: 2px;
        top: 50%;
        width: 5px;
        height: 5px;
        margin-top: -4px;
        border-right: 1.5px solid currentColor;
        border-bottom: 1.5px solid currentColor;
        transform: rotate(45deg);
    }

    .modal-logout {
        position: fixed;
        width: calc(100% - 32px);
        max-width: 360px;
    }
    .modal-logout .logout-wrapper {
        padding: 20px;
        background: #fff;
        border-radius: 15px;
        box-shadow: 0 0 19px -3px rgba(0, 0, 0, 0.11);
    }
    .modal-logout .compte-mobile {
        margin-bottom: 20px;
        color: #044346;
    }
    .modal-logout .compte-mobile-nom {
        font-size: 18px;
        font-weight: 700;
        line-height: 1.3;
    }
    .modal-logout .compte-mobile-societe-seule {
        margin-top: 4px;
        font-size: 14px;
        color: #5F6E6F;
    }
    .modal-logout .compte-mobile-societe {
        margin: 16px 0 0;
    }
    .modal-logout .compte-mobile-societe label {
        display: block;
        margin: 0 0 6px;
        font-size: 14px;
        font-weight: 700;
    }
    .modal-logout .compte-mobile-societe select.form-control {
        width: 100%;
        height: 48px;
        padding: 0 40px 0 14px;
        font-size: 16px; /* sous 16px, iOS zoome la page au focus */
        color: #044346;
        text-overflow: ellipsis;
        /* Apparence native retirée : iOS impose sinon son propre rayon */
        -webkit-appearance: none;
        appearance: none;
        background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23044346' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
        border: 1px solid #EAEAEA;
        border-radius: 15px;
        box-shadow: none;
    }
    .modal-logout .compte-mobile-aide {
        margin: 8px 0 0;
        font-size: 12px;
        line-height: 1.4;
        color: #5F6E6F;
    }
    .modal-logout .btn.logout {
        width: 100%;
        min-height: 44px;
    }
}
