/**
 * Responsive Navigation & Recursive Drilldown Styles
 * Algo Jungle - Modern Responsive Multi-level Mobile Menu
 */

/* ==========================================================================
   1. Découplage Desktop / Mobile via Media Queries (Breakpoints 768px / 769px)
   ========================================================================== */

/* --- Mode Desktop (>= 769px) --- */
@media (min-width: 769px) {
  /* Masquer complètement le bouton hamburger et le tiroir mobile sur Desktop */
  .mobile-nav-toggle,
  .mobile-nav-drawer,
  .mobile-nav-overlay {
    display: none !important;
  }
}

/* --- Mode Mobile / Tablette (<= 768px) --- */
@media (max-width: 768px) {
  /* Masquer le menu déroulant desktop Bootstrap pour laisser place au tiroir mobile */
  .navbar .collapse.navbar-collapse#navbarSupportedContent {
    display: none !important;
  }

  /* Afficher le bouton hamburger */
  .navbar-toggler.mobile-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }
}


/* ==========================================================================
   2. Bouton Hamburger (Header)
   ========================================================================== */
.mobile-nav-toggle {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 1.25rem;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.mobile-nav-toggle:hover,
.mobile-nav-toggle:focus {
  background-color: #f1f5f9;
  color: #3498db;
  border-color: #3498db;
  outline: none;
}


/* ==========================================================================
   3. Tiroir Mobile (Drawer) & Overlay
   ========================================================================== */

/* Overlay d'arrière-plan semi-transparent */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Tiroir coulissant (Drawer) */
.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 86vw;
  background-color: #ffffff;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.18);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.mobile-nav-drawer.is-open {
  transform: translateX(0);
}

/* En-tête du tiroir */
.mobile-nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.mobile-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #1e293b;
  font-weight: 700;
  font-size: 1.1rem;
}

.mobile-brand-text {
  letter-spacing: -0.3px;
}

.mobile-nav-close {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-nav-close:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}


/* ==========================================================================
   4. Conteneur Drilldown & Panneaux Récursifs
   ========================================================================== */
.drilldown-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Panneau individuel */
.drilldown-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #ffffff;
  transition: transform 0.32s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
}

/* Panneau actif (actuellement affiché) */
.drilldown-panel.is-active {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 3;
}

/* Panneau parent / ancêtre (en arrière-plan à gauche) */
.drilldown-panel.is-ancestor {
  transform: translateX(-30%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}


/* ==========================================================================
   5. En-tête de sous-menu & Bouton Retour (<) à droite
   ========================================================================== */
.drilldown-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  background-color: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 48px;
}

.drilldown-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  padding: 14px 16px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.drilldown-back-btn {
  background: transparent;
  border: none;
  border-left: 1px solid #f1f5f9;
  padding: 14px 18px;
  font-size: 0.95rem;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
  flex-shrink: 0;
  box-shadow: none;
  border-radius: 0;
}

.drilldown-back-btn:hover {
  color: #3498db;
  background-color: #f1f5f9;
}


/* ==========================================================================
   6. Liste des éléments & Lignes de navigation
   ========================================================================== */
.drilldown-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drilldown-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.15s ease;
  position: relative;
}

.drilldown-row:hover {
  background-color: #f8fafc;
}

/* Lien cliquable menant directement à la page */
.drilldown-link {
  flex: 1;
  padding: 14px 16px;
  color: #334155;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.2s ease, background-color 0.2s ease;
  display: block;
}

.drilldown-link:hover {
  color: #3498db;
  text-decoration: none;
}

/* Bouton déclencheur chevron (>) pour ouvrir le sous-menu */
.drilldown-forward-btn {
  background: transparent;
  border: none;
  padding: 14px 18px;
  color: #94a3b8;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
  border-left: 1px solid #f1f5f9;
}

.drilldown-forward-btn:hover {
  color: #3498db;
  background-color: #f1f5f9;
}

.drilldown-forward-btn:active {
  transform: scale(0.92);
}


/* ==========================================================================
   7. Surlignage de la Page Active (#3498db)
   ========================================================================== */
.drilldown-link.active,
.drilldown-row.is-active > .drilldown-link {
  color: #3498db !important;
  font-weight: 700 !important;
  background-color: rgba(52, 152, 219, 0.08) !important;
  border-left: 4px solid #3498db;
  padding-left: 12px;
}

.drilldown-row.is-active > .drilldown-forward-btn {
  color: #3498db;
}

/* Empêcher le défilement de l'arrière-plan quand le tiroir est ouvert */
body.mobile-nav-open {
  overflow: hidden !important;
}
