/* ============================================================
   LOPANGO — Sidebar Enterprise CSS v1.0
   Tokens : utilise exclusivement les variables CSS existantes
   ============================================================ */

/* ── Structure sidebar ─────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface1, #0f1117);
  border-right: 1px solid var(--border, rgba(255,255,255,.08));
  overflow: hidden;
  transition: width .25s ease, min-width .25s ease;
  z-index: 50;
}

/* ── Bouton collapse global ─────────────────────────────── */
.sidebar-collapse-btn {
  position: absolute;
  top: 14px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted, #94A3B8);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: transform .2s;
  z-index: 2;
}
.sidebar-collapse-btn:hover { color: #fff; background: var(--hover, rgba(255,255,255,.06)); }

/* ── Mode mini (icônes seules) ──────────────────────────── */
.sidebar.mini { width: 60px; min-width: 60px; }
.sidebar.mini .sidebar-logo-text { display: none; }
.sidebar.mini .sidebar-logo-mark { margin: 0 auto; }
.sidebar.mini .sidebar-logo { padding: 14px 8px; }
.sidebar.mini .sidebar-group-header { padding: 10px 6px; justify-content: center; }
.sidebar.mini .sidebar-group-label { display: none; }
.sidebar.mini .sidebar-group-chevron { display: none; }
.sidebar.mini .sidebar-group-items { max-height: 0 !important; opacity: 0; overflow: hidden; }
.sidebar.mini .sidebar-item { padding: 10px 6px; justify-content: center; }
.sidebar.mini .sidebar-item-label { display: none; }
.sidebar.mini .sidebar-item-icon { margin-right: 0; font-size: 18px; }
.sidebar.mini .sidebar-badge { display: none; }
.sidebar.mini .sidebar-collapse-btn { transform: rotate(180deg); right: auto; left: 50%; transform: translateX(-50%) rotate(180deg); }

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Logo ──────────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: var(--space-4, 16px) var(--space-4, 16px) var(--space-3, 12px);
  border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm, 8px);
  background: var(--color-accent, #4f8cff);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-weight: 800;
  font-size: 15px;
  color: var(--text1, #f1f5f9);
  display: block;
  line-height: 1.2;
}

.sidebar-logo-role {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-accent, #4f8cff);
  letter-spacing: .06em;
  display: block;
}

/* ── Navigation ────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2, 8px) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border, rgba(255,255,255,.08)) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border, rgba(255,255,255,.08)); border-radius: 4px; }

/* ── Groupes ────────────────────────────────────────────── */
.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2, 8px) var(--space-4, 16px);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3, #64748b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  transition: color .15s;
  text-align: left;
}

.sidebar-group-header:hover {
  color: var(--text2, #94a3b8);
}

.sidebar-group-header.open {
  color: var(--text2, #94a3b8);
}

.sidebar-group-chevron {
  font-size: 10px;
  opacity: .6;
  transition: transform .2s;
  flex-shrink: 0;
}

/* ── Items groupe ───────────────────────────────────────── */
.sidebar-group-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 0 var(--space-2, 8px);
  overflow: hidden;
}

.sidebar-group-items.open {
  display: flex;
  animation: slideDown .15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Item navigation ────────────────────────────────────── */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  padding: 7px var(--space-3, 12px);
  border-radius: var(--radius-sm, 8px);
  color: var(--text2, #94a3b8);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.sidebar-item:hover {
  background: var(--surface2, rgba(255,255,255,.05));
  color: var(--text1, #f1f5f9);
}

.sidebar-item.active {
  background: rgba(79,140,255,.15);
  color: var(--color-accent, #4f8cff);
  font-weight: 600;
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--color-accent, #4f8cff);
  border-radius: 0 3px 3px 0;
}

.sidebar-item-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Badges ─────────────────────────────────────────────── */
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--color-danger, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Footer utilisateur ─────────────────────────────────── */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  padding: var(--space-3, 12px) var(--space-3, 12px);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent, #4f8cff);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text1, #f1f5f9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--text3, #64748b);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-user-logout {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: none;
  color: var(--text3, #64748b);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.sidebar-user-logout:hover {
  color: var(--color-danger, #ef4444);
  background: rgba(239,68,68,.1);
  border-color: rgba(239,68,68,.3);
}

/* ── Overlay mobile ─────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 49;
}
#sidebar-overlay.active { display: block; }

/* ── Responsive mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: left .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .sidebar-mobile-toggle {
    display: flex !important;
  }
}

/* ── Bouton toggle mobile (topbar) ──────────────────────── */
.sidebar-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: none;
  color: var(--text2, #94a3b8);
  cursor: pointer;
  font-size: 18px;
}
