/* ==========================================================================
   BizFlow — sidebar.css
   Barre latérale fixe : version complète, réduite (rail d'icônes) et
   tiroir mobile (géré dans responsive.css).
   ========================================================================== */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  /* Menu indigo : les variables générales sont redéfinies pour ce bloc seulement */
  --surface: var(--nav-bg);
  --surface-2: var(--nav-hover);
  --surface-hover: var(--nav-hover);
  --surface-active: var(--nav-active);
  --border: var(--nav-line);
  --text: var(--nav-text-strong);
  --text-2: var(--nav-text);
  --text-3: #b8c0ea;
  --primary: var(--sun);
  --primary-soft: var(--nav-active);
  --primary-text: var(--nav-text-strong);
  --ring: 0 0 0 2px var(--nav-bg), 0 0 0 4px var(--sun);
  background: var(--nav-bg);
  color: var(--nav-text-strong);
  border-right: 1px solid var(--nav-line);
  transition: width var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

/* ---------- Marque ---------- */
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 18px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand__logo svg {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand__name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.icon-btn.sidebar__close {
  display: none;
}

/* ---------- Espace de travail ---------- */
.sidebar__workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 12px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.workspace__avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 11px;
  font-weight: 700;
}

.workspace__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.workspace__name {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace__meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ---------- Navigation ---------- */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px 16px;
  scrollbar-width: thin;
}

.nav__section {
  padding: 18px 10px 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
}

.nav__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-base);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.nav__link .lucide {
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease);
}

.nav__link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav__link:hover .lucide {
  color: var(--text-2);
}

.nav__link.is-active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}

.nav__link.is-active .lucide {
  color: var(--primary);
}

/* Indicateur latéral de la page active */
.nav__link.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  transition: opacity var(--dur) var(--ease);
}

.nav__badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.nav__badge--warning {
  background: var(--warning-soft);
  color: var(--warning-text);
}

/* ---------- Pied ---------- */
.sidebar__footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar__collapse .lucide {
  transition: transform var(--dur-slow) var(--ease-out), color var(--dur-fast) var(--ease);
}

/* ---------- État réduit (desktop) ---------- */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
}

.sidebar-collapsed .sidebar__brand {
  padding: 0 21px;
}

.sidebar-collapsed .brand__name,
.sidebar-collapsed .nav__label,
.sidebar-collapsed .nav__badge,
.sidebar-collapsed .workspace__info {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

/* Les infobulles débordent à droite : on ne doit pas les rogner */
.sidebar-collapsed .sidebar__nav {
  overflow: visible;
}

.sidebar-collapsed .sidebar__workspace {
  justify-content: center;
  padding: 8px 0;
  border-color: transparent;
  background: transparent;
}

.sidebar-collapsed .nav__section {
  height: 1px;
  margin: 12px 10px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: var(--border);
}

.sidebar-collapsed .nav__link {
  justify-content: center;
  gap: 0;
  padding: 0;
}

.sidebar-collapsed .sidebar__collapse .lucide {
  transform: scaleX(-1);
}

/* Point d'alerte sur l'icône quand le badge est masqué */
.sidebar-collapsed .nav__link:has(.nav__badge:not([hidden]))::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--surface);
}

/* Infobulles en mode réduit */
.sidebar-collapsed .nav__link[data-tooltip]:hover::before,
.sidebar-collapsed .nav__link[data-tooltip]:focus-visible::before {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  bottom: auto;
  width: auto;
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: #141a3a;
  color: #ffffff;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 10;
  animation: tooltip-in var(--dur) var(--ease-out);
}

@keyframes tooltip-in {
  from { opacity: 0; transform: translate(-4px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}

/* Pendant le chargement initial on coupe les transitions (pas d'animation parasite) */
.no-transition .sidebar,
.no-transition .main-wrapper {
  transition: none !important;
}
