/* 确保 nav 元素作为定位基准 */
nav {
  position: relative;
}

/* 共享下拉菜单容器 - 铺满屏幕宽度 */
.shared-dropdown-container {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 40;
  /* 提高层级确保在玻璃层之上 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  /* top: 100%; */
  padding-top: 64px;
  top: 0;
  left: 0;
  right: 0;
  /* 出现时的动画：包含下滑和高度展开 */
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease,
    height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* 初始高度为0 */
  height: 0;
  overflow: hidden;
  /* 移除container的限制，铺满整个屏幕宽度 */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  /* 确保背景覆盖整个宽度 */
  background-color: white;
}

.shared-dropdown-container.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 桌面端：使用 fixed 定位，确保跟随 fixed 导航栏，避免滚动时位置偏移 */
@media (min-width: 768px) {
  .shared-dropdown-container {
    position: fixed;
    /* 保持 top: 0，配合 padding-top: 64px 实现从导航栏下方开始的效果 */
  }
}

/* 消失时使用收缩和淡出结合的动画 */
.shared-dropdown-container.hiding {
  transform: translateY(0) !important;
  /* 不在这里设置 transition，让子类控制 */
}

/* 第一阶段：快速收缩一点 */
.shared-dropdown-container.hiding.contracting {
  transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  /* 第一阶段只收缩，不淡出 */
  opacity: 1 !important;
  visibility: visible !important;
}

/* 第二阶段：只淡出，不收缩高度 */
.shared-dropdown-container.hiding.fading {
  transition: opacity 0.5s ease, visibility 0.5s ease !important;
  /* 不设置height transition，保持当前高度不变，只淡出 */
}

/* 下拉内容区域 - 使用container限制内容宽度 */
.dropdown-content {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease, visibility 0.1s ease;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  pointer-events: none;
  padding: 1.5rem;
  /* 内容居中，但背景铺满 */
  max-width: 1200px;
  margin: 0 auto;
}

.dropdown-content.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  position: relative;
}

/* 顶部菜单激活状态下的下划线 */
.menu-active::after {
  transform: scaleX(1) !important;
}

/* 移动端菜单打开时的导航栏样式 */
nav.mobile-menu-open {
  /* 菜单打开时，菜单会覆盖导航栏，所以导航栏保持原样即可 */
  /* 菜单本身已经设置了更高的 z-index，会自然覆盖导航栏 */
}

/* 移动端深色logo定位 */
#mobileLogoDark {
  position: relative;
}

/* 确保导航栏在所有屏幕尺寸下都垂直居中 */
#mainNav {
  display: flex !important;
  align-items: center !important;
}

#mainNav > .container {
  display: flex !important;
  align-items: center !important;
}

/* 移动端菜单样式 */
#mobileMenu {
  z-index: 99999 !important; /* 确保菜单在所有元素之上，包括 Chat with us (z-50) */
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  overflow: hidden !important; /* 确保菜单本身不显示滚动条 */
}

/* 确保菜单显示时z-index正确应用 */
#mobileMenu:not(.hidden) {
  z-index: 99999 !important;
}

/* 确保菜单内容区域也不显示滚动条 */
#mobileMenu > * {
  overflow: hidden !important;
}

/* 菜单打开时，禁止 body 滚动 */
body.mobile-menu-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100vh !important;
  max-height: 100vh !important;
}

/* 确保 html 元素也不滚动 */
html.mobile-menu-open {
  overflow: hidden !important;
  height: 100vh !important;
  max-height: 100vh !important;
}

/* 移动端子菜单样式 */
.mobile-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out,
    padding 0.3s ease-out;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.mobile-submenu:not(.hidden) {
  max-height: 1000px;
  opacity: 1;
  transition: max-height 0.3s ease-in, opacity 0.3s ease-in,
    padding 0.3s ease-in;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
