/* 移动端触摸体验优化 */

/* 1. 增大触摸目标 */
@media (max-width: 768px) {
  /* 按钮最小触摸区域44x44px */
  button,
  .btn,
  a.btn,
  .navbar-cta,
  .navbar-phone,
  .load-more-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
  }

  /* 导航链接增大触摸区域 */
  .navbar-link,
  .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
  }

  /* 表单输入框优化 */
  input,
  select,
  textarea {
    font-size: 16px !important; /* 防止iOS自动缩放 */
    min-height: 44px;
    padding: 12px;
  }

  /* 卡片增大触摸反馈区域 */
  .service-card,
  .news-card,
  .case-card,
  .faq-item {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .service-card:active,
  .news-card:active,
  .case-card:active,
  .faq-item:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
}

/* 2. 触摸反馈优化 */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 允许文本选择（针对内容区域） */
p,
h1,
h2,
h3,
h4,
h5,
h6,
li,
td,
th,
.article-content,
.news-excerpt {
  -webkit-user-select: text;
  user-select: text;
}

/* 3. 平滑滚动 */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 4. 防止水平滚动 */
body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

/* 5. 优化滚动性能 */
.scroll-reveal,
.animated {
  will-change: transform, opacity;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* 6. 触摸滑动优化 */
.touch-slider,
.carousel {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* 7. 下拉菜单触摸优化 */
@media (max-width: 768px) {
  .navbar-dropdown {
    position: static;
    box-shadow: none;
    border-top: 1px solid rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .navbar-item.active .navbar-dropdown {
    max-height: 500px;
  }

  .dropdown-item {
    border-bottom: 1px solid rgba(0,0,0,0.05);
  }
}

/* 8. 浮动按钮优化 */
.floating-phone,
.float-contact {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.floating-phone:active,
.float-contact:active {
  transform: scale(0.95);
}

/* 9. 图片触摸优化 */
img {
  -webkit-touch-callout: none;
  pointer-events: auto;
}

/* 10. 加载动画优化 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* 11. 模态框触摸优化 */
.modal-overlay {
  touch-action: none;
}

.modal-content {
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 12. 表单验证反馈优化 */
.form-group input.error,
.form-group select.error,
.form-group textarea.error {
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* 13. 通知消息触摸优化 */
.notification {
  touch-action: manipulation;
  cursor: pointer;
}

.notification:active {
  opacity: 0.8;
}

/* 14. 手势操作提示 */
.swipe-hint {
  position: relative;
}

.swipe-hint::after {
  content: '← 滑动查看更多 →';
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: #999;
  white-space: nowrap;
}

/* 15. 优化长列表滚动 */
.news-grid,
.service-grid {
  -webkit-overflow-scrolling: touch;
}

/* 16. 防止双击缩放 */
@media (max-width: 768px) {
  button,
  a,
  input,
  select,
  textarea {
    touch-action: manipulation;
  }
}
