/* Mega Menu Styles */

/* Primary Menu Base */
.main-navigation {
  position: relative;
}

.primary-menu {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.primary-menu>li {
  position: relative;
}

.primary-menu>li>a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  color: var(--text-primary, #1a1a1a);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.primary-menu>li>a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary-color, #2563eb);
  transform: translateX(-50%);
  transition: width 0.3s ease;
}

.primary-menu>li>a:hover,
.primary-menu>li.current-menu-item>a {
  color: var(--primary-color, #2563eb);
}

.primary-menu>li>a:hover::after,
.primary-menu>li.current-menu-item>a::after {
  width: 80%;
}

/* Menu Icons */
.menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.primary-menu>li:hover .menu-icon {
  transform: translateY(-2px);
}

.menu-icon svg {
  width: 100%;
  height: 100%;
}

/* Dropdown Arrow */
.dropdown-arrow {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25rem;
  transition: transform 0.3s ease;
}

.menu-item-has-children:hover>a .dropdown-arrow {
  transform: rotate(180deg);
}

/* Standard Dropdown Submenu */
.sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: var(--card-bg, #ffffff);
  box-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.1));
  border-radius: 18px;
  padding: 0.75rem;
  margin: 0;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  border: 1px solid var(--border-color, transparent);
}

.menu-item-has-children:hover>.sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sub-menu li {
  position: relative;
}

.sub-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary, #374151);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.sub-menu a:hover {
  background: #f3f4f6;
  color: var(--primary-color, #2563eb);
  transform: translateX(4px);
}

/* Nested Submenus */
.sub-menu .sub-menu {
  top: 0;
  left: 100%;
  margin-left: 0.5rem;
}

/* Mega Menu Styles */
.mega-menu-item {
  position: static;
}

.mega-menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  background: var(--card-bg, #ffffff);
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.15));
  border-radius: 24px;
  padding: 2.5rem;
  display: grid;
  gap: 2.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  border: 1px solid var(--border-color, transparent);
}

.mega-menu-item:hover>.mega-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Mega Menu Column Layouts */
.mega-columns-2>.mega-menu-dropdown {
  grid-template-columns: repeat(2, 1fr);
}

.mega-columns-3>.mega-menu-dropdown {
  grid-template-columns: repeat(3, 1fr);
}

.mega-columns-4>.mega-menu-dropdown {
  grid-template-columns: repeat(4, 1fr);
}

.mega-columns-5>.mega-menu-dropdown {
  grid-template-columns: repeat(5, 1fr);
}

/* Mega Menu Items */
.mega-menu-dropdown>li {
  border-right: 1px solid #e5e7eb;
  padding-right: 2rem;
}

.mega-menu-dropdown>li:last-child {
  border-right: none;
  padding-right: 0;
}

.mega-menu-dropdown>li>a {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary, #111827);
  margin-bottom: 1.25rem;
  padding: 0;
  display: block;
}

.mega-menu-dropdown>li>a:hover {
  color: var(--primary-color, #2563eb);
  transform: none;
  background: none;
}

.mega-menu-dropdown .sub-menu {
  position: static;
  box-shadow: none;
  padding: 0;
  opacity: 1;
  visibility: visible;
  transform: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: transparent;
}

.mega-menu-dropdown .sub-menu a {
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  border-radius: 0;
}

.mega-menu-dropdown .sub-menu a:hover {
  background: transparent;
  color: var(--primary-color, #2563eb);
  transform: translateX(4px);
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  position: relative;
  width: 44px;
  height: 44px;
}

.menu-toggle-icon {
  display: block;
  position: relative;
  width: 24px;
  height: 2px;
  background: currentColor;
  transition: background 0.3s ease;
}

.menu-toggle-icon::before,
.menu-toggle-icon::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 2px;
  background: currentColor;
  transition: all 0.3s ease;
}

.menu-toggle-icon::before {
  top: -7px;
}

.menu-toggle-icon::after {
  bottom: -7px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon::after {
  bottom: 0;
  transform: rotate(-45deg);
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .primary-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg, #ffffff);
    flex-direction: column;
    padding: 1.25rem;
    box-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.1));
    border-radius: 0 0 24px 24px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    border: 1px solid var(--border-color, transparent);
    border-top: none;
  }

  .primary-menu.active {
    display: flex;
  }

  .primary-menu>li {
    width: 100%;
  }

  .primary-menu>li>a {
    padding: 0.875rem 1rem;
  }

  .primary-menu>li>a::after {
    display: none;
  }

  .sub-menu,
  .mega-menu-dropdown {
    position: static;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: none;
    width: 100%;
    padding: 0 0 0 1rem;
    margin-top: 0.5rem;
  }

  .menu-item-has-children.active>.sub-menu,
  .mega-menu-item.active>.mega-menu-dropdown {
    display: block;
  }

  .mega-menu-dropdown {
    grid-template-columns: 1fr;
    padding: 0 0 0 1rem;
  }

  .mega-menu-dropdown>li {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
  }

  .mega-menu-dropdown>li:last-child {
    border-bottom: none;
  }
}

@media (max-width: 640px) {
  .primary-menu>li>a {
    padding: 0.75rem;
    font-size: 0.875rem;
  }
}