/* LaFabrikTools — coque de l'application : menu « comptoir » à gauche, page à droite.
   S'appuie sur tokens.css et composants.css. */

/* Toute page interne (classe lf-coque posée sur <html> par session.js) : le menu est fixé à
   gauche, le corps est décalé de sa largeur. Le noir du menu est peint par le fond du <body>
   dès le premier affichage, avant même que le menu soit construit. */
html.lf-coque body {
    margin: 0; min-height: 100vh; padding-left: 232px;
    background: linear-gradient(90deg, var(--comptoir) 232px, var(--fond) 232px);
}
html.lf-coque #lf-menu { position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; height: 100vh; overflow-y: auto; }
.lf-app { display: block; }
.lf-menu__nom { white-space: nowrap; }
.lf-menu__pied { margin-top: auto; }
.lf-menu__icone { width: 18px; height: 18px; flex: none; }

.lf-page { flex: 1; min-width: 0; max-width: 1252px; padding: var(--espace-8) var(--espace-9) 64px; }
.lf-page > * + * { margin-top: var(--espace-5); }
.lf-page__tete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--espace-4); }
.lf-page__titre { margin: 0; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
.lf-page__contexte { margin: 2px 0 0; font-size: 14px; line-height: 20px; color: var(--encre-douce); max-width: 70ch; }
.lf-page__actions { display: flex; flex-wrap: wrap; gap: var(--espace-2); }

.lf-chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--espace-4); }
.lf-colonnes { display: flex; flex-wrap: wrap; gap: var(--espace-5); align-items: flex-start; }
.lf-colonnes > .lf-principal { flex: 999 1 560px; min-width: 0; }
.lf-colonnes > .lf-cote { flex: 1 1 300px; min-width: 0; }
.lf-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lf-vide { padding: 28px var(--espace-5); text-align: center; color: var(--encre-douce); }
.lf-vide strong { display: block; color: var(--encre); font-weight: 500; }

/* Barre de session (session.js) rangée en bas du menu */
.lf-menu .session-bar {
    position: static; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
    padding: 10px; border: 0; border-radius: 10px; background: #ffffff0d; box-shadow: none;
    color: var(--sur-comptoir); font-size: 13px;
}
.lf-menu .session-bar__user { color: #fff; font-size: 14px; }
.lf-menu .session-bar__role { background: #ffffff14; color: var(--sur-comptoir); }
.lf-menu .session-bar__shop { border-color: #ffffff2e; color: var(--sur-comptoir); }
.lf-menu .session-bar__shop:hover { background: var(--comptoir-survol); }
.lf-menu .session-bar__alert { background: var(--rouge-clair); border-color: transparent; color: var(--rouge-encre); }
.lf-menu .session-bar__logout { width: 100%; margin-top: 4px; padding: 8px 12px; border-radius: var(--arrondi-bouton); background: #ffffff14; color: var(--sur-comptoir); }
.lf-menu .session-bar__logout:hover { background: #ffffff24; color: #fff; }

/* Rubriques du menu (Magasin, Expéditions, Administration), repliables : le titre est un bouton ;
   le corps se replie en douceur (hauteur par la grille 1fr → 0fr, liens qui glissent et
   s'estompent), le chevron tourne. Repliée, la rubrique additionne ses compteurs sur son titre. */
.lf-menu__rubrique { display: flex; flex-direction: column; margin-top: 14px; }
.lf-menu__rubrique[hidden] { display: none; }
.lf-menu__rubrique-titre {
    display: flex; align-items: center; gap: 6px; width: 100%;
    margin: 0 0 4px; padding: 4px 12px; border: 0; border-radius: var(--arrondi-petit);
    background: none; cursor: pointer; text-align: left;
    font: inherit; font-size: 11px; line-height: 16px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase; color: var(--sur-comptoir-doux);
    transition: color .15s ease, background-color .15s ease;
}
.lf-menu__rubrique-titre:hover { color: var(--sur-comptoir); background: #ffffff0a; }
.lf-menu__rubrique-titre:focus-visible { outline: 2px solid var(--sur-comptoir); outline-offset: 1px; }
.lf-menu__chevron {
    width: 14px; height: 14px; margin-left: auto; flex: none; opacity: .7;
    transition: transform .28s cubic-bezier(.34, 1.56, .64, 1);   /* léger rebond */
}
.lf-menu__rubrique--repliee .lf-menu__chevron { transform: rotate(-90deg); }
.lf-menu__rubrique-total { margin-left: 2px; letter-spacing: 0; text-transform: none; }
.lf-menu__rubrique-total[hidden] { display: none; }
/* page ouverte dans une rubrique repliée : un trait rouge devant le titre */
.lf-menu__rubrique--repliee.lf-menu__rubrique--ici .lf-menu__rubrique-titre { color: var(--sur-comptoir); box-shadow: inset 2px 0 0 var(--rouge-haut); }
.lf-menu__rubrique-corps {
    display: grid; grid-template-rows: 1fr;
    transition: grid-template-rows .26s cubic-bezier(.2, .8, .2, 1);
}
.lf-menu__rubrique-interieur {
    display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden;
    transition: opacity .2s ease, transform .26s cubic-bezier(.2, .8, .2, 1);
}
.lf-menu__rubrique--repliee .lf-menu__rubrique-corps { grid-template-rows: 0fr; }
.lf-menu__rubrique--repliee .lf-menu__rubrique-interieur { opacity: 0; transform: translateY(-6px); visibility: hidden; transition: opacity .16s ease, transform .2s ease, visibility 0s .26s; }
/* état gardé, appliqué au chargement : sans animation */
.lf-menu--sans-animation .lf-menu__rubrique-corps, .lf-menu--sans-animation .lf-menu__rubrique-interieur,
.lf-menu--sans-animation .lf-menu__chevron { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    .lf-menu__rubrique-corps, .lf-menu__rubrique-interieur, .lf-menu__chevron { transition: none !important; }
}

/* Barres de défilement aux couleurs du design system, sur toutes les pages : fines, en pastille,
   sans flèches ; sable sur les pages, translucides sur le menu sombre (le comptoir).
   Chrome, Edge, Safari : ::-webkit-scrollbar (Chrome ignore ces règles dès que
   scrollbar-color est posé : celui-ci est donc réservé à Firefox). */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb {
    border: 3px solid transparent; border-radius: var(--arrondi-pastille);
    background: var(--ligne-forte); background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--contour-champ); }
::-webkit-scrollbar-thumb:active { background-color: var(--encre-douce); }
#lf-menu::-webkit-scrollbar, #lf-menu ::-webkit-scrollbar { width: 8px; height: 8px; }
#lf-menu::-webkit-scrollbar-thumb, #lf-menu ::-webkit-scrollbar-thumb { border-width: 2px; background-color: #ffffff26; }
#lf-menu::-webkit-scrollbar-thumb:hover, #lf-menu ::-webkit-scrollbar-thumb:hover { background-color: #ffffff47; }
@supports not selector(::-webkit-scrollbar) {
    html, html * { scrollbar-width: thin; scrollbar-color: var(--ligne-forte) transparent; }
    #lf-menu, #lf-menu * { scrollbar-color: #ffffff33 transparent; }
}

/* Tablette en portrait, téléphone : le menu devient une barre en haut, qui défile. */
@media (max-width: 900px) {
    html.lf-coque body { padding-left: 0; background: var(--fond); }
    html.lf-coque #lf-menu {
        position: sticky; top: 0; bottom: auto; z-index: 50; height: auto; width: auto;
        flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; overflow-x: auto;
    }
    .lf-menu__lieu { display: none; }
    .lf-menu__liens { flex-direction: row; }
    .lf-menu__rubrique { flex-direction: row; align-items: center; margin-top: 0; padding-left: 8px; border-left: 1px solid #ffffff24; }
    .lf-menu__rubrique-titre { display: none; }
    /* barre du haut : pas de rubrique repliée, tous les outils restent visibles */
    .lf-menu__rubrique .lf-menu__rubrique-corps, .lf-menu__rubrique--repliee .lf-menu__rubrique-corps { display: block; }
    .lf-menu__rubrique-interieur, .lf-menu__rubrique--repliee .lf-menu__rubrique-interieur { flex-direction: row; opacity: 1; transform: none; visibility: visible; overflow: visible; }
    .lf-menu__lien { white-space: nowrap; }
    .lf-menu__pied { margin-top: 0; margin-left: auto; }
    .lf-menu .session-bar { flex-wrap: nowrap; white-space: nowrap; padding: 6px 8px; }
    .lf-menu .session-bar__logout { width: auto; margin-top: 0; }
    .lf-page { padding: 20px 16px 48px; }
    .lf-chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--espace-3); }
}

@media print {
    html.lf-coque body { padding-left: 0; background: none; }
    html.lf-coque #lf-menu { display: none; }
    .lf-page { padding: 0; max-width: none; }
}

/* Cloche des rappels (RG-D4, rappels.js) : à côté du logo, rappels persistants */
.lf-menu__tete { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.lf-menu__tete .lf-menu__marque { flex: 1; min-width: 0; }
.lf-cloche {
    position: relative; flex: none; width: 36px; height: 36px; display: grid; place-items: center;
    border: 0; border-radius: var(--arrondi-bouton); background: transparent; color: var(--sur-comptoir-doux); cursor: pointer;
}
.lf-cloche:hover { background: var(--comptoir-survol); color: #fff; }
.lf-cloche:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.lf-cloche__symbole { width: 20px; height: 20px; }
.lf-cloche--active { color: #fff; }
.lf-cloche--active .lf-cloche__symbole { animation: lf-cloche-tinte 1.2s var(--courbe-sortie) 1; transform-origin: 50% 10%; }
.lf-cloche__compte {
    position: absolute; top: 1px; right: 0; min-width: 18px; padding: 0 5px; border-radius: var(--arrondi-pastille);
    background: var(--rouge); color: #fff; font-size: 11px; line-height: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
    box-shadow: 0 0 0 2px var(--comptoir);
}
.lf-cloche__compte[hidden] { display: none; }
@keyframes lf-cloche-tinte { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-4deg); } }

.lf-cloche__panneau {
    position: fixed; z-index: 200; width: 340px; max-width: calc(100vw - 16px); max-height: min(70vh, 520px); overflow-y: auto;
    padding: var(--espace-4); background: var(--surface); color: var(--encre);
    border: 1px solid var(--ligne); border-radius: var(--arrondi-carte); box-shadow: var(--ombre-fenetre);
    font-family: var(--font-interface);
}
.lf-cloche__panneau[hidden] { display: none; }
.lf-cloche__entete { margin: 0 0 var(--espace-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--encre-douce); }
.lf-cloche__liste { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--espace-3); }
.lf-cloche__rappel { display: flex; gap: var(--espace-3); padding: var(--espace-3); border-radius: var(--arrondi-bouton); background: var(--alerte-clair); border: 1px solid var(--alerte-bord); }
.lf-cloche__icone { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--alerte-fonce); }
.lf-cloche__texte { min-width: 0; display: grid; gap: 4px; justify-items: start; }
.lf-cloche__titre { margin: 0; font-weight: 600; font-size: 15px; }
/* RG-D5 : où se règle le rappel (menu › page › onglet) */
.lf-cloche__ou { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 2px; font-size: 11px; font-weight: 600; letter-spacing: .03em;
    text-transform: uppercase; color: var(--rouge-encre); text-decoration: none; }
.lf-cloche__ou:hover { text-decoration: underline; }
.lf-cloche__ou-icone { width: 13px; height: 13px; flex: none; }
.lf-cloche__detail, .lf-cloche__pied, .lf-cloche__vide { margin: 0; font-size: 13px; line-height: 18px; color: var(--encre-douce); }
.lf-cloche__lignes { margin: 2px 0; padding-left: 18px; font-size: 13px; }
.lf-cloche__lignes a { color: var(--encre); font-weight: 500; }
.lf-cloche__note { color: var(--encre-douce); }
.lf-cloche__action { margin-top: 4px; }
.lf-cloche__pied { margin-top: var(--espace-3); }

@media (max-width: 900px) {
    .lf-menu__tete { flex: none; }
}
@media (prefers-reduced-motion: reduce) {
    .lf-cloche--active .lf-cloche__symbole { animation: none; }
}
@media print { .lf-cloche__panneau { display: none; } }

/* ---- Aperçu « voir comme » (RG-P9, docs/droits/README.md) ------------------------------------
   Pastille « comptoir », comme le bouton Messagerie, et un fin cadre rouge autour de l'écran :
   on reste dans l'esthétique de l'outil, mais on ne peut pas oublier qu'on regarde avec les
   droits d'un autre. */
.lf-voir-comme-cadre { position: fixed; inset: 0; z-index: 990; pointer-events: none; box-shadow: inset 0 0 0 3px var(--rouge); }
.lf-voir-comme {
    /* centré dans la zone de la page (à droite du menu), sans jamais couvrir le bouton Messagerie */
    position: fixed; z-index: 1000; bottom: 20px; left: 232px; right: 0; margin: 0 auto; width: fit-content;
    display: flex; align-items: center; gap: 10px; height: 46px; max-width: calc(100% - 232px - 2 * 190px);
    padding: 0 6px 0 6px; border-radius: var(--arrondi-pastille);
    background: linear-gradient(180deg, #2a2522, var(--comptoir)); color: var(--sur-comptoir);
    box-shadow: inset 0 1px 0 #ffffff1a, 0 0 0 1px var(--rouge), 0 6px 18px #1c191740;
    font: 400 13px/18px var(--font-interface);
}
.lf-voir-comme__pastille {
    flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    border-radius: 50%; background: linear-gradient(180deg, var(--rouge-haut), var(--rouge)); box-shadow: inset 0 1px 0 #ffffff40;
}
.lf-voir-comme__oeil { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lf-voir-comme__texte { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lf-voir-comme__etiquette { margin-right: 8px; font: 500 11px/18px var(--font-interface); letter-spacing: .06em; text-transform: uppercase; color: var(--sur-comptoir-doux); }
.lf-voir-comme__qui { font-weight: 500; color: #fff; }
.lf-voir-comme__detail { margin-left: 8px; color: var(--sur-comptoir-doux); }
.lf-voir-comme__quitter {
    flex: none; height: 34px; padding: 0 14px; border: 0; border-radius: var(--arrondi-pastille); cursor: pointer;
    background: #ffffff14; color: var(--sur-comptoir); font: 500 13px/18px var(--font-interface);
    box-shadow: inset 0 0 0 1px #ffffff26; transition: background var(--duree-rapide);
}
.lf-voir-comme__quitter:hover { background: #ffffff26; color: #fff; }
.lf-voir-comme__quitter:focus-visible { outline: 2px solid var(--rouge-haut); outline-offset: 2px; }
@media (max-width: 1100px) {
    .lf-voir-comme { bottom: 76px; max-width: calc(100% - 232px - 32px); }
}
@media (max-width: 900px) {
    .lf-voir-comme { left: 16px; right: 16px; width: auto; max-width: none; height: auto; min-height: 46px; padding: 6px; }
    .lf-voir-comme__texte { white-space: normal; }
    .lf-voir-comme__detail { display: block; margin-left: 0; }
}
