/* 南模数字资源站 · 全局移动端适配补丁（mobile.css）
 * 目标：手机 100% / 平板 59% 的访问体验。只做通用的低风险修复，不覆盖各页独特样式。
 * 加载顺序：放在各页 <style> 之后，利用 @media 内的选择器做窄屏修正。
 */

/* ---------- 平板与手机通用（≤900px）---------- */
@media (max-width: 900px) {
  /* 常见双列主布局塌成单列：个人资料(.cols)、发现用户(.layout)、两列表单 */
  .cols, .layout, .grid-2, .two-col, .content-2 { grid-template-columns: 1fr !important; }
  /* 四列统计卡降为两列 */
  .stats, .stats-grid, .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ---------- 手机（≤720px）---------- */
@media (max-width: 720px) {
  /* 容器不超出视口（各页 .card/.modal 本身已 width:100%+max-width，无需改动） */
  .wrap, .container, main { max-width: 100% !important; }

  /* 多列网格统一降为窄列或单列 */
  .cat-grid, .badge-grid, .perm-grid, .app-grid,
  .grid, .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
  .admin-grid, .manage-grid, .stat-grid-4,
  [class*="grid-4"] { grid-template-columns: repeat(2, 1fr) !important; }

  /* 表格：外层可横向滚动，避免撑破视口 */
  table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead, tbody, tr { width: max-content; }

  /* 触控目标：按钮最小 40px 高 */
  button:not(.btn-sm):not(#nm-privacy-btn), .btn,
  .btn-sm, .back, a.btn { min-height: 40px; }
  input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; }
}

/* ---------- 窄屏手机（≤480px）---------- */
@media (max-width: 480px) {
  html, body { overflow-x: hidden; }

  /* 防 iOS Safari 聚焦输入框时自动放大页面（字号需 ≥16px） */
  input:not([type="checkbox"]):not([type="radio"]),
  textarea, select { font-size: 16px !important; max-width: 100%; }

  /* 双列表单（如注册姓名/班级）在窄屏单列 */
  .form-row, .row-2 { grid-template-columns: 1fr !important; }

  /* 顶栏/标题栏在窄屏允许换行，避免按钮挤压标题 */
  .top, .title-bar, .toolbar { flex-wrap: wrap; }
  .title-bar h2 { font-size: 17px; }

  /* 图片/媒体不超出容器 */
  img, video, canvas { max-width: 100%; height: auto; }

  /* 表格单元格缩小内边距 */
  th, td { padding: 7px 9px !important; font-size: 12.5px; }
}
