/* =========================================================
 * v1.3.0 · T04 日程「添加关联」选择器（sched-picker.js 专用样式）
 * =========================================================
 * 自包含：只依赖 main.css 的 :root 变量（缺失时有硬编码兜底），
 * 不改动 main.css，也不与其它模块的选择器重名（统一 .sp- 前缀）。
 *
 * ⚠️ 红线条（本项目栽过的坑）：表头 position:sticky 的祖先链上不得出现
 *   overflow:hidden —— 否则 sticky 失效、表头下移压住第一行。
 *   本文件的滚动容器只有 .sp-tbl（overflow:auto），.sp-wrap / .sp-tabs 均不设 hidden。
 * ========================================================= */

/* ---------- 容器 ---------- */
.sp-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;              /* 允许子项在 flex 容器内收缩，避免把弹窗撑宽 */
}

/* ---------- 种类分段（6 类） ---------- */
.sp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}
.sp-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2, #5b6779);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.sp-tab:hover {
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}
.sp-tab.is-on {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .22);
}
.sp-tabn {
  display: none;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--primary-soft, #eaf1ff);
  color: var(--primary, #2563eb);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.sp-tab.is-on .sp-tabn {
  background: rgba(255, 255, 255, .28);
  color: #fff;
}

/* ---------- 工具条：搜索 + 已选计数 + 清空 ---------- */
.sp-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sp-search {
  flex: 1 1 240px;
  min-width: 160px;
}
.sp-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 8px;
  background: #fff;
  color: var(--text, #1f2937);
  font-size: 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.sp-search input::placeholder { color: var(--text-3, #8b95a6); }
.sp-search input:focus {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}
/* 已选 N / 20 徽标 */
.sp-count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft, #eaf1ff);
  color: var(--text-2, #5b6779);
  font-size: 12.5px;
  white-space: nowrap;
}
.sp-count b {
  color: var(--primary, #2563eb);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sp-count.is-full {
  background: var(--amber-soft, #fdf3e3);
  color: var(--amber, #d97706);
}
.sp-count.is-full b { color: var(--amber, #d97706); }

/* ---------- 表格 ---------- */
/* 唯一滚动容器：overflow:auto（横向由移动端 min-width 触发，纵向由 max-height 触发） */
.sp-tbl {
  max-height: 44vh;
  overflow: auto;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 10px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.sp-table {
  width: 100%;
  border-collapse: separate;   /* sticky 表头要求 separate，collapse 会把表头边框带走 */
  border-spacing: 0;
  font-size: 13px;
  table-layout: auto;
}
.sp-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  background: #f7f9fc;
  color: var(--text-2, #5b6779);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  /* 用内阴影代替 border-bottom：separate 模式下边框会随内容滚走，表头接缝会漏 */
  box-shadow: inset 0 -1px 0 var(--border, #e6eaf0);
  transition: color .15s ease;
}
.sp-table thead th:hover { color: var(--primary, #2563eb); }
.sp-th-cb,
.sp-table thead th.sp-th-cb { cursor: default; }
.sp-table thead th.sp-th-cb:hover { color: var(--text-2, #5b6779); }
.sp-sort {
  margin-left: 3px;
  font-size: 10px;
  font-style: normal;
  color: var(--primary, #2563eb);
}
.sp-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f4f8;
  color: var(--text, #1f2937);
  vertical-align: middle;
  max-width: 320px;
  overflow-wrap: anywhere;
}
.sp-table tbody tr:last-child td { border-bottom: 0; }

/* 勾选列 */
.sp-c,
.sp-table thead th.sp-c {
  width: 42px;
  min-width: 42px;
  padding-right: 0;
  text-align: center;
}
.sp-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary, #2563eb);
  vertical-align: middle;
}
.sp-table input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .45; }

/* 行状态 */
.sp-row { cursor: pointer; transition: background .12s ease; }
.sp-row:hover { background: #f7faff; }
.sp-row.is-on { background: var(--primary-soft, #eaf1ff); }
.sp-row.is-on:hover { background: #dfe9ff; }
.sp-row:focus { outline: none; }
.sp-row:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: -2px;
}

/* 单元格语义 */
.sp-ta-right { text-align: right; }
.sp-ta-center { text-align: center; }
.sp-nowrap { white-space: nowrap; }
.sp-strong { font-weight: 600; color: var(--text, #1f2937); }
.sp-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.sp-dash { color: var(--text-3, #8b95a6); }
.sp-none {
  padding: 40px 12px !important;
  text-align: center;
  color: var(--text-3, #8b95a6);
  font-size: 13px;
}

/* ---------- 就地新建 / 去新建合同 ---------- */
.sp-new {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
}
.sp-new .link {
  color: var(--primary, #2563eb);
  font-weight: 600;
  cursor: pointer;
}
.sp-new .link:hover { text-decoration: underline; }
.sp-new-tip { color: var(--text-3, #8b95a6); font-size: 12px; }

/* ---------- 页脚（取消 / 加入日程（N）） ---------- */
.sp-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e6eaf0);
}
.sp-foot-tip {
  margin-right: auto;
  color: var(--text-3, #8b95a6);
  font-size: 12px;
}
.sp-foot .btn { min-width: 84px; height: 34px; }
.sp-foot .btn-primary { font-weight: 600; }

/* ---------- 移动端（≤768px）：弹窗全屏，表格内横向滚动 ---------- */
@media (max-width: 768px) {
  .sp-wrap { gap: 8px; }

  /* 6 个种类 tab 横向滚动，不换行挤压 */
  .sp-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;      /* 仅 tabs 自身横滚，不构成表头祖先 */
    scrollbar-width: none;
  }
  .sp-tabs::-webkit-scrollbar { display: none; }
  .sp-tab { flex: 0 0 auto; height: 30px; padding: 0 10px; font-size: 12.5px; }

  .sp-toolbar { gap: 8px; }
  .sp-search { flex: 1 1 100%; order: 1; }
  .sp-count { order: 2; height: 26px; padding: 0 10px; }
  .sp-toolbar .btn { order: 3; }

  /* 表体保留自身滚动（sticky 表头依赖它），高度按视口扣掉头部/tabs/工具条/页脚 */
  .sp-tbl {
    max-height: 200px;
    max-height: calc(100vh - 340px);
  }
  /* 列不压扁：触发 .sp-tbl 内部横向滚动（页面级不产生横向溢出） */
  .sp-table { min-width: 680px; }

  .sp-foot { flex-wrap: wrap; padding-top: 10px; }
  .sp-foot-tip { flex: 1 1 100%; margin: 0 0 2px; }
  .sp-foot .btn { flex: 1 1 0; min-width: 0; height: 36px; }
}
