/* ============================================
   MENU DESKTOP
   ============================================ */

/* Container principal */
#main-menu {
  position: relative;
  width: 100%;
}

/* Liste niveau 0 (menu horizontal) */
#main-menu .navbar-nav {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 2rem;
  align-items: center;
  flex-direction: row;
}

/* Items niveau 0 avec mega-menu ou card-menu : position static pour prendre toute la largeur */
#main-menu .navbar-nav > li.mega-menu,
#main-menu .navbar-nav > li.card-menu {
  position: static;
}

/* Items niveau 0 sans mega-menu ni card-menu : position relative pour que le dropdown se positionne sous le lien parent */
#main-menu .navbar-nav > li:not(.mega-menu):not(.card-menu) {
  position: relative;
}

/* Liens niveau 0 */
#main-menu .navbar-nav > li > a {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  color: var(--bs-gray-darker);
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  transition: color 0.3s ease;
  white-space: nowrap;
}

#main-menu .navbar-nav > li > a:hover {
  color: #3bbac9;
}

/* Icônes dans le menu niveau 0 */
#main-menu .navbar-nav > li > a .menu-item-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#main-menu .navbar-nav > li > a .menu-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Chevron pour les items avec sous-menu (niveau 0) */
#main-menu .navbar-nav > li.menu-item-has-children > a::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

#main-menu .navbar-nav > li.menu-item-has-children:hover > a::after {
  transform: rotate(45deg) translateY(2px);
}

/* ============================================
   MEGA MENU NIVEAU 1 (Sidebar + Content)
   ============================================ */

/* Mega menu : prend toute la largeur avec grid layout - UNIQUEMENT pour .mega-menu */
#main-menu .navbar-nav > li.mega-menu > .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #f1fafb;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 2%;
  list-style: none;
  z-index: 1000;
  min-height: 400px;
  padding: 0;
  overflow: visible;
}

/* Pseudo-élément pour maintenir le hover entre le lien parent et le mega menu */
#main-menu .navbar-nav > li.mega-menu > .sub-menu::before {
  content: '';
  position: absolute;
  top: -8%;
  left: 0;
  right: 0;
  height: 9%;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}

/* Afficher le mega menu en grid au hover */
#main-menu .navbar-nav > li.menu-item-has-children.mega-menu:hover > .sub-menu {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  grid-auto-flow: row dense;
  align-items: start;
}

/* Items de niveau 1 : tous dans la première colonne (sidebar), empilés verticalement */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li {
  position: static;
  grid-column: 1;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: block;
  width: 100%;
}

/* Liens de niveau 1 dans la sidebar */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > a {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  color: var(--bs-gray-darker);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > a:hover,
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li:hover > a {
  background-color: rgba(59, 186, 201, 0.05);
  border-left-color: #3bbac9;
  color: #3bbac9;
}

/* Icônes dans les items de niveau 1 */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > a .menu-icon {
  width: 24px;
  height: 24px;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

/* Contenu du menu item (icône + texte) */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > a .menu-item-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > a .menu-text {
  flex: 1;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Pas de chevron après pour les items de niveau 1 */
#main-menu
  .navbar-nav
  > li.mega-menu
  > .sub-menu
  > li.menu-item-has-children
  > a::after {
  display: none;
}

/* Masquer les sous-menus de niveau 2 dans le HTML (ils seront clonés par JS) */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li > .sub-menu {
  display: none !important;
}

/* Container pour la partie droite du mega menu (créé par JS) */
.mega-menu-content {
  grid-column: 2;
  grid-row: 1 / 999;
  background: #fff;
  padding: 2rem;
  height: 100%;
  overflow-y: auto;
  align-self: start;
}

/* Sous-menus clonés dans la partie droite */
.mega-menu-content > .sub-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}

/* Colonne image (3ème colonne) */
.mega-menu-image {
  grid-column: 3;
  grid-row: 1 / 999;
  align-self: stretch;
  height: 100%;
  padding: 1rem;
  background-color: #fff;
}

.mega-menu-image img {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border-radius: 8px;
  object-fit: cover;
}

/* Liens de niveau 2 dans la partie droite : uppercase, bleu, pas de chevron */
.mega-menu-content > .sub-menu > li > a {
  display: block;
  padding: 0.3rem 0;
  color: #3bbac9;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: color 0.3s ease;
  margin-bottom: 0.1rem;
  text-transform: uppercase;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mega-menu-content > .sub-menu > li > a:hover {
  color: #2a8d99;
}

/* Pas de chevron pour les liens de niveau 2 dans la partie droite */
.mega-menu-content > .sub-menu > li.menu-item-has-children > a::after {
  display: none;
}

/* Sous-menus de niveau 3 : réduire l'espacement */
.mega-menu-content > .sub-menu > li > .sub-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  margin-top: 0.1rem;
}

/* Liens de niveau 3 dans la partie droite : uppercase, gray-darker, pas de chevron */
.mega-menu-content > .sub-menu > li > .sub-menu > li > a {
  display: block;
  padding: 0.3rem 0;
  color: #32323f;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.3s ease;
  margin-bottom: 0;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mega-menu-content > .sub-menu > li > .sub-menu > li > a:hover {
  color: #3bbac9;
}

/* Pas de chevron pour les liens de niveau 3 dans la partie droite */
.mega-menu-content
  > .sub-menu
  > li
  > .sub-menu
  > li.menu-item-has-children
  > a::after {
  display: none;
}

/* Sous-menus de niveau 4+ : réduire l'espacement */
.mega-menu-content .sub-menu .sub-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  margin-top: 0.1rem;
}

/* Liens de niveau 4+ */
.mega-menu-content .sub-menu .sub-menu li a {
  padding: 0.1rem 0;
  margin-bottom: 0;
  line-height: 1.3;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  color: var(--bs-gray-darker);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.875rem;
  transition: color 0.3s ease;
}

.mega-menu-content .sub-menu .sub-menu li a:hover {
  color: #3bbac9;
}

/* État actif pour l'item de niveau 1 survolé */
#main-menu .navbar-nav > li.mega-menu > .sub-menu > li.active > a {
  background-color: rgba(59, 186, 201, 0.05);
  border-left-color: #3bbac9;
  color: #3bbac9;
}

/* ============================================
   DROPDOWN CLASSIQUE (sans .mega-menu)
   ============================================ */

/* Dropdown classique */
#main-menu .navbar-nav > li.menu-item-has-children:not(.mega-menu) > .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 250px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 2%;
  list-style: none;
  z-index: 1000;
  padding: 0.5rem 0;
}

/* Pseudo-élément pour maintenir le hover entre le lien parent et le dropdown */
#main-menu
  .navbar-nav
  > li.menu-item-has-children:not(.mega-menu)
  > .sub-menu::before {
  content: '';
  position: absolute;
  top: -15%;
  left: 0;
  right: 0;
  height: 3rem;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}

/* Afficher le dropdown au hover */
#main-menu
  .navbar-nav
  > li.menu-item-has-children:not(.mega-menu):hover
  > .sub-menu {
  display: block;
}

/* Liens dans le dropdown classique */
#main-menu .navbar-nav > li:not(.mega-menu) > .sub-menu > li > a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--bs-gray-darker);
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.3s ease;
  white-space: nowrap;
}

#main-menu .navbar-nav > li:not(.mega-menu) > .sub-menu > li > a:hover {
  background-color: rgba(59, 186, 201, 0.05);
  color: #3bbac9;
}

/* Sous-sous-menus dans le dropdown classique */
#main-menu .navbar-nav > li:not(.mega-menu) .sub-menu .sub-menu {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 0.5rem;
  min-width: 250px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 0.5rem 0;
}

/* Pseudo-élément pour maintenir le hover entre l'item parent et le sous-sous-menu */
#main-menu .navbar-nav > li:not(.mega-menu) .sub-menu .sub-menu::before {
  content: '';
  position: absolute;
  top: 0;
  left: -0.5rem;
  bottom: 0;
  width: 0.5rem;
  background: transparent;
  pointer-events: auto;
}

/* Afficher les sous-sous-menus au hover */
#main-menu
  .navbar-nav
  > li:not(.mega-menu)
  .sub-menu
  .menu-item-has-children:hover
  > .sub-menu {
  display: block;
}

/* ============================================
   CARD MENU (avec .card-menu)
   ============================================ */

/* Container du card menu */
#main-menu .navbar-nav > li.card-menu > .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 0.5rem;
  list-style: none;
  z-index: 1000;
  padding: 2rem;
}

/* Pseudo-élément pour maintenir le hover */
#main-menu .navbar-nav > li.card-menu > .sub-menu::before {
  content: '';
  position: absolute;
  top: -0.5rem;
  left: 0;
  right: 0;
  height: 0.5rem;
  background: transparent;
  pointer-events: auto;
}

/* Afficher le card menu au hover */
#main-menu .navbar-nav > li.card-menu:hover > .sub-menu {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 2rem;
  justify-content: center;
  align-items: center;
}

/* Cards individuelles */
#main-menu .navbar-nav > li.card-menu > .sub-menu > li {
  background: #3bbac9;
  border-radius: 8px;
  padding: 2rem;
  display: flex !important;
  flex-direction: column !important;
  align-items: center;
  justify-content: center;
  width: 18rem !important;
  height: 16rem !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  text-align: center;
  position: relative !important;
  grid-column: unset !important;
}

/* Masquer le lien original */
#main-menu .navbar-nav > li.card-menu > .sub-menu > li > a {
  display: none;
}

/* Titre de la card */
#main-menu .navbar-nav > li.card-menu > .sub-menu > li::before {
  content: attr(data-title);
  display: block;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* Bouton "En savoir plus" */
#main-menu .navbar-nav > li.card-menu > .sub-menu > li .btn-white-bed {
  display: inline-block !important;
  padding: 0.75rem 2rem;
  background: white;
  color: #3bbac9;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-top: 1rem;
  z-index: 10;
  position: relative;
}

#main-menu .navbar-nav > li.card-menu > .sub-menu > li .btn-white-bed:hover {
  background: #f8f9fa;
  color: #3bbac9;
}

/* Items de niveau 2 dans le content */
#main-menu .navbar-nav > li > .sub-menu > li > .sub-menu > li {
  position: relative;
}

#main-menu .navbar-nav > li > .sub-menu > li > .sub-menu > li > a {
  display: block;
  padding: 0.75rem 0;
  color: #3bbac9;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: color 0.3s ease;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

#main-menu .navbar-nav > li > .sub-menu > li > .sub-menu > li > a:hover {
  color: #2a8d99;
}

/* Pas de chevron pour les liens de niveau 2 */
#main-menu
  .navbar-nav
  > li
  > .sub-menu
  > li
  > .sub-menu
  > li.menu-item-has-children
  > a::after {
  display: none;
}

/* Sous-sous-menus niveau 3+ dans le content : affichés en dessous avec indentation */
#main-menu .navbar-nav > li > .sub-menu > li > .sub-menu > li > .sub-menu {
  display: block !important;
  position: static;
  background: none;
  padding: 0;
  padding-left: 1rem;
  margin-top: 0.5rem;
  height: auto;
  grid-column: 1 / -1;
}

#main-menu
  .navbar-nav
  > li
  > .sub-menu
  > li
  > .sub-menu
  > li
  > .sub-menu
  > li
  > a {
  display: block;
  padding: 0.25rem 0;
  color: var(--bs-gray-darker);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.875rem;
  transition: color 0.3s ease;
}

#main-menu
  .navbar-nav
  > li
  > .sub-menu
  > li
  > .sub-menu
  > li
  > .sub-menu
  > li
  > a:hover {
  color: #3bbac9;
}

/* Items dans les sous-menus généraux (fallback) - ne s'applique PAS aux liens dans .mega-menu-content */
#main-menu .sub-menu li:not(.mega-menu-content *) {
  position: relative;
}

#main-menu .sub-menu li:not(.mega-menu-content *) > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 1.25rem;
  color: #3bbac9;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  white-space: nowrap;
}

#main-menu .sub-menu li:not(.mega-menu-content *) > a:hover {
  color: #3bbac9;
  background-color: rgba(59, 186, 201, 0.05);
}

/* Icônes dans les sous-menus */
#main-menu .sub-menu .menu-item-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

#main-menu .sub-menu .menu-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Chevron pour les items avec sous-sous-menu */
#main-menu .sub-menu .menu-item-has-children > a::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

/* ============================================
   SOUS-SOUS-MENUS NIVEAU 2+ (Flyout)
   ============================================ */

/* Sous-sous-menus : apparaissent à droite */
#main-menu .sub-menu .sub-menu {
  top: 0;
  left: 100%;
  margin-top: 0;
  margin-left: 0.5rem;
}

/* Afficher les sous-sous-menus au hover */
#main-menu .sub-menu .menu-item-has-children:hover > .sub-menu {
  display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Masquer le menu desktop sur mobile */
@media (max-width: 991px) {
  #main-menu {
    display: none !important;
  }
}
