/* ==========================================================================
 * core/search.css —— 全局搜索组件（v0.6.0 R6）
 *
 * 顶栏右侧搜索框：默认 200px，聚焦展开 320px；下拉面板分组展示
 * [菜单][功能]（功能分组当前无数据源，仅在有数据时渲染）；关键词黄色
 * 高亮；↑↓ 选择 / Enter 跳转 / ESC 关闭；空输入聚焦展示最近 5 条历史。
 * 仅消费 --yx-* 变量。
 * ========================================================================== */

.yx-search {
  position: relative;
  display: flex;
  align-items: center;
}

.yx-search__icon {
  position: absolute;
  left: var(--yx-spacing-x3);
  color: var(--yx-color-text-secondary);
  pointer-events: none;
}

.yx-search__input {
  width: 200px;
  height: 32px;
  padding: 0 var(--yx-spacing-x3) 0 32px;
  border: 1px solid var(--yx-color-border-default);
  border-radius: var(--yx-radius-input);
  background: var(--yx-color-bg-subtle);
  color: var(--yx-color-text-primary);
  font-size: var(--yx-font-size-sm);
  outline: none;
  transition:
    width 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.yx-search__input:focus {
  width: 320px;
  border-color: var(--yx-color-brand-primary);
  background: var(--yx-color-bg-card);
}

@media (max-width: 768px) {
  .yx-search__input {
    width: 140px;
  }

  .yx-search__input:focus {
    width: 200px;
  }
}

/* ---------- 下拉面板 ---------- */
.yx-search__panel {
  position: absolute;
  top: calc(100% + var(--yx-spacing-x2));
  right: 0;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--yx-color-border-default);
  border-radius: var(--yx-radius-card);
  background: var(--yx-color-bg-card);
  box-shadow: var(--yx-shadow-dropdown);
  z-index: 100;
}

.yx-search__panel[aria-hidden="true"] {
  display: none;
}

.yx-search__group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--yx-spacing-x2) var(--yx-spacing-x3);
  font-size: var(--yx-font-size-xs);
  color: var(--yx-color-text-secondary);
  background: var(--yx-color-bg-subtle);
}

.yx-search__group-clear {
  border: none;
  background: none;
  padding: 0;
  font-size: var(--yx-font-size-xs);
  color: var(--yx-color-brand-primary);
  cursor: pointer;
}

/* v0.7.0-dev2 块C2：分组类型色点（菜单/伙伴/产品/凭证/帮助，仅消费 --yx-* 变量） */
.yx-search__group-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: var(--yx-spacing-x1);
  border-radius: 50%;
  vertical-align: middle;
}

.yx-search__group-dot--menu {
  background: var(--yx-color-brand-primary);
}

.yx-search__group-dot--partner {
  background: var(--yx-color-functional-success-solid);
}

.yx-search__group-dot--product {
  background: var(--yx-color-functional-info-solid);
}

.yx-search__group-dot--voucher {
  background: var(--yx-color-functional-warning-solid);
}

/* v0.7.1-dev3 F13：合同/证照/报价分组色点（仅消费 --yx-* 变量） */
.yx-search__group-dot--contract {
  background: var(--yx-color-functional-danger-solid);
}

.yx-search__group-dot--license {
  background: var(--yx-color-text-tertiary);
}

.yx-search__group-dot--quotation {
  background: var(--yx-color-brand-primary-active);
}

.yx-search__group-dot--help {
  background: var(--yx-color-text-secondary);
}

.yx-search__item {
  display: flex;
  align-items: center;
  gap: var(--yx-spacing-x2);
  width: 100%;
  padding: var(--yx-spacing-x2) var(--yx-spacing-x3);
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--yx-color-text-primary);
  font-size: var(--yx-font-size-sm);
}

.yx-search__item:hover,
.yx-search__item.is-active {
  background: var(--yx-color-brand-primary-subtle);
}

.yx-search__item-icon {
  flex: 0 0 16px;
  display: inline-flex;
  color: var(--yx-color-text-secondary);
}

.yx-search__item-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yx-search__item-path {
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--yx-font-size-xs);
  color: var(--yx-color-text-secondary);
}

/* 关键词黄色高亮 */
.yx-search__item mark {
  background: var(--yx-color-functional-warning-subtle);
  color: var(--yx-color-functional-warning-solid);
  border-radius: 2px;
  padding: 0 1px;
}

.yx-search__empty {
  padding: var(--yx-spacing-x5) var(--yx-spacing-x3);
  text-align: center;
  font-size: var(--yx-font-size-sm);
  color: var(--yx-color-text-secondary);
}
