/* sidebar.css - Styles dédiés à la barre latérale */

/* ========================================
   VARIABLES SIDEBAR
======================================== */
:root {
  --sidebar-width: 280px;

  /* Palette moderne */
  --sidebar-bg-from: #0f1923;
  --sidebar-bg-to: #0d1f2d;
  --sidebar-accent: #3dd9b3;
  --sidebar-accent-glow: rgba(61, 217, 179, 0.18);
  --sidebar-accent-soft: rgba(61, 217, 179, 0.08);

  /* Rétrocompatibilité */
  --sidebar-color: #0f1923;
  --sidebar-color-dark: #0d1f2d;
  --primary-blue: #3498db;
  --primary-green: #27ae60;
  --primary-purple: #9b59b6;
  --primary-orange: #e67e22;
  --primary-red: #e74c3c;
  --primary-teal: #1abc9c;
  --primary-indigo: #5a6bdb;

  --text-dark: #2c3e50;
  --text-medium: #34495e;
  --text-light: #5a6c7d;
  --border-color: #e5e7eb;

  --nav-text: rgba(255, 255, 255, 0.78);
  --nav-text-hover: #ffffff;
  --nav-text-active: #ffffff;
  --nav-hover-bg: rgba(255, 255, 255, 0.055);
  --nav-active-bg: rgba(61, 217, 179, 0.13);
  --nav-section-color: rgba(255, 255, 255, 0.3);

  --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   SIDEBAR - CONTENEUR PRINCIPAL
======================================== */
#sidebar-container {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 2147483647;
  pointer-events: none;
}

#sidebar-container .sidebar {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    160deg,
    var(--sidebar-bg-from) 0%,
    var(--sidebar-bg-to) 100%
  );
  color: white;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow:
    4px 0 24px rgba(0, 0, 0, 0.35),
    1px 0 0 rgba(255, 255, 255, 0.04);
  transition: transform var(--sidebar-transition);
  pointer-events: auto;
  transform: translateZ(0);
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

#sidebar-container .sidebar::-webkit-scrollbar {
  width: 4px;
}
#sidebar-container .sidebar::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar-container .sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* ========================================
   SIDEBAR HEADER
======================================== */
.sidebar-header {
  padding: 1.4rem 1.25rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.sidebar-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 1.25rem;
  right: 1.25rem;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(61, 217, 179, 0.25),
    transparent
  );
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.sidebar-header:hover .sidebar-logo {
  transform: scale(1.06);
  box-shadow: 0 0 14px var(--sidebar-accent-glow);
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: linear-gradient(
    135deg,
    #ffffff 0%,
    rgba(255, 255, 255, 0.65) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========================================
   SIDEBAR NAVIGATION
======================================== */
.sidebar-nav {
  padding: 0.75rem 0 1.5rem;
}

.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  padding: 0.9rem 1.25rem 0.35rem;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--nav-section-color);
  font-weight: 600;
}

/* ========================================
   NAV ITEMS
======================================== */
.nav-item {
  display: flex;
  align-items: center;
  padding: 0.62rem 1.25rem;
  color: var(--nav-text);
  text-decoration: none;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0 8px 8px 0;
  margin-right: 0.75rem;
  position: relative;
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-text-hover);
  border-left-color: rgba(61, 217, 179, 0.45);
}

.nav-item.active {
  background: var(--nav-active-bg);
  color: var(--nav-text-active);
  border-left-color: var(--sidebar-accent);
  font-weight: 600;
}

.nav-item.active::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sidebar-accent);
  box-shadow: 0 0 8px var(--sidebar-accent-glow);
}

.nav-item i {
  width: 18px;
  margin-right: 0.7rem;
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.75;
  transition:
    opacity 0.18s ease,
    color 0.18s ease;
}

.nav-item:hover i,
.nav-item.active i {
  opacity: 1;
  color: var(--sidebar-accent);
}

/* ========================================
   SOUS-MENUS
======================================== */
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-submenu.open {
  max-height: 500px;
}

.nav-submenu .nav-item {
  padding-left: 3rem;
  font-size: 0.845rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.62);
  border-radius: 0 8px 8px 0;
}

.nav-submenu .nav-item:hover {
  color: var(--nav-text-hover);
}
.nav-submenu .nav-item.active {
  color: var(--nav-text-active);
}

/* ========================================
   NAV TOGGLE (Chevron déroulant)
======================================== */
.nav-toggle {
  position: relative;
}

.nav-toggle::after {
  content: "\f078";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  right: 1.25rem;
  font-size: 0.62rem;
  opacity: 0.45;
  transition:
    transform 0.25s ease,
    opacity 0.18s ease;
}

.nav-toggle:hover::after {
  opacity: 0.85;
}
.nav-toggle.open::after {
  transform: rotate(180deg);
  opacity: 0.85;
}

/* ========================================
   SHOP LINK
======================================== */
.nav-item.shop-link {
  margin: 0.75rem 0.75rem 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  overflow: hidden;
  display: block;
}

.shop-link-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  text-decoration: none;
  background: linear-gradient(
    135deg,
    rgba(61, 217, 179, 0.1) 0%,
    rgba(61, 165, 217, 0.08) 100%
  );
  border: 1px solid rgba(61, 217, 179, 0.18);
  border-radius: 10px;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.shop-link-container:hover {
  background: linear-gradient(
    135deg,
    rgba(61, 217, 179, 0.18) 0%,
    rgba(61, 165, 217, 0.14) 100%
  );
  border-color: rgba(61, 217, 179, 0.38);
  box-shadow: 0 4px 16px rgba(61, 217, 179, 0.1);
}

.shop-link-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.shop-link-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.shop-link-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}

.shop-link-subtitle {
  font-size: 0.72rem;
  color: var(--sidebar-accent);
  font-weight: 500;
}

/* ========================================
   NAV ITEM ACCOUNT
======================================== */
.nav-item-account {
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.22),
    rgba(99, 102, 241, 0.17)
  );
  color: white !important;
  font-weight: 600;
  margin-top: 0.25rem;
  border-radius: 0 8px 8px 0;
  border-left: 2px solid rgba(99, 102, 241, 0.65);
  transition: all 0.2s ease;
}

.nav-item-account:hover {
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.32),
    rgba(99, 102, 241, 0.26)
  );
  border-left-color: #a5b4fc;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.18);
}

.nav-item-account i {
  color: #a5b4fc;
  opacity: 1;
}

.nav-item-account.active {
  background: linear-gradient(
    135deg,
    rgba(55, 48, 163, 0.38),
    rgba(67, 56, 202, 0.32)
  );
  border-left-color: #a5b4fc;
}

/* ========================================
   MOBILE MENU BUTTON
======================================== */
.mobile-menu-btn {
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sidebar-color);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 999;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn:hover {
  background: var(--sidebar-color-dark);
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

/* ========================================
   SIDEBAR 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;
  animation: fadeIn 0.3s ease-out;
}

.sidebar-overlay.active {
  display: block;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 768px) {
  #sidebar-container .sidebar {
    transform: translateX(-100%);
    width: 250px;
  }

  body.sidebar-open #sidebar-container .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-logo {
    width: 34px;
    height: 34px;
  }
  .sidebar-title {
    font-size: 1rem;
  }
  .nav-item {
    padding: 0.58rem 1rem;
  }
  .nav-section-title {
    padding: 0.8rem 1rem 0.3rem;
    font-size: 0.63rem;
  }
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ========================================
   BOUTON TOGGLE SIDEBAR
======================================== */
#sidebar-toggle-btn,
.sidebar-toggle {
  position: fixed !important;
  z-index: 10000 !important;
  background: linear-gradient(
    160deg,
    var(--sidebar-bg-from) 0%,
    var(--sidebar-bg-to) 100%
  ) !important;
  color: rgba(255, 255, 255, 0.85) !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  font-size: 13px !important;
}

#sidebar-toggle-btn:hover,
.sidebar-toggle:hover {
  transform: translateY(-50%) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
  color: var(--sidebar-accent) !important;
}

#sidebar-toggle-btn:active,
.sidebar-toggle:active {
  transform: scale(0.95) !important;
}

#sidebar-toggle-btn i,
.sidebar-toggle i {
  transition: none !important;
  display: block !important;
}

/* ========================================
   DESKTOP MODE (> 1024px)
======================================== */
@media (min-width: 1025px) {
  #sidebar-toggle-btn,
  .sidebar-toggle {
    top: 50% !important;
    left: 280px !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    height: 56px !important;
    border-radius: 0 8px 8px 0 !important;
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.3) !important;
  }

  body.sidebar-collapsed #sidebar-toggle-btn,
  body.sidebar-collapsed .sidebar-toggle {
    left: 0 !important;
  }

  body.sidebar-collapsed #sidebar-toggle-btn i,
  body.sidebar-collapsed .sidebar-toggle i {
    transform: none !important;
  }
}

/* ========================================
   MOBILE MODE (<= 1024px)
======================================== */
@media (max-width: 1024px) {
  #sidebar-toggle-btn,
  .sidebar-toggle {
    bottom: 1rem !important;
    right: 1rem !important;
    top: auto !important;
    left: auto !important;
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
  }

  #sidebar-toggle-btn i,
  .sidebar-toggle i {
    transform: none !important;
  }
}

/* ========================================
   ÉTAT SIDEBAR FERMÉE
======================================== */
#sidebar-container,
#sidebar-container > *,
.main-sidebar,
aside[class*="sidebar"],
div[class*="sidebar"],
.sidebar {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateX(0) !important;
}

@media (min-width: 1025px) {
  body.sidebar-collapsed #sidebar-container,
  body.sidebar-collapsed #sidebar-container > *,
  body.sidebar-collapsed .main-sidebar,
  body.sidebar-collapsed .sidebar {
    transform: translateX(-280px) !important;
  }
}

@media (max-width: 1024px) {
  #sidebar-container {
    z-index: 9999 !important;
  }

  #sidebar-container .sidebar,
  #sidebar-container > * {
    z-index: 9999 !important;
  }

  body.sidebar-collapsed #sidebar-container {
    z-index: 1 !important;
  }

  body.sidebar-collapsed #sidebar-container .sidebar,
  body.sidebar-collapsed #sidebar-container > * {
    transform: translateX(-100%) !important;
  }
}

/* ========================================
   ÉLARGIR LE CONTENU
======================================== */
.main-wrapper,
.main-content {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@media (min-width: 1025px) {
  body.sidebar-collapsed .main-wrapper {
    margin-left: 0 !important;
  }
  body.sidebar-collapsed .main-content {
    max-width: 100% !important;
  }
}

@media (max-width: 1024px) {
  .main-wrapper,
  .main-content {
    margin-left: inherit !important;
    max-width: 100% !important;
  }
}

/* ========================================
   OVERLAY MOBILE (full)
======================================== */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9998 !important;
  animation: fadeIn 0.2s ease-out;
}

@media (min-width: 1025px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* ========================================
   MODAL OPEN
======================================== */
body.modal-open #sidebar-container {
  z-index: 9998 !important;
  pointer-events: none !important;
}

body.modal-open #sidebar-toggle-btn,
body.modal-open .sidebar-toggle {
  z-index: 9998 !important;
}
