/* =====================================================================
 * wb-table.css — 工作台通用表格增强组件（独立样式文件）
 * 配套 wb-table.js 使用。由 index.html 通过 <link> 引入。
 *
 * 能力：
 *  1) 表头固定   —— 容器加 .wb-scroll（表格内部纵向滚动，表头真正吸顶）
 *  2) 左列固定   —— data-wb-frozen="N"，JS 自动注入 .wb-fix 类与 left 偏移
 *  3) 斑马纹     —— data-wb-zebra
 *  4) 排序箭头   —— .wb-sort（th[data-wb-sort] 注入）
 *  5) 表头筛选器 —— .wb-th-filter（搜索框 / 下拉）
 *  6) 合计行     —— .wb-sum-row（th[data-wb-sum]）
 * ===================================================================== */

/* ---------- 滚动容器：表头吸顶的物理前提 ----------
 * 说明：仅 overflow 纵向滚动的容器内，position:sticky 才真正生效。
 * 工作台原全局 th{position:sticky;top:0} 在「页面级滚动」时吸顶无效，
 * 组件对主表格容器加 .wb-scroll 后表格内部滚动，表头固定才成立。
 * 高度可用 --wb-maxh 覆盖（不同模块 toolbar 高度不同）。 */
.wb-scroll {
  max-height: var(--wb-maxh, calc(100vh - 240px));
  overflow: auto;
  padding-bottom: 4px;
}
.wb-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  box-shadow: 0 1px 0 #e2e8f0;
}

/* ---------- 冻结列（前 N 列固定） ----------
 * JS 给前 N 列的 th/td 注入 .wb-fix，并逐个写入 inline left。
 * 末列加 .wb-fix-last 右侧阴影，提示右侧内容在滚动。 */
[data-wb-frozen] th.wb-fix,
[data-wb-frozen] td.wb-fix {
  position: sticky;
  background: #fff;
  z-index: 4;
  white-space: nowrap;
}
[data-wb-frozen] thead th.wb-fix {
  z-index: 7;
  background: #f0f4f9;
}
[data-wb-frozen] th.wb-fix-last,
[data-wb-frozen] td.wb-fix-last {
  box-shadow: 2px 0 4px rgba(20, 40, 70, 0.08);
}
[data-wb-frozen] tbody tr:nth-child(even) td.wb-fix {
  background: #fafbfd;
}
[data-wb-frozen] tbody tr:hover td.wb-fix {
  background: #f0f7ff;
}

/* ---------- 斑马纹 ---------- */
.wb-zebra tbody tr:nth-child(even) td {
  background: #fafbfd;
}
.wb-zebra tbody tr:hover td {
  background: #f0f7ff;
}

/* ---------- 排序 ---------- */
th.wb-sortable {
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.wb-sort {
  cursor: pointer;
  font-size: 11px;
  color: #8a94a6;
  user-select: none;
  margin-left: 3px;
  display: inline-block;
  min-width: 13px;
}
.wb-sort:hover {
  color: #2b6cb0;
}
.wb-sort.on {
  color: #2b6cb0;
  font-weight: 700;
}

/* ---------- 表头内嵌筛选器 ---------- */
.wb-th-filter {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 3px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid #dbe4ef;
  border-radius: 5px;
  background: #fff;
  color: #2d3748;
}
.wb-th-filter:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.12);
}
th.wb-th-f {
  padding: 5px 6px;
  vertical-align: top;
}

/* ---------- 表头「服务端筛选」搜索框（data-wb-srv，2026-09-18） ----------
   与 .wb-th-filter 的区别：它不筛 DOM，而是触发整表重查（分页表专用）。
   刻意做成"小一号"的观感，并给已生效状态一个明显标记，避免用户忘了自己筛过什么。 */
.wb-srvf {
  display: block;
  width: 100%;
  min-width: 84px;
  box-sizing: border-box;
  margin-top: 3px;
  padding: 2px 6px;
  font-size: 11.5px;
  line-height: 1.5;
  border: 1px dashed #cbd5e0;
  border-radius: 5px;
  background: #fcfdff;
  color: #2d3748;
}
.wb-srvf::placeholder {
  color: #a9b4c2;
}
.wb-srvf:focus {
  outline: none;
  border-style: solid;
  border-color: #2b6cb0;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.12);
}
.wb-srvf.on {
  border-style: solid;
  border-color: #2b6cb0;
  background: #eef4fb;
  color: #1a5490;
  font-weight: 600;
}

/* ---------- 合计行 / 行数统计 ---------- */
.wb-sum-row td {
  background: #fff8e6 !important;
  font-weight: 700;
  color: #1a365d;
}
.wb-sum-row td.wb-count-cell {
  font-weight: 400;
  color: #5f6b7a;
  font-size: 12px;
  text-align: left;
}

/* ---------- 筛选后空结果提示 ---------- */
tr.wb-empty td {
  text-align: center;
  color: #999;
  padding: 14px;
}

/* ---------- 弹窗内表格统一（.modal 下生效，覆盖全局细字体） ---------- */
.modal .tablewrap {
  padding: 0;
  max-height: 62vh;
  overflow: auto;
}
.modal .tablewrap th,
.modal .tablewrap td {
  padding: 6px 8px;
}
.modal .tablewrap thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f0f4f9;
}

/* ---------- 面板式筛选器（可搜索下拉 / 年月可展开）2026-09-15 新增 ---------- */
button.wb-th-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 3px;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid #dbe4ef;
  border-radius: 5px;
  background: #fff;
  color: #2d3748;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
button.wb-th-btn::after {
  content: '▾';
  float: right;
  color: #a0aec0;
  margin-left: 4px;
}
button.wb-th-btn:hover {
  border-color: #2b6cb0;
  color: #2b6cb0;
}
button.wb-th-btn.on {
  background: #e8f1ff;
  border-color: #2b6cb0;
  color: #1a56a0;
  font-weight: 600;
}
.wb-th-panel {
  position: absolute;
  z-index: 1300;
  background: #fff;
  border: 1px solid #dbe4ef;
  border-radius: 9px;
  box-shadow: 0 12px 30px rgba(20, 40, 70, 0.18);
  padding: 7px;
  max-height: 330px;
  overflow: auto;
  font-size: 12.5px;
  color: #2d3748;
}
.wb-tp-head {
  font-size: 11px;
  color: #8a94a6;
  padding: 1px 4px 6px;
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 5px;
}
.wb-tp-search {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  margin-bottom: 5px;
  border: 1px solid #dbe4ef;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
}
.wb-tp-search:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.12);
}
.wb-tp-item,
.wb-tp-day {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.wb-tp-item:hover,
.wb-tp-day:hover {
  background: #f0f6ff;
}
.wb-tp-item.on,
.wb-tp-day.on {
  background: #e8f1ff;
  color: #1a56a0;
  font-weight: 600;
}
.wb-tp-lbl {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-tp-n {
  flex: 0 0 auto;
  font-size: 11px;
  color: #8a94a6;
  font-variant-numeric: tabular-nums;
}
.wb-tp-all {
  font-weight: 600;
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 3px;
  border-radius: 0;
}
.wb-tp-month {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 5px;
  font-weight: 600;
  color: #1a365d;
}
.wb-tp-month:hover {
  background: #f0f6ff;
}
.wb-tp-month.on {
  background: #e8f1ff;
  color: #1a56a0;
}
.wb-tp-plus {
  flex: 0 0 auto;
  width: 16px;
  text-align: center;
  color: #2b6cb0;
  cursor: pointer;
  font-weight: 700;
  border: 1px solid #cbd7e6;
  border-radius: 4px;
  background: #f7fafc;
  line-height: 14px;
}
.wb-tp-ml {
  cursor: pointer;
  flex: 1 1 auto;
}
.wb-tp-days {
  padding: 2px 0 4px 18px;
  border-left: 1px dashed #dbe4ef;
  margin-left: 8px;
}
