/**
 * NextGen TechEdge Solutions - Centralized Reusable Header Stylesheet
 * Authoritative Modular Stylesheet for Desktop 5-Column Mega Menu & Mobile Drawer
 */

:root {
  --header-height: 84px;
  --brand-purple: #8426b0;
  --brand-fuchsia: #b81c8c;
  --brand-coral: #df414c;
  --brand-gradient: linear-gradient(135deg, #8426b0 0%, #b81c8c 50%, #df414c 100%);
  --brand-gradient-hover: linear-gradient(135deg, #6c1f91 0%, #9e1878 50%, #c4323d 100%);
  --brand-glow: 0 10px 25px -5px rgba(132, 38, 176, 0.35);
  --brand-glow-lg: 0 14px 35px -5px rgba(132, 38, 176, 0.5);
  --header-bg: rgba(255, 255, 255, 0.92);
  --header-bg-scrolled: rgba(255, 255, 255, 0.98);
  --text-main: #171124;
  --text-body: #4a4256;
  --text-muted: #6a6279;
  --border-light: rgba(132, 38, 176, 0.12);
}

/* Smooth anchor scrolling offset accounting for fixed header */
html {
  scroll-padding-top: var(--header-height);
}

[id] {
  scroll-margin-top: var(--header-height);
}

/* --------------------------------------------------------------------------
   1. FIXED HEADER CONTAINER
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10000;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  background: var(--header-bg-scrolled);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.site-header .container {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

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

/* --------------------------------------------------------------------------
   2. BRAND LOGO
   -------------------------------------------------------------------------- */
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
}

.logo-img {
  height: 44px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.logo-container:hover .logo-img {
  transform: scale(1.02);
}

.logo-container:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 4px;
  border-radius: 6px;
}

/* --------------------------------------------------------------------------
   3. PRIMARY NAVIGATION LINKS
   -------------------------------------------------------------------------- */
.main-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 1.4vw, 1.6rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  position: relative;
  flex-shrink: 0;
}

/* Ensure desktop mega-menu item is statically positioned so dropdown spans the full 1320px header container */
@media (min-width: 1081px) {
  .site-header .nav-item.has-mega-menu,
  .nav-item.has-mega-menu,
  li.has-mega-menu {
    position: static !important;
  }

  .site-header .container {
    position: relative !important;
  }

  .site-header .mega-menu,
  .mega-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
  }
}

.nav-link {
  color: var(--text-body);
  text-decoration: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.94rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  white-space: nowrap !important;
  line-height: 1.2;
  transition: color 0.2s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-purple) !important;
}

.nav-link svg {
  opacity: 0.65;
  transition: transform 0.22s ease, opacity 0.22s ease, stroke 0.22s ease;
  flex-shrink: 0;
}

.nav-link:hover svg,
.nav-link.active svg {
  opacity: 1;
  stroke: var(--brand-purple);
}

.nav-link:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 4px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   4. 5-COLUMN FULL-WIDTH MEGA-MENU
   -------------------------------------------------------------------------- */
.mega-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid rgba(132, 38, 176, 0.16);
  border-top: 1px solid rgba(132, 38, 176, 0.08);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 28px 60px -12px rgba(17, 12, 28, 0.18), 0 0 0 1px rgba(132, 38, 176, 0.04);
  padding: 30px 32px 20px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s;
  z-index: 1000;
  pointer-events: none;
}

/* Invisible safety bridge preventing hover drop when cursor glides down */
.mega-menu::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  height: 24px;
  background: transparent;
  pointer-events: auto;
}

/* Desktop open states: Hover, Focus within, or programmatic open */
.nav-item.has-mega-menu:hover .mega-menu,
.nav-item.has-mega-menu:focus-within .mega-menu,
.nav-item.has-mega-menu.is-open .mega-menu,
.nav-item.has-mega-menu.is-hovered .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-item.has-mega-menu:hover > .nav-link svg,
.nav-item.has-mega-menu.is-hovered > .nav-link svg,
.nav-item.has-mega-menu.is-open > .nav-link svg {
  transform: rotate(180deg);
  opacity: 1;
  stroke: var(--brand-purple);
}

.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 22px;
  margin-bottom: 22px;
}

.mega-col {
  display: flex;
  flex-direction: column;
}

.mega-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-purple);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1.5px solid rgba(132, 38, 176, 0.12);
}

.mega-col-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-purple);
  flex-shrink: 0;
}

.mega-col-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mega-col-list li {
  margin: 0;
  padding: 0;
}

.mega-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none !important;
  color: inherit;
  transition: background 0.18s ease, transform 0.18s ease;
}

.mega-link:hover,
.mega-link:focus-visible {
  background: rgba(132, 38, 176, 0.06);
  transform: translateX(3px);
}

.mega-link-title {
  display: block;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main) !important;
  line-height: 1.3;
  text-decoration: none !important;
}

.mega-link:hover .mega-link-title {
  color: var(--brand-purple) !important;
}

.mega-link-desc {
  display: block;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.72rem;
  color: var(--text-muted) !important;
  line-height: 1.35;
  margin-top: 2px;
  text-decoration: none !important;
}

.mega-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(132, 38, 176, 0.1);
  padding-top: 16px;
  font-size: 0.84rem;
}

.mega-bottom-left {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.mega-bottom-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mega-bottom-link {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-weight: 700;
  color: var(--brand-purple) !important;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.mega-bottom-link:hover {
  color: var(--brand-fuchsia) !important;
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   4B. COMPACT DROPDOWN SUBMENU (LEGAL)
   -------------------------------------------------------------------------- */
.nav-item.has-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 200px;
  background: #ffffff;
  border: 1px solid rgba(132, 38, 176, 0.16);
  border-radius: 12px;
  box-shadow: 0 16px 36px -8px rgba(17, 12, 28, 0.15), 0 0 0 1px rgba(132, 38, 176, 0.04);
  padding: 10px 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.2s;
  z-index: 1000;
  pointer-events: none;
}

/* Hover safety bridge */
.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  height: 16px;
  background: transparent;
  pointer-events: auto;
}

.nav-item.has-dropdown:hover .dropdown-menu,
.nav-item.has-dropdown:focus-within .dropdown-menu,
.nav-item.has-dropdown.is-open .dropdown-menu,
.nav-item.has-dropdown.is-hovered .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.nav-item.has-dropdown:hover > .nav-link svg,
.nav-item.has-dropdown.is-hovered > .nav-link svg,
.nav-item.has-dropdown.is-open > .nav-link svg {
  transform: rotate(180deg);
  opacity: 1;
  stroke: var(--brand-purple);
}

.dropdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-link {
  display: block;
  padding: 9px 14px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.90rem;
  font-weight: 600;
  color: var(--text-body);
  text-decoration: none !important;
  border-radius: 8px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

.dropdown-link:hover,
.dropdown-link:focus-visible {
  background: rgba(132, 38, 176, 0.06);
  color: var(--brand-purple) !important;
  transform: translateX(3px);
  outline: none;
}

/* --------------------------------------------------------------------------
   5. HEADER ACTIONS (CTA BUTTON & MOBILE TOGGLE)
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.btn-talk {
  background: var(--brand-gradient);
  color: #ffffff !important;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 11px 24px;
  border-radius: 26px;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  box-shadow: var(--brand-glow);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-talk:hover {
  background: var(--brand-gradient-hover);
  transform: translateY(-2px);
  box-shadow: var(--brand-glow-lg);
  color: #ffffff !important;
}

.btn-talk:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 3px;
}

.btn-talk svg {
  transition: transform 0.2s ease;
}

.btn-talk:hover svg {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   6. MOBILE TOGGLE & RESPONSIVE DRAWER
   -------------------------------------------------------------------------- */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
  z-index: 10002;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-toggle:hover {
  background: rgba(132, 38, 176, 0.08);
}

.mobile-toggle:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 2px;
}

.mobile-toggle span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text-main);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
  pointer-events: none;
}

/* Animated X state */
.mobile-toggle.open span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.mobile-toggle.open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-toggle.open span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* Mobile & Tablet Breakpoint (<= 1080px) */
@media (max-width: 1080px) {
  .mobile-toggle {
    display: flex;
  }

  .main-nav {
    display: none;
  }

  .main-nav.active {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    padding: 24px 28px 36px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.14);
    border-bottom: 1px solid var(--border-light);
    gap: 1.1rem;
    align-items: stretch;
    z-index: 10001;
    transform: translateZ(0);
    will-change: transform;
  }

  .main-nav .nav-item {
    width: 100%;
  }

  .main-nav .nav-link {
    font-size: 1.05rem;
    padding: 10px 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(132, 38, 176, 0.06);
  }

  .nav-item.has-mega-menu {
    position: relative;
    width: 100%;
  }

  .nav-item.has-dropdown {
    position: relative;
    width: 100%;
  }

  /* Mobile Mega Menu & Dropdown Accordions */
  .mega-menu,
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-left: 2px solid rgba(132, 38, 176, 0.25);
    margin: 8px 0 12px 10px;
    padding: 10px 0 10px 16px;
    background: transparent;
    pointer-events: auto;
    display: none;
  }

  .dropdown-menu {
    min-width: 0;
    padding: 6px 0 6px 14px;
  }

  .dropdown-link {
    font-size: 0.96rem;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(132, 38, 176, 0.04);
  }

  .nav-item.has-mega-menu.is-open .mega-menu,
  .nav-item.has-dropdown.is-open .dropdown-menu {
    display: block;
    animation: mobileAccordionOpen 0.25s ease-out forwards;
  }

  @keyframes mobileAccordionOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .mega-menu-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-bottom: 16px;
  }

  .mega-col-header {
    font-size: 0.72rem;
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  .mega-link {
    padding: 8px 10px;
  }

  .mega-link-title {
    font-size: 0.88rem;
  }

  .mega-bottom-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .site-header .container {
    padding: 0 16px;
  }

  .mobile-toggle {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
    padding: 8px !important;
    touch-action: manipulation;
  }

  .logo-img {
    height: 38px;
    max-width: 155px;
  }

  .btn-talk {
    padding: 9px 16px;
    font-size: 0.84rem;
  }

  .btn-talk span {
    display: none;
  }

  .btn-talk::after {
    content: "Talk to Us";
  }
}

/* --------------------------------------------------------------------------
   7. PRINT STYLES
   -------------------------------------------------------------------------- */
@media print {
  .site-header {
    position: static;
    background: transparent;
    box-shadow: none;
    border-bottom: 1px solid #ddd;
  }
  .header-actions,
  .mobile-toggle {
    display: none !important;
  }
}
