/* ═══════════════════════════════════════════════════════════════
   TOMCO TECHNOLOGIES - NAVIGATION STYLES
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   NAV CONTAINER
   ─────────────────────────────────────────────────────────────── */

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-height);
  gap: var(--space-2xl);
}

.nav-logo img {
  height: 50px;
  width: auto;
  filter: drop-shadow(0 0 10px rgba(58, 78, 225, 0.3));
  transition: filter var(--transition-base);
}

.nav-logo:hover img {
  filter: drop-shadow(0 0 20px rgba(207, 28, 213, 0.5));
}

/* ───────────────────────────────────────────────────────────────
   NAV MENU
   ─────────────────────────────────────────────────────────────── */

.nav-menu {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2xl);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  list-style: none;
  margin: 0 auto;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-weight: var(--fw-medium);
  font-size: var(--fs-base);
  transition: all var(--transition-base);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--blue-electric);
  background: rgba(58, 78, 225, 0.15);
  box-shadow: 0 0 12px rgba(58, 78, 225, 0.2);
}

.nav-link i {
  font-size: var(--fs-sm);
  transition: transform var(--transition-base);
}

.nav-item.has-megamenu .nav-link:hover i,
.nav-item.has-megamenu.active .nav-link i {
  transform: rotate(180deg);
}

/* ───────────────────────────────────────────────────────────────
   MEGA MENU
   ─────────────────────────────────────────────────────────────── */

.megamenu {
  position: absolute;
  top: calc(100% + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px) scale(0.98);
  min-width: 600px;
  padding: var(--space-xl);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-smooth);
  z-index: var(--z-dropdown);
  /* Enhanced glassmorphism for mega menu */
  background: rgba(18, 18, 42, 0.95) !important;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xl);
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(58, 78, 225, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Ensure megamenu stays opaque on hover */
.megamenu:hover {
  background: rgba(18, 18, 42, 0.95) !important;
}

/* Hover bridge - creates invisible bridge between nav item and megamenu */
.nav-item.has-megamenu::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
  z-index: var(--z-dropdown);
}

/* Desktop only: mega menu hover effect */
@media (min-width: 1025px) {
  .nav-item.has-megamenu:hover .megamenu,
  .nav-item.has-megamenu.active .megamenu {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    top: calc(100% + 10px);
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.megamenu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.megamenu-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  transition: all var(--transition-smooth);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.megamenu-item:hover {
  background: rgba(58, 78, 225, 0.15);
  border-color: rgba(58, 78, 225, 0.4);
  box-shadow:
    0 4px 16px rgba(58, 78, 225, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.megamenu-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  font-size: var(--fs-2xl);
  color: white;
}

.megamenu-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.megamenu-content strong {
  color: var(--text-primary);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}

.megamenu-content span {
  color: var(--blue-electric);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.megamenu-content small {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* ───────────────────────────────────────────────────────────────
   NAV CTA - Bouton Espace Client
   ─────────────────────────────────────────────────────────────── */

.nav-cta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  white-space: nowrap;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3A4EE1 0%, #6D3DDD 50%, #CF1CD5 100%);
  color: white !important;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  transition: all var(--transition-smooth);
  box-shadow: 0 4px 16px rgba(58, 78, 225, 0.4);
  border: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

/* Hover gradient overlay */
.nav-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #6D3DDD 0%, #CF1CD5 100%);
  opacity: 0;
  transition: opacity var(--transition-smooth);
  border-radius: inherit;
  z-index: -1;
}

.nav-cta:hover::before {
  opacity: 1;
}

.nav-cta:hover {
  box-shadow:
    0 6px 24px rgba(207, 28, 213, 0.5),
    0 0 30px rgba(207, 28, 213, 0.3);
  transform: translateY(-2px);
  color: white !important;
}

.nav-cta i {
  font-size: var(--fs-lg);
  transition: transform var(--transition-base);
  position: relative;
  z-index: 1;
}

.nav-cta:hover i {
  transform: scale(1.1);
}

/* Ensure text is above pseudo-element */
.nav-cta > * {
  position: relative;
  z-index: 1;
}

/* ───────────────────────────────────────────────────────────────
   MOBILE TOGGLE
   ─────────────────────────────────────────────────────────────── */

.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10001;
  position: relative;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
  background: white;
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
  background: white;
}

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .nav-toggle {
    display: flex;
    align-self: center;
  }

  /* Hide CTA button on mobile by default */
  .nav-cta {
    display: none;
  }

  /* Full-screen mobile menu with glassmorphism */
  .nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    background: linear-gradient(
      180deg,
      rgba(10, 10, 26, 0.85) 0%,
      rgba(18, 18, 42, 0.90) 50%,
      rgba(10, 10, 26, 0.85) 100%
    );
    backdrop-filter: blur(50px) saturate(200%) brightness(1.1);
    -webkit-backdrop-filter: blur(50px) saturate(200%) brightness(1.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: calc(var(--navbar-height) + var(--space-md)) 0 0 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    overflow: hidden;
  }

  .nav-menu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Menu content container */
  .nav-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: var(--space-md) var(--space-md) var(--space-md);
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-item:last-child {
    border-bottom: none;
  }

  .nav-link {
    padding: 0;
    justify-content: space-between;
    font-size: var(--fs-lg);
    font-weight: 600;
    color: white;
    height: 60px;
    display: flex;
    align-items: center;
  }

  .nav-link i {
    font-size: var(--fs-sm);
    margin-left: var(--space-sm);
  }

  /* Mega menu on mobile - liste simple */
  .megamenu {
    position: absolute;
    transform: none;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent !important;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    height: 0;
    opacity: 0;
    visibility: hidden;
  }

  .nav-item.has-megamenu .megamenu {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .nav-item.has-megamenu.active .megamenu {
    position: static;
    opacity: 1;
    visibility: visible;
    max-height: 2000px;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .megamenu-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 0;
    width: 100%;
  }

  /* Unified mobile submenu items - same style as nav items */
  .megamenu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: var(--space-lg) 0 var(--space-lg) var(--space-lg);
    margin: 0;
    border-radius: 0;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    min-height: 60px;
  }

  .megamenu-item:last-child {
    border-bottom: none;
  }

  .megamenu-item:hover,
  .megamenu-item:active {
    background: rgba(58, 78, 225, 0.08);
    transform: none;
  }

  .megamenu-icon {
    width: 32px;
    height: 32px;
    font-size: var(--fs-base);
    flex-shrink: 0;
  }

  .megamenu-content {
    flex: 1;
    min-width: 0;
  }

  .megamenu-content strong {
    font-size: var(--fs-sm);
    display: block;
    margin-bottom: 2px;
    line-height: 1.3;
  }

  .megamenu-content span,
  .megamenu-content small {
    font-size: 11px;
    line-height: 1.2;
    display: block;
  }

  /* Show CTA button at bottom when menu is active */
  .nav-menu.active .nav-cta {
    display: flex;
    position: relative;
    margin: var(--space-lg);
    padding: 16px 24px;
    justify-content: center;
    z-index: 10001;
    box-shadow:
      0 -4px 20px rgba(0, 0, 0, 0.3),
      0 8px 32px rgba(58, 78, 225, 0.5);
    animation: slideUpFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
  }
}

@keyframes slideUpFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .nav-logo img {
    height: 40px;
  }

  .nav-menu {
    padding: calc(var(--navbar-height) + var(--space-sm)) 0 0 0;
  }

  .nav-list {
    padding: var(--space-sm) var(--space-sm) var(--space-sm);
  }

  .nav-link {
    padding: 0;
    font-size: var(--fs-base);
    height: 50px;
  }

  .nav-menu.active .nav-cta {
    font-size: var(--fs-sm);
    padding: 14px 20px;
    margin: var(--space-md);
  }

  .megamenu-item {
    padding: var(--space-md) 0 var(--space-md) var(--space-md);
    gap: var(--space-xs);
    min-height: 50px;
  }

  .megamenu-icon {
    width: 28px;
    height: 28px;
    font-size: var(--fs-sm);
  }

  .megamenu-content strong {
    font-size: 13px;
  }

  .megamenu-content span,
  .megamenu-content small {
    font-size: 10px;
  }
}
