/* 响应式设计和跨浏览器兼容性增强 */

/* 基础重置和浏览器兼容性 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 针对旧版浏览器的兼容性 */
@media screen and (max-width: 768px) {
  /* 强制移动设备全屏显示，防止缩放问题 */
  html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* 确保触摸元素有足够的点击区域 */
  button, a {
    min-width: 44px;
    min-height: 44px;
  }
}

/* 移动端优化 */
@media screen and (max-width: 640px) {
  /* 导航栏优化 */
  header#navbar {
    padding: 0.5rem 1rem;
  }
  
  /* 移动端导航菜单 */
  #mobile-menu {
    background-color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }
  
  #mobile-menu a {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
  }
  
  /* 导航菜单布局优化 */
  #mobile-menu .flex-col {
    justify-content: center;
  }
  
  /* 英雄区域优化 */
  section.hero-section {
    padding-top: 20vh !important;
    padding-bottom: 10vh !important;
  }
  
  /* 统计数据列数调整 */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* 按钮组调整为垂直排列 */
  .btn-group {
    flex-direction: column !important;
    width: 100%;
  }
  
  /* 表单元素调整 */
  .form-control {
    width: 100% !important;
    margin-bottom: 1rem !important;
  }
  
  /* 卡片布局调整 */
  .card-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* 字体大小响应式调整 */
  h1 {
    font-size: 1.8rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
  
  h3 {
    font-size: 1.3rem !important;
  }
  
  p {
    font-size: 1rem !important;
  }
}

/* 平板设备优化 */
@media screen and (min-width: 641px) and (max-width: 1024px) {
  /* 卡片布局调整为2列 */
  .card-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  /* 统计数据调整为2列 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* 大屏幕优化 */
@media screen and (min-width: 1025px) and (max-width: 1440px) {
  .container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* 超大屏幕优化 */
@media screen and (min-width: 1441px) {
  .container {
    max-width: 1400px;
    margin: 0 auto;
  }
  
  /* 字体大小略微放大以适应大屏幕 */
  .large-screen-text {
    font-size: 1.1rem;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  :root {
    --color-primary: #000000;
    --color-secondary: #000000;
    --color-background: #ffffff;
  }
  
  body {
    background-color: var(--color-background) !important;
    color: var(--color-secondary) !important;
  }
  
  button, .btn {
    border: 2px solid currentColor;
  }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 打印样式 */
@media print {
  /* 隐藏导航栏、按钮等打印时不需要的元素 */
  header,
  footer,
  button,
  .no-print {
    display: none !important;
  }
  
  /* 设置打印样式 */
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background-color: #fff;
  }
  
  /* 优化页面布局 */
  .container {
    width: 100%;
    max-width: none;
    padding: 0;
  }
  
  /* 确保链接显示完整URL */
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* 浏览器特定样式修复 */

/* Webkit内核浏览器 (Chrome, Safari) */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  /* 修复Webkit下的一些渲染问题 */
  .webkit-fix {
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
  }
}

/* Firefox特定修复 */
@-moz-document url-prefix() {
  /* Firefox特定样式 */
  .firefox-fix {
    /* Firefox特定修复 */
  }
}

/* IE/Edge特定修复 */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  /* IE/Edge特定样式 */
  .ie-fix {
    /* IE/Edge特定修复 */
  }
}

/* 触摸设备特定样式 */
@media (hover: none) and (pointer: coarse) {
  /* 为触摸设备优化的样式 */
  .touch-optimized {
    /* 触摸优化样式 */
    padding: 0.75rem;
  }
}

/* 响应式表格 */
@media screen and (max-width: 768px) {
  /* 使表格在小屏幕上可以水平滚动 */
  .responsive-table {
    overflow-x: auto;
    display: block;
  }
  
  /* 如果需要，可以进一步优化表格布局 */
  .responsive-table table {
    width: 100%;
    min-width: 640px;
  }
}

/* 图片响应式处理 */
img {
  max-width: 100%;
  height: auto;
}

/* 确保SVG图标在所有设备上正确显示 */
svg {
  width: 100%;
  height: auto;
  fill: currentColor;
}
