/* ============================================================
   推薪客 唯一响应式框架 — tkx-responsive.css v1.0
   合并 tuixinke-responsive.css + responsive-unified.css
   断点：<768px 手机 | 768-1023px 平板 | ≥1024px 桌面
   ============================================================ */

/* ----- 基础变量 ----- */
: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;
}

/* ============================================
   手机端 (< 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; }
  .hero-title { font-size: 26px; }
  .hero-subtitle { font-size: 15px; margin-bottom: 24px; }
  .section-title { font-size: 20px; margin-bottom: 16px; }

  /* 按钮全宽 */
  .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; }
  .navbar-toggle { display: flex; align-items: center; justify-content: center; }
  .navbar-links {
    display: none;
    position: fixed; top: 50px; left: 0; right: 0;
    background: var(--bg-card, #fff); flex-direction: column;
    padding: 12px 16px 16px; gap: 2px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    border-bottom: 1px solid var(--border, #e5e7eb); z-index: 99;
  }
  .navbar-links.active { display: flex; }
  .navbar-links a { padding: 10px 14px; font-size: 15px; width: 100%; border-radius: var(--radius, 8px); }
  .navbar-links .navbar-actions {
    display: flex; gap: 10px; margin-top: 10px;
    padding: 10px 14px 4px; border-top: 1px solid var(--border); width: 100%;
  }
  .navbar-links .navbar-actions .btn { flex: 1; text-align: center; padding: 10px 0; font-size: 14px; }
  .navbar { height: 50px; }
  .navbar .container { height: 50px; padding: 0 12px; }
  .navbar-brand { font-size: 16px; }
  .navbar-brand img { height: 28px; }

  /* 表格 → 卡片式 */
  .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;
  }
  .table-wrap { overflow-x: auto; }
  .table-wrap table { min-width: 600px; }

  /* 弹窗全屏 */
  .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 .3s ease;
  }
  @keyframes modalSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* 侧边栏 */
  .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 .25s ease;
  }
  @keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: calc(var(--z-sidebar, 600) - 1);
  }
  .main-content { margin-left: 0 !important; padding: 16px; }

  /* Hero/门户 */
  .hero-section { padding: 50px 0 36px; }
  .cta-actions { flex-direction: column; align-items: center; }
  .cta-actions .btn { width: 100%; max-width: 280px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { min-width: 0; width: 100%; }
  .portal-header { padding: 24px 16px; }
  .portal-header h1 { font-size: 20px; }
  .portal-header p { font-size: 14px; }
  .portal-grid { grid-template-columns: 1fr; gap: 10px; }
  .portal-grid-3 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .portal-grid-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .portal-card { padding: 16px; }
  .portal-stat { min-width: calc(50% - 8px); padding: 12px 8px; }
  .portal-stat .number { font-size: 18px; }
  .portal-stat .label { font-size: 12px; }
  .hero-stats { gap: 8px; }

  /* 网格 */
  .feature-grid { grid-template-columns: 1fr; gap: 14px; }
  .role-grid { grid-template-columns: 1fr; gap: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .panel-grid { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }

  /* 工具 */
  .search-bar { flex-direction: column; padding: 12px; }
  .search-bar .field { width: 100%; }
  .search-bar .actions { width: 100%; }
  .search-bar .actions .btn { flex: 1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { flex-wrap: wrap; }
  .toolbar-right { justify-content: flex-start; }
  .info-row { flex-direction: column; gap: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .content-card { padding: 16px; }
  .page-header { padding: 16px 0; }
  .page-header h1 { font-size: 18px; }
  .portal-actions { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .pagination button { padding: 6px 10px; font-size: 12px; }
  
  /* section间距 */
  .section { padding: 30px 0; }

  /* 隐藏控制 */
  .hide-mobile { display: none !important; }
  .desktop-only { display: none !important; }

  /* 响应式flex */
  .flex-responsive { flex-direction: column; }
  .flex-responsive > * { width: 100%; }

  /* tabbar + safe-area */
  .tabbar { padding-bottom: env(safe-area-inset-bottom, 4px); }
  .tabbar-auto-hide { transition: transform .3s ease; }
  .tabbar-auto-hide.hidden-scroll { transform: translateY(100%); }
  .has-tabbar { padding-bottom: calc(var(--tabbar-height, 50px) + env(safe-area-inset-bottom, 0px)); }
  .safe-bottom-mobile { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ============================================
   平板端 (768px ~ 1023px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .container, .tkx-container { padding-left: 24px; padding-right: 24px; }
  .container-narrow { max-width: 720px; }
  
  /* 网格 */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .role-grid { grid-template-columns: repeat(2, 1fr); }
  .portal-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar .field { flex: 1; min-width: 160px; }

  /* 排版 */
  h1 { font-size: 26px; }
  h2 { font-size: 20px; }
  h3 { font-size: 17px; }
  .hero-title { font-size: 30px; }
  .hero-subtitle { font-size: 16px; }
  .section-title { font-size: 22px; }
  .portal-header h1 { font-size: 24px; }
  .portal-header { padding: 30px 20px; }

  /* 卡片 */
  .card, .tkx-card { padding: 18px; }

  /* Hero */
  .hero-section { padding: 60px 0 44px; }

  /* section */
  .section { padding: 40px 0; }

  /* 隐藏控制 */
  .hide-tablet { display: none !important; }
  .mobile-only { display: none !important; }
  .desktop-only-tablet { display: block !important; }
}

/* ============================================
   桌面端 (>= 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; }
  .hero-title { font-size: 36px; }
  .hero-subtitle { font-size: 18px; }

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

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

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

/* ============================================
   触摸优化（移动端全局）
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  .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; }
  .btn:hover, .tkx-btn:hover, .navbar-links a:hover, .list-item:hover {
    transform: none; box-shadow: none;
  }
  .btn:active, .tkx-btn:active, .navbar-links a:active, .list-item:active {
    opacity: .8; transform: scale(.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); }
.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);
}

/* ============================================
   横屏提示
   ============================================ */
@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);
  }
}

/* ============================================
   通用响应式辅助类
   ============================================ */
.flex-responsive {
  display: flex; flex-wrap: wrap; gap: var(--space-md, 16px);
}
.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; }

/* ============================================
   推薪客响应式增强 v2.0 (2026-05-18)
   - 自适应容器
   - 比例缩放字体
   - 安全边距
   ============================================ */

/* 全站基础响应式重置 */
html { -webkit-text-size-adjust: 100%; }
img, video, svg { max-width: 100%; height: auto; }
table { width: 100%; overflow-x: auto; display: block; }
input, select, textarea { max-width: 100%; }

/* 容器自适应 */
.container-fluid {
  width: 100%;
  max-width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
}
@media (min-width: 1200px) {
  .container-fluid {
    padding: 0 32px;
  }
}

/* 比例字体 */
@media (max-width: 480px) {
  body { font-size: 14px; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.1rem; }
  .tkx-card, [class*="card"]:not(.tkx-theme-card) { padding: 12px; }
}
@media (min-width: 481px) and (max-width: 767px) {
  body { font-size: 15px; }
}
@media (min-width: 768px) {
  body { font-size: 16px; }
}

/* 响应式表格 */
@media (max-width: 640px) {
  table.tkx-responsive-table thead { display: none; }
  table.tkx-responsive-table tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px;
  }
  table.tkx-responsive-table td {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    border: none;
  }
  table.tkx-responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6B7280;
  }
}

/* 响应式网格间距 */
@media (max-width: 480px) {
  .tkx-grid, .grid-2, .grid-3, .grid-4 {
    gap: 8px;
  }
}

/* ============================================
   登录/注册页面 — 统一响应式
   ============================================ */

/* ----- 登录卡片（桌面居中，移动全宽） ----- */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 60px;
}

.auth-card {
  background: var(--bg-card, #fff);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(79,70,229,0.1);
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo img {
  height: 32px;
  border-radius: 6px;
}
.auth-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary, #FF6600);
  margin-top: 8px;
}

/* 手机端 (<=480px) 登录卡片全宽 */
@media (max-width: 480px) {
  .auth-page {
    padding: 60px 12px 40px;
  }
  .auth-card {
    padding: 24px 16px;
    border-radius: 12px;
    max-width: 100%;
  }
  .auth-logo h1 { font-size: 18px; }
  .auth-logo img { height: 28px; }
}

/* 平板 (481-767px) */
@media (min-width: 481px) and (max-width: 767px) {
  .auth-page {
    padding: 70px 20px 50px;
  }
  .auth-card {
    padding: 32px 24px;
    max-width: 380px;
  }
}

/* ----- 登录表单字段 ----- */
.auth-page .form-group {
  margin-bottom: 16px;
}
.auth-page .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #333);
  margin-bottom: 6px;
}
.auth-page .form-group .input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-page .form-group .input:focus {
  border-color: var(--primary, #FF6600);
  box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.1);
}

/* 验证码行 */
.auth-page .code-row {
  display: flex;
  gap: 8px;
}
.auth-page .code-row .input { flex: 1; }
.auth-page .code-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* 密码切换 */
.auth-page .pwd-wrap {
  position: relative;
}
.auth-page .pwd-wrap .pwd-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #9ca3af;
  font-size: 13px;
  background: none;
  border: none;
  padding: 4px 8px;
}

/* 协议勾选 */
.auth-page .agreement {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary, #9CA3AF);
  margin-bottom: 12px;
}
.auth-page .agreement input[type="checkbox"] {
  accent-color: var(--primary, #FF6600);
  margin-top: 2px;
}
.auth-page .agreement a {
  color: var(--primary, #FF6600);
  text-decoration: none;
}

/* 登录按钮 */
.auth-page .btn-login {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
}

/* 其他登录方式分隔线 */
.auth-page .divider {
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-page .divider::before,
.auth-page .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, #E5E7EB);
}
.auth-page .divider span {
  font-size: 13px;
  color: var(--text-secondary, #9CA3AF);
  white-space: nowrap;
}

/* 微信登录按钮 */
.auth-page .btn-wechat {
  width: 100%;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #07C160;
  border-color: #07C160;
}
.auth-page .btn-wechat:hover {
  background: rgba(7, 193, 96, 0.05);
}

/* 底部切换链接 */
.auth-page .auth-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary, #9CA3AF);
}
.auth-page .auth-footer a {
  color: var(--primary, #FF6600);
  text-decoration: none;
  font-weight: 600;
}

/* 错误提示 */
.auth-page .error-msg {
  display: none;
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

/* ----- 角色选择卡片（登录中心/注册中心） ----- */
.role-cards {
  display: grid;
  gap: 12px;
}
@media (min-width: 481px) {
  .role-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}
.role-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.role-card:hover {
  border-color: var(--primary, #FF6600);
  box-shadow: 0 4px 16px rgba(255, 102, 0, 0.12);
  transform: translateY(-2px);
}
.role-card .role-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.role-card .role-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #333);
  margin-bottom: 4px;
}
.role-card .role-desc {
  font-size: 12px;
  color: var(--text-secondary, #9CA3AF);
}

/* 手机端角色卡片单列 */
@media (max-width: 480px) {
  .role-cards { grid-template-columns: 1fr; }
  .role-card { padding: 18px 14px; display: flex; align-items: center; gap: 12px; text-align: left; }
  .role-card .role-icon { font-size: 28px; margin-bottom: 0; }
}

/* ===== dark模式适配 ===== */
body[data-theme="dark"] .auth-card {
  background: #1e1e2e;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
body[data-theme="dark"] .auth-page .form-group .input {
  background: #2a2a3e;
  border-color: #3a3a4e;
  color: #e0e0e0;
}
body[data-theme="dark"] .auth-page .error-msg {
  background: #3a1a1a;
  border-color: #5a2a2a;
  color: #ff6b6b;
}
body[data-theme="dark"] .role-card {
  background: #1e1e2e;
  border-color: #3a3a4e;
}
body[data-theme="dark"] .role-card:hover {
  border-color: var(--primary, #FF6600);
}
