/**
 * ScopeBar 搜索范围条样式 —— FullPage / Modal 共享。
 * 视觉：左 label + 默认 radio（圆点）+ 右 extra；
 * 始终是一行 flex，选项过多自动换行，不撑破容器。
 */
.pisell-global-search-scope-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  // 只保留换行时的行距；label→options、options 间距分别由各自控制
  row-gap: 4px;
  padding-top: 6px;

  &__label {
    font-size: 13px;
    color: #6b7280;
    user-select: none;
    flex: 0 0 auto;
    // 搜索范围 label 右侧留 6px
    margin-right: 6px;
  }

  &__radio {
    display: inline-flex;
    flex-wrap: wrap;
    // options 之间统一 4px（行 + 列）
    gap: 4px;

    // 用 gap 统一控制间距，去掉 antd Radio 默认的右侧 margin，避免叠加
    .pisell-lowcode-radio-wrapper,
    .ant-radio-wrapper {
      margin-inline-end: 0;
      margin-right: 0;
    }

    // 让单个 Radio 项的 label 内部 icon 与文字对齐
    .pisell-lowcode-radio-wrapper > span:last-child,
    .ant-radio-wrapper > span:last-child {
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
  }

  &__extra {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
  }

  &__spacer {
    flex: 1 1 auto;
  }
}

/**
 * 业务模式（精确搜索）命中订单：逐条 SaleDetail 卡片化，彼此清晰分隔。
 * —— FullPage / Modal 共享（两壳层均 import 本文件）。
 */
.pisell-global-search-order-business {
  display: flex;
  flex-direction: column;
  // 卡片之间间距（≤6px）
  gap: 6px;
  // 单 tab（订单）业务模式：撑满结果区并内部上下滚动（命中多单时可滚）。
  // All 分组里父级非 flex，这些属性不生效，自然增长由外层滚动，互不影响。
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  // 给卡片阴影留出空间，避免被滚动容器裁掉
  padding: 2px;

  &__item {
    // 收缩时不被压扁，保持各自高度
    flex: 0 0 auto;
    background: #fff;
    // 整圈主题色边框，强化「一张订单 = 一张卡」的边界
    border: 1.5px solid
      var(--ant-color-primary, var(--color-primary, #5d3f9f));
    border-radius: 12px;
    padding: 6px;
    // 更明显的浮起阴影，让每张订单卡片彼此清晰分隔
    box-shadow: 0 2px 10px rgba(17, 24, 39, 0.1);
    // 防止内部详情把卡片撑破
    overflow: hidden;
  }

  /** 首屏 loading / 空态 / 错误（padding ≤6px，与卡片间距一致） */
  &__status {
    display: flex;
    justify-content: center;
    padding: 6px;
    text-align: center;
    color: #9ca3af;
  }
}

/**
 * 单 tab 业务列表的虚拟滚动变体：滚动交给 rc-virtual-list 内部 holder，
 * 容器只负责给出确定高度（flex 撑满）、自身不滚动；间距改用行内 marginBottom。
 */
.pisell-global-search-order-business--virtual {
  position: relative;
  overflow: hidden;
  gap: 0;
}

/**
 * 管理模式订单表格：点击某行打开右侧/抽屉详情时，高亮该行（选中态，比 hover 更亮）。
 * 行 class 由 OrderAdminGrid 的 grid.rowClassName 注入；用 !important 压过 antd 行 hover / 斑马纹。
 */
// 兼容普通表（<tr><td>）与虚拟表（virtual: true → antd5 行/格渲染为 div：
// .ant-table-row / .ant-table-cell，prefix 下为 .pisell-lowcode-table-cell），
// 否则只写 `> td` 在虚拟模式下选不中 → 点击行不高亮。
.pisell-global-search-order-row--active > td,
.pisell-global-search-order-row--active > .pisell-lowcode-table-cell,
.pisell-global-search-order-row--active > .ant-table-cell {
  background: var(--ant-color-primary-bg, var(--color-primary-bg, #e6f0ff)) !important;
}
.pisell-global-search-order-row--active:hover > td,
.pisell-global-search-order-row--active:hover > .pisell-lowcode-table-cell,
.pisell-global-search-order-row--active:hover > .ant-table-cell {
  background: var(
    --ant-color-primary-bg-hover,
    var(--color-primary-bg, #d6e7ff)
  ) !important;
}

/**
 * 分组（All 模式）头部右侧「View all N」：文字链接（主题色），替代原来的「共 N 条」。
 * —— FullPage / Modal 共享（GroupedResults 输出 pisell-global-search__* 类）。
 */
.pisell-global-search__view-all {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--ant-color-primary, var(--color-primary, #5d3f9f));
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;

  &:hover {
    text-decoration: underline;
  }
}

/** 单行省略：盒模型撑满列宽、不被压扁，超出显示省略号。 */
.pisell-global-search-cell-ellipsis() {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/**
 * 管理模式订单表格（内嵌 PisellSalesGrid）：让每一列内容收进列宽。
 * - 单元格保持多行堆叠（render 出来的 flex 列不变）；
 * - 每一行（文本 / 标签 / 姓名 / 日期）超出列宽时单行省略，避免内容溢出邻列；
 * - 仅作用于全局搜索内嵌表格（.pisell-global-search-order-table），不影响主销售管理页。
 * 表格已开启 virtual（固定列宽），故内容超出即触发省略。
 * —— FullPage / Modal 共享（两壳层均定义 .pisell-global-search-order-table 并 import 本文件）。
 */
.pisell-global-search-order-table {
  // 表头保持单行（约 40px），与 RecordBoard autoCalc 写死的表头预留高度（40px）对齐。
  // 缩窄列宽后标题（如 Payment Info / Payment Method）默认会换成两行 → 真实表头变高，
  // 导致 scroll.y 偏大、表体多出半行被外层裁掉、最后一行展示不全。
  // 这里收窄表头左右 padding + 不换行，让标题尽量单行，修正高度错位。
  .pisell-lowcode-table-thead .pisell-lowcode-table-cell,
  .pisell-lowcode-table-thead .ant-table-cell {
    padding: 6px !important;
    white-space: nowrap;
  }

  .pisell-lowcode-table-tbody .pisell-lowcode-table-cell,
  .pisell-lowcode-table-tbody .ant-table-cell {
    // 表体单元格内边距统一 6px
    padding: 6px !important;

    // 单元格内容容器：约束在列宽内、超出隐藏
    .pisell-lowcode-table-cell-content {
      min-width: 0;
      max-width: 100%;
      overflow: hidden;
    }

    // render 根容器（多为 flex 列）：撑满列宽并允许收缩，保留多行堆叠
    .pisell-lowcode-table-cell-content > div,
    .pisell-lowcode-table-cell-content > span {
      max-width: 100%;
      min-width: 0;
    }

    // 关键修复：render 内联把 flex 列写成 align-items: flex-start，
    // 导致每个子行宽度 = 内容宽度（收缩到内容），永远不超过列宽 → 省略号不触发。
    // 这里强制 flex 列容器（根 + 嵌套一层，如 Payment Method 每个支付的包裹层）
    // 横向拉伸子项，子行才会受列宽约束、超出时省略。block 子项不受 align-items 影响，安全。
    .pisell-lowcode-table-cell-content > div,
    .pisell-lowcode-table-cell-content > div > div {
      align-items: stretch !important;
    }

    // 文本叶子行（本行不含标签）：超出列宽单行省略
    .pisell-lowcode-table-cell-content
      > div
      > div:not(:has(.ant-tag)):not(:has(.pisell-lowcode-tag)):not(
        :has(.pisell-tags)
      ),
    .pisell-lowcode-table-cell-content > div > span,
    .pisell-lowcode-table-cell-content > span {
      .pisell-global-search-cell-ellipsis();
    }

    // 再深一层的文本行（如 Payment Method：每个支付在 flex 列里又包一层，
    // 「方式: 金额」行位于 cell-content > div > div > div）：同样单行省略。
    .pisell-lowcode-table-cell-content
      > div
      > div
      > div:not(:has(.ant-tag)):not(:has(.pisell-lowcode-tag)):not(
        :has(.pisell-tags)
      ):not(:has(.pisell-datetime-display)) {
      .pisell-global-search-cell-ellipsis();
    }

    // 标签自身：省略，不撑破列宽
    .pisell-lowcode-tag,
    .ant-tag {
      .pisell-global-search-cell-ellipsis();
      display: inline-block;
      vertical-align: top;
    }

    // 姓名：单行省略（超长姓名也截断，不溢出邻列）
    .pisell-client-name {
      .pisell-global-search-cell-ellipsis();
      display: block;
    }

    // 日期等组件：约束宽度，避免溢出邻列
    .pisell-datetime-display,
    .pisell-datetime-display-inline,
    .pisell-time-range-display {
      max-width: 100%;
      min-width: 0;
    }

  }

  // Payment Status 列单元格（普通 td / 虚拟 div 均带列 className）：允许标签内换行
  .pisell-global-search-col-payment-status {
    .pisell-lowcode-table-cell-content {
      overflow: visible;
    }

    .pisell-tags,
    .pisell-lowcode-tag,
    .ant-tag {
      display: inline-flex;
      max-width: 100%;
      white-space: normal !important;
      overflow: visible !important;
      text-overflow: clip !important;
      height: auto;
      // 文字换行：长单词/标签文案在标签内断行
      overflow-wrap: anywhere;
      word-break: break-word;
    }
  }

  // 文本堆叠列省略容器（由 orderResultViews 的 wrapEllipsisRender 注入，
  // 直接是 td / 虚拟单元格 div 的子节点，故不依赖 antd 内部 cell-content 结构）。
  // 用 :has() 自动区分两类节点，处理任意嵌套深度的「多行堆叠 + 单行省略」：
  //   1) 含子 div 的布局容器（如根 flex 列、payment method 每笔支付的包裹层）→
  //      强制 align-items: stretch，让子项横向撑满列宽（覆盖 render 内联的 flex-start，
  //      否则子行宽度=内容宽度，永远不溢出，省略号永不触发）；
  //   2) 不含子 div 的文本叶子行 → 单行省略（保留标签行、不动）。
  .pisell-global-search-ellipsis-cell {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;

    // 布局容器（含子 div、且本层不含标签）：撑满 + 可收缩。
    // 加标签排除，避免未来某行用 align-items: center 放图标/标签时被强行拉伸。
    div:has(> div):not(:has(.ant-tag)):not(:has(.pisell-lowcode-tag)):not(
        :has(.pisell-tags)
      ) {
      align-items: stretch !important;
      min-width: 0;
      max-width: 100%;
    }

    // 文本叶子行（无子 div、且不含标签）：超出列宽单行省略
    div:not(:has(> div)):not(:has(.ant-tag)):not(:has(.pisell-lowcode-tag)):not(
        :has(.pisell-tags)
      ) {
      box-sizing: border-box;
      min-width: 0;
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
