/* 通用自绘下拉（原生 select 外观由系统绘制，深浅色不受控，这里统一接管）
   用法：页面引入本文件与 select.js，脚本会自动接管 select.select。
   颜色全部走宿主页面的 CSS 变量，未定义时回退到云白默认值。 */

.xy-select__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  opacity: 0;
  pointer-events: none;
}

.xy-select__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-align: left;
  cursor: pointer;
  padding-right: 28px;
  /* button 默认字体来自 UA，不继承页面字体，这里显式对齐 */
  font-family: inherit;
}

.xy-select__btn .xy-select__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 箭头用 CSS 画，避免额外图标依赖 */
.xy-select__btn::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -4px;
  border-right: 1.5px solid var(--muted, #7d8a9b);
  border-bottom: 1.5px solid var(--muted, #7d8a9b);
  transform: rotate(45deg);
  transition: transform .18s var(--ease, ease);
}

.xy-select__btn[aria-expanded="true"]::after {
  margin-top: -1px;
  transform: rotate(-135deg);
}

.xy-select__btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.xy-select__list {
  position: fixed;
  z-index: 90;
  box-sizing: border-box;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface, #fff);
  color: var(--ink, #0d1523);
  border: 1px solid var(--line-strong, #d3dae5);
  border-radius: 8px;
  box-shadow: 0 16px 36px -18px rgba(13, 21, 35, .35), 0 2px 6px rgba(13, 21, 35, .08);
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.xy-select__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink, #0d1523);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.xy-select__opt.is-active {
  background: var(--accent-weak, #eef4fe);
}

.xy-select__opt[aria-selected="true"] {
  color: var(--accent, #0b57d0);
  font-weight: 600;
}

.xy-select__opt[aria-selected="true"]::after {
  content: "✓";
  margin-left: auto;
  font-weight: 400;
}

.xy-select__opt[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .xy-select__btn::after { transition: none; }
}
