/* ============================================================================
   GeekOzon ERP · UI Density 层  (2026-11-11)
   ----------------------------------------------------------------------------
   背景：23 个页面的字号曾在 JS/CSS 里散落成 9/10/10.5/11/11.5/12/12.5/13.5 共
   9 档（960 处），缩略图 24/34/44px 三种，按钮高度 18~36px 共 9 档。
   现在字号已统一迁移到 11 / 12 / 13 / 14 四档（见 tools/migrate_typography.py），
   本文件只负责「图片尺寸、行高、按钮档位、工具栏排布」四件事。

   加载顺序：必须在 design-system.css 之后。
   特异性：页面运行时注入的 <style> 在 body 末尾，故统一用 html body 前缀。

   按钮档位（唯一标准）：
     24px  —— 徽标 / 分页 / 段控 tab
     28px  —— 表格行内操作、表格工具栏
     32px  —— 页面工具栏、表单、弹窗底部
     40px  —— 登录等大 CTA
   ========================================================================== */

:root {
  --ui-thumb-md: 56px;   /* 商品表格缩略图（在线商品 / 采集箱） */
  --ui-thumb-sm: 40px;   /* 订单行、明细行缩略图 */
  --ui-thumb-lg: 72px;   /* 图片预览浮层缩略 */
  --ui-row-py: 9px;
  --ui-row-px: 10px;
}

/* ==========================================================================
   1. 缩略图 —— 统一 56px（明细行 40px），点击看大图
   ========================================================================== */
html body #onlineTable .product-thumb,
html body #collectTable .product-thumb {
  width: var(--ui-thumb-md);
  height: var(--ui-thumb-md);
  aspect-ratio: auto;
  border-radius: 6px;
}
html body #collectTable .product-thumb { aspect-ratio: 3 / 4; height: auto; }
html body .product-thumb:hover { transform: scale(3); }
html body .product-info-cell { gap: 12px; align-items: center; }

/* 订单行 / 明细行 / 拒收行 */
/* 订单行缩略图单独放大（2026-11-12：40→56px；2026-11-27：56→76px，用户反馈图偏小看不清商品） */
html body .odp-gthumb { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 7px; }
html body .odp-pack-thumb { width: 44px; height: 44px; border-radius: 6px; }
html body .rj-thumb { width: var(--ui-thumb-sm); height: var(--ui-thumb-sm); border-radius: 6px; }

/* ==========================================================================
   2. 行高与信息密度
   ========================================================================== */
html body #onlineTable td { padding: var(--ui-row-py) var(--ui-row-px); }
html body #collectTable td { padding: 12px; }
html body .collect-table td { line-height: 1.5; }
html body .collect-table thead th { height: 40px; }
html body #onlineTable thead th { height: 38px; }

/* 单元格内多行信息：标题 13px / 辅助 12px，不再三行挤成一团 */
html body .product-title-line,
html body .pc-title { font-size: calc(13px * var(--font-scale)); font-weight: 500; }
html body .pc-subline,
html body .product-subline { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); }

/* ==========================================================================
   3. 按钮档位 —— 按所在区域决定高度，不再各页自定
   ========================================================================== */

/* 3.1 页面工具栏 / 表单 / 弹窗底部：32px */
html body :is(
  .odp-head-actions, .batch-action-bar, .collect-toolbar, .online-toolbar,
  .st-toolbar, .pu-toolbar, .publish-toolbar, .promo-toolbar,
  [class*="toolbar"], [class*="-actions"], .modal-footer, .form-actions
) :is(button, .ds-btn, a[class*="btn"]) {
  height: var(--control-h-md);
  min-height: var(--control-h-md);
  padding: 0 12px;
  border-radius: var(--control-radius);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

/* 3.2 表格行内操作：28px，文字按钮（action-link 等）保持文字形态 */
html body .collect-table td :is(button, .ds-btn, .row-btn, .cs-btn, .card-action-btn):not(.action-link):not(.row-link) {
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0 10px;
  border-radius: var(--control-radius-sm);
  font-size: calc(12px * var(--font-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 3.3 分页 / 段控 tab：24px */
html body :is(.online-pager, .collect-pager, .st-pager, .pu-pager, .odp-tabs, .online-tabs, .st-tabs, .collect-tabs) :is(button, .ds-btn) {
  height: var(--control-h-xs);
  min-height: var(--control-h-xs);
  padding: 0 9px;
  font-size: calc(12px * var(--font-scale));
  border-radius: var(--control-radius-sm);
}

/* 3.4 行内文字型动作（AI优化 / 链接 / 删除）：不加边框，靠颜色分层 */
html body :is(.action-link, .row-link) {
  background: transparent;
  border: 0;
  padding: 0 2px;
  height: auto;
  min-height: 22px;
  font-size: calc(12px * var(--font-scale));
  color: var(--action-link);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
html body :is(.action-link, .row-link):hover { color: var(--action-link-hover); text-decoration: underline; }
html body .action-link.danger { color: var(--state-danger); }
html body .action-link.danger:hover { color: var(--state-danger-hover); }

/* 3.5 卡片内的迷你动作按钮（译 / 管理商品 等）：与行内 24px 档对齐 */
html body :is(.promo-tr-btn, .card-mini-btn, .mini-btn) {
  height: var(--control-h-xs);
  min-height: var(--control-h-xs);
  padding: 0 8px;
  font-size: calc(12px * var(--font-scale));
  border-radius: var(--control-radius-sm);
}

/* 3.6 按钮组间距与换行 */
html body :is(.odp-head-actions, .batch-action-left, .batch-action-right,
              .collect-footer-left, .row-actions, .row-links) {
  display: flex;
  align-items: center;
  gap: var(--control-gap);
  flex-wrap: wrap;
}
html body .row-links { gap: 10px; margin-top: 2px; }
html body .row-actions { gap: 6px; }
html body .pu-row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ==========================================================================
   4. 工具栏排布 —— 左右分区，右侧最多 2 个动作
   ========================================================================== */
html body .batch-action-bar,
html body .collect-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 4px;
}
html body .batch-action-left,
html body .batch-action-right,
html body .collect-footer-left,
html body .collect-footer-right {
  display: flex;
  align-items: center;
  gap: var(--control-gap);
  flex-wrap: wrap;
}
html body .select-info,
html body .total-info { font-size: calc(12px * var(--font-scale)); color: var(--text-secondary); white-space: nowrap; }

/* 页头：标题左、动作右，按钮只在右侧一列 */
html body .odp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
html body .odp-head > div:first-child { min-width: 0; }
html body .odp-head-actions { justify-content: flex-end; }

/* 「更多」下拉：一组次要动作用一个入口，避免一排平铺。
   fixed 定位由 js/components/ui-menu.js 计算，脱离表格绘制顺序，不会被下一行盖住 */
html body .ui-more { position: relative; display: inline-flex; }
html body .ui-more-menu {
  position: fixed;
  top: 0;
  left: 0;
  min-width: calc(184px * var(--font-scale));
  width: max-content;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  display: none;
}
html body .ui-more-menu.is-open { display: block; }
html body .ui-more-menu button,
html body .ui-more-menu a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: calc(30px * var(--font-scale));
  height: auto;
  padding: 6px 10px;
  line-height: 1.35;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: calc(12.5px * var(--font-scale));
  text-align: left;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}
html body .ui-more-menu button:hover,
html body .ui-more-menu a:hover { background: var(--action-primary-soft); color: var(--action-primary-ink); }
html body .ui-more-menu .is-danger { color: var(--state-danger); }
html body .ui-more-menu .is-danger:hover { background: var(--state-danger-soft); color: var(--state-danger-hover); }
html body .ui-more-menu .is-filled { color: var(--state-success); }

/* 图标按钮（刷新等）：正方形，不再和文字按钮抢宽度 */
html body .ui-icon-btn {
  width: var(--control-h-md);
  padding: 0;
  flex: 0 0 var(--control-h-md);
}
html body .ui-icon-btn svg,
html body .ui-icon-btn i { width: 15px; height: 15px; flex: 0 0 15px; }
html body .ui-more-menu svg,
html body .ui-more-menu i,
html body :is(.odp-head-actions, .batch-action-left, .batch-action-right) svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   5. 表格内小元素：徽标 / 状态 / 金额
   ========================================================================== */
html body :is(.online-status-badge, .status-badge, .src-badge, .stock-badge, [class*="-badge"]) {
  font-size: calc(11px * var(--font-scale));
  line-height: 18px;
  padding: 1px 7px;
  border-radius: 5px;
}
/* 订单状态徽章随表格正文一起放大（2026-11-27），其余页面徽章维持 11px */
html body .odp-badge { font-size: calc(12px * var(--font-scale)); line-height: 20px; }
html body .collect-table .tag,
html body .collect-table .mini-tag { font-size: calc(11px * var(--font-scale)); padding: 0 6px; height: 18px; line-height: 18px; }

/* 表格里的金额 / 数字：等宽数字，便于纵向对比 */
html body .collect-table td { font-variant-numeric: tabular-nums; }

/* 订单表按百分比列宽严格分配：长 Posting / 时间不再把表格撑出容器，
   超长内容省略显示（title 仍可悬停查看完整值） */
html body .odp-table { table-layout: fixed; width: 100%; }
html body .odp-table th,
html body .odp-table td { overflow: hidden; text-overflow: ellipsis; }
html body .odp-table td:last-child,
html body .odp-table th:last-child { overflow: visible; }

/* 危险动作用「白底红字」而不是红描边，避免在工具栏里抢主按钮的注意力 */
html body :is(.st-toolbar, .pu-toolbar, [class*="toolbar"]) :is(.st-btn, .pu-btn, .btn).danger:not(:hover) {
  background: var(--action-secondary-bg);
  border-color: var(--action-secondary-border);
  color: var(--state-danger);
}

/* ==========================================================================
   6. 窄屏：工具栏换行而不是溢出
   ========================================================================== */
@media (max-width: 1280px) {
  html body .odp-head { flex-direction: column; align-items: stretch; }
  html body .odp-head-actions { justify-content: flex-start; }
}
@media (max-width: 1366px) {
  /* 1366/1280 笔记本：城市是信息密度最低的一列，先让位给 Posting / 时间 / 运单 / 成本。
     列序：勾选1 店铺2 Posting3 状态4 商品5 金额6 成本7 利润8 时间9 运单10 城市11 操作12
     —— 改订单表列数/顺序时，这里的 nth-child 必须跟着改，否则会隐掉别的列。 */
  html body .odp-table thead th:nth-child(11),
  html body .odp-table tbody td:nth-child(11) { display: none; }
}
@media (max-width: 768px) {
  html body :is(.batch-action-bar, .collect-footer-bar) { flex-wrap: wrap; min-height: 0; }
  html body .collect-footer-right { width: 100%; justify-content: space-between; }
}
