/* ================================================
   星辰星联 - 统一导航和页脚样式
   ================================================ */

/* ================================================
   1. 变量定义
   ================================================ */
:root {
  /* 导航专用变量 */
  --header-height-mobile: 64px;

  /* z-index */
  --z-header: 1000;
  --z-dropdown: 1001;
  --z-mobile-menu: 1002;
}

/* ================================================
   2. 导航栏基础样式
   ================================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: #fff;
  z-index: var(--z-header);
  transition: box-shadow var(--transition-normal);
  padding-top: env(safe-area-inset-top);
}

.site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.site-header.menu-open {
  height: auto;
}

/* 移动端滚动保护 */
body.header-menu-open {
  overflow: hidden;
}

/* ================================================
   3. 导航栏内部布局
   ================================================ */
.header-inner {
  display: grid !important;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px !important;
  height: 100%;
}

/* ================================================
   4. Logo样式
   ================================================ */
.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-img {
  height: 40px;
  width: auto;
  max-width: 200px;
  display: block;
}

/* SVG logo specific styles */
.logo-img[src*=".svg"] {
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

/* Logo 深浅模式切换 */
.logo-dark {
  display: none;
}

.logo-light {
  display: block;
}

[data-theme="dark"] .logo-dark {
  display: block;
}

[data-theme="dark"] .logo-light {
  display: none;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 2px;
  transition: color var(--transition-fast);
}

.logo:hover .logo-text {
  color: var(--primary-dark);
}

/* ================================================
   5. 导航链接样式 - 6个独立容器
   ================================================ */
.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px !important;
  margin: 0 auto;
}

/* 导航项容器 - 每个导航项独立 */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 500 !important;
  color: #1F2937;
  text-decoration: none;
  border-radius: 0;
  transition: color var(--transition-fast);
  white-space: normal;
  position: relative;
  min-height: 44px;
}

/* 导航链接下划线动效 - 从中间向两边展开 */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--transition-fast);
}

/* wrapper 内的 .nav-link 隐藏自身下划线，由 wrapper 统一显示 */
.nav-link-wrapper .nav-link::after {
  content: none;
}

/* 下划线放在 wrapper 上，覆盖文字+箭头整体 */
.nav-link-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--transition-fast);
}

.nav-link:hover {
  color: var(--primary-color);
  background: transparent;
}

.nav-link:hover::after {
  transform: scaleX(1);
}

/* wrapper hover/active 时下划线显示 */
.nav-link-wrapper:hover::after,
.nav-item.has-dropdown.open > .nav-link-wrapper::after {
  transform: scaleX(1);
}

.nav-link.active {
  color: var(--primary-color);
  background: transparent;
}

.nav-link.active::after {
  transform: scaleX(1);
}

/* wrapper 内的 active 链接也触发 wrapper 下划线 */
.nav-item:has(.nav-link.active) > .nav-link-wrapper::after {
  transform: scaleX(1);
}

/* 深色模式导航链接颜色 */
[data-theme="dark"] .nav-link {
  color: #FFFFFF;
}

[data-theme="dark"] .nav-link:hover {
  color: #0036FC;
}

[data-theme="dark"] .nav-link.active {
  color: #0036FC;
}

/* 深色模式箭头图标 */
[data-theme="dark"] .nav-arrow-img {
  filter: brightness(0) invert(1);
}

/* ================================================
   6. 下拉菜单样式
   ================================================ */
.nav-item {
  position: relative;
}

.nav-item.has-dropdown {
  display: flex;
  align-items: center;
}

/* 导航链接+箭头容器 */
.nav-link-wrapper {
  display: inline-flex;
  align-items: center;
  position: relative;
  cursor: pointer;
}

/* 导航链接在下拉项中保持原有样式 */
.nav-link-wrapper .nav-link {
  padding: 8px 16px;
}

/* 移动端菜单底部免费咨询按钮 - 桌面端隐藏 */
.mobile-cta-wrapper {
  display: none;
}

/* 箭头图片 - 原图29x17，缩小显示 */
.nav-arrow-img {
  width: 9px;
  height: 6px;
  margin-left: 4px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  object-fit: contain;
  cursor: pointer;
}

/* 深色模式下箭头反转为白色 */
[data-theme="dark"] .nav-arrow-img {
  filter: invert(1);
}

/* hover时箭头旋转 */
.nav-item.has-dropdown:hover .nav-arrow-img,
.nav-item.has-dropdown.open .nav-arrow-img {
  transform: rotate(180deg);
}

/* 下拉菜单容器 */
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  padding: 8px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: var(--z-dropdown);
  margin-top: 8px;
}

/* 下拉菜单显示 */
.nav-item.has-dropdown:hover .nav-dropdown {
  opacity: 1;
  visibility: visible;
}

/* 下拉菜单项 */
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: normal;
  min-height: 44px;
}

.dropdown-item:hover {
  color: #0036FC;
  background: rgba(0, 54, 252, 0.08);
}

.dropdown-item.active {
  color: var(--primary-color);
  background: rgba(37, 99, 235, 0.1);
}

/* 下拉菜单动画 */
@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.nav-item.has-dropdown:hover .nav-dropdown {
  animation: dropdownFadeIn 0.2s ease forwards;
}

/* ================================================
   7. 右侧功能区
   ================================================ */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* 语言切换 - 简洁文字链接样式 (参考 deerviz) */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

/* 深色模式切换按钮 */
.theme-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  margin-right: 4px;
  flex-shrink: 0;
}

.theme-switch:hover {
  color: var(--primary-color);
  background: rgba(0, 54, 252, 0.05);
}

[data-theme="dark"] .theme-switch:hover {
  background: rgba(74, 111, 255, 0.1);
}

[data-theme="dark"] .theme-switch {
  color: #E0E0E0;
}

[data-theme="dark"] .theme-switch:hover {
  color: #0036FC;
}

.theme-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: absolute;
}

.theme-switch:hover .theme-icon {
  transform: rotate(15deg);
}

/* 默认显示月亮图标（浅色模式），深色模式显示太阳图标 */
.theme-icon-sun {
  display: none;
}

.theme-icon-moon {
  display: block;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

/* 自动模式指示器 - 小圆点 */
.theme-switch::after {
  content: '';
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-color);
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* auto模式显示指示器 */
.theme-switch[data-theme-mode="auto"]::after {
  opacity: 1;
}

/* light模式 - 太阳图标带浅色背景 */
.theme-switch[data-theme-mode="light"] {
  background: rgba(0, 54, 252, 0.08);
  color: var(--primary-color);
}

/* dark模式 - 月亮图标带深色背景 */
.theme-switch[data-theme-mode="dark"] {
  background: rgba(74, 111, 255, 0.15);
  color: #4A6FFF;
}

[data-theme="dark"] .theme-switch[data-theme-mode="dark"] {
  background: rgba(74, 111, 255, 0.2);
  color: #6B8CFF;
}

.lang-btn {
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  user-select: none;
  padding: 8px 12px;
  min-height: 44px;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.lang-btn:hover {
  color: var(--primary-color);
  background: rgba(0, 54, 252, 0.05);
}

.lang-btn.lang-active {
  color: var(--primary-color);
  font-weight: 500;
  background: transparent;
}

.lang-divider {
  color: var(--text-light);
  opacity: 0.5;
}

/* CTA按钮 */
.cta-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-white);
  background: rgba(0, 54, 252, 1);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.3s ease;
  white-space: normal;
  min-height: 44px;
}

.cta-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 54, 252, 0.3);
}

.cta-btn:active {
  transform: scale(1.02);
}

/* 导航栏按钮 */
.btn-primary,
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  background-color: var(--primary-color);
  color: var(--text-white);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  min-height: 44px;
}

.btn-primary:hover,
.nav-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 54, 252, 0.3);
}

/* ================================================
   8. 移动端菜单按钮
   ================================================ */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--bg-light);
}

/* 汉堡图标 */
.hamburger {
  position: relative;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all var(--transition-fast);
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all var(--transition-fast);
}

.hamburger::before {
  top: -7px;
}

.hamburger::after {
  bottom: -7px;
}

/* 汉堡图标动画 */
.mobile-menu-btn.active .hamburger {
  background: transparent;
}

.mobile-menu-btn.active .hamburger::before {
  top: 0;
  transform: rotate(45deg);
}

.mobile-menu-btn.active .hamburger::after {
  bottom: 0;
  transform: rotate(-45deg);
}

/* ================================================
   9. 页脚样式
   ================================================ */
.site-footer {
  background: var(--bg-dark) !important;
  color: var(--text-white);
  padding: 60px 0 24px;
  margin-top: auto;
  position: relative;
  z-index: 1;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  line-height: 1.5;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.footer-top {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 60px;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 品牌区域 */
.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.footer-logo .logo-text {
  color: var(--text-white);
  font-size: 28px;
}

.footer-logo {
  /* 覆盖 components.css 中的 background-image 冲突 */
  background-image: none !important;
  background: none !important;
  width: auto !important;
  height: auto !important;
}

.footer-logo-img {
  height: 40px;
  width: auto;
  max-width: 200px;
  max-height: 40px;
  display: block;
  object-fit: contain;
}

/* SVG footer logo specific styles */
.footer-logo-img[src*=".svg"] {
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.footer-brand-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  margin: 0;
}

.footer-contact {
  margin-top: 8px;
}

.footer-contact p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 8px;
  line-height: 1.5;
}

.footer-contact a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-contact a:hover {
  color: var(--text-white);
}

/* 链接组 */
.footer-links-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.footer-col-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-white);
  margin-bottom: 12px;
}

.footer-col a {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  padding: 6px 0;
  margin-bottom: 4px;
  line-height: 1.5;
  min-height: 44px;
}

.footer-col a:hover {
  color: var(--primary-light);
  padding-left: 4px;
}

/* 底部版权 */
.footer-bottom {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 24px;
  padding-bottom: 30px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  margin-top: 0;
  gap: 8px;
}

.footer-bottom p {
  margin: 0;
}

.footer-bottom a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-bottom a:hover {
  color: var(--primary-light);
}

/* ================================================
   10. 响应式设计
   ================================================ */

/* 平板 (1024px以下) */
@media (max-width: 1024px) {
  .nav-links {
    gap: 4px;
  }
  
  .nav-link {
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .cta-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* 移动端 (768px以下) */
@media (max-width: 768px) {
  .site-header {
    height: var(--header-height-mobile);
  }
  
  .header-inner {
    padding: 0 16px;
  }
  
  /* 隐藏桌面导航 */
  .nav-links {
    position: fixed;
    top: var(--header-height-mobile);
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 16px;
    background: var(--bg-white);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: var(--z-mobile-menu);
  }
  
  .nav-links.active {
    transform: translateX(0);
  }
  
  .nav-link {
    padding: 14px 16px;
    font-size: 16px;
    border-radius: var(--radius-md);
    border-bottom: 1px solid var(--border-light);
  }
  
  .nav-link:last-child {
    border-bottom: none;
  }
  
  /* 下拉菜单移动端样式 */
  .nav-item.has-dropdown {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav-item.has-dropdown > .nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .nav-item.has-dropdown .arrow-icon {
    transform: rotate(-45deg);
    margin-left: 8px;
    transition: transform var(--transition-fast);
  }
  
  .nav-item.has-dropdown.open .arrow-icon {
    transform: rotate(135deg);
  }
  
  .nav-dropdown {
    position: static;
    transform: none;
    box-shadow: none;
    padding: 0 0 16px 24px;
    margin-top: 0;
    opacity: 1;
    visibility: visible;
    display: none;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
  }
  
  .nav-item.has-dropdown.open .nav-dropdown {
    display: block;
    animation: none;
  }
  
  .dropdown-item {
    padding: 12px 16px;
    font-size: 15px;
  }
  /* P2-8: 移动端下拉菜单子项最小高度 */
  .dropdown-item { min-height: 44px; display: flex; align-items: center; }
  
  /* 隐藏右侧功能区 */
  .header-right {
    display: none;
  }
  
  /* 显示移动端菜单按钮 */
  .mobile-menu-btn {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 1001;
  }

  /* 移动端菜单底部免费咨询按钮 */
  .mobile-cta-wrapper {
    display: block;
    padding: 20px 16px;
    border-top: 1px solid var(--border-light);
    margin-top: 16px;
  }

  .mobile-cta-btn {
    width: 100%;
    text-align: center;
    padding: 14px;
    font-size: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* 页脚响应式 */
  .footer-top {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  
  .footer-links-group {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .site-footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* 移动端横屏适配 */
@media (max-width: 768px) and (orientation: landscape) {
  .nav-links {
    max-width: 320px;
  }
  .nav-link {
    padding: 10px 16px;
  }
  .site-header {
    height: var(--header-height-mobile);
  }
}

/* 小屏幕 (480px以下) */
@media (max-width: 480px) {
  .logo-text {
    font-size: 20px;
  }
  
  .footer-links-group {
    grid-template-columns: 1fr;
  }
  
  .footer-brand-text {
    font-size: 13px;
  }
  
  .footer-contact p {
    font-size: 13px;
  }
}

/* ================================================
   11. 中英切换动画
   ================================================ */
@keyframes i18nFade {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes i18nFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0.7;
    transform: translateY(-2px);
  }
}

/* 页面级语言切换过渡效果 */
body.i18n-switching {
  pointer-events: none;
}

body.i18n-switching .site-header,
body.i18n-switching .site-footer {
  opacity: 0.95;
  transition: opacity 0.3s ease;
}

/* 元素级过渡效果 */
[data-i18n] {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-i18n].i18n-transition {
  animation: i18nFade 0.3s ease;
}

/* 语言切换按钮高亮效果 */
.lang-btn.i18n-transition {
  animation: i18nFade 0.2s ease;
}

/* 语言切换时的整体页面淡入效果 */
@keyframes pageFadeIn {
  from {
    opacity: 0.95;
  }
  to {
    opacity: 1;
  }
}

body.i18n-switching-complete {
  animation: pageFadeIn 0.3s ease;
}

/* ================================================
   12. 滚动阴影效果
   ================================================ */
@media (min-width: 769px) {
  .site-header {
    box-shadow: var(--shadow-sm);
  }
  
  .site-header.scrolled {
    box-shadow: var(--shadow-md);
  }
}

/* ================================================
   13. 无障碍支持
   ================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 焦点样式 */
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.cta-btn:focus-visible,
.lang-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000;
    --text-secondary: #333;
  }
  
  .site-header {
    border-bottom: 2px solid var(--border-color);
  }
}
