/*
 * DBM Core 1.6.3
 * Correctif global du panneau latéral CRM.
 *
 * Objectif :
 * - fond bleu sur toute la hauteur visible ;
 * - menu stable quelle que soit la longueur de la page ;
 * - défilement interne si le menu dépasse la hauteur de l'écran ;
 * - aucun changement du contenu du Dashboard.
 */

html,
body,
.dbm-body,
#dbm-main-content {
    min-height: 100%;
}

body.dbm-body {
    min-height: 100vh;
    min-height: 100dvh;
}

/*
 * Bureau et tablette large :
 * la barre est fixée au viewport. Elle ne dépend donc plus de la
 * hauteur du contenu principal.
 */
@media (min-width: 761px) {
    #dbm-main-content > .crm-shell {
        display: block;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #dbm-main-content > .crm-shell > .crm-sidebar {
        position: fixed;
        z-index: 100;
        top: 0;
        bottom: 0;
        left: 0;
        width: 260px;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        background: var(--navy, #0b2554);
    }

    #dbm-main-content > .crm-shell > .crm-main {
        width: auto;
        min-width: 0;
        min-height: 100vh;
        min-height: 100dvh;
        margin-left: 260px;
    }

    /*
     * Le compte utilisateur reste en bas lorsque le menu tient dans
     * l'écran, tout en restant accessible par défilement sur les
     * écrans moins hauts.
     */
    #dbm-main-content > .crm-shell > .crm-sidebar .crm-user {
        margin-top: auto;
        flex: 0 0 auto;
    }
}

/*
 * Mobile :
 * conservation du comportement piloté par dbm-ui.js.
 */
@media (max-width: 760px) {
    #dbm-main-content > .crm-shell {
        display: block;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #dbm-main-content > .crm-shell > .crm-sidebar {
        width: min(88vw, 300px);
        height: 100vh;
        height: 100dvh;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
        background: var(--navy, #0b2554);
    }

    #dbm-main-content > .crm-shell > .crm-main {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        margin-left: 0;
    }
}

/*
 * Compatibilité avec la GED qui emploie ses propres classes.
 */
@media (min-width: 761px) {
    #dbm-main-content > .ged-app {
        display: block;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #dbm-main-content > .ged-app > .ged-sidebar {
        position: fixed;
        z-index: 100;
        top: 0;
        bottom: 0;
        left: 0;
        width: 260px;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #dbm-main-content > .ged-app > .ged-main {
        min-height: 100vh;
        min-height: 100dvh;
        margin-left: 260px;
    }
}

@media (max-width: 760px) {
    #dbm-main-content > .ged-app > .ged-sidebar {
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
    }
}
