/* PDF Tools Mega Menu Styles (Fixed Positioning & Zero-Gap Hover Bridge) */

/* Make clean-nav relative parent so mega-menu centers across whole screen */
.clean-nav {
  position: relative !important;
}

.nav-mega-wrap {
  display: inline-flex;
  align-items: center;
}

@media (min-width: 1051px) {
  .nav-mega-wrap {
    position: static; /* Centers the mega-menu relative to .clean-nav container */
  }
}

.nav-tools-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: #111b34;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Hover Bridge on the link to prevent cursor dead-zone */
.nav-tools-link::after {
  content: "";
  position: absolute;
  top: 100%;
  left: -10px;
  right: -10px;
  height: 25px;
  background: transparent;
  pointer-events: auto;
}

.nav-tools-link:hover,
.nav-tools-link.active,
.nav-mega-wrap.open .nav-tools-link,
.nav-mega-wrap:hover .nav-tools-link {
  background: #edf4ff;
  color: #1769f6;
}

.nav-caret {
  font-size: 9px;
  transition: transform 0.2s ease;
}

.nav-mega-wrap.open .nav-caret,
.nav-mega-wrap:hover .nav-caret {
  transform: rotate(180deg);
}

/* Floating Mega Menu */
.pdf-mega-menu {
  position: absolute;
  top: calc(100% - 2px);
  left: 20px;
  right: 20px;
  width: auto;
  max-width: 1260px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 16px;
  box-shadow: 0 25px 60px -10px rgba(7, 27, 61, 0.22), 0 0 0 1px rgba(7, 27, 61, 0.04);
  padding: 24px 20px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  transition-delay: 0.12s; /* Grace period so moving mouse doesn't close menu */
  z-index: 1050;
}

/* Top invisible hover bridge on mega menu */
.pdf-mega-menu::after {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 24px;
  background: transparent;
  pointer-events: auto;
}

/* Arrow pointer at top */
.pdf-mega-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  left: var(--arrow-left, 380px);
  transform: translateX(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-top: 1px solid #dce5f0;
  border-left: 1px solid #dce5f0;
  z-index: 2;
}

/* Show on hover OR click (.open) */
.nav-mega-wrap:hover .pdf-mega-menu,
.nav-mega-wrap.open .pdf-mega-menu,
.pdf-mega-menu:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

/* Column Structure */
.mega-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mega-col-title {
  font-size: 11px;
  font-weight: 800;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #edf2f7;
  white-space: nowrap;
}

.mega-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #1e293b;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  transition: all 0.16s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mega-item:hover {
  background: #f1f5f9;
  color: #1769f6;
  transform: translateX(2px);
}

.mega-item:hover .mega-icon {
  transform: scale(1.08);
}

/* Icon Badges */
.mega-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: transform 0.16s ease;
}

.mega-icon.red { background: #fee2e2; color: #dc2626; }
.mega-icon.green { background: #dcfce7; color: #16a34a; }
.mega-icon.blue { background: #dbeafe; color: #2563eb; }
.mega-icon.yellow { background: #fef9c3; color: #ca8a04; }
.mega-icon.orange { background: #ffedd5; color: #ea580c; }
.mega-icon.purple { background: #f3e8ff; color: #9333ea; }
.mega-icon.navy { background: #e0e7ff; color: #3730a3; }
.mega-icon.ai { background: linear-gradient(135deg, #ede9fe, #fae8ff); color: #7c3aed; }

/* Mega Menu Footer Bar */
.mega-footer-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid #edf2f7;
  margin-top: 6px;
  font-size: 12.5px;
  color: #64748b;
}

.mega-all-tools-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1769f6, #0d55cd);
  color: #ffffff !important;
  font-size: 12.5px;
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(23, 105, 246, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.mega-all-tools-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(23, 105, 246, 0.35);
  color: #ffffff !important;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .pdf-mega-menu {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px;
  }
}

@media (max-width: 1050px) {
  .nav-mega-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }
  .nav-tools-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
  }
  .nav-tools-link::after {
    display: none;
  }
  .nav-tools-link .nav-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: #edf4ff;
    color: #1769f6;
    font-size: 11px;
    transition: transform 0.25s ease;
  }
  .nav-mega-wrap.open .nav-caret {
    transform: rotate(180deg);
  }
  .pdf-mega-menu {
    position: static;
    transform: none !important;
    width: 100% !important;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    margin-top: 8px;
    display: none;
    max-height: none !important;
    overflow: visible !important;
    padding: 12px;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    gap: 10px;
    grid-template-columns: 1fr;
  }
  .pdf-mega-menu::before,
  .pdf-mega-menu::after {
    display: none;
  }
  .nav-mega-wrap.open .pdf-mega-menu {
    display: flex;
    flex-direction: column;
  }
  .mega-col {
    background: #ffffff;
    border: 1px solid #edf2f7;
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  }
  .mega-col-title {
    font-size: 10.5px;
    font-weight: 800;
    color: #1769f6;
    letter-spacing: 0.08em;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 6px;
  }
  .mega-item {
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 13px;
  }
  .mega-item:hover, .mega-item:active {
    background: #edf4ff;
  }
  .mega-footer-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding-top: 10px;
  }
  .mega-all-tools-cta {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 13.5px;
  }
}
