.@{css-prefix}select,
.@{css-prefix}cascader {
  display: inline-block;
  width: 100%;
  position: relative;
  vertical-align: bottom;
  border-radius: @border-radius-base;
  cursor: pointer;
  .bui-single-prefix-wrapper,
  .bui-multiple-prefix-wrapper {
    color: @select-prefix-color;
  }

  .bui-select-wrapper {
    position: relative;
    width: 100%;
    cursor: pointer;
    &-multiple {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      border: 1px solid @select-border;
      border-radius: @border-radius-base;
      padding-right: @select-input-padding-right;
      padding-left: 8px;
      position: relative;
      &:hover {
        border-color: @select-multiple-input-hover-border;
        z-index: @input-active-zindex;
      }
      &.bui-select-wrapper-absolute {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        padding-left: 8px;
        padding-right: 32px;
        border: 1px solid @select-multiple-collapse-border;
        background-color: @component-bg;
        border-radius: @border-radius-base;
        box-shadow: @select-active-box-shadow;
        margin: 0;
        z-index: @input-clear-zindex;
        max-height: 102px;
        overflow-y: auto;
        .scrollbar();
        .bui-select-tag {
          max-width: 100%;
        }
      }
      .bui-select-tag {
        margin-bottom: 3px;
        margin-left: 4px;
        margin-top: 3px;
        max-width: calc(100% - 45px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .bui-selected-label {
        color: @select-selected-label-color;
        margin-left: 4px;
        background-color: @select-selected-label-bg;
        text-align: center;
        border-radius: 13px;
        padding: 0 6px;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: @select-input-padding-right;
        font-size: @font-size-md;
        &-ellipsis {
          display: inline-block;
          span {
            width: 2px;
            height: 2px;
            margin: 1px;
            background: @text-color-3;
            display: inline-block;
            vertical-align: 2px;
            border-radius: 50%;
          }
        }
      }
      .bui-select-filter {
        display: inline-block;
        width: 100%;
        border: none;
        outline: none;
        padding-top: 6px;
        padding-bottom: 6px;
        padding-left: 4px;
        font-size: @font-size-md;
      }
      &-collapse {
        height: @select-height-base;
        overflow: hidden;
      }
    }
    .bui-input {
      .input();
      padding-right: @select-input-padding-right;
    }
    &.active {
      .bui-select-wrapper-multiple,
      .bui-input[readonly] {
        z-index: @input-clear-zindex;
        border-color: @select-multiple-input-active-border;
        box-shadow: @select-active-box-shadow;
      }
    }
    &-plain {
      line-height: 0;
    }
    .bui-single-prefix-wrapper {
      position: absolute;
      left: 12px;
      z-index: @input-clear-zindex;
      top: 0;
      height: 100%;
      display: inline-flex;
      align-items: center;
      font-size: @font-size-md;
    }
    .bui-multiple-prefix-wrapper {
      margin-left: 3px;
      display: inline-flex;
      align-items: center;
      font-size: @font-size-md;
    }
  }
  .bui-select-icon {
    fill: @select-icon-color;
    position: absolute;
    right: 12px;
    top: 50%;
    height: 14px;
    width: 14px;
    transform:rotate(0deg);
    transition: transform .2s ease;
    margin-top: -7px;
    z-index: @input-active-zindex;

    cursor: pointer;
    &.open{
      z-index: @select-open-zindex;
      transform:rotate(-180deg);
    }
    &.bui-select-clear-icon {
      z-index: @input-clear-zindex;
    }
  }

  &-custom {
    .bui-select-wrapper {
      border: 1px solid @select-border;
      padding: 5px 32px 5px 12px;
      border-radius: @border-radius-base;
      min-height: @select-height-base;
      &.active {
        border-color: @select-custom-active-border;
        box-shadow: @select-active-box-shadow;
      }
      &:hover {
        border-color: @select-custom-hover-border;
      }
    }

  }
  &-multiple {
    .bui-select-wrapper {
      min-height: @select-height-base;
    }
    &.@{css-prefix}select-lg .bui-select-wrapper{
      min-height: @select-height-lg;
      .bui-select-tag{
        margin-top: 3px;
        margin-bottom: 3px;
      }
      .bui-select-wrapper-multiple-collapse {
        height: @select-height-lg;
      }
    }
    &.@{css-prefix}select-xl .bui-select-wrapper{
      min-height: @select-height-xl;
      .bui-select-tag{
        margin-top: 3px;
        margin-bottom: 3px;
      }
      .bui-select-wrapper-multiple-collapse {
        height: @select-height-xl;
      }
    }
    &.@{css-prefix}select-xs .bui-select-wrapper{
      min-height: @select-height-xs;
      .bui-select-tag{
        margin-top: 2px;
        margin-bottom: 2px;
      }
      .bui-select-wrapper-multiple-collapse {
        height: @select-height-xs;
      }
    }
    &.@{css-prefix}select-sm  .bui-select-wrapper,
    &.@{css-prefix}cascader-sm  .bui-select-wrapper {
      min-height: @select-height-sm;
      .bui-select-wrapper-multiple-collapse {
        height: @select-height-sm;
      }
    }
  }

  .bui-selected-label {
    font-size: @font-size-md;
    line-height: @line-height-xl;
    min-width: @line-height-xl;
    pointer-events: none;
  }

  &-xs {
    .bui-select-wrapper .bui-input{
      .input-xs();
      padding-right: @select-input-padding-right;
    }
    .bui-select-icon {
      height: 12px;
      width: 12px;
      margin-top: -6px;
    }
    .bui-selected-label {
      font-size: @font-size-sm;
      line-height: @line-height-md;
      min-width: @line-height-md;
    }
    .bui-single-prefix-wrapper {
      font-size: @font-size-sm;
    }
  }
  &-sm,
  &-small {
    .bui-select-wrapper .bui-input{
      .input-sm();
      padding-right: @select-input-padding-right;
    }
    .bui-select-icon {
      height: 12px;
      width: 12px;
      margin-top: -6px;
    }
    .bui-selected-label {
      font-size: @font-size-sm;
      line-height: @line-height-md;
      min-width: @line-height-md;
    }
    .bui-single-prefix-wrapper {
      font-size: @font-size-sm;
    }
  }
  &-lg,
  &-large {
    .bui-select-wrapper .bui-input{
      .input-lg();
      padding-right: @select-input-padding-right;
    }
    .bui-selected-label {
      font-size: @font-size-lg;
      line-height: @line-height-xl;
      min-width: @line-height-xl;
    }
    .bui-single-prefix-wrapper {
      font-size: @font-size-lg;
    }
  }
  &-xl {
    .bui-select-wrapper .bui-input{
      .input-xl();
      padding-right: @select-input-padding-right;
    }
    .bui-selected-label {
      font-size: @font-size-xl;
      line-height: @line-height-xl;
      min-width: @line-height-xl;
    }
    .bui-single-prefix-wrapper {
      font-size: @font-size-xl;
    }
  }
  &-error {
    .bui-select-wrapper {
      .bui-input {
        .input-danger();
        &:hover:not([disabled]) {
          .input-danger-hover();
        }
        &:focus:not([disabled]),
        &:active:not([disabled]),
        &.active {
          .input-danger-active();
        }
      }
      .bui-select-wrapper-multiple {
        border-color: @input-danger-border;
      }
      &.active {
        .bui-select-wrapper-multiple,
        .bui-input[readonly] {
          z-index: @input-clear-zindex;
          border-color: @input-danger-border;
          box-shadow: @input-danger-box-shadow;
        }
      }
    }


    &.@{css-prefix}select-custom .bui-select-wrapper,
    &.@{css-prefix}select-multiple  .bui-select-wrapper-multiple {
      border-color: @select-multiple-error-border;
    }
  }
  &-plain {
    .bui-select-wrapper {
      font-size: 0;
      .bui-input {
        .select-plain-input();
        padding-left: 0;
        padding-right: 0;
        width: auto;
        max-width: calc(100% - 22px);
        overflow: hidden;
        white-space: nowrap;
      }
      &:hover,
      &.active,
      &:focus {
        .bui-input {
          color: @select-plain-color;
        }
        .bui-select-icon-plain {
          fill: @select-plain-color;
        }
      }
    }
    .bui-select-icon-plain{
      width: 14px;
      height: 14px;
      margin-bottom: 10px;
      fill: @text-color-3;
      margin-left: 8px;
      &.open {
        fill: @select-plain-color;
        transform:rotate(-180deg);
      }
    }
    &.@{css-prefix}select-sm,
    &.@{css-prefix}select-small{
      .bui-select-icon-plain{
        width: 12px;
        height: 12px;
        margin-bottom: 9px;
      }
    }
    &.@{css-prefix}select-custom {
      .bui-select-wrapper {
        border: none;
        padding: 0;
        &.active,
        &:hover {
          box-shadow: none;
        }
      }
      .bui-select-icon {
        display: none;
      }
    }
  }
  &-disabled {
    cursor: not-allowed;
    &.@{css-prefix}select-custom .bui-select-wrapper,
    &.@{css-prefix}select-multiple  .bui-select-wrapper-multiple,
    &.@{css-prefix}cascader-multiple  .bui-select-wrapper-multiple {
      cursor: not-allowed;
      background-color: @select-disabled-bg;
      border-color: @select-disabled-border;
      &:hover {
        background-color: @select-disabled-bg;
        border-color: @select-disabled-border;
        z-index: 0;
      }
      .bui-selected-label {
        color: @select-disabled-color;
        background-color: @select-disabled-bg;
        border: 1px solid @select-disabled-border;
        &-ellipsis * {
          background-color: @select-disabled-color;
        }
      }
    }
    & .bui-selected-label {
      line-height: @line-height-lg;
    }
    &.@{css-prefix}select-sm, &.@{css-prefix}cascader-sm {
      .bui-selected-label {
        line-height: @line-height-sm;
      }
    }
    .bui-select-icon,
    .bui-select-icon-plain {
      cursor: not-allowed;
      fill: @select-icon-disabled-color;
    }
    &.@{css-prefix}select-plain{
      .bui-select-wrapper {
        cursor: not-allowed;
        .bui-input {
          background-color: @select-plain-disabled-bg;
          color: @select-plain-disabled-color;
          &:hover,
          &:focus {
            border-color: @select-plain-hover-disabled-border;
          }
        }
        &:hover,
        &.active,
        &:focus {
          .bui-select-icon-plain {
            cursor: not-allowed;
            fill: @select-plain-icon-hover-disabled-color;
          }
        }
      }

    }
  }
  &-filled {
    .bui-select-wrapper {
      &-multiple {
        .bui-select-filled();
        &.bui-select-wrapper-absolute {
          .bui-select-filled();
        }
      }
      .bui-selected-label {
        color: @select-fill-label-color;
        background-color: @select-fill-label-bg;
      }
    }

  }
  &-active&-filled {
    .bui-select-wrapper {
      &-multiple {
        &.bui-select-wrapper-absolute {
          border-color: @select-filled-focus-border;
          box-shadow: @input-active-box-shadow;
          background-color: @select-filled-focus-bg;
        }
      }
    }
  }
  &-error&-filled {
    .bui-select-wrapper {
      .bui-input {
        .input-danger(@input-filled-error-bg, @input-filled-error-border);
        &:hover:not([disabled]) {
          .input-danger-hover(@input-filled-error-hover-bg, @input-filled-error-hover-border);
        }
        &:focus:not([disabled]),
        &:active:not([disabled]),
        &.active {
          .input-danger-active(@input-filled-error-bg);
        }
      }
      &-multiple {
        .input-danger(@input-filled-error-bg, @input-filled-error-border);
        &:hover:not([disabled]) {
          .input-danger-hover(@input-filled-error-hover-bg, @input-filled-error-hover-border);
        }
      }
    }
  }
  &-error&-filled&-active {
    .bui-select-wrapper {
      &-multiple {
        .input-danger-active(@input-filled-error-bg);
        &:hover:not([disabled]){
          .input-danger-active(@input-filled-error-bg);
        }
      }
    }
  }
}
.bui-select-popper {
  margin-top: 4px;
  margin-bottom: 4px;
  box-shadow: @select-popper-shadow;
  border-radius: @border-radius-base;
  z-index: @popper-z-index;
  background-color: @select-popper-bg;
  overflow: auto;
  .bui-select-option {
    &-wrapper {
      max-height: @select-option-wrapper-height;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 6px 0;
      // 美化滚动条
      .scrollbar();
    }
    .bui-option-match-none {
      font-size: @font-size-md;
      line-height: @line-height-md;
      padding: 62px 12px;
      min-width: 200px;
      color: @select-popper-match-none-color;
      text-align: center;
      font-size: @font-size-sm;
      line-height: @line-height-sm;
      .bui-icon-empty {
        fill: @select-popper-match-none-icon-color;
        width: 37px;
        height: 37px;
        display: block;
        margin: 0 auto 10px;
      }
    }
  }
  .bui-select-option {
    border-radius: 4px;
    .bui-option-filter {
      border-style: solid;
      border-color: transparent;
      border-bottom-color: @input-border;
      border-width: 0 0 1px 0;
      .@{css-prefix}input {
        .bui-input {
          border-color: transparent;
          outline: none;
          &:active,
          &:focus {
            border-color: transparent;
            box-shadow: none;
          }
        }
        .bui-input-group-addon {
          border-color: transparent;
          background-color: transparent;
          &::before {
            content: "";
            position: absolute;
            top: 8px;
            bottom: 8px;
            left: 0;
            width: 1px;
            background-color: @border-color-split;
          }
        }
      }
    }
  }
}

.@{css-prefix}option {
  position: relative;
  padding: @list-padding-top @list-padding-left;
  font-size: @font-size-md;
  line-height: @line-height-md;
  color: @text-color-1;
  cursor: pointer;
  &:last-child {
    margin-bottom: @list-padding-top;
  }
  &:hover{
    background-color: @select-option-hover-bg;
  }
  .bui-option-checkbox {
    display: none;
    position: absolute;
    top: 50%;
    left: @padding-sm;
    margin-top: (-@line-height-md / 2);
  }

  &-ingroup {
    padding: @list-padding-top @list-group-padding-left;
    &:last-child {
      margin-bottom: 0;
    }
  }

  &-selected {
    color: @select-option-active-color;
  }
  &-disabled {
    color: @select-option-disabled-color;
    cursor: not-allowed;
    &:hover {
      background-color: @select-option-hover-disabled-bg;
    }
  }
  &-sm,
  &-small,
  &-xs {
    font-size: @font-size-sm;
    line-height: @line-height-sm;
    padding: @list-padding-top - 1 @list-padding-left;
  }
  &-multiple {
    padding-left: @list-multiple-padding-left;
    .bui-option-checkbox {
      display: inline-block;
    }
  }
  &-multiple.@{css-prefix}option-ingroup {
    padding-left: @list-group-multiple-padding-left;
    .bui-option-checkbox {
      left: @list-group-padding-left;
    }
  }
}

.@{css-prefix}optgroup {
  .bui-optgroup-label {
    font-size: @font-size-md;
    padding: @select-optgroup-label-padding-top @select-optgroup-label-padding-left ;
    margin: 0;
    color: @select-optgroup-label-color;
  }
  &-sm,
  &-small,
  &-xs {
    .bui-optgroup-label {
      font-size: @font-size-sm;
    }
  }
}

.select-plain-input(){
  border-color: @select-plain-input-border;
  &:hover,
  &:active,
  &.active,
  &:focus {
    color: @select-plain-hover-color;
    border-color: @select-plain-hover-border;
    box-shadow: none  !important;
  }
  &[disabled],
  &-disabled {
    color: @select-plain-disabled-color;
    border-color: @select-plain-disabled-border;
    background-color: @select-plain-disabled-bg;
  }
}

.@{css-prefix}select-rtl {
  direction: rtl;
  .bui-select-icon {
    right: auto;
    left: 12px;
  }
  .bui-select-wrapper {
    .bui-input {
      padding-right: 12px;
      padding-left: @select-input-padding-right;
    }
    &-multiple {
      &, &.bui-select-wrapper-absolute{
        padding-left: @select-input-padding-right;
        padding-right: 8px;
      }
    }
    .bui-selected-label {
      right: auto;
      left: @select-input-padding-right;
    }
  }
  .bui-select-wrapper {
    .bui-single-prefix-wrapper {
      right: 12px;
      left: auto;
    }
  }
}
.@{css-prefix}option-rtl {
  direction: rtl;
  .bui-option-checkbox {
    left: auto;
    right: 12px;
  }

  &.@{css-prefix}option-multiple {
    padding-left: 12px;
    padding-right: @list-multiple-padding-left;
  }
  &.@{css-prefix}option-multiple.@{css-prefix}option-ingroup {
    padding-right: @list-group-multiple-padding-left;
    .bui-option-checkbox {
      right: @list-group-padding-left;
    }
  }
}
.@{css-prefix}optgroup-rtl {
  direction: rtl;
}
.bui-select-filled() {
  background-color: @select-filled-bg;
  border-color: @select-filled-border;
  &:hover {
    background-color: @select-filled-hover-bg;
    border-color: @select-filled-hover-border;
  }
  &:active,
  &.active {
    border-color: @select-filled-active-border;
    background-color: @select-filled-active-bg;
  }
  &:focus {
    border-color: @select-filled-focus-border;
    box-shadow: @input-active-box-shadow;
    background-color: @select-filled-focus-bg;
  }
}
