/* ============================
   Megamenu Styles
   ============================ */

/* 覆盖原有sub-menu样式 - megamenu项目不使用原始下拉 */
header nav .menu > li.has-megamenu > .sub-menu {
  display: none !important;
}

/* Megamenu Panel - 全宽下拉面板 */
header nav .menu > li.has-megamenu {
  position: static;
}

header nav .menu > li.has-megamenu > a {
  position: relative;
}

header nav .menu > li.has-megamenu > a .megamenu-arrow {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
  margin-left: 6px;
  transition: transform 0.3s;
}

header nav .menu > li.has-megamenu:hover > a .megamenu-arrow,
header nav .menu > li.has-megamenu.megamenu-active > a .megamenu-arrow {
  transform: rotate(-135deg) translateY(-2px);
}

/* Megamenu面板容器 */
.megamenu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 8px 20px rgba(0, 0, 0, 0.04);
  border-top: 3px solid var(--primary);
  overflow: hidden;
}

/* 显示状态 */
header nav .menu > li.has-megamenu:hover > .megamenu-panel,
header nav .menu > li.has-megamenu.megamenu-active > .megamenu-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 内部容器 */
.megamenu-inner {
  max-width: 138rem;
  margin: 0 auto;
  padding: 3.6rem 4rem;
}

/* 列布局 */
.megamenu-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-template-columns: repeat(5,1fr);
  gap: 2.4rem 3rem;
  list-style: none;
}

/* 单列样式 */
.megamenu-col {
  list-style: none;
}

/* 列标题 */
.megamenu-col-title {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--title);
  padding: 8px 0;
  margin-bottom: 4px;
  position: relative;
  transition: color 0.3s;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.megamenu-col-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background-color: var(--primary);
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.megamenu-col-title:hover {
  color: var(--primary);
}

/* 列描述 */
.megamenu-col-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
  padding-left: 14px;
}

/* 带图片的卡片样式 */
.megamenu-col-card {
  display: block;
  text-decoration: none;
  border-radius: 0;
  overflow: hidden;
  transition: all 0.3s;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  height: 100%;
}

.megamenu-col-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.1);
  transform: translateY(-3px);
}

.megamenu-col-thumb {
  width: 100%;
  height: 0;
  padding-bottom: 56%;
  position: relative;
  overflow: hidden;
  background-color: var(--bg);
}

.megamenu-col-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}

.megamenu-col-card:hover .megamenu-col-thumb img {
  transform: scale(1.05);
}

.megamenu-col-card-title {
  display: block;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--title);
  transition: color 0.3s;
  overflow: hidden;
}

.megamenu-col-card:hover .megamenu-col-card-title {
  color: var(--primary);
}

/* 有图片的列不显示圆点 */
.megamenu-col.has-thumb .megamenu-col-title::before {
  display: none;
}

/* 链接列表 */
.megamenu-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.megamenu-links > li {
  margin: 0;
}

.megamenu-links > li > a {
  display: block;
  font-size: 14px;
  color: var(--text);
  padding: 9px 12px 9px 14px;
  border-radius: 0;
  transition: all 0.25s;
  text-decoration: none;
  position: relative;
}

.megamenu-links > li > a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 60%;
  background-color: var(--primary);
  border-radius: 2px;
  transition: width 0.25s;
}

.megamenu-links > li > a:hover {
  color: var(--primary);
  background-color: rgba(13, 148, 136, 0.05);
}

.megamenu-links > li > a:hover::before {
  width: 3px;
}

.megamenu-links > li.current-menu-item > a {
  color: var(--primary);
  background-color: rgba(13, 148, 136, 0.05);
}

.megamenu-links > li.current-menu-item > a::before {
  width: 3px;
}

/* 没有子项的megamenu列 - 作为直接链接 */
.megamenu-col:not(.menu-item-has-children) .megamenu-col-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  padding: 9px 12px 9px 14px;
  border-radius: 0;
  margin-bottom: 0;
}

.megamenu-col:not(.menu-item-has-children) .megamenu-col-title::before {
  display: none;
}

.megamenu-col:not(.menu-item-has-children) .megamenu-col-title:hover {
  color: var(--primary);
  background-color: rgba(13, 148, 136, 0.05);
}

/* 遮罩层 */
.megamenu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 995;
  background-color: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s;
  pointer-events: none;
}

.megamenu-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

/* ============================
   响应式 - 平板和移动端
   ============================ */
@media screen and (max-width: 1024px) {
  header nav .menu > li.has-megamenu {
    position: relative;
  }

  .megamenu-panel {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border-top: none;
    display: none;
    transition: none;
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 0;
    margin: 8px 0;
  }

  header nav .menu > li.has-megamenu.active > .megamenu-panel {
    display: block;
  }

  .megamenu-inner {
    padding: 16px 12px;
  }

  .megamenu-columns {
    display: block;
  }

  .megamenu-col {
    margin-bottom: 16px;
  }

  .megamenu-col:last-child {
    margin-bottom: 0;
  }

  .megamenu-col-card {
    margin-bottom: 8px;
  }

  .megamenu-col-thumb {
    padding-bottom: 45%;
  }

  .megamenu-col-title {
    font-size: 14px;
    padding: 6px 0;
  }

  .megamenu-col-desc {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .megamenu-links > li > a {
    font-size: 13px;
    padding: 8px 12px 8px 14px;
  }

  /* 移动端箭头 */
  header nav .menu > li.has-megamenu > a .megamenu-arrow {
    position: absolute;
    right: -36px;
    top: 50%;
    transform: rotate(45deg) translateY(-50%);
    margin-left: 0;
  }

  header nav .menu > li.has-megamenu.active > a .megamenu-arrow {
    transform: rotate(-135deg) translateY(50%);
  }

  header nav .menu > li.has-megamenu > a {
    margin-right: 46px;
  }

  .megamenu-overlay {
    display: none;
  }
}

/* ============================
   动画效果
   ============================ */
@media screen and (min-width: 1025px) {
  .megamenu-col {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
  }

  header nav .menu > li.has-megamenu:hover .megamenu-col,
  header nav .menu > li.has-megamenu.megamenu-active .megamenu-col {
    opacity: 1;
    transform: translateY(0);
  }

  /* 列的依次出现动画 */
  .megamenu-col:nth-child(1) { transition-delay: 0.05s; }
  .megamenu-col:nth-child(2) { transition-delay: 0.1s; }
  .megamenu-col:nth-child(3) { transition-delay: 0.15s; }
  .megamenu-col:nth-child(4) { transition-delay: 0.2s; }
  .megamenu-col:nth-child(5) { transition-delay: 0.25s; }
  .megamenu-col:nth-child(6) { transition-delay: 0.3s; }
}
