/*
 * Navigation (refonte du 22/11/2026) : menu latéral (templates/menu.html.twig, public/js/ws-nav.js), barre du haut
 * (templates/header.html.twig, _topbar_alerts.html.twig) et barre d'actions rapides de la vue tablette
 * (templates/_tabbar.html.twig). Chargé en dernier par base.html.twig, sur toutes les pages.
 *
 * Trois modes du menu :
 *  - colonne (vue ordinateur, ≥ 1200 px, souris) : panneau blanc collé à gauche sous la barre du haut, 256 px
 *    (280 px en 2K, 320 px en 4K) ; réductible en barre d'icônes de 68 px (html[data-nav=mini]) avec panneau flottant ;
 *  - tiroir (vue tablette, < 1200 px, ou écran tactile de 1200 à 1400 px) : par-dessus la page, ouvert par ☰ ;
 *  - impression : masqué.
 */
:root {
    --fl-top: 64px;
    --fl-nav-w: 256px;
    --fl-nav-ink: #212529;
    --fl-nav-text: #3d4752;
    --fl-nav-muted: #5f6b78;
    --fl-nav-line: #dde3ea;
    --fl-nav-hover: #f1f4f8;
    --fl-nav-sel: #e6effa;
    --fl-nav-blue: #0062cc;
    --fl-nav-navy: #0b3a6e;
    --fl-tabbar-h: 0px;
}
@media (min-width: 2200px) { :root { --fl-nav-w: 280px; } }
@media (min-width: 3000px) { :root { --fl-nav-w: 320px; } }
html[data-nav=mini] { --fl-nav-w: 68px; }
/* Fond clair jusqu'en bas de la fenêtre sur les pages avec menu (avant : bande sombre sous une page courte) */
html:has(#sidebar) { background: #f3f5f8; }
/* Écrans de travail : un seul fond (même teinte que la zone de contenu, workspace.css), sans rectangle à bord net */
html:has(body.ws) { background: #e9edf2; }
body:has(#sidebar):not(.ws) { background: #f3f5f8; }

/* =========================================================================================================
   Barre du haut
   ========================================================================================================= */
/* Hauteur totale = --fl-top, bordure du bas comprise (avant : 64 + 1 px, d'où 1 px de défilement sur toute page courte, le
   menu collé mesurant 100vh - 64 px) */
.topbar { box-sizing: border-box; height: var(--fl-top); margin-bottom: 20px; }
/* Ombre portée sur un calque fixe, pas sur la barre collante : une ombre (ou tout dépassement) agrandit le calque de la barre
   collante, que Chrome place alors au sous-pixel près quand le défilement tombe entre deux pixels physiques (mise à l'échelle
   125 %, zoom 110 %…) : ligne de 1 px, noire ou blanche, au-dessus de la barre. La barre est toujours en haut de la fenêtre
   (premier élément du body, top: 0), le calque fixe reste donc dessous ; z-index -1 : sous le contenu de la barre ; étalement
   négatif : rien ne dépasse au-dessus (arrondi au zoom 110 %). */
.topbar::after { content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: -1; height: var(--fl-top); box-shadow: 0 6px 10px -4px rgba(0, 0, 0, .3);
    pointer-events: none; }
.topbar > .container { width: 100%; max-width: none; padding-left: 12px; padding-right: 16px; }
.topbar__inner { height: 100%; min-height: 0; gap: 4px; }
.topbar__left { gap: 10px; }
.topbar__burger { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; border: 1px solid transparent;
    border-radius: 10px; color: #e9ecef; font-size: 1.15rem; }
.topbar__burger:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .15); }
.topbar__burger:focus { outline: none; }
.topbar__burger:focus-visible { box-shadow: 0 0 0 2px #4da3ff; }
/* Page sans menu latéral (fiche imprimable, page autonome) : pas de bouton ☰ */
body:not(:has(#sidebar)) .topbar__burger { display: none; }
.topbar__brand img { max-height: 40px; max-width: 190px; }
.topbar__right { gap: 6px; }
.topbar__right > * + * { margin-left: 0; }
.topbar__menu > summary { height: 44px; }
.topbar__menu > summary:focus-visible { box-shadow: 0 0 0 2px #4da3ff; }
/* Compte : nom et profil de droits */
.topbar__who { flex-direction: column; justify-content: center; margin-left: 10px; line-height: 1.15; text-align: left; }
.topbar__who .topbar__username { margin: 0; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.topbar__profile { color: #c3ccd5; font-size: .75rem; font-weight: 500; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.topbar__dropdown .topbar__role { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-top: 8px; padding: 3px 10px; border-radius: 10px;
    background: var(--fl-nav-sel); color: var(--fl-nav-navy); font-size: .8rem; font-weight: 600; }
/* Pastilles d'alertes : visibles dès la tablette portrait (compactes), le reste dans la cloche */
@media (max-width: 991.98px) {
    .topbar__alerts { margin: 0 8px; }
    .topbar__who { display: none !important; }
    .topbar__vue [data-vue-label] { display: none !important; }
    .topbar__brand img { max-width: 150px; max-height: 34px; }
}
@media (max-width: 767.98px) {
    .topbar__alerts { display: none !important; }
}

/* =========================================================================================================
   Menu latéral : apparence commune (colonne et tiroir)
   ========================================================================================================= */
.sidenav { display: none; flex-direction: column; gap: 2px; margin: 0; padding: 12px 10px 8px; border: 0; border-radius: 0; background: #fff; color: var(--fl-nav-text);
    font-size: .875rem; scrollbar-width: thin; scrollbar-color: #c5ced8 transparent; }
.sidenav__list, .sidenav__sublist { margin: 0; padding: 0; list-style: none; }
.sidenav__list { display: flex; flex-direction: column; gap: 2px; }
.sidenav__list > li + li { margin-top: 0; }
.sidenav [hidden] { display: none !important; }

/* Recherche */
.sidenav__search { position: relative; margin: 0 0 8px; }
.sidenav__search > .fa { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--fl-nav-muted); font-size: .8rem; pointer-events: none; }
.sidenav__search-input { width: 100%; height: 36px; padding: 0 10px 0 32px; border: 1px solid var(--fl-nav-line); border-radius: 8px; background: #f6f8fa;
    color: var(--fl-nav-ink); font-size: .875rem; }
.sidenav__search-input::placeholder { color: var(--fl-nav-muted); opacity: 1; }
.sidenav__search-input:focus { outline: none; border-color: var(--fl-nav-blue); background: #fff; box-shadow: 0 0 0 3px rgba(0, 98, 204, .15); }
.sidenav__empty { margin: 8px 10px; color: var(--fl-nav-muted); font-size: .85rem; }

/* Regroupement (ou lien direct) */
.sidenav__link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 8px; color: var(--fl-nav-ink); font-size: .9rem;
    font-weight: 600; line-height: 1.2; cursor: pointer; list-style: none; user-select: none; text-decoration: none; }
.sidenav__link::-webkit-details-marker { display: none; }
.sidenav__link::marker { content: ""; }
a.sidenav__link:hover, summary.sidenav__link:hover { background: var(--fl-nav-hover); color: var(--fl-nav-ink); text-decoration: none; }
.sidenav__link:focus, .sidenav__sublink:focus, .sidenav__plus:focus, .sidenav__star:focus, .sidenav__collapse:focus { outline: none; }
.sidenav__link:focus-visible, .sidenav__sublink:focus-visible, .sidenav__plus:focus-visible, .sidenav__star:focus-visible, .sidenav__collapse:focus-visible {
    box-shadow: inset 0 0 0 2px var(--fl-nav-blue); }
.sidenav__icon { flex: none; width: 20px; margin: 0; color: var(--fl-nav-muted); font-size: .95rem; text-align: center; }
.sidenav__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidenav__chevron { flex: none; margin: 0; color: var(--fl-nav-muted); font-size: .65rem; transition: transform .15s ease; }
.sidenav__section[open] > summary .sidenav__chevron { transform: rotate(90deg); }
/* Regroupement de la page courante, et lien direct actif */
.sidenav__link.has-active { color: var(--fl-nav-navy); }
.sidenav__link.has-active .sidenav__icon, a.sidenav__link.is-active .sidenav__icon { color: var(--fl-nav-blue); }
a.sidenav__link.is-active { background: var(--fl-nav-sel); color: var(--fl-nav-navy); }
.sidenav__group--fav .sidenav__icon { color: #c58a00; }

/* Sous-pages */
.sidenav__sublist { margin: 0 0 6px; padding: 0; border: 0; }
.sidenav__flyhead { display: none; }
.sidenav__head { padding: 10px 10px 3px 40px; color: var(--fl-nav-muted); font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.sidenav__row { position: relative; display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.sidenav__row:hover { background: var(--fl-nav-hover); }
.sidenav__sublink { display: block; flex: 1; min-width: 0; margin: 0; padding: 7px 8px 7px 40px; border-radius: 8px; color: var(--fl-nav-text); font-size: .875rem;
    line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.sidenav__sublink:hover { color: var(--fl-nav-ink); background: transparent; text-decoration: none; }
.sidenav__row.is-active { background: var(--fl-nav-sel); }
.sidenav__row.is-active::before { content: ""; position: absolute; top: 7px; bottom: 7px; left: 22px; width: 3px; border-radius: 2px; background: var(--fl-nav-blue); }
.sidenav__row.is-active .sidenav__sublink { color: var(--fl-nav-navy); font-weight: 600; }
/* Libellé long (« Productions échantillons » en gras quand la page est ouverte) : à la ligne plutôt que coupé « … » */
.sidenav__sublink { white-space: normal; }
/* « + » : page de création sur la ligne de sa liste ; étoile : favori (au survol, ou si épinglé) */
.sidenav__plus, .sidenav__star { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-right: 2px; padding: 0;
    border: 0; border-radius: 7px; background: transparent; color: var(--fl-nav-muted); font-size: .75rem; text-decoration: none; cursor: pointer; }
.sidenav__plus:hover, .sidenav__star:hover { background: #e2e8ef; color: var(--fl-nav-ink); text-decoration: none; }
.sidenav__plus.is-active { background: var(--fl-nav-blue); color: #fff; }
/* Étoile par-dessus la fin du libellé (ne réduit pas la place du texte), visible au survol ou si épinglée */
.sidenav__star { position: absolute; top: 50%; right: 4px; margin: -14px 0 0; opacity: 0; background: var(--fl-nav-hover); }
.sidenav__row:has(.sidenav__plus) .sidenav__star { right: 34px; }
.sidenav__row.is-active .sidenav__star { background: var(--fl-nav-sel); }
.sidenav__row .sidenav__star.is-on { position: static; margin: 0 2px 0 0; background: transparent; }
.sidenav__row:hover .sidenav__star, .sidenav__star:focus-visible, .sidenav__star.is-on { opacity: 1; }
.sidenav__star.is-on { color: #c58a00; }
.sidenav__row--fav .sidenav__sublink { padding-left: 40px; }

/* Bas du menu : réduire en barre d'icônes (vue ordinateur seulement) */
.sidenav__collapse { display: none; align-items: center; gap: 10px; width: 100%; min-height: 38px; margin-top: auto; padding: 0 10px; border: 0; border-top: 1px solid var(--fl-nav-line);
    border-radius: 0; background: transparent; color: var(--fl-nav-muted); font-size: .8rem; font-weight: 600; text-align: left; cursor: pointer; }
.sidenav__collapse .fa { width: 20px; text-align: center; font-size: .95rem; }
.sidenav__collapse:hover { color: var(--fl-nav-ink); background: var(--fl-nav-hover); }

/* =========================================================================================================
   Colonne (vue ordinateur, ≥ 1200 px, souris) : panneau collé à gauche, contenu à côté
   ========================================================================================================= */
@media (min-width: 1200px) and (pointer: fine), (min-width: 1200px) and (pointer: none), (min-width: 1401px) {
    html[data-vue=ordinateur] body:has(#sidebar) .topbar { margin-bottom: 0; }
    html[data-vue=ordinateur] .container:has(> .row > .layout-sidebar) { width: 100%; max-width: none; margin-left: 0; padding-left: 0; }
    html[data-vue=ordinateur] .container:has(> .row > .layout-sidebar) > .row { flex-wrap: nowrap; margin-left: 0; }
    html[data-vue=ordinateur] body .container > .row > .layout-sidebar { flex: 0 0 var(--fl-nav-w); max-width: var(--fl-nav-w); padding: 0; z-index: 20; transition: flex-basis .15s ease, max-width .15s ease; }
    html[data-vue=ordinateur] body .container > .row > .layout-content { flex: 1 1 0; max-width: none; min-width: 0; margin-top: 20px; margin-left: 20px; margin-bottom: 20px; }
    html[data-vue=ordinateur] .sidenav { display: flex; position: sticky; top: var(--fl-top); height: calc(100vh - var(--fl-top)); max-height: none; overflow-y: auto;
        border-right: 1px solid var(--fl-nav-line); }
    html[data-vue=ordinateur] .sidenav__collapse { display: flex; }

    /* ---- Barre d'icônes ---- */
    html[data-vue=ordinateur][data-nav=mini] .sidenav { overflow: visible; padding: 12px 8px 8px; align-items: stretch; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__search,
    html[data-vue=ordinateur][data-nav=mini] .sidenav__link > .sidenav__label,
    html[data-vue=ordinateur][data-nav=mini] .sidenav__chevron,
    html[data-vue=ordinateur][data-nav=mini] .sidenav__collapse .sidenav__label,
    html[data-vue=ordinateur][data-nav=mini] .sidenav__empty { display: none; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__group { position: relative; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__link { justify-content: center; min-height: 44px; padding: 0; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__icon { width: auto; font-size: 1.05rem; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__link.has-active { background: var(--fl-nav-sel); }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__section[open] > summary { background: var(--fl-nav-hover); }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__section > .sidenav__sublist { position: absolute; top: -6px; left: calc(100% + 10px); z-index: 1036; width: 270px;
        max-height: calc(100vh - var(--fl-top) - 24px); overflow-y: auto; margin: 0; padding: 6px; border: 1px solid var(--fl-nav-line); border-radius: 12px; background: #fff;
        box-shadow: 0 12px 32px rgba(16, 24, 40, .18); }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__section > .sidenav__sublist::before { content: ""; position: absolute; top: 0; bottom: 0; left: -14px; width: 14px; } /* pont de survol */
    html[data-vue=ordinateur][data-nav=mini] .sidenav__flyhead { display: block; padding: 8px 10px 6px; color: var(--fl-nav-ink); font-size: .85rem; font-weight: 700; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__head { padding-left: 12px; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__sublink { padding-left: 12px; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__row.is-active::before { left: 3px; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__collapse { justify-content: center; padding: 0; }
    html[data-vue=ordinateur][data-nav=mini] .sidenav__collapse .fa { transform: rotate(180deg); }
}

/* =========================================================================================================
   Tiroir (vue tablette, petit écran, écran tactile 1200–1400 px) : ouvert par ☰
   ========================================================================================================= */
.sidenav.show { display: flex !important; position: fixed; top: var(--fl-top); left: 0; bottom: 0; z-index: 1045; width: 340px; max-width: 88vw; max-height: none; margin: 0;
    padding: 14px 12px 16px; border-radius: 0 14px 14px 0; overflow-y: auto; box-shadow: 6px 0 28px rgba(16, 24, 40, .28); }
.drawer-backdrop { position: fixed; inset: var(--fl-top) 0 0 0; z-index: 1040; background: rgba(16, 24, 40, .45); }
body.drawer-open { overflow: hidden; }
/* Vue tablette forcée sur un grand écran : pas de colonne vide à gauche */
html[data-vue=tablette] body .container > .row > .layout-sidebar { flex: 0 0 0; max-width: 0; padding: 0; }
html[data-vue=tablette] body .container > .row > .layout-content { flex: 0 0 100%; max-width: 100%; }
/* Cibles tactiles ≥ 48 px */
html[data-vue=tablette] .sidenav, .sidenav.show { font-size: 1rem; }
html[data-vue=tablette] .sidenav__link { min-height: 50px; font-size: 1rem; }
html[data-vue=tablette] .sidenav__sublink { padding-top: 13px; padding-bottom: 13px; font-size: 1rem; }
html[data-vue=tablette] .sidenav__plus { width: 48px; height: 48px; font-size: .9rem; }
html[data-vue=tablette] .sidenav__star { display: none; }
html[data-vue=tablette] .sidenav__search-input { height: 48px; font-size: 1rem; }
html[data-vue=tablette] .sidenav__head { padding-top: 14px; font-size: .75rem; }
html[data-vue=tablette] .topbar__burger { width: 48px; height: 48px; }
/* Barre du haut (relevé par tests/e2e/layout-check.js) : logo, pastilles d'alerte (32 px sous 1200 px) et menu « Vue »
   (icône seule en portrait, 41 px) à 44 px au moins */
html[data-vue=tablette] .topbar__brand { display: inline-flex; align-items: center; min-height: 44px; }
html[data-vue=tablette] .topbar__alerts { height: auto; }
html[data-vue=tablette] a.topbar__alert { height: 44px; min-width: 52px; border-radius: 22px; }
html[data-vue=tablette] .topbar__menu > summary { min-width: 44px; justify-content: center; }
.sidenav.show .sidenav__collapse { display: none; }

/* =========================================================================================================
   Barre d'actions rapides (vue tablette, maquette « Écrans Scan ») : fixe en bas, au-dessus des barres collantes
   ========================================================================================================= */
.fl-tabbar { display: none; }
html[data-vue=tablette]:has(.fl-tabbar) { --fl-tabbar-h: 78px; }
html[data-vue=tablette] .fl-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; display: grid; grid-template-columns: repeat(var(--fl-tabs, 5), minmax(0, 180px));
    justify-content: center; height: calc(var(--fl-tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid #dee2e6; background: #fff; box-shadow: 0 -4px 18px rgba(16, 24, 40, .07); }
html[data-vue=tablette] body:has(.fl-tabbar) { padding-bottom: calc(var(--fl-tabbar-h) + 8px); }
.fl-tabbar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 6px 4px;
    color: var(--fl-nav-muted); font-size: 13px; font-weight: 600; line-height: 1.1; text-align: center; text-decoration: none; }
.fl-tabbar__item:hover { color: var(--fl-nav-ink); text-decoration: none; }
.fl-tabbar__item:focus { outline: none; }
.fl-tabbar__item:focus-visible { box-shadow: inset 0 0 0 2px var(--fl-nav-blue); border-radius: 10px; }
.fl-tabbar__icon { font-size: 24px; line-height: 1; }
.fl-tabbar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-tabbar__item.is-active { color: var(--fl-nav-blue); }
.fl-tabbar__item.is-active::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--fl-nav-blue); }
/* Barres collantes du bas des pages et panneaux du bas : au-dessus de la barre d'actions rapides */
html[data-vue=tablette] .pcard-actions, html[data-vue=tablette] .prf-bar, html[data-vue=tablette] .pur-footer, html[data-vue=tablette] .rcp-actionbar,
html[data-vue=tablette] .wsa-savebar, html[data-vue=tablette] .wsp-bar, html[data-vue=tablette] .rcl .rx-savebar, html[data-vue=tablette] .rx-page .rx-savebar,
html[data-vue=tablette] .labels-bar, html[data-vue=tablette] .sorders-bar, html[data-vue=tablette] .cond--wide .cond-actions,
html[data-vue=tablette] .ach .pur-footer.ach-savebar { bottom: var(--fl-tabbar-h); }
html[data-vue=tablette] .rk-drawer { bottom: var(--fl-tabbar-h); }
html[data-vue=tablette] .prods-toast { bottom: calc(24px + var(--fl-tabbar-h)); }
@media (orientation: portrait), (max-width: 1000px) {
    html[data-vue=tablette] .ws-split__aside { bottom: var(--fl-tabbar-h); max-height: calc(62vh - var(--fl-tabbar-h) / 2); }
}

@media print {
    .sidenav, .fl-tabbar, .drawer-backdrop, .topbar::after { display: none !important; }
    html[data-vue=tablette] body:has(.fl-tabbar) { padding-bottom: 0; }
}

/* Menu sans défilement (23/11/2026) : sur ordinateur, hauteurs et espacements suivent la hauteur de la fenêtre, entre un
   minimum lisible et cliquable (≈ 30 px par ligne, écran de 768 px) et la taille d'origine (écran ≥ 1100 px) ; un seul
   regroupement ouvert à la fois (ws-nav.js). La tablette garde ses cibles de 48–50 px. */
@media (min-width: 1200px) {
    html[data-vue=ordinateur] .sidenav__link { min-height: clamp(30px, 3.7vh, 40px); }
    html[data-vue=ordinateur] .sidenav__sublink { padding-top: clamp(3px, .6vh, 7px); padding-bottom: clamp(3px, .6vh, 7px); font-size: clamp(.8rem, 1.3vh, .875rem); }
    html[data-vue=ordinateur] .sidenav__head { padding-top: clamp(4px, .9vh, 10px); padding-bottom: 2px; font-size: clamp(.65rem, 1vh, .7rem); }
    html[data-vue=ordinateur] .sidenav__sublist { margin-bottom: clamp(2px, .5vh, 6px); }
    html[data-vue=ordinateur] .sidenav__search { margin-bottom: clamp(4px, .7vh, 8px); }
    html[data-vue=ordinateur] .sidenav__search-input { height: clamp(30px, 3.4vh, 36px); }
    html[data-vue=ordinateur] .sidenav__collapse { min-height: clamp(30px, 3.5vh, 38px); }
    html[data-vue=ordinateur] .sidenav__plus, html[data-vue=ordinateur] .sidenav__star { width: clamp(24px, 2.6vh, 28px); height: clamp(24px, 2.6vh, 28px); }
}
/* Liens « ← retour » des écrans d'atelier et de commande en tablette : touch.css les met à 44 px, mais ui.css (chargé
   après, même spécificité) les ramenait à 36 px (mélange, conditionnement, liste de prélèvement…) */
html[data-vue=tablette] .page a.cond-back, html[data-vue=tablette] .page a.sorders-back { min-height: 44px; }
