/**
 * Navigation Fix CSS
 * Prevents ghost loading and animation issues
 */

/* Prevent animations on initial page load */
body:not(.nav-ready) .sc-nav-item-enterprise {
  animation: none !important;
}

body:not(.nav-ready) .sc-nav-enterprise {
  transition: none !important;
}

body:not(.nav-ready) .sc-mega-menu {
  transition: none !important;
}

body:not(.nav-ready) .sc-mobile-menu-overlay {
  transition: none !important;
}

/* Override the automatic slideIn animation */
@media (min-width: 1025px) {
  .sc-nav-item-enterprise {
    animation: none !important;
  }
  
  /* Add animation only when nav is ready and user hovers */
  body.nav-ready .sc-nav-item-enterprise:hover {
    animation: subtle-bounce 0.3s ease;
  }
}

@keyframes subtle-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Fix mobile menu positioning to use transform instead of right */
@media (max-width: 1024px) {
  .sc-nav-enterprise {
    right: 0 !important;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  
  .sc-nav-enterprise.active {
    transform: translateX(0);
  }
  
  /* Ensure mobile menu is hidden initially */
  body:not(.nav-ready) .sc-nav-enterprise {
    visibility: hidden;
  }
  
  body.nav-ready .sc-nav-enterprise {
    visibility: visible;
  }
}

/* Prevent flash of unstyled content for mega menus */
.sc-mega-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sc-nav-item-enterprise:hover .sc-mega-menu,
.sc-nav-item-enterprise.active .sc-mega-menu,
.has-mega-menu[aria-expanded="true"] + .sc-mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Ensure overlay starts hidden */
.sc-mobile-menu-overlay {
  display: none;
  opacity: 0;
}

.sc-mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}

/* Fix z-index stacking issues */
.sc-header-enterprise {
  z-index: 1000;
}

.sc-menu-toggle-enterprise {
  z-index: 1002;
  position: relative;
}

.sc-nav-enterprise {
  z-index: 1001;
}

.sc-mobile-menu-overlay {
  z-index: 999;
}

/* Ensure menu toggle is always clickable */
.sc-menu-toggle-enterprise {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent iOS bounce effect */
@media (max-width: 1024px) {
  .sc-nav-enterprise {
    position: fixed;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  
  .sc-nav-enterprise.active {
    overflow-y: auto;
  }
}

/* Smooth transitions only after nav is ready */
body.nav-ready .sc-header-enterprise {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

body.nav-ready .sc-menu-toggle-enterprise .sc-menu-bar-enterprise {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Fix for header scroll behavior */
.sc-header-enterprise.hide-nav {
  transform: translateY(-100%);
}

.sc-header-enterprise.show-nav {
  transform: translateY(0);
}

/* Ensure proper stacking during scroll */
.sc-header-enterprise.scrolled {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Mobile menu animation improvements */
@media (max-width: 1024px) {
  /* Stagger nav items only when opening */
  .sc-nav-enterprise.active .sc-nav-item-enterprise {
    animation: slideInRight 0.4s ease backwards;
  }
  
  .sc-nav-enterprise.active .sc-nav-item-enterprise:nth-child(1) { animation-delay: 0.05s; }
  .sc-nav-enterprise.active .sc-nav-item-enterprise:nth-child(2) { animation-delay: 0.1s; }
  .sc-nav-enterprise.active .sc-nav-item-enterprise:nth-child(3) { animation-delay: 0.15s; }
  .sc-nav-enterprise.active .sc-nav-item-enterprise:nth-child(4) { animation-delay: 0.2s; }
  .sc-nav-enterprise.active .sc-nav-item-enterprise:nth-child(5) { animation-delay: 0.25s; }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Prevent double-tap zoom on iOS */
.sc-menu-toggle-enterprise,
.sc-nav-link-enterprise,
.sc-mega-menu-link {
  touch-action: manipulation;
}

/* Ensure clickable area for menu toggle */
.sc-menu-toggle-enterprise {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Debug helper - remove in production */
body:not(.nav-ready)::before {
  content: "Navigation loading...";
  position: fixed;
  top: 0;
  left: 0;
  background: #ff0000;
  color: white;
  padding: 2px 8px;
  font-size: 10px;
  z-index: 9999;
  display: none; /* Enable for debugging */
}