@import '../../Form/style/common.scss';
@import '../../../styles/assets/mixin.scss';
@import './common.scss';

.#{$prefixCls}select {
  position: relative;
  width: 100%;
  min-width: 80px;
  height: $select-height;
  font-size: $font-size-sm;
  border: 1px solid $input-border-color;
  border-radius: $select-radius;
  background-color: $select-background;
  color: $select-color;
  &:hover {
    border: 1px solid $select-hover-border-color;
    .drop-down-icon {
      stroke: $icon-hover-color;
    }
  }

  // TODO 添加mini状态
  &.mini {
    @include miniStyle();
    .select-input-dom {
      font-size: $font-size-sm;
    }
    .Select-control {
      .Select-input {
        line-height: $height-sm - 2px;
        font-size: $font-size-sm;
      }
    }
    .Select-label {
      line-height: $height-sm - 2px;
    }
    .Select-placeholder {
      font-size: $font-size-sm;
      line-height: $height-sm - 2px;
    }
    .del-icon {
      width: $icon-size-sm;
      height: $icon-size-sm;
    }
    .multi-select-value {
      height: 22px;
    }

    .select-option-item {
      min-height: 27px;
      line-height: 27px;
      font-size: $font-size-sm;
    }
    .multi-select-value {
      font-size: $font-size-sm;
    }
  }
  .Select-control {
    padding: 0 5px;
    width: 100%;
    position: relative;
    display: flex;
    height: 100%;
    cursor: pointer;
    overflow: hidden;

    .select-multi-ell-label {
      flex-shrink: 0;
      min-width: 25px;
      height: $label-height;
      background: #ffffff;
      border: 1px solid $shallow-color;
      box-sizing: border-box;
      border-radius: 2px;
      padding: 0 5px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: ArialMT;
      font-size: $font-size-sm;
      color: $base-color;
      margin-right: 5px;
    }

    .delete-icon {
      display: inline-block;
      width: 13px;
      height: 13px;
      line-height: 11px;
      font-size: $font-size-sm;
      text-align: center;
      &:hover {
        cursor: pointer;
      }
    }
  }
  &.multi {
    height: auto;
    min-height: $input-height-base;
    &.mini {
      min-height: $input-height-sm;
    }
    .Select-control {
      padding-left: 5px;
    }
  }
  &.background {
    background-color: $input-background-base;
  }
  .Select-value-zone {
    display: flex;
    position: relative;
    align-items: center;
    flex: 1;
    height: 100%;
    overflow: hidden;
  }
  .Select-label {
    line-height: $input-height-base - 2px;
  }
  .Select-placeholder {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
    position: absolute;
    width: 100%;
    color: $input-placeholder-color;
  }
  .Select-input {
    position: relative;
    line-height: $select-height - 2px;
    flex-wrap: nowrap;
    align-items: center;
    overflow: hidden;
    display: flex;
    justify-content: flex-start;
    flex: 1;
    padding: 0 1px;

    input {
      padding: 0;
      box-sizing: content-box;
      width: 5px;
      background: none transparent;
      border: 0 none;
      box-shadow: none;
      cursor: default;
      display: inline-block;
      margin: 0;
      outline: none;
      line-height: 17px;
    }
  }

  .control-zone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0px;
    &.zone-show {
      width: 16px;
    }
    &.zone-hover-show {
      .Select-clear-zone {
        display: none;
      }
    }
  }
  &:hover {
    .control-zone {
      &.zone-hover-show {
        .Select-clear-zone {
          display: block;
        }
        .Select-arrow-zone {
          display: none;
        }
      }
    }
  }
  .Select-clear-zone {
    line-height: 0;
    color: #999;
    cursor: pointer;
    text-align: center;
    display: flex;
    align-items: center;
    .del-icon {
      width: $icon-size-base;
      height: $icon-size-base;
      fill: $icon-color;
      vertical-align: middle;
      &:hover {
        fill: $icon-hover-color;
      }
    }
  }

  .Select-arrow-zone {
    cursor: pointer;
    display: flex;
    position: relative;
    // flex: 0 0 26px;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    // padding-right: 10px;
    padding-top: 2px;
  }

  .drop-down-icon {
    stroke: none;
    // transform: rotate(180deg);
    transition: transform 0.2s ease-in-out;
    stroke: $icon-color;
    width: 10px;

    &.mini {
      width: 10px;
    }
  }

  &.is-open {
    @include focusStyle();
    .drop-down-icon {
      stroke: $icon-hover-color;
      // transform: rotate(180deg);
    }
  }
  &.white {
    .Select-control {
      background-color: #fff;
    }
    .Select-option {
      background-color: #fff;
      color: $text-color;
    }
  }
  &.disabled {
    @include disabledStyle();
    .Select-input {
      @include disabledStyle();
    }
    .Select-clear-zone {
      display: none;
    }
    .Select-arrow-zone {
      @include disabledStyle();
    }
    .Select-placeholder {
      @include disabledStyle();
    }
  }
  &.error {
    @include errorStyle();
  }
}
.#{$prefixCls}select-option-wrap {
  display: none;
  width: 100%;
  margin-top: 0;
  background: #ffffff;
  @include wrapShadow;
  color: $select-option-text;
  z-index: $select-option-z-index;
  border: 1px solid #e4e6eb;
  box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  position: absolute;
  font-size: $font-size-sm;
  &.mini {
    font-size: $font-size-sm;
  }
  &.inline {
    top: 100%;
    margin-top: 5px;
    left: 0;
    width: 100%;

    &.trigger-hover {
      margin-top: 0;
    }
  }
  &.show {
    @include selectOptionWrapShow();
  }
  .scroll-box {
    position: relative;
    max-height: 210px;
    margin: 10px 0;
    overflow: auto;
    @include scrollbar();
  }
  .select-option-content {
    list-style: none;
    margin: 0;
    padding: 0;
    // padding: 10px 0;
  }
  .select-option-item {
    min-height: $select-option-height;
    line-height: $select-option-height;
    margin: 2px 0;
    cursor: pointer;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 10px;
    .text-box {
      display: flex;
      justify-content: flex-start;
      width: 100%;
      overflow: hidden;
      align-items: center;
      padding-right: 10px;
      .icon {
        flex-shrink: 0;
        stroke: $select-active-tag-color;
        width: 10px;
        height: 10px;
        margin: 0 7px;
      }
    }
    .text {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      word-break: keep-all;
    }
    &.active {
      padding-left: 0px;
      background: $select-focus-background;
      &::before {
        content: '';
        display: block;
        flex-shrink: 0;
        width: 2px;
        height: $select-option-height;
        margin-right: 8px;
        background: $select-active-tag-color;
        position: relative;
      }
    }
    &.multi {
      padding-left: 0;
      background: none;
      .text-box {
        padding-left: 24px;
      }
      &.active {
        .text-box {
          padding-left: 0;
        }
      }
      &::before {
        content: none;
      }
    }
    &.focus {
      @include selectFocus();
    }
    &.disabled {
      @include disabledStyle();
      background-color: #f9f9f9;
    }
  }
  .select-no-result {
    color: $text-color;
    line-height: $input-height-base - 2px;
    padding-left: 10px;
  }
}
.remove-icon {
  stroke: $icon-color;
  width: 9px;
  height: 9px;
}
.select-line {
  height: 1px;
  margin: 5px 0;
  background: #e4e6eb;
}
