/* ============================================================
   推薪客 统一响应式框架 — responsive-unified.css v1.0
   三断点体系，移动端触摸优化，safe-area支持
   ============================================================ */

/* ============================================================
   断点定义（由低到高）：
     - 手机：  < 768px
     - 平板：  768px – 1023px
     - 桌面：  >= 1024px
   ============================================================ */

/* ===== 基础响应式容器 ===== */
.container,
.tkx-container {
  width: 100%;
  margin: 0 auto;
  padding-left: var(--space-md, 16px);
  padding-right: var(--space-md, 16px);
  box-sizing: border-box;
}

/* 小容器（窄版） */
.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding-left: var(--space-md, 16px);
  padding-right: var(--space-md, 16px);
}

/* 宽容器 */
.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding-left: var(--space-md, 16px);
  padding-right: var(--space-md, 16px);
}

/* ===== 响应式网格 ===== */
.grid {
  display: grid;
  gap: var(--space-md, 16px);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== 手机端 (< 768px) ===== */
@media (max-width: 767px) {
  /* 容器 */
  .container,
  .tkx-container,
  .container-narrow,
  .container-wide {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* 网格 → 单列 */
  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .grid-2-mobile {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* 排版缩放 */
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }
  body, .text-base { font-size: 14px; }
  .text-sm { font-size: 12px; }

  /* 按钮全宽触摸优化 */
  .btn-block-mobile {
    width: 100%;
    text-align: center;
  }

  /* 卡片间距 */
  .card, .tkx-card {
    padding: 14px;
    border-radius: 10px;
  }

  /* 导航折叠 */
  .navbar-desktop-links { display: none; }
  .navbar-mobile-toggle { display: flex; }

  /* 表格 → 卡片式 */
  .table-responsive thead { display: none; }
  .table-responsive tr {
    display: block;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
  }
  .table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 13px;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
  }

  /* 弹窗全屏 */
  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    animation: modalSlideUp 0.3s ease;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Tabbar适配 */
  .tabbar { padding-bottom: env(safe-area-inset-bottom, 4px); }

  /* Safe area padding */
  .safe-bottom-mobile {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* 隐藏桌面元素 */
  .desktop-only { display: none !important; }

  /* 移动端section间距 */
  .section { padding: 30px 0; }
  .section-title { font-size: 20px; margin-bottom: 16px; }
}

/* ===== 平板端 (768px ~ 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  .container,
  .tkx-container {
    padding-left: 24px;
    padding-right: 24px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }

  h1 { font-size: 26px; }
  h2 { font-size: 20px; }
  h3 { font-size: 17px; }

  .card, .tkx-card { padding: 18px; }

  .mobile-only { display: none !important; }
  .desktop-only-tablet { display: block !important; }

  .section { padding: 40px 0; }
  .section-title { font-size: 24px; }
}

/* ===== 桌面端 (>= 1024px) ===== */
@media (min-width: 1024px) {
  .container,
  .tkx-container {
    max-width: 1200px;
    padding-left: 32px;
    padding-right: 32px;
  }
  .container-narrow {
    max-width: 800px;
  }
  .container-wide {
    max-width: 1400px;
  }

  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }

  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
  h3 { font-size: 18px; }

  .card, .tkx-card { padding: 24px; }

  .mobile-only { display: none !important; }
  .tablet-only { display: none !important; }
  .navbar-mobile-toggle { display: none; }

  .section { padding: 60px 0; }
  .section-title { font-size: 28px; margin-bottom: 32px; }
}

/* ===== 触摸优化（移动端全局） ===== */
@media (hover: none) and (pointer: coarse) {
  /* 按钮和链接最小触摸区域 44px */
  .btn, .tkx-btn,
  a.nav-link, .navbar-links a,
  .tab, .pagination button, .pagination a,
  .list-item, .dropdown-item,
  [role="button"], .touchable {
    min-height: 44px;
  }

  /* 防止双击缩放 */
  * { touch-action: manipulation; }

  /* 禁用hover效果（触摸设备悬停永远无效） */
  .btn:hover, .tkx-btn:hover,
  .navbar-links a:hover,
  .list-item:hover {
    transform: none;
    box-shadow: none;
  }

  /* 触摸反馈替代hover */
  .btn:active, .tkx-btn:active,
  .navbar-links a:active,
  .list-item:active {
    opacity: 0.8;
    transform: scale(0.97);
  }

  /* 下拉菜单触摸友好 */
  select {
    font-size: 16px !important;
    padding: 12px 14px;
  }
}

/* ===== Safe Area 支持 ===== */
.safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}
.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);
}
.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);
}

/* ===== 隐式展示控制类 ===== */
.mobile-only,
.tablet-only,
.desktop-only-tablet,
.desktop-only {
  /* 由各断点媒体查询控制显示/隐藏 */
}

/* ===== 响应式字体缩放 ===== */
:root {
  --h1-size-mobile: 22px;
  --h1-size-tablet: 26px;
  --h1-size-desktop: 32px;
  --h2-size-mobile: 18px;
  --h2-size-tablet: 20px;
  --h2-size-desktop: 24px;
  --section-padding-mobile: 30px;
  --section-padding-tablet: 40px;
  --section-padding-desktop: 60px;
}

/* ===== 响应式布局辅助 ===== */
.flex-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md, 16px);
}
@media (max-width: 767px) {
  .flex-responsive {
    flex-direction: column;
  }
  .flex-responsive > * {
    width: 100%;
  }
}

/* ===== Hero区域响应式 ===== */
.hero-section {
  padding: 80px 0 60px;
  text-align: center;
}
.hero-title { font-size: 36px; font-weight: 700; margin-bottom: 16px; }
.hero-subtitle { font-size: 18px; color: var(--text-secondary); margin-bottom: 32px; }

@media (max-width: 767px) {
  .hero-section { padding: 50px 0 36px; }
  .hero-title { font-size: 26px; }
  .hero-subtitle { font-size: 15px; margin-bottom: 24px; }
  .cta-actions { flex-direction: column; align-items: center; }
  .cta-actions .btn { width: 100%; max-width: 280px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .hero-section { padding: 60px 0 44px; }
  .hero-title { font-size: 30px; }
  .hero-subtitle { font-size: 16px; }
}

/* ===== 特性/功能网格响应式 ===== */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 767px) {
  .feature-grid { grid-template-columns: 1fr; gap: 14px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
}

/* ===== 统计数字响应式 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 767px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ===== 门户卡片网格 ===== */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.portal-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 767px) {
  .portal-grid { grid-template-columns: 1fr; gap: 10px; }
  .portal-grid-3 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ===== 侧边栏响应式 ===== */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .sidebar.open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: var(--z-sidebar, 600);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    animation: slideInLeft 0.25s ease;
  }
  @keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-sidebar, 600) - 1);
  }
  .main-content {
    margin-left: 0 !important;
    padding: 16px;
  }
}

/* ===== Tabbar 滚动隐藏效果（移动端） ===== */
@media (max-width: 767px) {
  .tabbar-auto-hide {
    transition: transform 0.3s ease;
  }
  .tabbar-auto-hide.hidden-scroll {
    transform: translateY(100%);
  }
}

/* ===== 图片响应式 ===== */
.img-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}
.img-round { border-radius: 50%; }
.img-rounded { border-radius: var(--radius); }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-pale);
}
.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 56px; height: 56px; }

/* ===== 底部间距适配（tabbar 占用） ===== */
.has-tabbar {
  padding-bottom: calc(var(--tabbar-height, 50px) + env(safe-area-inset-bottom, 0px));
}

/* ===== 横屏提示 ===== */
@media (orientation: landscape) and (max-height: 500px) {
  .landscape-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: var(--primary-pale);
    font-size: 12px;
    color: var(--primary-dark);
  }
}
