/* ============================================
   推薪客 (Tuixinke) 移动端适配样式
   Version: 1.0
   Last updated: 2026-05-12
   ============================================ */

/* ---- 基础重置 ---- */

/* 移除移动端点击高亮 */
* {
  -webkit-tap-highlight-color: transparent;
}

/* 防止 iOS 输入框自动缩放 (必须 >= 16px) */
input,
button,
select,
textarea {
  font-size: 16px !important;
}

/* 防止移动端双击缩放 */
a,
button,
[onclick],
[role="button"],
.touchable {
  touch-action: manipulation;
}

/* ---- Safe Area 支持 (刘海屏/圆角屏) ---- */

/* 顶部安全区 */
.safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}

/* 底部安全区 (常见于 iPhone X+) */
.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* 左右安全区 */
.safe-left {
  padding-left: env(safe-area-inset-left, 0px);
}
.safe-right {
  padding-right: env(safe-area-inset-right, 0px);
}

/* 全安全区边距 */
.safe-area-padding {
  padding: env(safe-area-inset-top, 0px)
           env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px)
           env(safe-area-inset-left, 0px);
}

/* 固定底部栏适配 (常见于 iOS/Android App 内嵌) */
.fixed-bottom-safe {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.fixed-top-safe {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

/* ---- 触摸反馈 ---- */

/* 通用点击反馈 */
.touchable:active,
a:active,
button:active,
[onclick]:active,
.btn:active,
.button:active {
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

/* 缩放点击反馈 (更适合卡片式按钮) */
.touch-scale:active {
  transform: scale(0.97);
  transition: transform 0.15s ease;
}

/* 最小触摸目标 (44px 规范) */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 触摸按钮通用样式 */
.btn-touch {
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---- 响应式布局 (max-width: 640px) ---- */

/* 手机横屏适配 */
@media screen and (max-width: 640px) {
  /* 隐藏桌面端专属元素 */
  .desktop-only {
    display: none !important;
  }

  /* 全宽容器 */
  .container,
  .wrapper,
  .page-content {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }

  /* 表单元素适配 */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 表格水平滚动 */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 防止内容溢出 */
  img,
  video,
  iframe {
    max-width: 100%;
    height: auto;
  }

  /* 调整字体大小 */
  body {
    font-size: 14px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }

  /* 间距调整 */
  .section,
  .card,
  .panel {
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
  }

  /* 按钮全宽 */
  .btn-block-mobile {
    width: 100%;
  }
}

/* ---- iOS/Android 特定修复 ---- */

/* 修复 iOS 滚动卡顿 */
.scroll-container {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* 修复 iOS input 内阴影 */
input {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

/* 修复 iOS select */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%23999' d='M1 1l5 5 5-5'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  padding-right: 32px;
}

/* 修复 Android input 下边框 */
input:focus,
textarea:focus,
select:focus {
  outline: none;
}

/* ---- 移动端 Toast/Notify 适配 ---- */

.toast-mobile {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: 80%;
  padding: 10px 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 14px;
  text-align: center;
  white-space: normal;
}

/* ---- 移动端 Tab Bar 适配 ---- */

.tab-bar-mobile {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid #eee;
  z-index: 100;
}

.tab-bar-mobile .tab-item {
  flex: 1;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---- 横向滚动容器 ---- */

.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
}

.scroll-x::-webkit-scrollbar {
  display: none;
}

/* ---- 禁用文本选择 (对按钮/操作类) ---- */

.no-select {
  -webkit-user-select: none;
  user-select: none;
}
