/**
 * Admin Sidebar - Modern Navigation Component
 * Pour le backoffice TOWeb V14
 * Design inspiré de Vercel/GitHub/Linear
 */

/* ============================================
   SIDEBAR STRUCTURE
   ============================================ */

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: left 0.3s var(--ease-in-out), transform 0.3s var(--ease-in-out);
}

.admin-sidebar::-webkit-scrollbar {
  width: 6px;
}

.admin-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.admin-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.admin-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   CLOSE BUTTON (Mobile only)
   ============================================ */

.sidebar-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s var(--ease-out);
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.sidebar-close svg {
  width: 20px;
  height: 20px;
  stroke: white;
}

/* ============================================
   BRAND / LOGO
   ============================================ */

.sidebar-brand {
  padding: var(--space-6) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-surface);
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  transition: opacity 0.2s var(--ease-out);
}

.sidebar-brand:hover {
  opacity: 0.9;
  text-decoration: none;
  color: var(--color-surface);
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.sidebar-brand-icon svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.sidebar-brand-text {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: white;
  letter-spacing: -0.01em;
}

/* ============================================
   NAVIGATION MENU
   ============================================ */

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
}

.sidebar-nav-section {
  margin-bottom: var(--space-6);
}

.sidebar-nav-section:last-child {
  margin-bottom: 0;
}

.sidebar-nav-label {
  padding: 0 var(--space-4);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.sidebar-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ============================================
   MENU ITEMS
   ============================================ */

.sidebar-nav-item {
  margin: 0;
  padding: 0;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-1) var(--space-2);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 300;
  border-radius: var(--radius-md);
  transition: all 0.15s var(--ease-out);
  position: relative;
}

.sidebar-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-decoration: none;
}

.sidebar-nav-link.active {
  background: var(--sidebar-active-bg);
  color: white;
}

.sidebar-nav-link.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

/* ============================================
   ICONS
   ============================================ */

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s var(--ease-out);
}

.sidebar-nav-link:hover .sidebar-nav-icon,
.sidebar-nav-link.active .sidebar-nav-icon {
  opacity: 1;
}

.sidebar-nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* ============================================
   BADGES (pour notifications)
   ============================================ */

.sidebar-nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.sidebar-nav-link.active .sidebar-nav-badge {
  background: var(--color-primary);
}

/* ============================================
   USER SECTION
   ============================================ */

.sidebar-user {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

.sidebar-user-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5);
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.15s var(--ease-out);
}

.sidebar-user-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-decoration: none;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  color: white;
}

.sidebar-user-avatar svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: white;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  line-height: 1.4;
}

.sidebar-user-action {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.15s var(--ease-out);
}

.sidebar-user-link:hover .sidebar-user-action {
  opacity: 1;
}

.sidebar-user-action svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
  /* Sidebar réduite sur tablette */
  .admin-sidebar {
    width: 200px;
  }

  .sidebar-brand {
    padding: var(--space-4) var(--space-3);
  }

  .sidebar-brand-text {
    font-size: var(--text-base);
  }

  .sidebar-nav-link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
  }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
  .admin-sidebar,
  .sidebar-toggle,
  .sidebar-overlay {
    display: none !important;
  }

  .admin-main {
    margin-left: 0 !important;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.admin-sidebar.animating {
  animation: slideInFromLeft 0.3s var(--ease-out);
}

/* ============================================
   SCROLLBAR CUSTOM (Firefox)
   ============================================ */

.admin-sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ============================================
   FOCUS STATES (Accessibilité)
   ============================================ */

.sidebar-nav-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================
   DIVIDER (Séparateur entre sections)
   ============================================ */

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: var(--space-4) var(--space-4);
}

/* ============================================
   COLLAPSE SUBMENU (pour futures extensions)
   ============================================ */

.sidebar-nav-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
}

.sidebar-nav-item.expanded .sidebar-nav-submenu {
  max-height: 500px;
}

.sidebar-nav-submenu .sidebar-nav-link {
  padding-left: calc(var(--space-4) + var(--space-6));
  font-size: var(--text-sm);
}

.sidebar-nav-chevron {
  margin-left: auto;
  transition: transform 0.2s var(--ease-out);
}

.sidebar-nav-item.expanded .sidebar-nav-chevron {
  transform: rotate(90deg);
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

/* Mobile Toggle Button */
.sidebar-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1002;
  width: 44px;
  height: 44px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  background: #f9fafb;
}

.sidebar-toggle svg {
  width: 24px;
  height: 24px;
  stroke: #111827;
}

/* Backdrop pour mobile */
.sidebar-backdrop,
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active,
.sidebar-overlay.active {
  opacity: 1;
}

@media (max-width: 768px) {
  /* Afficher le bouton toggle sur mobile */
  .sidebar-toggle {
    display: flex;
  }

  /* Masquer le bouton toggle quand sidebar active */
  .sidebar-toggle.active {
    opacity: 0;
    pointer-events: none;
  }

  /* Afficher le bouton close en mobile */
  .sidebar-close {
    display: flex;
  }

  /* Sidebar cachée par défaut sur mobile */
  .admin-sidebar {
    left: calc(-1 * var(--sidebar-width));
    z-index: 1001;
  }

  /* Sidebar visible quand active */
  .admin-sidebar.active {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  /* Backdrop visible quand sidebar active */
  .sidebar-backdrop,
  .sidebar-overlay {
    display: block;
  }

  /* Ajuster le contenu principal pour mobile */
  .admin-main {
    margin-left: 0 !important;
    padding: 0 !important;
    padding-top: 4rem !important; /* Espace pour le bouton toggle */
  }

  /* admin-content padding is handled in admin-modern.css */
}

@media (min-width: 769px) {
  /* Desktop: toujours afficher la sidebar */
  .admin-sidebar {
    left: 0 !important;
  }

  .sidebar-toggle,
  .sidebar-backdrop,
  .sidebar-overlay {
    display: none !important;
  }
}
