// @import "./variables.scss";

.#{$namespace}select {
  display: inline-block;
  vertical-align: middle;

  &-label-highlightText {
    color: $select-item-highlight-color;
  }

  &-loading {
    pointer-events: none;
    height: 26px;
    text-align: center;

    &:before {
      content: '';
      display: inline-block;
      height: 1em;
      width: 1em;
      border-radius: .5em;
      line-height: $select-before-line-height;
      vertical-align: -0.15em;
      border: 1px solid currentColor;
      border-top-color: rgba(255, 255, 255, .35);
      margin-right: $select-before-margin-right;
      animation: loading .5s infinite linear;
    }

    &:after {
      pointer-events: none;
      content: "";
      border-radius: inherit;
      position: absolute;
      right: 8px;
      top: $select-after-top;
      background-color: rgba(255, 255, 255, .35);
    }
  }

  &:hover .#{$namespace}input>input {
    border: $select-hover-border;

    &[disabled] {
      border: $select-hover-disabled-border;
    }

    &.#{$namespace}select-value-input-readonly {
      border: $select-hover-readonly-border;
    }

  }

  .#{$namespace}select-cross {
    cursor: pointer;
  }

  .#{$namespace}select-arrow-down {
    transition: transform .2s;
  }

  &.#{$namespace}select-isopen {
    .#{$namespace}select-arrow-down {
      transform: rotate(180deg);
    }
  }

  .#{$namespace}select-arrow-down {
    &::before {
      border-width: $select-arrow-border-width;
    }
  }

  .#{$namespace}select-value-box {
    position: relative;
    overflow: hidden;

    .#{$namespace}select-value-input {
      transition: height .1s;
      background: $select-background;
    }

    // 选择框（非输入）
    .#{$namespace}select-value-input[readonly] {
      border-style: solid;
      background: $select-background;

      &:focus {
        border: $select-focus-border !important;
      }
    }

    .#{$namespace}select-value-input-readonly {
      border-style: dotted !important;
      background: $select-readonly-background !important;

      &[readonly]:focus {
        border: $select-readonly-focus-border !important;
      }
    }

    .#{$namespace}select-value-input[disabled] {
      border-style: dotted;
      background: $select-disabled-background;
      color: $select-disabled-color;
    }

    .#{$namespace}select-tags {
      position: absolute;
      z-index: 1;
      width: calc(100% - 30px);
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding-left: $select-tags-padding-left;
      .#{$namespace}select-input {
        color: $select-input-color;
      }
    }

    .#{$namespace}select-tag {
      color: $select-tag-color;
      display: flex;
      flex-grow: 0;
      flex-shrink: 0;
      align-items: center;
      height: $select-tag-height;
      line-height: $select-tag-height;
      margin: 2px 0px 2px 8px;
      padding-left: 8px;
      padding-right: 8px;
      border-radius: $select-tag-radius;
      background-color: $select-tag-background;
      max-width: calc(100% - 5px);
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      display: inline-block;
      padding-right:calc(4px + $select-tag-icon-font-size); 
      position: relative;
      .#{$namespace}select-tag-del {
        // flag 这里没有做hover的颜色变化 需要和XDC沟通颜色的变化
        display: inline-block;
        margin-left: 8px;
        height: $select-tag-icon-height;
        width: $select-tag-icon-width;
        color: $select-tag-icon-color;
        cursor: pointer;
        font-family: "font_family"; // 这是icon的样式
        font-size: $select-tag-icon-font-size;
        line-height: normal;
        font-style: normal;
        -webkit-font-smoothing: antialiased;
        position: absolute;
        right: 3px;
        top:calc($select-tag-height / 2 - 0.5em);
        &::before {
          content: $select-tag-icon;
        }
      }

      .#{$namespace}select-tag-del.#{$namespace}select-tag-del-disabled {
        cursor: not-allowed;
      }
    }

    .#{$namespace}select-tag-disabled,
    .#{$namespace}select-prefixTitle-disabled,
    .#{$namespace}select-string-disabled {
      color: $select-tag-disabled-color;
    }

    .#{$namespace}select-input {
      display: block;
      width: 20px;
      flex-grow: 1;
      flex-shrink: 0;
      border: none;
      outline: 0;
      padding: 0;
      margin-left: 9px;
      color: $select-input-color;
      font-size: $select-input-font-size;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      height: 28px;
      background-color: transparent;
    }

    .#{$namespace}select-input-prefixTitle {
      margin-left: 6px;
    }

    .#{$namespace}select-prefixTitle {
      padding-left: 8px;
      padding-right: 0;
      margin-right: 0;
      color: $select-item-color;
    }
  }

  &.#{$namespace}select-xs {
    .#{$namespace}select-tags>.#{$namespace}select-tag {
      height: 20px;
      padding: 0 5px;
      line-height: 20px;
      padding-right:calc(4px + $select-tag-icon-font-size); 
      .#{$namespace}select-tag-del {
        top:calc(10px - 0.5em);
      }
    }
  }

}

.#{$namespace}select-input-active {
  border-color: $select-item-active-border-color;

  &.#{$namespace}select-value-input-readonly[readonly] {
    border-color: $select-item-readonly-border-color;
  }
}

.#{$namespace}select-options {
  color: $select-item-color;
  max-height: 290px;
  overflow: auto;
  padding-top: 5px;
  padding-bottom: 5px;
  border-radius: $select-options-radius;
  background-color: #fff;
  box-shadow: $select-options-box-shadow;
  cursor: pointer;
  white-space: nowrap;

  .#{$namespace}select-item {
    display: flex;
    align-items: center;
    padding-left: 12px;
    padding-right: 12px;
    height: $select-item-height;
    color: $select-item-color;

    &:hover,&.#{$namespace}select-item-hover {
      background-color: $select-item-hover-background;
    }

    &.#{$namespace}select-item-active {
      color: $select-item-active-color;
    }

    &.#{$namespace}select-item-disabled {
      color: $select-item-disabled-color;
      cursor: not-allowed;

      &:hover {
        background-color: $select-item-disabled-background;
      }
    }
  }

  .#{$namespace}select-options-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 12px;
    padding-right: 12px;
    height: 30px;
    color:$select-options-empty-color;
  }
}

// flag 兼容以前的selectfield
.#{$namespace}selectfield {

  .#{$namespace}select-item {
    white-space: nowrap;
    padding-left: 12px;
    padding-right: 12px;
    line-height: $select-item-height;
    cursor: pointer;
  }

  .#{$namespace}select-item-active {
    color: $select-item-active-color;
  }

  .#{$namespace}select-item:hover {
    // background-color: $background-color-secondary;
  }

  .#{$namespace}select-item {
    i {
      position: relative;
      display: inline-block;
      transition: all .2s ease;
      width: 1em;
      height: 1em;
      vertical-align: -0.15em;
      margin-right: 6px;
      cursor: pointer;
      border: $select-item-i-border;
      background-color: $select-item-i-background-color;
      border-radius: $select-item-i-border-radius;
    }

    &.#{$namespace}select-item-active>i {
      border-color: $select-item-active-i-border-color;
    }

    &.#{$namespace}select-item-active>i::before {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 4px;
      height: 6px;
      margin-top: -4px;
      margin-left: -2px;
      content: '';
      transform: rotate(45deg);
      border: 1px solid $select-item-active-color;
      border-top-width: 0;
      border-left-width: 0;
      background-clip: padding-box;
    }
  }

  .#{$namespace}select-tag {
    position: relative;
    display: inline-flex;
    height: $select-tag-height;
    margin: 1px 6px 1px 0;
    padding-right: 8px;
    padding-left: 8px;
    border-radius: $select-tag-radius;
    background-color: $select-tag-background;
    align-items: center;

    .#{$namespace}select-tag-cross {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      right: 0;
      z-index: 10;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 12px;
      width: 12px;
      border-radius: 6px;
      color: #fff;
      background-color: $select-tag-cross-background-color;
      margin-left: 4px;
      margin-right: 4px;
      cursor: pointer;
    }

    .#{$namespace}select-tag-cross:hover {
      background-color: $select-tags-cross-hover-background-color;
    }
  }
}

.#{$namespace}formfield .#{$namespace}select-tags {
  padding-left: 4px !important;
}