* {
  box-sizing: border-box;
}

.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 120px;
  margin: auto;
  position: relative;
  background-color: #2c3e50;
  z-index: 7;
}

.menu li {
  float: left;
  height: 100%;
  margin: 0;
  padding: 0;
  width: calc(100% / var(--total-items));
}

.menu a {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  color: #fff;
  text-decoration: none;
  position: relative;
  font-size: 18px;
  z-index: 9;
}

.menu-logo {
  height: 40px;
  width: auto;
  display: block;
  margin: auto;
}

a.active {
  background-color: #B4B8AB;
}

.slider {
  width: calc(100% / var(--total-items));
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background-color: #B4B8AB;
  z-index: 8;
  transition: left 0.4s ease, background-color 0.4s;
}

/* Estilos para menús agrupados */
.menu-group {
  position: relative;
}

.submenu {
  display: block;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: #34495e;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.menu-group:hover .submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.submenu li {
  width: 100% !important;
  height: auto !important;
  overflow: hidden;
}

.submenu a {
  padding: 15px 0;
  justify-content: center;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
}

.submenu a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background-color: #B4B8AB;
  transition: left 0.3s ease;
}

.submenu a:hover {
  background-color: rgba(180, 184, 171, 0.2);
  color: #B4B8AB;
}

.submenu a:hover::before {
  left: 0;
}

.menu-group:hover ~ .slider {
  background-color: #B4B8AB !important;
}





.navbar-container {
  position: relative;
  width: 100%;
}

/* Botón hamburguesa */
.menu-toggle {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  z-index: 1001;
  background: #2c3e50;
  color: white;
  padding: 15px;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 1.5rem;
  text-align: right;
  border-bottom: 1px solid #3d5166;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Menú mobile */
.mobile-menu {
  display: none;
  flex-direction: column;
  position: fixed;
  top: -100vh; /* Cambiado a viewport height */
  left: 0;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 60px); /* Restamos la altura del botón */
  background: #2c3e50; /* Fondo sólido */
  transition: top 0.4s ease-out;
  padding: 0;
  margin-top: 60px; /* Empieza debajo del botón */
  z-index: 998; /* Un nivel menos que el botón */
  overflow-y: auto; /* Scroll si es necesario */
}

.mobile-menu.active {
  top: 0;
}

.mobile-menu li:first-child a {
  padding-top: 30px;
}

.mobile-menu li {
  width: 100%;
  height: auto;
}

.mobile-menu a {
  padding: 15px;
  text-align: left;
}

.mobile-menu .menu-logo {
  margin: 0 auto 20px;
}

body {
  padding-top: 0; /* Compensa la altura del botón fijo */
}

/* Responsividad */
@media (max-width: 1090px) {
  .desktop-menu {
      display: none;
  }

  .menu-toggle {
      display: block;
  }

  .mobile-menu {
      display: flex;
  }
}

@media (max-width: 1090px) {
  /* Estilos para menús agrupados en mobile */
  .mobile-menu .menu-group {
    position: relative;
  }

  .mobile-menu .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #34495e;
    width: 100%;
    position: relative;
    top: 0;
    left: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: block !important; /* Forzar display */
  }

  .mobile-menu .menu-group.active .submenu {
    max-height: 500px; /* Valor suficiente para mostrar todo */
  }

  /* Flecha indicadora */
  .mobile-menu .menu-group > a::after {
    float: right;
    transition: transform 0.3s;
  }

  .mobile-menu .menu-group.active > a::after {
    transform: rotate(180deg);
  }

  /* Ajuste de altura del menú mobile */
  .mobile-menu {
    max-height: 100vh;
    overflow-y: auto;
  }

  .mobile-menu.active {
    height: auto;
    max-height: calc(100vh - 60px); /* Altura máxima menos el botón */
    overflow-y: auto; /* Scroll si es necesario */
  }

  body {
    padding-top: 60px; /* Compensa la altura del botón fijo */
  }
}

