/* --- 2. HEADER Y NAVEGACIÓN --- */
.header {
  width: 100%;
  background: #fff;
  top: 0;
  position: relative;
  box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.1);
  z-index: 1000;
}

.nav-container {
  max-width: 1000px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 70px;
}
 
.logo a { 
  text-decoration: none; 
  font-size: 24px; 
  color: #334155; 
  display: flex; 
  align-items: center; 
}

/* --- 3. BOTÓN HAMBURGUESA (CON TRANSFORMACIÓN A X) --- */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 10px;
  z-index: 1100;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  background: #333;
  transition: all 0.3s ease-in-out;
  transform-origin: center;
}

/* Animación de la cruz */
.menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; transform: translateX(-20px); }
.menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* --- 4. LISTA DE NAVEGACIÓN Y FLECHAS --- */
.ul-nav { 
  display: flex; 
  margin-left: 0;
  list-style: none; 
  height: 100%; 
}

.ul-nav > li { 
  display: flex; 
  align-items: center; 
  margin-top: 0;
}

.ul-nav > li > a {
  padding: 0 18px;
  text-decoration: none;
  color: #111;
  font-weight: 600;
  font-size: 15px;
  height: 100%;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.ul-nav > li > a:hover { color: #6a11cb; }

/* Icono de flecha ▼ */
.ul-nav > li.has-mega > a::after {
  content: '▼';
  font-size: 10px;
  margin-left: 8px;
  opacity: 0.4;
  display: inline-block;
  transition: transform 0.3s ease;
}

/* También asegúrate de que la rotación apunte solo a .has-mega (aunque ya debería estar así) */
.has-mega.open > a::after { 
  transform: rotate(180deg); 
}

/* --- 5. MEGA MENÚ (ESCRITORIO - SOLO HOVER) --- */
@media (min-width: 993px) {
  .mega-menu-content {
      display: none;
      position: absolute;
      top: 70px;
      left: 50%;
      transform: translateX(-50%);
      width: 95vw;
      max-width: 1000px;
      background: #fff;
      border: 1px solid #eee;
      box-shadow: 0 20px 50px rgba(0,0,0,0.15);
      z-index: 9999;
      grid-template-columns: 240px 1fr;
  }

  .ul-nav > li:hover .mega-menu-content { 
      display: grid; 
  }
}

/* --- 6. COMPONENTES INTERNOS DEL MEGA MENÚ --- */
/* Sidebar */
.mega-sidebar { background: #fcfcfc; border-right: 1px solid #eee; padding: 15px 0; }
.sidebar-item {
  padding: 12px 25px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: #555;
  border-left: 4px solid transparent;
  transition: 0.2s;
}
.sidebar-item:hover, .sidebar-item.active {
  background: #fff;
  color: #6a11cb;
  border-left-color: #6a11cb;
}

/* Contenido Principal */
.mega-main { padding: 30px; }
.mega-main h3 { font-size: 18px; margin-bottom: 20px;margin-top: 0; font-weight: 800; border-bottom: 2px solid #eee;}
.category-group { display: none; }
.category-group.active { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Tarjetas de Producto */
.mega-card {
  text-decoration: none;
  text-align: center;
  color: inherit;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid #eee;
  background: #fff;
  transition: 0.2s;
}
.mega-card:hover { border-color: #6a11cb; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.mega-card img { width: 100%; height: 50px; object-fit: contain;  }
.mega-card h4 { font-size: 13px; margin-bottom: 4px; font-weight: 700;margin-top: 0; }
.mega-card p { font-size: 11px; color: #777; line-height: 1.4; }

/* Pipeline y Actividad */
.pipeline-bar {
  margin-top: 30px; padding: 20px; background: #fdfdfd; border: 1px solid #eee; border-radius: 4px; display: flex; gap: 40px;
}
.pipeline-item { font-size: 11px; font-weight: 800; color: #888; text-transform: uppercase; }
.pipeline-item span { color: #000; font-family: monospace; font-size: 15px; margin-left: 8px; }

.mega-activity { padding: 25px; background: #fafafa; border-left: 1px solid #eee; }
.mega-activity h4 { font-size: 12px; text-transform: uppercase; color: #9ca3af; margin-bottom: 15px; font-weight: 800; }
.latest-box { background: #fff; padding: 15px; border: 1px solid #eee; border-radius: 4px; }
.latest-box p { font-size: 13px; font-weight: 600; line-height: 1.5; color: #333; }
.mega-sidebar ul {
  list-style: none;
  margin-left: 0;
}
/* --- 7. MOBILE RESPONSIVE (MÁXIMO 992px) --- */
@media (max-width: 992px) {
  .menu-toggle { display: flex; }
  #main-nav {
    max-height: 80vh; /* Ocupa todo el alto de la pantalla */
    /* ESTO ARREGLA EL SCROLL */
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; /* Suavidad en iOS */
    
    z-index: 999;
    transition: all 0.3s ease;
    background: #fff;
  }
  .ul-nav {
      display: none;
      flex-direction: column;
      position: absolute;
      top: 70px;
      left: 0;
      width: 100%;
      background: #fff;
      height: fit-content;

      overflow-y: auto;
      border-top: 1px solid #eee;
  }

  .ul-nav.active { display: flex; }

  .ul-nav > li { display: block; width: 100%; border-bottom: 1px solid #f5f5f5; }

  .ul-nav > li > a { 
      width: 100%; 
      height: 60px; 
      padding: 0 20px; 
      justify-content: space-between;
      font-size: 15px;
  }

  /* Rotación de flecha en móvil al abrir */
  .has-mega.open > a::after { transform: rotate(180deg); color: #6a11cb; opacity: 1; }

  /* Forzar ocultamiento del contenido si NO está abierto */
  .mega-menu-content {
      display: none !important;
      position: static;
      width: 100%;
      grid-template-columns: 1fr;
      box-shadow: none;
      border: none;
  }

  .has-mega.open .mega-menu-content { 
      display: block !important; 
  }

  /* Sidebar horizontal en móvil */
  .mega-sidebar { border-right: none; border-bottom: 1px solid #eee; }
  .mega-sidebar ul { display: flex; overflow-x: auto; padding: 10px; gap: 8px; list-style:none;}
  .sidebar-item {
      flex-shrink: 0; padding: 8px 15px; border-left: none; border-radius: 20px;
      background: #f4f4f7; font-size: 13px; border: 1px solid transparent;
  }
  .sidebar-item.active { border-color: #6a11cb; background: #fff; }

  .mega-main { padding: 20px 15px; }
  .category-group.active { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  
  .pipeline-bar { flex-direction: row; justify-content: space-between; gap: 10px; padding: 15px; }
  .mega-activity { border-left: none; border-top: 1px solid #eee; }
}

@media (max-width: 300px) {
  .category-group.active { grid-template-columns: 1fr; }
}
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Color negro traslúcido */
  backdrop-filter: blur(4px);    /* Efecto de desenfoque moderno */
  z-index: 998;                  /* Por debajo del nav (que debería ser 999) */
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

#overlay.overlay-active {
  opacity: 1;
  visibility: visible;
}

