/* ============================================================
   Global Styles — 全局基础样式与工具类
   ============================================================ */

/* === 容器 === */
.v2-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.v2-section {
  padding: var(--space-4xl) 0;
  min-width: auto;
  overflow: visible;
}

.v2-section--gray {
  background: var(--color-bg);
}

.v2-section--white {
  background: var(--color-bg-white);
}

/* === 排版 === */
.v2-heading-1 {
  font-size: var(--text-5xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-heading);
  letter-spacing: 1px;
}

.v2-heading-2 {
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-heading);
  letter-spacing: 1px;
}

.v2-heading-3 {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-heading);
}

.v2-subtitle {
  font-size: var(--text-xl);
  font-weight: 300;
  color: var(--color-caption);
  line-height: var(--leading-relaxed);
}

.v2-text {
  font-size: var(--text-base);
  color: var(--color-body);
  line-height: var(--leading-relaxed);
}

.v2-text--small {
  font-size: var(--text-sm);
  color: var(--color-caption);
  line-height: var(--leading-normal);
}

/* === 网格 === */
.v2-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.v2-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.v2-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

/* === Flex 工具 === */
.v2-flex {
  display: flex;
}

.v2-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.v2-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.v2-flex-col {
  display: flex;
  flex-direction: column;
}

/* === 文本工具 === */
.v2-text-center { text-align: center; }
.v2-text-left { text-align: left; }
.v2-text-right { text-align: right; }

/* === 间距工具 === */
.v2-mt-sm { margin-top: var(--space-sm); }
.v2-mt-md { margin-top: var(--space-md); }
.v2-mt-lg { margin-top: var(--space-lg); }
.v2-mt-xl { margin-top: var(--space-xl); }
.v2-mt-2xl { margin-top: var(--space-2xl); }
.v2-mb-sm { margin-bottom: var(--space-sm); }
.v2-mb-md { margin-bottom: var(--space-md); }
.v2-mb-lg { margin-bottom: var(--space-lg); }
.v2-mb-xl { margin-bottom: var(--space-xl); }
.v2-mb-2xl { margin-bottom: var(--space-2xl); }
.v2-mb-3xl { margin-bottom: var(--space-3xl); }

/* === 图片工具 === */
.v2-img-fluid {
  max-width: 100%;
  height: auto;
}

/* === Badge / 标签 === */
.v2-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
}

.v2-badge--primary {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.v2-badge--success {
  background: rgba(0, 212, 170, 0.1);
  color: var(--color-secondary-dark);
}

.v2-badge--accent {
  background: rgba(255, 107, 74, 0.1);
  color: var(--color-accent);
}

/* === 分隔线 === */
.v2-divider {
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: var(--gradient-hero);
  margin: var(--space-md) auto;
}

/* === 区域标题块 === */
.v2-section-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.v2-section-header .v2-heading-2 {
  margin-bottom: var(--space-sm);
}

.v2-section-header .v2-subtitle {
  margin-top: 0;
}

/* === 面包屑 === */
.v2-breadcrumb {
  display: flex;
  align-items: center;
  list-style: none;
  padding: var(--space-md) 0;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-caption);
}

.v2-breadcrumb li {
  display: inline-flex;
  align-items: center;
}

.v2-breadcrumb li:not(:last-child)::after {
  content: '/';
  margin: 0 var(--space-xs);
  color: var(--color-border);
}

.v2-breadcrumb a {
  color: var(--color-caption);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.v2-breadcrumb a:hover {
  color: var(--color-primary);
}

.v2-breadcrumb .active {
  color: var(--color-heading);
  font-weight: 500;
}

/* === 滚动进度条 === */
.v2-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gradient-hero);
  z-index: 10000;
  transition: width 0.1s linear;
}

/* ============================================================
   Header & Footer V2 增强
   ============================================================ */

/* 顶部工具条占位：原 padding-top 80px → 116px */
body {
  padding-top: 116px; /* 80px header + 36px topbar */
}

/* 修复 header 与 v2-topbar 重叠：旧 CSS header top:0 盖住 topbar */
header {
  top: var(--topbar-height); /* 36px */
}

/* Header 滚动收缩状态 */
header.v2-header--scrolled {
  height: var(--header-height-scrolled);
}

header.v2-header--scrolled .logo {
  top: 6px; /* 旧 CSS top:15px 在 60px 头部中溢出，重新居中: (60-48)/2=6 */
  transform: scale(0.8);
  transition: transform var(--transition-base);
}

header.v2-header--scrolled nav a {
  line-height: var(--header-height-scrolled);
}

/* 收缩后下划线按比例上移: 20*(60/80)=15 */
header.v2-header--scrolled nav li a::after {
  bottom: 15px;
}

header.v2-header--scrolled .online {
  top: 12px;
  padding: 8px 0 8px 0;
}

header.v2-header--scrolled .v2-btn--header-cta {
  top: 9px;
  padding: 8px 20px;
  font-size: var(--text-sm);
}

/* 导航项 hover 下划线效果 */
nav li a {
  position: relative;
}

nav li a::after {
  content: '';
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: width var(--transition-base);
}

nav li a:hover::after,
nav li.active a::after {
  width: 100%;
}

/* 导航项 Mega Menu 触发位 */
.v2-nav-mega-trigger {
  position: relative;
}

/* 移动端汉堡按钮 */
.v2-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  position: absolute;
  right: 16px;
  top: 24px;
  z-index: 600;
  padding: 0;
}

.v2-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-heading);
  border-radius: 2px;
  transition: all var(--transition-base);
}

.v2-hamburger--active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.v2-hamburger--active span:nth-child(2) {
  opacity: 0;
}

.v2-hamburger--active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* 移动端导航打开状态 */
@media (max-width: 768px) {
  .v2-hamburger {
    display: flex;
  }

  body.v2-body--nav-open {
    overflow: hidden;
  }

  header nav {
    display: none;
    position: fixed;
    top: 116px;
    left: 0;
    width: 100%;
    height: calc(100vh - 116px);
    background: var(--color-bg-white);
    z-index: 599;
    overflow-y: auto;
  }

  header nav.v2-nav--mobile-open {
    display: block;
  }

  header nav ul {
    flex-direction: column;
    padding: var(--space-lg);
  }

  header nav li {
    float: none;
    margin-left: 0;
    border-bottom: 1px solid var(--color-border);
  }

  header nav li a {
    line-height: 3.5;
    font-size: var(--text-lg);
    display: block;
  }

  nav li a::after {
    display: none;
  }

  .v2-mega-menu {
    position: static;
    box-shadow: none;
    padding: 0 0 16px;
    min-width: auto;
    display: block;
  }

  .v2-mega-menu__grid {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  header .v2-btn--header-cta {
    position: static !important;
    margin: 12px 16px;
    display: block;
    text-align: center;
  }

  header .online {
    display: none;
  }

  /* 重置旧 CSS 的固定 padding，改为汉堡菜单模式 */
  header .header-container {
    padding-left: 16px;
    padding-right: 56px;
  }
}

/* ===== Header 中间断点（769-1200px），防止导航溢出 ===== */

/* 1200px：首次收缩 */
@media (max-width: 1200px) {
  header .header-container {
    width: auto;
    padding-left: 220px;
    padding-right: 280px;
  }
  nav li {
    margin-left: 36px;
  }
  nav a {
    font-size: var(--text-sm);
  }
  header .online {
    width: 88px;
    font-size: var(--text-xs);
    padding: 6px 8px;
    top: 24px;
  }
  header .online[href*="oj"] {
    right: 110px;
  }
  header .online[href*="create"] {
    right: 8px;
  }
  header .v2-btn--header-cta {
    right: 200px !important;
    font-size: var(--text-xs);
    padding: 6px 14px;
    top: 22px;
  }
}

/* 1024px：进一步收缩，隐藏次要按钮 */
@media (max-width: 1024px) {
  header .header-container {
    padding-left: 200px;
    padding-right: 80px;
  }
  nav li {
    margin-left: 20px;
  }
  nav a {
    font-size: 13px;
  }
  header .online {
    display: none;
  }
  header .v2-btn--header-cta {
    right: 8px !important;
    font-size: var(--text-xs);
    padding: 5px 12px;
    top: 23px;
  }
  .logo {
    width: 160px;
    height: 38px;
    top: 20px;
    background-size: contain;
    background-repeat: no-repeat;
  }
}

/* 480px：微小屏幕微调 */
@media (max-width: 480px) {
  .v2-topbar .v2-container span {
    display: none;
  }
  header .header-container {
    padding-left: 140px;
  }
  .logo {
    width: 130px;
    height: 32px;
    top: 22px;
  }
}

/* Footer 响应式 */
@media (max-width: 768px) {
  .v2-footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 32px !important;
  }
}

@media (max-width: 480px) {
  .v2-footer-grid {
    grid-template-columns: 1fr !important;
  }
}

/* 将 fixed-form 原有样式覆盖为 v2（原 box 注释块保持） */
.v2-fixed-lead-bar .v2-lead-form .v2-input,
.v2-fixed-lead-bar .v2-lead-form .v2-select {
  width: 180px;
}

@media (max-width: 768px) {
  .v2-fixed-lead-bar .v2-lead-form .v2-input,
  .v2-fixed-lead-bar .v2-lead-form .v2-select {
    width: 100%;
  }
}

/* ============================================================
   兼容性覆盖 — 覆盖旧版 style.css / index.css 固定布局
   ============================================================ */

/* 旧 CSS body > footer { min-width: 1200px; background: #525e76 } 与 V2 冲突 */
body > footer {
  min-width: auto;
  background: var(--color-footer-bg);
}

/* 旧 CSS header .header-container { width: 1200px } 不响应式 */
header .header-container {
  width: 100%;
  max-width: var(--container-max);
}

/* 旧 CSS .section-content { width: 1200px } */
.section-content {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
}

/* 旧 CSS section { min-width: 1200px } 防止溢出 */
body > main > section {
  min-width: auto;
}

/* 旧 CSS .contact-panel { width: 1200px } 已被新 footer 取代，不需覆盖 */

/* Footer 链接 hover 增强 */
footer a:hover {
  color: #fff !important;
}

/* === 回到顶部按钮增强 === */
.toback {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-bg-white);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.toback:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.toback::before {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  border-left: 2px solid var(--color-primary);
  border-top: 2px solid var(--color-primary);
  transform: rotate(45deg);
  margin-top: 4px;
}
