/* =========================================================
   T84 — Barre latérale gauche (menu vertical) + module Demandes
   La barre complète le menu horizontal existant (jamais remplacé) :
   • ≥ 1280 px : barre fixe à gauche, repliable (icônes seules).
   • < 1280 px : masquée (le menu horizontal + un bouton ☰ du header
     ouvrent la même liste en panneau coulissant).
   ========================================================= */

:root { --sidebar-w: 232px; --sidebar-w-mini: 58px; }

.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #312e81 0%, #4338ca 55%, #4f46e5 100%);
  color: #fff;
  z-index: 60;
  display: none;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(30, 27, 75, .25);
  transition: width .18s ease;
}
.app-sidebar .sb-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px;
}
.app-sidebar .sb-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex: none;
}
.app-sidebar .sb-title { font-size: 12px; font-weight: 800; line-height: 1.25; }
.app-sidebar .sb-sub { font-size: 9.5px; color: rgba(255, 255, 255, .6); }

.app-sidebar nav {
  flex: 1; overflow-y: auto; padding: 4px 8px 12px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 10px; margin: 1px 0;
  border-radius: 9px;
  font-size: 12px; font-weight: 600;
  color: rgba(255, 255, 255, .82);
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden;
}
.sb-item i { width: 18px; text-align: center; flex: none; font-size: 13px; }
.sb-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sb-item.sb-active { background: #fff; color: #4338ca; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.sb-item .sb-badge {
  margin-left: auto;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px;
  background: #ef4444; color: #fff;
  font-size: 9.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-sep {
  margin: 8px 10px 4px;
  font-size: 9px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255, 255, 255, .45);
  white-space: nowrap; overflow: hidden;
}

.sb-collapse {
  margin: 6px 8px 10px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .85);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap; overflow: hidden;
}
.sb-collapse:hover { background: rgba(255, 255, 255, .2); }
.sb-collapse i { width: 18px; text-align: center; flex: none; }

/* --- Desktop large : barre visible, contenu décalé --- */
@media (min-width: 1280px) {
  .app-sidebar { display: flex; }
  body.has-sidebar #app-header,
  body.has-sidebar main { margin-left: var(--sidebar-w); transition: margin-left .18s ease; }
  body.has-sidebar.sidebar-mini #app-header,
  body.has-sidebar.sidebar-mini main { margin-left: var(--sidebar-w-mini); }
  body.sidebar-mini .app-sidebar { width: var(--sidebar-w-mini); }
  body.sidebar-mini .app-sidebar .sb-title,
  body.sidebar-mini .app-sidebar .sb-sub,
  body.sidebar-mini .app-sidebar .sb-sep,
  body.sidebar-mini .sb-item span,
  body.sidebar-mini .sb-item .sb-badge,
  body.sidebar-mini .sb-collapse span { display: none; }
  body.sidebar-mini .sb-item { justify-content: center; padding: 9px 0; }
  body.sidebar-mini .sb-item i { font-size: 15px; }
  body.sidebar-mini .sb-collapse { justify-content: center; }
}

/* --- Mobile / tablette : panneau coulissant ouvert par le bouton ☰ --- */
@media (max-width: 1279.98px) {
  .app-sidebar { display: flex; transform: translateX(-105%); transition: transform .2s ease; width: min(80vw, 270px); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .sb-overlay {
    position: fixed; inset: 0; z-index: 59;
    background: rgba(15, 23, 42, .5);
    display: none;
  }
  body.sidebar-open .sb-overlay { display: block; }
}

/* Bouton ☰ du header (ouvre la barre sur mobile, replie sur desktop) */
#btn-sidebar-toggle { display: inline-flex; }

/* La barre est cachée tant que l'utilisateur n'est pas connecté */
body.sb-logged-out .app-sidebar, body.sb-logged-out .sb-overlay { display: none !important; }
@media (min-width: 1280px) {
  body.sb-logged-out #app-header, body.sb-logged-out main { margin-left: 0 !important; }
}

/* =========================================================
   Module Demandes
   ========================================================= */
.dem-sub-btn.active-sub, .dem-vue-btn.active-sub {
  background: #4f46e5 !important; color: #fff !important;
  border-color: #4f46e5 !important;
}
/* Bouton + Contact flottant, toujours visible dans l'onglet (mobile d'abord) */
.dem-fab {
  position: fixed;
  right: 18px; bottom: 76px;
  z-index: 45;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  font-weight: 800; font-size: 14px;
  padding: 13px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(234, 88, 12, .45);
  transition: transform .12s ease;
}
.dem-fab:hover { transform: scale(1.05); }
@media (min-width: 768px) { .dem-fab { bottom: 28px; right: 28px; } }

/* Entonnoir de conversion (bilan hebdo) */
.dem-funnel-row { display: flex; align-items: center; gap: 10px; margin: 3px 0; }
.dem-funnel-label { width: 230px; flex: none; font-size: 11px; font-weight: 600; color: #475569; text-align: right; }
.dem-funnel-bar {
  height: 24px; border-radius: 6px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 8px; min-width: 34px;
  transition: width .3s ease;
}
@media (max-width: 640px) { .dem-funnel-label { width: 128px; font-size: 9.5px; } }

/* Chronologie des contacts dans la fiche dossier */
.dem-timeline { border-left: 2px solid #e2e8f0; margin-left: 8px; padding-left: 14px; }
.dem-timeline-item { position: relative; padding: 6px 0; }
.dem-timeline-item::before {
  content: ''; position: absolute; left: -19.5px; top: 13px;
  width: 9px; height: 9px; border-radius: 999px;
  background: #6366f1; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #c7d2fe;
}
.dem-timeline-item.sortant::before { background: #f59e0b; box-shadow: 0 0 0 1.5px #fde68a; }
