/* 企业网站样式文件 - 性能优化版 */
/* 基于Tailwind CSS定制，专注于性能优化和移动端适配 */

/* 重置样式 - 性能优化 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 基础样式优化 */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1f2937;
  background-color: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* 企业主色调 - 缓存优化 */
:root {
  --primary-blue: #1e40af;
  --primary-blue-dark: #1e3a8a;
  --accent-gold: #d97706;
  --light-gray: #f8fafc;
  --dark-gray: #374151;
}

/* 导航栏样式 - 移动端优化 */
.navbar {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  will-change: transform;
}

.navbar-scrolled {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* 移动端菜单优化 - 性能优先 */
.mobile-menu {
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateZ(0); /* GPU加速 */
}

.mobile-menu a {
  border-bottom: 1px solid #f3f4f6;
  transition: all 0.2s ease;
  will-change: transform;
}

.mobile-menu a:last-child {
  border-bottom: none;
}

.mobile-menu a:hover {
  background-color: #f8fafc;
  transform: translateX(4px);
}

/* 按钮样式优化 - 移动端触摸友好 */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
  color: white;
  padding: 0.875rem 1.75rem;
  border-radius: 0.75rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(30, 64, 175, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  border: 2px solid var(--primary-blue);
  color: var(--primary-blue);
  background: transparent;
  padding: 0.875rem 1.75rem;
  border-radius: 0.75rem;
  font-weight: 500;
  transition: all 0.3s ease;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.btn-outline:hover {
  background: var(--primary-blue);
  color: white;
}

/* 卡片样式优化 - 移动端适配 */
.card {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 2px 8px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  will-change: transform;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.1);
}

/* 轮播图样式优化 - 移动端性能 */
.swiper-container {
  width: 100%;
  height: auto;
  min-height: 300px;
  max-height: 500px;
  border-radius: 0;
  overflow: hidden;
  position: relative;
  contain: layout style paint; /* 性能优化 */
}

.swiper-slide {
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 300px;
  will-change: transform;
}

.swiper-slide-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  z-index: 2;
  padding: 1rem;
  width: 100%;
}

/* 图片懒加载样式 - 性能关键 */
img[data-src] {
  opacity: 0;
  transition: opacity 0.3s ease;
  content-visibility: auto; /* 性能优化 */
}

img.lazy-loaded {
  opacity: 1;
}

/* 图片加载占位符 */
.image-placeholder {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  content-visibility: auto;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 响应式图片优化 */
.responsive-image {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  content-visibility: auto;
}

/* 网格布局优化 - 移动端优先 */
.grid-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  content-visibility: auto;
}

/* 页脚样式优化 */
.footer {
  background: var(--dark-gray);
  color: white;
  padding: 2rem 0 1rem;
  content-visibility: auto;
}

.footer a {
  color: #d1d5db;
  transition: color 0.3s ease;
  padding: 0.25rem 0;
  display: inline-block;
}

.footer a:hover {
  color: white;
}

/* 动画效果优化 - 性能优先 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
  will-change: transform, opacity;
}

/* 响应式设计 - 移动端优先 */
@media (max-width: 640px) {
  .swiper-container {
    min-height: 250px;
    max-height: 400px;
  }
  
  .swiper-slide-content h1 {
    font-size: 2rem !important;
    line-height: 1.2;
  }
  
  .swiper-slide-content p {
    font-size: 1.125rem !important;
  }
  
  .grid-layout {
    gap: 1rem;
  }
  
  .card {
    margin: 0.5rem;
    border-radius: 0.75rem;
  }
  
  .btn-primary,
  .btn-outline {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 100%;
    max-width: 300px;
  }
  
  /* 移动端字体优化 */
  html {
    font-size: 14px;
  }
  
  h1 {
    font-size: 2rem !important;
    line-height: 1.2;
  }
  
  h2 {
    font-size: 1.75rem !important;
    line-height: 1.3;
  }
  
  h3 {
    font-size: 1.5rem !important;
    line-height: 1.4;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  .grid-layout {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
  
  .swiper-container {
    min-height: 350px;
    max-height: 450px;
  }
}

@media (min-width: 769px) {
  .grid-layout {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
  }
}

/* 移动端导航菜单优化 */
@media (max-width: 768px) {
  .navbar-menu {
    position: fixed;
    top: 64px;
    left: -100%;
    width: 100%;
    height: calc(100vh - 64px);
    background: white;
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .navbar-menu.active {
    left: 0;
  }
  
  .mobile-menu-button {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation; /* 移动端优化 */
  }
}

/* 加载状态优化 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f4f6;
  border-radius: 50%;
  border-top-color: var(--primary-blue);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 工具类优化 */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.border-gradient {
  border: 2px solid;
  border-image: linear-gradient(135deg, var(--primary-blue), var(--accent-gold)) 1;
}

/* 无障碍支持优化 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 焦点样式优化 */
button:focus,
a:focus {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    transform: none;
  }
  
  .btn-primary:hover,
  .btn-outline:hover {
    transform: none;
  }
  
  /* 移动端触摸反馈 */
  .touch-feedback:active {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

/* 微信浏览器优化 */
@media (max-width: 768px) {
  /* 微信浏览器字体渲染优化 */
  body {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
  }
  
  /* 防止微信浏览器缩放 */
  input, select, textarea {
    font-size: 16px !important;
  }
  
  /* 微信浏览器下拉刷新区域 */
  body {
    overscroll-behavior-y: contain;
  }
  
  /* 微信浏览器长按菜单优化 */
  img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
  }
}

/* 性能优化类 */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* 滚动条优化 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 打印样式优化 */
@media print {
  .navbar, .footer, .btn-primary, .swiper-container {
    display: none !important;
  }
  
  body {
    color: #000;
    background: #fff;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .text-gradient {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* 减少动画对性能的影响 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 移动端表单优化 */
input, textarea, select {
  font-size: 16px; /* 防止iOS缩放 */
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.75rem;
  width: 100%;
  -webkit-appearance: none; /* 移动端样式统一 */
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* 移动端触摸反馈优化 */
.touch-feedback:active {
  opacity: 0.7;
  transform: scale(0.98);
}

/* 内容安全区域适配（iPhone X及以上） */
@supports(padding: max(0px)) {
  .safe-area-inset-top {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  
  .safe-area-inset-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  
  .safe-area-inset-left {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
  
  .safe-area-inset-right {
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* 性能优化：GPU加速 */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 移动端字体大小优化 */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  h1 {
    font-size: 2rem !important;
    line-height: 1.2;
  }
  
  h2 {
    font-size: 1.75rem !important;
    line-height: 1.3;
  }
  
  h3 {
    font-size: 1.5rem !important;
    line-height: 1.4;
  }
  
  p, li {
    font-size: 1rem !important;
    line-height: 1.6;
  }
}

/* 移动端性能优化：减少重绘 */
.static-transform {
  transform: translate3d(0, 0, 0);
}

/* 微信小程序样式兼容 */
.wechat-compatible {
  -webkit-overflow-scrolling: touch;
  overflow-scrolling: touch;
}

/* 移动端点击延迟优化 */
.tap-highlight-none {
  -webkit-tap-highlight-color: transparent;
}

/* 响应式间距优化 */
@media (max-width: 768px) {
  .mobile-padding {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .mobile-margin {
    margin-left: 1rem;
    margin-right: 1rem;
  }
}

/* 图片懒加载优化 */
.lazy-image-container {
  position: relative;
  overflow: hidden;
}

.lazy-image-container img {
  width: 100%;
  height: auto;
  transition: opacity 0.3s ease;
}

.lazy-image-container img:not([src]) {
  opacity: 0;
}

.lazy-image-container img[src] {
  opacity: 1;
}

/* 性能优化：内容可见性 */
.content-visibility-auto {
  content-visibility: auto;
  contain-intrinsic-size: 1px 5000px; /* 预估高度 */
}

/* 移动端性能优化：避免布局抖动 */
.avoid-layout-shift {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* 微信浏览器特定优化 */
.wechat-browser body {
  -webkit-user-select: none;
  user-select: none;
}

.wechat-browser img {
  -webkit-touch-callout: none;
}

/* 性能监控样式 */
.performance-monitor {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px;
  border-radius: 5px;
  font-size: 12px;
  z-index: 10000;
  display: none;
}

/* 加载性能指示器 */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-blue), var(--accent-gold));
  z-index: 10000;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.loading-indicator.active {
  transform: scaleX(1);
}

/* 资源加载优化 */
.preload-critical {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* 移动端滚动性能优化 */
.smooth-scroll {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 微信端访问速度优化 */
@media (max-width: 768px) {
  /* 减少微信端重绘 */
  .wechat-optimize {
    will-change: transform;
    transform: translateZ(0);
  }
  
  /* 微信端图片加载优化 */
  .wechat-optimize img {
    loading: lazy;
    decoding: async;
  }
}

/* 关键渲染路径优化 */
.critical-css {
  /* 首屏关键样式 */
}

/* 非关键样式延迟加载 */
.non-critical {
  display: none;
}

.non-critical.loaded {
  display: block;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 移动端性能监控 */
@media (max-width: 768px) {
  .performance-warning {
    background: #ff6b6b;
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    display: none;
  }
}

/* 微信端访问速度特定优化 */
.wechat-speed-optimize {
  /* 禁用复杂动画 */
  animation: none !important;
  transition: none !important;
  
  /* 简化阴影效果 */
  box-shadow: none !important;
  
  /* 优化图片显示 */
  image-rendering: -webkit-optimize-contrast;
}

/* 移动端触摸性能优化 */
.touch-performance {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* 响应式图片容器优化 */
.responsive-image-container {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 比例 */
  overflow: hidden;
}

.responsive-image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 微信端访问速度最终优化 */
@media (max-width: 768px) {
  .final-wechat-optimize {
    /* 最小化重绘区域 */
    contain: layout style paint;
    
    /* 优化字体渲染 */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeSpeed;
    
    /* 禁用不必要的效果 */
    filter: none;
    backdrop-filter: none;
  }
}