/* Mode d'affichage "horizontal" (par groupe de collaborateurs)
   Shell Fashion : la sidebar est remplacee par une barre de menu horizontale,
   le contenu occupe 100% de la largeur. */

body.pap-layout-horizontal #layout-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
}

body.pap-layout-horizontal .isogo-sidebar,
body.pap-layout-horizontal .pap-home-sidebar,
body.pap-layout-horizontal .pap-app-topbar {
    display: none !important;
}

body.pap-layout-horizontal .pap-hznav {
    grid-column: 1;
    grid-row: 1;
}

body.pap-layout-horizontal .main-content {
    grid-column: 1;
    grid-row: 2;
    margin-left: 0 !important;
    width: 100%;
    max-width: 100%;
}

body.pap-layout-horizontal .page-content > .container-fluid,
body.pap-layout-horizontal .page-content > .container {
    max-width: 100%;
    width: 100%;
}

/* Espace resserre entre la barre de menu et le titre de la page.
   En layout horizontal, le theme Velzon reserve la place d'une topnav fixe
   (.page-content : padding-top 45px+1.5rem et margin-top 70px) : inutile ici,
   notre barre de menu fait partie de la grille. */
body.pap-layout-horizontal .page-content {
    margin-top: 0 !important;
    padding-top: .35rem !important;
}

body.pap-layout-horizontal .page-title-box {
    margin: 0 0 .35rem !important;
    padding: .35rem 0 0 !important;
}

body.pap-layout-horizontal .page-content > .container-fluid > .row:first-child {
    margin-bottom: 0;
}

/* ---- Barre horizontale ---- */

.pap-hznav {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 0 12px;
    background: #ffffff;
    border-bottom: 1px solid #e6eaf0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.pap-hznav__brand {
    display: flex;
    align-items: center;
    padding-right: 10px;
    margin-right: 6px;
    border-right: 1px solid #eef1f6;
    flex: 0 0 auto;
}

.pap-hznav__brand img {
    height: 30px;
    width: auto;
    object-fit: contain;
}

.pap-hznav__burger {
    display: none;
    border: 0;
    background: transparent;
    font-size: 20px;
    color: #0f172a;
    padding: 0 10px;
}

.pap-hznav__list {
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: stretch;
}

.pap-hznav__item {
    position: relative;
    display: flex;
    align-items: stretch;
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
}

/* Bloc utilisateur cale a l'extreme droite de la barre */
.pap-hznav__right {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin-left: 0;
    padding-left: 12px;
    border-left: 1px solid #eef1f6;
}

.pap-hznav__right .isogo-user-wrap {
    position: relative;
}

.pap-hznav__right .isogo-chip--user {
    padding: 4px 8px;
}

.pap-hznav__right .isogo-chip--user .isogo-chip__name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pap-hznav__right .isogo-user-menu {
    right: 0;
    left: auto;
    z-index: 1000;
}

.pap-hznav__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    background: transparent;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: .01em;
    color: #0f172a;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.pap-hznav__link span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.pap-hznav__link i {
    font-size: 18px;
    color: #0f766e;
    line-height: 1;
    flex: 0 0 auto;
}

.pap-hznav__caret {
    font-size: 14px !important;
    color: #94a3b8 !important;
    margin-left: 2px;
    transition: transform .15s ease;
}

.pap-hznav__link:hover {
    color: #0f766e;
    background: #f1f7f6;
}

.pap-hznav__item.is-active > .pap-hznav__link {
    color: #0f766e;
    border-bottom-color: #0f766e;
}

.pap-hznav__item.is-open > .pap-hznav__link .pap-hznav__caret {
    transform: rotate(180deg);
}

.pap-hznav__submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    background: #ffffff;
    border: 1px solid #e6eaf0;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
    display: none;
    z-index: 950;
}

.pap-hznav__item.is-open > .pap-hznav__submenu {
    display: block;
}

.pap-hznav__sublink {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    white-space: nowrap;
}

.pap-hznav__sublink:hover {
    background: #f1f7f6;
    color: #0f766e;
}

/* Les derniers menus ouvrent leur sous-menu vers la gauche pour rester visibles */
.pap-hznav__item:nth-last-child(-n+3) > .pap-hznav__submenu {
    left: auto;
    right: 0;
}

@media (min-width: 993px) {
    /* Survol confortable en desktop, en plus du clic */
    .pap-hznav__item.has-children:hover > .pap-hznav__submenu {
        display: block;
    }
}

@media (max-width: 992px) {
    .pap-hznav {
        top: 0;
        flex-wrap: wrap;
        align-items: center;
    }

    .pap-hznav__right {
        order: 2;
        margin-left: auto;
    }

    .pap-hznav__right .isogo-chip--user .isogo-chip__name {
        display: none;
    }

    .pap-hznav__burger {
        display: inline-flex;
        align-items: center;
        order: 3;
        margin-left: 4px;
    }

    .pap-hznav__list {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 6px 0 10px;
        order: 4;
    }

    .pap-hznav__list.is-open {
        display: flex;
    }

    .pap-hznav__item {
        display: block;
    }

    .pap-hznav__link {
        width: 100%;
        justify-content: flex-start;
    }

    .pap-hznav__submenu {
        position: static;
        display: none;
        box-shadow: none;
        border: 0;
        border-left: 2px solid #e6eaf0;
        border-radius: 0;
        margin: 0 0 4px 22px;
        min-width: 0;
    }
}

/* Filet CSS : en dessous de lg, ne jamais laisser le shell horizontal
   (le PHP force déjà vertical via erp_layout_is_mobile_request). */
@media (max-width: 991.98px) {
    body.pap-layout-horizontal .pap-hznav {
        display: none !important;
    }
    body.pap-layout-horizontal #layout-wrapper {
        grid-template-columns: auto 1fr;
    }
    body.pap-layout-horizontal .app-menu,
    body.pap-layout-horizontal .navbar-menu,
    body.pap-layout-horizontal .vertical-menu {
        display: block !important;
    }
}
