/* ============================================================================
   涂大大知识库 · 手机端自适应覆盖样式
   2026-10-21 ｜ 皮皮 ｜ 只在 ≤720px 生效，桌面端零影响

   背景：前端只有编译产物、没有源码，所以走「CSS 覆盖」而非改组件。
   实测环境：项目自带 UI 陪跑服务（server/scripts/ui-probe-serve.mjs）+ 真实 web/dist，
             iPhone 13（390×664）、320/360/414/768 四档宽度。

   ⚠️ 全部关键规则带 !important：这段样式放在 <head> 靠前位置，
      antd v5 的样式是运行时注入到 <head> 末尾的，同权重时后者胜 ——
      不加 !important 会被 antd 盖掉（这是实测踩过的取舍，别删）。
   ========================================================================== */

@media (max-width: 720px) {

  /* ── ① 顶栏：这是全站最大的毛病 ────────────────────────────────────────
     现象（改前实测）：antd Layout.Header 默认 height:64px + line-height:64px，
     但顶栏里的用户名 / 角色 / 3 个按钮在 390px 宽下需要 200px 高。
     容器高度写死 ⇒ 内容上下溢出：y=-68（跑到屏幕外）+ y=108（压住正文标题）。
     ⇒ 必须让容器自己撑高，并允许换行。                                        */
  .app-header {
    height: auto !important;
    line-height: 1.45 !important;
    /* 左侧 48px 让给 absolute 定位的汉堡按钮，否则它会压住第一行文字 */
    padding: 8px 10px 8px 48px !important;
    flex-wrap: wrap !important;
    row-gap: 6px !important;
    align-items: flex-start !important;
  }
  /* 侧栏收起后，顶栏这份大标题是重复信息，手机上让位给操作区 */
  .app-header > .ant-typography { display: none !important; }

  .app-header-who {
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    font-size: 13px;
  }
  /* 第一行（积分/姓名/花名/公司/角色）允许换行，不撑破屏幕 */
  .app-header-who > .ant-space {
    width: 100% !important;
    flex-wrap: wrap !important;
    row-gap: 4px !important;
    column-gap: 10px !important;
  }
  .app-header-who > .ant-space .ant-space-item { flex: 0 1 auto; min-width: 0; }
  .app-header-who > .ant-space .ant-tag { margin: 0 !important; }

  /* 三个操作按钮平分一行 */
  .app-header-who .ant-btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 32px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
  }
  .app-header-who .ant-btn > span:last-child {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ── ② 汉堡按钮 ────────────────────────────────────────────────────────
     默认 top:64px，正好落在正文第一行上（改前实测压住「内容录入」标题）。 */
  .ant-layout-sider-zero-width-trigger {
    top: 8px !important;
    left: 6px !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    border-radius: 10px !important;
    background: rgba(0, 0, 0, .72) !important;
    z-index: 30 !important;
  }
  .ant-layout-sider-zero-width-trigger .anticon { font-size: 16px !important; }

  /* ── ③ 内容区留白 ──────────────────────────────────────────────────────
     桌面 20px 在手机上浪费一条手指宽，收到 12px 换来更宽的卡片。 */
  .app-content { padding: 12px !important; }
  .page-title { font-size: 18px !important; }
  .page-subtitle { font-size: 12.5px !important; }

  /* ── ④ 按钮组：antd Space 默认不换行 ──────────────────────────────────
     现象（改前实测）：内容输入台的「开始上传/刷新进度/清除已结束/清空列表」
     挤在一个不换行的 ant-space 里，总宽 508px，把整页撑到 545px。 */
  .ant-space { flex-wrap: wrap !important; row-gap: 8px !important; }
  .ant-space-item { max-width: 100%; }
  .ant-tabs-tabpane .ant-space .ant-btn { flex: 0 1 auto !important; }

  /* ── ⑤ 卡片头：标题与右侧操作重叠 ────────────────────────────────────
     现象（改前实测）：专家审核台的「专家审核」标题被「自动委派」按钮压住。
     ⇒ 标题独占一行，按钮换到下一行。 */
  .ant-card-head-wrapper { flex-wrap: wrap !important; row-gap: 8px !important; }
  .ant-card-head-title {
    flex: 1 1 100% !important;
    padding-right: 0 !important;
    white-space: normal !important;
  }
  .ant-card-extra { width: 100% !important; margin-left: 0 !important; }
  .ant-card-extra .ant-space { width: 100% !important; }

  /* ── ⑥ 触控目标：antd 默认 32px，手指略勉强 ────────────────────────── */
  .ant-btn { min-height: 34px; }
  .ant-btn-sm { min-height: 30px; }
  .ant-select-selector { min-height: 34px !important; }
  .ant-input, .ant-input-affix-wrapper { min-height: 34px; }

  /* ── ⑦ 表格：单元格收紧、滚动条细化（列本身靠 antd 的 scroll.x 横滑）── */
  .ant-table-cell { font-size: 13px !important; padding: 8px 8px !important; }
  .ant-table-thead .ant-table-cell { font-size: 12.5px !important; }
  .ant-table-content { -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .ant-table-content::-webkit-scrollbar { height: 4px; }
  .ant-table-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,.22); border-radius: 2px; }

  /* ── ⑧ 弹窗/抽屉：留边距，别顶满屏 ─────────────────────────────────── */
  .ant-modal { max-width: calc(100vw - 16px) !important; margin: 8px auto !important; top: 8px !important; }
  .ant-drawer-content-wrapper { max-width: 92vw; }

  /* ── ⑨ 兜底：任何意外都不该把整页撑出横向滚动条 ────────────────────── */
  html, body { overflow-x: hidden; }
}

/* ============================================================================
   第二轮移动端修补 · 2026-11-17 ｜ 皮皮
   只新增，不改上面 ①-⑨ 一条规则。
   ⚠️ 踩过的坑：不要用 Chrome --window-size 判断手机布局 ——
      它不改布局视口（实测 innerWidth=500），截出来的图会把右侧裁掉、看着像溢出。
      真实测量必须用 Playwright setViewport({width:390})，本项目已验证。
   ========================================================================== */

@media (max-width: 720px) {

  /* ── ⑩ 登录 / 注册页：防御性约束 ──────────────────────────────────────
     实测（Playwright 390×844）：卡片 342 宽、左右各 24，docScrollWidth == innerWidth，
     **本来就没有溢出**。这条只是把 flex item 的 min-width:auto 钉死，
     防止以后往卡片里塞宽内容（比如二维码、长提示）时把整页顶宽。 */
  .auth-card {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* ── ⑪ 表格：内容不换行、容器横滑 ────────────────────────────────────
     52 张表只有 26 张配了 scroll={{x}}，其余在手机上会把列挤成多行。
     取舍：**不设 max-width 截断** —— 宁可多滑两下，也不能把备注/摘要列吃成省略号。 */
  .ant-table-content {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .ant-table-content table { min-width: max-content !important; }
  .ant-table-cell { white-space: nowrap !important; }
  /* 展开行里的长文本必须能换行 */
  .ant-table-expanded-row .ant-table-cell { white-space: normal !important; }

  /* ── ⑫ 表单：窄屏单列 ────────────────────────────────────────────────
     页面里大量 <Col span={12}> / span={8}，两列在 390px 下挤成一团。 */
  .ant-form .ant-col {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .ant-form-item { margin-bottom: 12px !important; }

  /* ── ⑬ 分页：收起「每页条数」选择器，页码居中换行 ─────────────────── */
  .ant-pagination {
    justify-content: center !important;
    flex-wrap: wrap !important;
    row-gap: 8px !important;
  }
  .ant-pagination-options { display: none !important; }

  /* ── ⑭ 布局兜底：flex 子项不给 min-width:0 就会把整页顶宽 ──────────── */
  .ant-layout,
  .ant-layout-content { min-width: 0 !important; }
}
