/**
 * CustomSelect：样式仅作用于 .custom-select 及其子节点。
 * 不复写站点 :root 主题变量、不重置全局 * / body / button，避免影响导航栏与页脚等公共壳层。
 */

:root {
  /* 尺寸与下拉私有变量（不覆盖 style-box.css 的全局色板） */
  --select-height-sm: 24px;
  --select-height-md: 32px;
  --select-height-lg: 40px;
  --select-font-size: 14px;
  --select-line-height: 1.5715;
  --select-shadow-dropdown: rgba(0, 0, 0, 0.15);
  --select-option-hover-bg: #f5f5f5;
  --select-inner-divider: #f0f0f0;
  --select-focus-ring: rgba(255, 77, 0, 0.2);
}

/* 下拉框容器 */
.custom-select {
  position: relative;
  width: 100%;
}

/* 尺寸：small / default / large */
.custom-select.select-size-small .select-trigger {
  min-height: var(--select-height-sm);
}

.custom-select.select-size-small .select-value,
.custom-select.select-size-small .select-search input {
  font-size: var(--select-font-size);
  line-height: var(--select-line-height);
}

.custom-select.select-size-small .select-arrow {
  width: 12px;
  height: 12px;
}

.custom-select.select-size-small .select-search input {
  height: var(--select-height-sm);
  padding: 0 7px;
}

.custom-select.select-size-large .select-trigger {
  min-height: var(--select-height-lg);
  padding: 0 11px;
}

.custom-select.select-size-large .select-value,
.custom-select.select-size-large .select-search input {
  font-size: 16px;
  line-height: var(--select-line-height);
}

.custom-select.select-size-large .select-arrow {
  width: 14px;
  height: 14px;
}

.custom-select.select-size-large .select-search input {
  height: var(--select-height-lg);
  padding: 0 11px;
}

.custom-select.select-size-default .select-trigger {
  min-height: var(--select-height-md);
  padding: 0 11px;
}

.custom-select.select-size-default .select-value,
.custom-select.select-size-default .select-search input {
  font-size: var(--select-font-size);
  line-height: var(--select-line-height);
}

.custom-select.select-size-default .select-search input {
  height: var(--select-height-md);
  padding: 0 11px;
}

/* 选择器触发按钮 */
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 11px;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s;
  min-height: var(--select-height-md);
  font-size: var(--select-font-size);
  line-height: var(--select-line-height);
  -webkit-user-select:none;
  -moz-user-select:none;
  -ms-user-select:none;
  user-select:none;
}
.select-trigger img{
  -webkit-user-drag: none;
  -moz-user-drag: none;
  -ms-user-drag: none;
}
.select-trigger:hover {
  border-color: var(--color-primary-hover);
}
.select-trigger.disabled:hover{
  border-color: var(--color-border);
}

.select-radius{
  border-radius: 4px;
}

.select-trigger.active {
  border-color: var(--color-primary-hover);
  box-shadow: 0 0 0 2px var(--select-focus-ring);
}

.custom-select.select-status-error .select-trigger {
  border-color: #ff4d4f;
}

.custom-select.select-status-error .select-trigger.active {
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
}

.custom-select.select-status-warning .select-trigger {
  border-color: #faad14;
}

.custom-select.select-status-warning .select-trigger.active {
  box-shadow: 0 0 0 2px rgba(250, 173, 20, 0.2);
}

.select-trigger.disabled {
  background: var(--color-bg-soft, #f6f6f6);
  cursor: not-allowed;
  color: var(--color-text-muted);
}

/* 边框开关：bordered=false => 不显示触发器边框 */
.custom-select.select-borderless .select-trigger {
  border: none;
  box-shadow: none;
  padding: 0;
}

.custom-select.select-borderless .select-trigger:hover {
  border-color: transparent;
  box-shadow: none;
}

.custom-select.select-borderless .select-trigger.active {
  box-shadow: none;
}

/* 选中值显示区域 */
.select-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-primary);
}

.select-value-content {
  max-width: 100%;
}

.select-value.placeholder {
  color: var(--color-text-muted);
}

/* 多选标签 */
.select-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.select-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--color-bg-soft);
  border-radius: 4px;
  font-size: 13px;
  color: var(--color-text-primary);
}

.select-tag .tag-close {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.select-tag .tag-close:hover {
  background: var(--color-border);
}

/* 箭头图标 */
.select-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
  color: var(--color-text-muted);
}

.select-suffix {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.select-clear {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  background: var(--color-bg-soft);
  cursor: pointer;
  line-height: 16px;
  text-align: center;
}

.select-trigger.can-clear:hover .select-clear {
  display: inline-flex;
}

.select-trigger.can-clear:hover .select-arrow {
  display: none;
}

.select-loading {
  display: none;
  color: var(--color-text-muted);
  animation: select-spin 1s linear infinite;
}

.select-loading.show {
  display: inline-flex;
}

@keyframes select-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.select-trigger.active .select-arrow {
  transform: rotate(180deg);
}

/* 下拉面板 */
.select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid rgba(31, 31, 31, 0.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translate(-12px, 14px);
  transform-origin: left top;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.select-dropdown img{
  -webkit-user-drag: none;
  -moz-user-drag: none;
  -ms-user-drag: none;
}

/* antvue dropdownMatchSelectWidth 行为（映射到本组件） */
.custom-select.dropdown-match-select-width-true .select-dropdown {
  left: 0;
  right: 0;
  width: 100%;
}

.custom-select.dropdown-match-select-width-true .select-option-label,
.custom-select.dropdown-match-select-width-true .select-option-content {
  overflow: visible !important;
  white-space: normal !important;
  text-overflow: clip !important;
}

.custom-select.dropdown-match-select-width-false .select-dropdown {
  left: 0;
  right: auto;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
}

.custom-select.dropdown-match-select-width-false .select-options {
  width: auto;
  max-width: 100%;
}

/* 关闭时不要用 max-content 撑出页面横向滚动 */
.custom-select:not(.is-open) {
  overflow: hidden;
}

.custom-select:not(.is-open) .select-dropdown {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.select-dropdown.show {
  visibility: visible;
}

.select-dropdown.show.is-enter {
  opacity: 1;
  transform: translate(0, 0);
}

.select-dropdown.is-fixed-popup {
  position: fixed;
  right: auto;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.custom-select.is-open {
  z-index: 20;
}

.select-arrow .g-icon {
  width: 16px;
  height: 16px;
}

.select-clear .g-icon,
.select-loading .g-icon,
.tag-close .g-icon {
  width: 12px;
  height: 12px;
}

.select-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--select-inner-divider);
  background: #ffffff;
}

.select-search-icon {
  color: var(--color-text-muted);
  display: inline-flex;
}

.select-search-icon .g-icon {
  width: 16px;
  height: 16px;
}

.select-search input {
  flex: 1;
  min-width: 0;
  padding: 0 11px;
  height: var(--select-height-md);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: var(--select-font-size);
  line-height: var(--select-line-height);
  outline: none;
  background: #ffffff;
}

.select-search input:focus {
  border-color: var(--color-primary-hover);
}

/* 选项列表 */
.select-options {
  overflow-y: auto;
  max-height: 240px;
  padding: 6px 4px;
  background: #ffffff;
  border-radius: 4px;
}

.select-option-group {
  padding-bottom: 4px;
}

.select-option-group + .select-option-group {
  border-top: 1px solid var(--select-inner-divider, #f0f0f0);
  margin-top: 4px;
  padding-top: 4px;
}

.select-option-group-label {
  padding: 8px 12px 4px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--color-text-muted, #999);
  user-select: none;
  pointer-events: none;
}

.select-option {
  min-height: var(--select-height-md);
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: var(--color-text-primary);
  font-size: var(--select-font-size);
  line-height: var(--select-line-height);
  background: #ffffff;
}

.select-option:hover {
  background: var(--select-option-hover-bg);
}

.select-option.selected {
  background: var(--color-selected-bg, #fff1e8);
  color: var(--color-primary);
  font-weight: 400;
}

.select-option-label {
  flex: 1;
}

.select-option-content {
  flex: 1;
  min-width: 0;
}

.select-option.disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.select-option.disabled:hover {
  background: transparent;
}

/* 多选复选框 */
.select-option .checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-radius: 2px;
  margin-right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: transparent;
}

.select-option .checkbox .g-icon {
  width: 12px;
  height: 12px;
  opacity: 0;
}

.select-option.selected .checkbox {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.select-option.selected .checkbox .g-icon {
  opacity: 1;
}

/* 空状态 */
.select-empty {
  padding: 30px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  background: #ffffff;
}

/* 移动端底部面板：固定屏幕高度 80% */
body.select-sheet-lock {
  overflow: hidden;
}

.select-sheet-host {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.select-sheet-host.is-open {
  pointer-events: auto;
}

.select-sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.select-sheet-host.is-open .select-sheet-mask {
  opacity: 1;
}

.select-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 80vh;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow: hidden;
}

.select-sheet-host.is-open .select-sheet-panel {
  transform: translateY(0);
}

.select-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  height: 52px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #ffffff;
}

.select-sheet-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-sheet-cancel {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #666;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.select-sheet-cancel:active {
  background: #f5f5f5;
}

.select-sheet-cancel .g-icon {
  width: 20px;
  height: 20px;
}

.select-sheet-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.select-dropdown.is-sheet {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  max-height: none;
  flex: 1;
  min-height: 0;
  opacity: 1;
  visibility: visible;
  transform: none;
  box-shadow: none;
  border-radius: 0;
  background: #ffffff;
  transition: none;
  display: flex;
  flex-direction: column;
}

.select-dropdown.is-sheet .select-options {
  max-height: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.select-dropdown.is-sheet .select-option {
  min-height: 48px;
  padding: 12px 16px;
  font-size: 16px;
}

@media (max-width: 768px) {
  .custom-select .select-trigger {
    min-height: 44px;
  }
}