@tailwind base;
@tailwind components;
@tailwind utilities;

/* 自定义基础样式 */
@layer base {
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  html {
    height: 100%;
    scroll-behavior: smooth;
    /* 优化触摸滚动 */
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
  }

  body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
    /* 优化触摸滚动 */
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
    /* 防止文本选择干扰触摸交互 */
    -webkit-user-select: none;
    user-select: none;
    /* 防止双击缩放 */
    -webkit-tap-highlight-color: transparent;
  }

  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* 优化触摸交互的链接和按钮 */
  a, button, [role="button"], [tabindex="0"] {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    /* 优化触摸反馈 */
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
    /* 确保可点击元素有适当的触摸反馈 */
    cursor: pointer;
  }

  /* 按钮和交互元素的触摸优化 */
  button, [role="button"], [tabindex="0"] {
    /* 增加点击区域 */
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 优化点击区域 */
    padding: 0.5rem 0.75rem;
  }

  /* 普通链接样式 */
  a {
    display: inline;
    min-height: auto;
    min-width: auto;
    padding: 0;
    align-items: normal;
    justify-content: normal;
  }

  /* 调整表单元素的触摸交互 */
  input, textarea, select {
    outline: none;
    border: 1px solid #e2e8f0;
    transition: border-color 0.3s ease;
    /* 增加表单元素的触摸区域 */
    min-height: 44px;
    /* 允许表单元素选择文本 */
    -webkit-user-select: text;
    user-select: text;
  }

  input:focus, textarea:focus, select:focus {
    border-color: #3b82f6;
  }

  /* 优化触摸设备上的滚动条 */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  /* 防止iOS上的橡皮筋效果 */
  .no-bounce {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
  }
}

/* 自定义组件样式 */
@layer components {
  .btn {
    @apply px-6 py-3 rounded-lg font-medium;
    /* 直接使用CSS过渡效果，不依赖Tailwind插件 */
    transition: all 0.3s ease;
    /* 确保按钮有足够的触摸区域 */
    min-height: 44px;
    min-width: 44px;
    /* 优化触摸反馈 */
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
    /* 确保按钮有适当的触摸反馈 */
    touch-action: manipulation;
    /* 防止双击缩放 */
    -webkit-user-select: none;
    user-select: none;
  }

  .btn-primary {
    @apply bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800;
  }

  .btn-secondary {
    @apply bg-gray-200 text-gray-700 hover:bg-gray-300 active:bg-gray-400;
  }

  .card {
    @apply bg-white rounded-lg;
    /* 直接使用CSS属性，不依赖Tailwind插件 */
    cursor: pointer;
    /* 直接使用CSS阴影效果，不依赖Tailwind插件 */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    /* 悬停时的阴影效果 */
    transition: all 0.3s ease;
    /* 优化卡片触摸交互 */
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
  }
  
  .card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  }

  .container {
    @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
  }

  .section {
    @apply py-16 lg:py-24;
  }

  .heading-primary {
    @apply text-4xl lg:text-5xl font-bold text-gray-900;
  }

  .heading-secondary {
    @apply text-2xl lg:text-3xl font-semibold text-gray-800;
  }

  .text-gradient {
    @apply bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent;
  }

  /* 优化触摸导航 */
  .nav-item {
    @apply hover:text-blue-600;
    /* 直接使用CSS过渡效果，不依赖Tailwind插件 */
    transition: all 0.3s ease;
    /* PC端样式 - 正常的文本显示 */
    display: inline;
    align-items: normal;
    justify-content: normal;
    min-height: auto;
    min-width: auto;
    padding: 0;
  }

  /* 触摸友好的列表项 */
  .list-item {
    @apply py-4 px-6 hover:bg-gray-50;
    /* 直接使用CSS过渡效果，不依赖Tailwind插件 */
    transition: all 0.2s ease;
    /* 确保列表项有足够的触摸区域 */
    min-height: 48px;
    display: flex;
    align-items: center;
  }
}

/* 动画效果 */
@layer utilities {
  .animate-fade-in {
    animation: fadeIn 0.5s ease-in-out;
  }

  .animate-slide-up {
    animation: slideUp 0.5s ease-out;
  }

  .animate-bounce-slow {
    animation: bounce 2s infinite;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* 响应式工具类 */
.mobile-only {
  @apply block lg:hidden;
}

.desktop-only {
  @apply hidden lg:block;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
}

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

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

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