/* ===================== APP SHELL ===================== */
.app {
  display: grid;
  /* minmax(0, 1fr) : sinon un contenu large — un fil de discussion,
     un tableau — pousse la colonne principale au-delà de l'écran. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "side head" "side main";
  height: 100dvh;
  overflow: hidden;
}
.app[data-nav="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---------------------- SIDEBAR ---------------------- */
.sidebar {
  grid-area: side;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  z-index: var(--z-sidebar);
  transition: width var(--t-mid) var(--e-out);
}
.brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.brand-mark { flex: none; width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text b {
  font-family: var(--f-display); font-size: var(--fs-14);
  letter-spacing: .06em; color: var(--tx-1); text-transform: uppercase;
}
.brand-text span { font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em; color: var(--tx-3); }

.nav { flex: 1 1 auto; overflow-y: auto; padding: var(--s-3) var(--s-2) var(--s-6); }

.nav-cat { margin-bottom: var(--s-1); }
.nav-cat-btn {
  width: 100%; display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: .14em; text-transform: uppercase; color: var(--tx-3);
  border-radius: var(--r-sm);
}
.nav-cat-btn:hover { color: var(--tx-2); background: var(--tint); }
.nav-cat-btn .chev { margin-left: auto; transition: transform var(--t-fast) var(--e-out); opacity: .6; }
.nav-cat[data-open="false"] .chev { transform: rotate(-90deg); }
.nav-cat-items {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows var(--t-mid) var(--e-out), opacity var(--t-fast);
}
.nav-cat[data-open="false"] .nav-cat-items { grid-template-rows: 0fr; opacity: 0; }
.nav-cat-inner { overflow: hidden; min-height: 0; }

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px var(--s-3);
  margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--tx-2); font-size: var(--fs-13);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--bg-2); color: var(--tx-1); }
.nav-item .ico { flex: none; width: 18px; height: 18px; opacity: .8; }
.nav-item .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .pill {
  margin-left: auto; flex: none;
  font-family: var(--f-mono); font-size: 10px;
  background: var(--bg-3); color: var(--tx-2);
  padding: 1px 6px; border-radius: var(--r-full);
}
.nav-item.is-active { background: var(--brand-soft); color: var(--tx-1); }
.nav-item.is-active .ico { opacity: 1; color: var(--brand); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item.is-active .pill { background: var(--brand); color: var(--brand-tx); }

.nav-foot { flex: none; padding: var(--s-3); border-top: 1px solid var(--line-soft); }

/* Sidebar repliée */
.app[data-nav="collapsed"] .brand-text,
.app[data-nav="collapsed"] .nav-cat-btn span,
.app[data-nav="collapsed"] .nav-cat-btn .chev,
.app[data-nav="collapsed"] .nav-item .lbl,
.app[data-nav="collapsed"] .nav-foot .lbl { display: none; }
.app[data-nav="collapsed"] .nav-cat-btn { justify-content: center; padding: var(--s-2) 0; }
.app[data-nav="collapsed"] .nav-cat-btn::after {
  content: ""; width: 16px; height: 1px; background: var(--line);
}
.app[data-nav="collapsed"] .nav-item { justify-content: center; padding: 10px 0; }
.app[data-nav="collapsed"] .nav-item .pill {
  position: absolute; top: 2px; right: 6px; margin: 0; padding: 0 4px; font-size: 9px;
}
.app[data-nav="collapsed"] .nav-cat[data-open="false"] .nav-cat-items { grid-template-rows: 1fr; opacity: 1; }

/* ----------------------- HEADER ---------------------- */
.header {
  grid-area: head;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-5);
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-header);
}
.header-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.header-title h1 { font-size: var(--fs-16); letter-spacing: 0; }
.header-title .eyebrow { font-size: 10px; }

.icon-btn {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--tx-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-2); color: var(--tx-1); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: var(--r-full);
  background: var(--danger); border: 2px solid var(--bg-1);
}

.searchbox {
  display: flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-3);
  background: var(--bg-3); border: 1px solid transparent;
  border-radius: var(--r-md); color: var(--tx-3);
  min-width: 200px; max-width: 340px; flex: 1 1 240px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.searchbox:hover { border-color: var(--line); }
.searchbox input { flex: 1 1 auto; min-width: 0; background: none; border: 0; outline: none; color: var(--tx-1); font-size: var(--fs-13); }
.searchbox input::placeholder { color: var(--tx-3); }
.searchbox kbd {
  font-family: var(--f-mono); font-size: 10px; color: var(--tx-3);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}

/* Profil (droite) */
.profile-btn { display: flex; align-items: center; gap: var(--s-2); padding: 4px 6px 4px 4px; border-radius: var(--r-full); transition: background var(--t-fast); }
.profile-btn:hover { background: var(--bg-2); }
.avatar {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--bg-3); color: var(--tx-1);
  font-family: var(--f-mono); font-size: var(--fs-11); letter-spacing: .04em;
  border: 1px solid var(--line);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-13); }
.profile-meta { display: none; flex-direction: column; line-height: 1.15; text-align: left; }
.profile-meta b { font-size: var(--fs-13); color: var(--tx-1); font-weight: 500; }
.profile-meta span { font-size: 10px; color: var(--tx-3); font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .08em; }
@media (min-width: 900px) { .profile-meta { display: flex; } }

/* Popovers header */
.pop {
  position: fixed; z-index: var(--z-drawer);
  width: min(360px, calc(100vw - 24px));
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: pop-in var(--t-fast) var(--e-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
.pop-head { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; }
.pop-body { max-height: min(420px, 60dvh); overflow-y: auto; }
.pop-foot { padding: var(--s-2) var(--s-3); border-top: 1px solid var(--line-soft); }
.pop-item {
  display: flex; gap: var(--s-3); width: 100%; text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--t-fast);
}
.pop-item:last-child { border-bottom: 0; }
.pop-item:hover { background: var(--bg-2); }
.pop-item.unread { background: var(--brand-soft); }
.pop-item .ico { flex: none; margin-top: 2px; color: var(--tx-3); }

/* ------------------------ MAIN ----------------------- */
.main { grid-area: main; min-width: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.page { padding: var(--s-6); max-width: 1560px; margin: 0 auto; animation: page-in var(--t-mid) var(--e-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* --------------------- RESPONSIVE -------------------- */
.nav-scrim { display: none; }
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "head" "main"; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--t-mid) var(--e-out);
    box-shadow: var(--shadow-3);
  }
  .app[data-nav="open"] .sidebar { transform: none; }
  .app[data-nav="open"] .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 45;
    background: var(--scrim); animation: fade-in var(--t-fast) var(--e-out);
  }
  .app[data-nav="collapsed"] .brand-text,
  .app[data-nav="collapsed"] .nav-item .lbl { display: flex; }
  .page { padding: var(--s-4); }
}
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 700px) {
  .header { padding: 0 var(--s-3); gap: var(--s-2); }
  .header .searchbox { display: none; }
  .header-title h1 { font-size: var(--fs-14); }
  .page { padding: var(--s-3) var(--s-3) var(--s-12); }
}

/* Popovers : positionnés par le CSS seul, sous leur bouton.
   Le JavaScript ne calcule aucune coordonnée. */
.pop-hote { position: relative; display: flex; align-items: center; }
.pop-hote .pop { position: absolute; top: calc(100% + 8px); right: 0; }
/* Le panneau ne doit jamais sortir de l'écran : sur les largeurs
   moyennes, il se cale sur le bord droit de la fenêtre. */
@media (max-width: 1500px) {
  .pop-hote .pop-profil { position: fixed; top: calc(var(--header-h) + 6px); right: var(--s-4); left: auto; }
}
.pop-profil { width: 260px; }
.cliquable { cursor: pointer; }
@media (max-width: 480px) {
  /* Sur petit écran, le panneau se cale sur la largeur de la fenêtre. */
  .pop-hote .pop { position: fixed; top: var(--header-h); right: var(--s-3); left: var(--s-3); width: auto; }
}

/* ================= LANGAGE VISUEL — MAQUETTE 25 =================
   Header : marque à gauche, CERCLE 25 au centre, profil à droite. */
.header { gap: var(--s-5); }

.marque {
  display: flex; align-items: baseline; gap: 7px; flex: none;
  font-weight: 700; letter-spacing: .04em;
}
.marque b { color: var(--brand); font-size: 22px; line-height: 1; }
.marque span { color: var(--tx-1); font-size: var(--fs-13); letter-spacing: .22em; }

.ruban { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.ruban-fleche { color: var(--tx-3); opacity: .5; display: flex; }
.ruban-etape {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 6px 2px 10px; min-width: 92px;
  transition: color var(--t-fast);
}
.ruban-etape .l {
  font-size: 10px; letter-spacing: .12em; font-weight: 600; color: var(--tx-3);
  white-space: nowrap;
}
.ruban-etape .n {
  font-size: var(--fs-16); font-weight: 700; color: var(--tx-2); line-height: 1.3;
}
.ruban-etape:hover .l, .ruban-etape:hover .n { color: var(--tx-1); }
.ruban-etape.is-actif .l { color: var(--dep); }
.ruban-etape.is-actif .n { color: var(--tx-1); }
.ruban-etape.is-actif::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0;
  height: 2px; border-radius: 2px; background: var(--dep);
}
@media (max-width: 1250px) { .ruban-etape { min-width: 74px; } .ruban { gap: var(--s-2); } }
@media (max-width: 1080px) { .ruban, .marque span { display: none; } }

/* Sidebar : plus dense, catégories nettes */
.sidebar { background: var(--bg-1); }
.nav-cat-btn { font-size: 10px; letter-spacing: .18em; font-weight: 600; }
.nav-item { font-size: var(--fs-14); font-weight: 500; padding: 9px var(--s-3); }
.nav-item.is-active { background: var(--brand-soft); }
.nav-item.is-active .lbl { color: var(--brand); font-weight: 600; }
.nav-item.is-active .ico { color: var(--brand); }

/* Profil : panneau à droite, comme la maquette */
.pop-profil { width: 300px; }
.pop-profil .pop-head { padding: var(--s-5); }

/* La marque vit dans le header ; la sidebar ne la répète pas. */
@media (min-width: 1081px) { .brand { display: none; } .nav { padding-top: var(--s-4); } }
.app[data-nav="collapsed"] .brand { display: flex; justify-content: center; }

/* Compteur de notifications : un nombre, lisible, jamais une pastille muette. */
.icon-btn .compteur {
  position: absolute; top: 2px; right: 0;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  border: 2px solid var(--bg-1);
}
/* Une seule pulsation, au moment où le nombre augmente. */
.icon-btn .compteur.arrive { animation: arrivee 900ms var(--e-out) 1; }
@keyframes arrivee {
  0%   { transform: scale(.6); }
  45%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .icon-btn .compteur.arrive { animation: none; } }

/* Zones tactiles : au doigt, rien en dessous de 44 px. */
@media (max-width: 1024px) {
  .icon-btn { width: 44px; height: 44px; }
  .nav-item { padding: 12px var(--s-3); }
  .btn-sm { height: 38px; }
  .chip { height: 36px; padding: 0 var(--s-4); }
  .profile-btn { min-height: 44px; }
}

/* ---- Le logo, à sa vraie place ---- */
.marque-logo { height: 30px; width: auto; display: block; }
.brand { display: flex; align-items: center; padding: var(--s-5) var(--s-4) var(--s-4); }
.brand-logo { height: 34px; width: auto; }
.brand-marque { height: 30px; width: auto; display: none; }
.app[data-nav="collapsed"] .brand-logo { display: none; }
.app[data-nav="collapsed"] .brand-marque { display: block; margin: 0 auto; }

/* Signature fixe, en bas de la sidebar. */
.nav-signature {
  padding: var(--s-4) var(--s-5) var(--s-2);
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--line-soft);
}
.nav-signature b {
  font-size: var(--fs-12); letter-spacing: .18em; color: var(--tx-2); font-weight: 700;
}
.nav-signature span { font-size: 10px; letter-spacing: .1em; color: var(--tx-3); }
.app[data-nav="collapsed"] .nav-signature { display: none; }

/* ---- Panneau profil : jamais vide ---- */
.pop-profil { width: 320px; max-height: 78vh; overflow-y: auto; }
.pop-infos { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line-soft); }
.profil-ligne {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-3); padding: 5px 0; min-width: 0;
}
.profil-ligne .l { font-size: var(--fs-12); color: var(--tx-3); flex: none; }
.profil-ligne .v {
  font-size: var(--fs-13); color: var(--tx-1); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profil-ligne .v.vide { color: var(--tx-3); font-style: italic; }
.pop-body.borde { border-top: 1px solid var(--line-soft); }
.pop-foot { border-top: 1px solid var(--line-soft); padding: var(--s-2) 0; }
.pop-item.danger .ico, .pop-item.danger span { color: var(--danger); }

/* ---- En-tête : ce qui doit céder quand la place manque ----
   Le ruban est le premier à se réduire, puis à disparaître : il
   double une information déjà présente dans la page Projets. Le
   badge de démonstration, lui, ne disparaît jamais. */
.header .ruban { flex: 0 1 auto; overflow: hidden; }
.header .badge-demo { flex: none; }
.header .profile-btn { flex: none; }
.profile-meta b { white-space: nowrap; }
@media (max-width: 1500px) { .header .ruban { display: none; } }
@media (min-width: 1501px) { .header .ruban { display: flex; } }
