@use '../helpers/baseMixin.scss';
@use '../helpers/placement.scss';

// 局部变量
.vxe-select,
.vxe-select--panel {
  --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-default);
  --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-default);
  &.size--xlarge {
    --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-xlarge);
    --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-xlarge);
  }
  &.size--large {
    --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-large);
    --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-large);
  }
  &.size--medium {
    --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-medium);
    --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-medium);
  }
  &.size--small {
    --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-small);
    --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-small);
  }
  &.size--mini {
    --vxe-ui-select-current-font-size: var(--vxe-ui-font-size-mini);
    --vxe-ui-select-current-option-height: var(--vxe-ui-select-option-height-mini);
  }
}
.vxe-select,
.vxe-select--panel {
  --vxe-ui-select-current-padding: var(--vxe-ui-layout-padding-default);
  &.size--small,
  &.size--mini {
    --vxe-ui-select-current-padding: var(--vxe-ui-layout-padding-half);
  }
}

.vxe-select {
  position: relative;
  display: inline-block;
  width: 180px;
  font-size: var(--vxe-ui-select-current-font-size);
  color: var(--vxe-ui-font-color);
  text-align: left;
  & > .vxe-input {
    .vxe-input--inner {
      cursor: pointer;
    }
  }
  &.is--disabled {
    & > .vxe-input {
      .vxe-input--inner {
        cursor: no-drop;
      }
    }
  }
  &.is--loading {
    & > .vxe-input {
      .vxe-input--inner {
        cursor: progress;
      }
    }
  }
  & > .vxe-input {
    width: 100%;
    .vxe-input--suffix-icon > i {
      display: inline-block;
      @include baseMixin.createAnimationTransition(transform, .2s);
    }
  }
  &.is--active {
    &:not(.is--filter) {
      & > .vxe-input {
        border-color: var(--vxe-ui-font-primary-color);
      }
    }
  }
}
.vxe-select--readonly {
  color: var(--vxe-ui-font-color);
  display: inline-flex;
}

.vxe-select,
.vxe-select--readonly {
  &.is--badge {
    position: relative;
  }
  &.is--badge-dot {
    &::before {
      content: "";
      position: absolute;
      top: -0.25em;
      right: -0.25em;
      text-align: center;
      width: 0.5em;
      height: 0.5em;
      border-radius: 50%;
      background-color: var(--vxe-ui-badge-label-background-color);
      z-index: 1;
    }
  }
}

.vxe-select-slots {
  display: none;
}

.vxe-select--panel {
  font-size: var(--vxe-ui-select-current-font-size);
  @include placement.createPlacementPanel();
}

.vxe-select--panel-search {
  display: block;
  flex-shrink: 0;
  padding: var(--vxe-ui-layout-padding-default);
  .vxe-select-search--input {
    width: 100%;
  }
}

.vxe-select--panel-wrapper {
  display: flex;
  flex-direction: column;
  position: relative;
  max-height: 18em;
  border-radius: var(--vxe-ui-base-border-radius);
  border: 1px solid var(--vxe-ui-base-popup-border-color);
  box-shadow: var(--vxe-ui-base-popup-box-shadow);
  background-color: var(--vxe-ui-layout-background-color);
}

.vxe-select--panel-body {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-grow: 1;
  overflow: hidden;
}

.vxe-select--header-button {
  display: flex;
  flex-direction: row;
}

.vxe-select--header-button,
.vxe-select--footer-button {
  display: flex;
  flex-direction: row;
  white-space: nowrap;
  align-items: center;
  min-height: 2em;
}
.vxe-select--total-btns {
  padding-left: var(--vxe-ui-select-current-padding);
  flex-grow: 1;
}
.vxe-select--total-btns,
.vxe-select--oper-btns {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.vxe-select--oper-btns {
  flex-shrink: 0;
}
.vxe-select--footer-button {
  display: flex;
  flex-direction: row;
}


.vxe-select--panel-header {
  border-bottom: 1px solid var(--vxe-ui-base-popup-border-color);
}

.vxe-select--panel-footer {
  border-top: 1px solid var(--vxe-ui-base-popup-border-color);
}

.vxe-select--panel-header,
.vxe-select--panel-footer {
  flex-shrink: 0;
  padding: 4px 0;
}

.vxe-select-option--wrapper {
  flex-grow: 1;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}
.vxe-select--y-space {
  width: 0;
  float: left;
}
.vxe-select-option--wrapper,
.vxe-select--body {
  padding: 0;
  margin: 0;
  border: 0;
  outline: 0;
}
.vxe-select-option {
  position: relative;
  flex-direction: row;
  display: flex;
  padding: 0 0.6em;
  user-select: none;
  cursor: pointer;
  &.is--add {
    padding-right: 2em;
    &:hover {
      .vxe-select-option--add-icon {
        color: var(--vxe-ui-font-primary-color);
      }
    }
    .vxe-select-option--add-icon {
      display: block;
    }
  }
  &.is--selected {
    color: var(--vxe-ui-font-primary-color);
  }
  &:not(.is--disabled) {
    &.is--hover {
      background-color: var(--vxe-ui-select-option-hover-background-color);
    }
  }
  &.is--disabled {
    color: var(--vxe-ui-font-disabled-color);
    cursor: no-drop;
  }
}
.vxe-select-optgroup {
  color: var(--vxe-ui-select-title-color);
  font-size: 12px;
  cursor: default;
}

.vxe-select-option--label {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vxe-select-option--add-icon {
  display: none;
  position: absolute;
  top: 0;
  right: 0.6em;
}

.vxe-select-option--checkbox {
  padding-right: 0.4em;
  @include baseMixin.createCheckboxIcon();
}
.vxe-select-option--radio {
  padding-right: 0.4em;
  @include baseMixin.createRadioIcon();
}

.vxe-select--search-icon {
  margin-right: 0.5em;
}

.vxe-select--search-loading,
.vxe-select--empty-placeholder {
  padding: 0 0.6em;
  text-align: center;
  color: var(--vxe-ui-select-empty-color);
}

.vxe-select-option {
  height: var(--vxe-ui-select-current-option-height);
}
.vxe-select-option,
.vxe-select--search-loading,
.vxe-select--empty-placeholder {
  line-height: var(--vxe-ui-select-current-option-height);
}

// 滚动条
.vxe-select--panel-body {
  &.ov-padding {
    &.overflow-x {
      &.sx-pos--top {
        padding-top: var(--vxe-ui-scrollbar-x-height);
      }
      &.sx-pos--bottom {
        padding-bottom: var(--vxe-ui-scrollbar-x-height);
      }
    }
    &.overflow-y {
      &.sy-pos--left {
        padding-left: var(--vxe-ui-scrollbar-y-width);
      }
      &.sy-pos--right {
        padding-right: var(--vxe-ui-scrollbar-y-width);
      }
    }
  }
  &.ov-x--hidden {
    & > .vxe-select-option--wrapper {
      overflow-x: hidden;
    }
  }
  &.ov-y--hidden {
    & > .vxe-select-option--wrapper {
      overflow-y: hidden;
    }
  }
  &.is--virtual-scrollbar {
    &.ov-x--auto-hide {
      &:hover {
        & > .vxe-scrollbar {
          & > .vxe-scrollbar--track-x {
            opacity: 1;
          }
        }
      }
      & > .vxe-scrollbar {
        & > .vxe-scrollbar--track-x {
          opacity: 0;
          @include baseMixin.createAnimationTransition(opacity, 0.8s);
        }
      }
    }
    &.ov-y--auto-hide {
      &:hover {
        & > .vxe-scrollbar {
          & > .vxe-scrollbar--track-y {
            opacity: 1;
          }
        }
      }
      & > .vxe-scrollbar {
        & > .vxe-scrollbar--track-y {
          opacity: 0;
          @include baseMixin.createAnimationTransition(opacity, 0.8s);
        }
      }
    }
  }
  & > .vxe-scrollbar {
    position: unset;
  }
  &.is--virtual-scrollbar {
    & > .vxe-select-option--wrapper {
      scrollbar-width: none;
      -ms-overflow-style: none;
    }
    & > .vxe-select-option--wrapper::-webkit-scrollbar {
      display: none;
    }
  }
}