/* ============================================
   AI4PDG — Navigation & Footer CSS — Megamenú v2
   ============================================ */

/* ---- NAV ---- */
#main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  z-index: 1000;
  background: transparent;
  border-bottom: 0.5px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

#main-nav.scrolled {
  background: var(--bg-surface);
  border-bottom-color: var(--border);
  backdrop-filter: blur(12px);
  opacity: 0.97;
}

.nav-inner {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo:hover { color: var(--text-primary); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 4px;
  flex: 1;
  justify-content: center;
  align-items: center;
}

.nav-link {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 6px 14px;
  text-decoration: none;
  transition: color var(--transition);
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 14px; right: 14px;
  height: 0.5px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--transition);
}
.nav-link:hover { color: var(--text-primary); }
.nav-link:hover::after { transform: scaleX(1); }
.nav-link.active { color: var(--accent); }
.nav-link.active::after { transform: scaleX(1); }

/* ---- Mega menu wrapper ---- */
.mega-wrap {
  position: relative;
  list-style: none;
  /* Extend the hover area downward so the cursor doesn't leave the wrap
     when moving from the button toward the panel below */
  padding-bottom: 16px;
  margin-bottom: -16px;
}

/* Ensure the nav-links ul does not clip the dropdown */
.nav-links {
  overflow: visible;
}

.mega-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

/* ---- Mega panel ---- */
/* Bridge: invisible area above the panel that connects it to the button,
   preventing mouseleave from firing when moving cursor from button to panel */
.mega-panel::before {
  content: '';
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  height: 16px;
  background: transparent;
  pointer-events: auto;
}
.mega-panel {
  display: none;
  visibility: hidden;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  min-width: 260px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  border-top: 0.5px solid var(--accent);
  z-index: 999;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  animation: megaFadeIn 0.18s ease;
  overflow: visible;
}

@keyframes megaFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.mega-panel.open {
  display: block;
  visibility: visible;
}

.mega-panel-inner {
  padding: 8px 0;
}

/* Column layout */
.mega-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  min-width: 480px;
}
.mega-col.mega-col-3 {
  grid-template-columns: 1fr 1fr 1fr !important;
  min-width: 720px !important;
}

.mega-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
  border: 0.5px solid transparent;
  border-left: 0.5px solid transparent;
  position: relative;
}

.mega-item:hover {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}

.mega-item-active {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}

.mega-item-icon {
  width: 18px;
  height: 18px;
  line-height: 1;
  margin-top: 3px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mega-item:hover .mega-item-icon {
  color: var(--accent);
}
.mega-item-active .mega-item-icon {
  color: var(--accent);
}

.mega-item-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mega-item-title {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  transition: color var(--transition);
}

.mega-item:hover .mega-item-title {
  color: var(--accent);
}

.mega-item-active .mega-item-title {
  color: var(--accent);
}

.mega-item-desc {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  line-height: 1.45;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* ---- Grouped mega layout (CONTENIDO) ---- */
.mega-grouped {
  display: grid;
  grid-template-columns: 220px 0.5px 1fr 0.5px 1fr;
  min-width: 860px;
  gap: 0;
}

.mega-section-divider {
  background: var(--border);
  width: 0.5px;
  margin: 8px 0;
}

.mega-section {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.mega-section-header {
  font-family: var(--font-body);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-tertiary);
  padding: 6px 16px 8px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 4px;
}

/* Acceso rápido column: items slightly larger */
.mega-grouped .mega-section:first-child .mega-item {
  padding: 7px 16px;
}
.mega-grouped .mega-section:first-child .mega-item-title {
  font-size: 0.85rem;
}
.mega-grouped .mega-section:first-child .mega-item-desc {
  font-size: 0.80rem;
}

/* ---- "Más" dropdown ---- */
.nav-more-wrap {
  position: relative;
}
.nav-more-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  min-width: 180px;
  list-style: none;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
.nav-more-dropdown.open { display: block; }
.nav-more-dropdown li a {
  display: block;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.nav-more-dropdown li a:hover {
  color: var(--accent);
  background: var(--accent-subtle);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Theme toggle removed — sistema de diseño Ágere no usa modo oscuro */
.theme-toggle { display: none !important; }

/* ---- Hamburger ---- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  transition: all var(--transition);
}

/* ---- Mobile menu ---- */
.nav-mobile {
  display: none;
  background: var(--bg-surface);
  border-top: 0.5px solid var(--border);
  padding: 16px 0;
}
.nav-mobile.open { display: block; }
.nav-mobile ul { list-style: none; }
.nav-mobile li a {
  display: block;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.nav-mobile li a:hover { color: var(--accent); }

@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .nav-search-wrap { display: none; }
  .mega-panel { display: none !important; }
}

/* ---- Global Search ---- */
.nav-search-wrap {
  position: relative;
}
.nav-search-btn {
  background: transparent;
  border: 0.5px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.nav-search-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.nav-search-box {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: width 0.25s cubic-bezier(0.23,1,0.32,1), opacity 0.2s;
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  z-index: 2000;
}
.nav-search-box.open {
  width: 320px;
  opacity: 1;
}
.nav-search-box input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-primary);
  padding: 10px 14px;
  box-sizing: border-box;
}
.nav-search-box input::placeholder { color: var(--text-tertiary); }
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 8px + 42px);
  right: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  z-index: 2001;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.gsd-heading {
  font-family: var(--font-body);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  padding: 10px 14px 4px;
}
.gsd-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 14px;
  text-decoration: none;
  transition: background var(--transition);
  border-top: 0.5px solid var(--border);
}
.gsd-item:hover { background: var(--bg-elevated); }
.gsd-badge {
  font-family: var(--font-body);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 60px;
}
.gsd-title {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.35;
}
.gsd-empty {
  padding: 20px 14px;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* ---- Page offset for fixed nav ---- */
.page-content {
  padding-top: var(--nav-height);
}

/* ---- FOOTER ---- */
#main-footer {
  background: var(--bg-surface);
  border-top: 0.5px solid var(--border);
  margin-top: var(--section-y);
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: grid;
  grid-template-columns: 220px 1fr 1fr 1fr;
  gap: 48px;
  padding: 56px 0 40px;
  align-items: flex-start;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-tagline {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  max-width: 200px;
  line-height: 1.6;
  margin-top: 4px;
}

.footer-cols {
  display: contents;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.footer-col-title {
  font-family: var(--font-head);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 16px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.footer-col ul li {
  border-bottom: 0.5px solid var(--border);
}

.footer-col ul li:last-child {
  border-bottom: none;
}

.footer-col ul li a {
  display: block;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 7px 0;
  transition: color var(--transition), padding-left var(--transition);
}

.footer-col ul li a:hover {
  color: var(--accent);
  padding-left: 6px;
}

/* Legacy .footer-links support */
.footer-links ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.footer-links a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--accent); }

.footer-bottom {
  border-top: 0.5px solid var(--border);
  padding: 16px 0;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 1024px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
  .footer-cols {
    display: contents;
  }
}

@media (max-width: 640px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .footer-brand {
    grid-column: 1;
  }
}

/* ── Back to top button ── */
#back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.3s ease, background var(--transition);
  pointer-events: none;
}
#back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#back-to-top:hover {
  background: var(--accent-hover);
}
#back-to-top svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 640px) {
  #back-to-top { bottom: 20px; right: 20px; }
}

/* ---- Mega-menu separator (used in HERRAMIENTAS for Creatividad IA block) ---- */
.mega-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 4px;
  margin-top: 4px;
  border-top: 0.5px solid var(--border);
}
.mega-separator-label {
  font-family: var(--font-body);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  white-space: nowrap;
}

/* ── HERRAMIENTAS: 2-section grouped layout ── */
.mega-grouped-2col {
  grid-template-columns: 1fr 0.5px 1fr;
  min-width: 760px;
}
.mega-grouped-2col .mega-section {
  padding: 8px 0;
}
