nav {
  background: #181828;
  padding: 0.5em 0;
  margin-bottom: 20px;
}

/* --- Structure principale --- */
.nav-links {
  display: flex;
  gap: 1em;
  list-style: none;
  padding-left: 0;
  margin: 0;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-links li {
  position: relative;
  display: flex;
  align-items: stretch;
  text-align: center;
}

/* --- Liens principaux --- */
.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  padding: 0.7em 1.2em;
  border-radius: 6px;
  transition: background 0.2s, transform 0.15s;
  line-height: 1.3em;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
  text-wrap: balance;
  min-height: 40px;
  font-size: 1rem;
  background: #1c1c3a;
  box-sizing: border-box;
}

.nav-links a:hover {
  background: #222244;
  transform: translateY(-1px);
}

.disabled a {
  opacity: 0.5;
  pointer-events: none;
}

/* --- Menu déroulant --- */
.dropdown {
  position: relative;
}

/* 🧩 FIX : colle parfaitement le menu au bouton */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; /* au lieu de calc(100% + 5px) */
  left: 0;
  background: #222244;
  border-radius: 8px;
  list-style: none;
  padding: 0.5em 0;
  margin-top: 2px; /* petit espace visuel sans “trou” */
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  min-width: 180px;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

/* items internes */
.dropdown-menu li {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 0.6em 1em;
  color: #fff;
  text-decoration: none;
  transition: background 0.2s;
  line-height: 1.3em;
  text-align: left;
  white-space: normal;
}

.dropdown-menu a:hover {
  background: #2e2e5e;
}

/* 🧩 FIX : garde le menu ouvert quand la souris passe du bouton au menu */
.dropdown:hover > .dropdown-menu,
.dropdown:focus-within > .dropdown-menu,
.dropdown-menu:hover {
  display: block;
}

/* 🧩 Le hover du bouton reste cohérent */
.dropdown:hover > a {
  background: #222244;
}

/* --- Animation --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .nav-links {
    flex-direction: column;
    align-items: stretch;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    background: #202040;
    padding-left: 1em;
    border-radius: 0;
  }
}
