@import "mixins/mixins";
@import "common/var";
@import "./input";
@import "./popper";
@import "./tag";
@import "./cascader-panel";

@include b(cascader) {
  display: inline-block;
  position: relative;
  font-size: $--font-size-base;
  line-height: $--input-height;

  @include e(multiple) {
    overflow: hidden;
    vertical-align: bottom;
  }
  &:not(.is-disabled):hover {
    .el-input__inner:not(.is-readable) {
      cursor: pointer;
      border-color: $--color-text-placeholder;
      // bug 128259
      // background-color: transparent;

      &::placeholder {
        color: $--color-text-placeholder;
      }
    }
    .el-cascader-tags-modal:not(.modal-is-active) {
      border-color: $--color-text-placeholder;
    }
  }

  .temp-input-value {
    position:absolute;
    left: 15px;
    top: 0;
    color: $--color-text-3;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    z-index:1;
  }

  .el-input {
    cursor: pointer;
    display: block; // 行高问题，放大视图，小尺寸少一条边

    .el-input__inner {
      text-overflow: ellipsis;
      padding-left: 12px;
      display: block; // 行高问题，放大视图，小尺寸少一条边
      &:focus {
        border-color: $--primary-6 !important;
      }
    }

    &.el-input--suffix {
      .el-input__inner {
        padding-right: 40px;
      }
    }

    .el-icon-arrow-down {
      font-size: $--font-size-title-1;
      transition: all 0ms;
      color: $--color-text-placeholder;
      @include when(reverse) {
        transform: rotateZ(180deg);
      }
    }

    .el-icon-circle-close:hover {
      color: $--input-clear-hover-color;
    }

    .el-input__suffix {
      transition: all 0s;
    }

    .close-svg {
      width: 20px;
      height: 36px;
      display: flex;
      align-items: center;

      a {
        // border-radius: 50%;
        border-radius: $--border-radius-circle;
        width: 20px;
        height: 20px;
        line-height: 20px;
        font-size: $--font-size-title-1;
        display: inline-block;

        &:hover {
          background: $--color-bg-3;
        }
      }
      &:hover {
        color: $--color-text-secondary;
        // 鼠标移除清空按钮显示异常
        // background-color: $--color-text-active;
      }
    }

    @include when(focus) {
      .el-input__inner {
        border-color: $--input-focus-border;
      }
    }
  }

  @include m(medium) {
    font-size: $--input-small-font-size;
    height: $--input-medium-height;
    line-height: $--input-medium-height;

    .el-input .close-svg {
      height: $--input-medium-height;
    }
  }

  @include m(small) {
    font-size: $--input-small-font-size;
    height: $--input-small-height;
    line-height: $--input-small-height;

    .el-input .close-svg {
      height: $--input-small-height;
    }
  }

  @include when(disabled) {
    .el-cascader__label {
      z-index: #{$--index-normal + 1};
      color: $--disabled-color-base;
    }
    .el-checkbox__inner {
      background-color: $--color-disabled-background;
      border-color: $--color-disabled-background;
    }
    .el-icon-arrow-down {
      color: $--color-secondary-active;
    }
    .el-cascader-tags-modal{
      background-color: $--color-secondary-disabled-background;
    }
    .el-tag{
      color: $--color-text-4!important;
    }
  }

  @include e(dropdown) {
    margin: 5px 0;
    font-size: $--cascader-menu-font-size;
    background: $--cascader-menu-fill;
    border: $--cascader-menu-border;
    border-right: none;
    // border-radius: $--cascader-menu-radius;
    border-radius: $--border-radius-medium;
    // box-shadow: $--box-shadow;
    box-shadow: $--shadow1-center;
  }

  .el-cascader-tags-modal {
    position: absolute;
    border-left: $--border-1 solid $--color-border-3;
    width: 3px;
    top: 4px;
    left: 0px;
    z-index: 10;
    height: 80%;
    background: #fff;
    &.modal-is-active {
      border-color: $--color-primary;
    }
  }

  @include e(tags) {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    line-height: normal;
    display: flex;
    flex-wrap: nowrap;
    box-sizing: border-box;

    .el-tag {
      display: inline-flex;
      align-items: center;
      max-width: 100%;
      margin: 4px;
      text-overflow: ellipsis;
      background: $--cascader-tag-background;
      // height: 28px;
      &:not(.is-hit) {
        border-color: transparent;
      }

      + .el-tag {
        margin-left: 0;
      }

      > span {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .el-icon-close {
        flex: none;
        background-color: $--color-secondary;
        color: $--color-text-secondary;
        font-weight: $--font-weight-700;
        top: initial;
        &:hover {
          background-color: $--tag-close-hover-background-color;
        }
      }

      &:last-of-type {
        margin-right: 2px;
      }
    }

    .el-tag--info {
      color: $--color-text-regular;
    }
  }

  @include e(caret) {
    color: $--color-text-3;
    font-size: $--font-size-title-1;
    transition: transform .3s;
    transform: rotateZ(0deg);
    cursor: pointer;
  }
  @include e(suggestion-panel) {
    // border-radius: $--cascader-menu-radius;
    border-radius: $--border-radius-medium;
    margin: 4px 0;
  }

  @include e(suggestion-list) {
    max-height: 204px;
    margin: 0;
    // padding: 6px 0px;
    font-size: $--font-size-base;
    color: $--cascader-menu-font-color;
    text-align: center;
  }

  @include e(suggestion-item) {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    text-align: left;
    outline: none;
    cursor: pointer;

    &:hover, &:focus {
      background: $--cascader-node-background-hover;
    }

    &.is-checked {
      color: $--cascader-menu-selected-font-color;
      font-weight: $--font-weight-700;
    }

    // > span {
    //   margin-right: 10px;
    // }
  }

  @include e(empty-text) {
    margin: 10px 0;
    color: $--cascader-color-empty;
  }

  @include e(search-input) {
    margin: 2px 0;
    padding: 0;
    color: $--cascader-menu-font-color;
    border: none;
    outline: none;
    box-sizing: border-box;

    &::placeholder {
      color: $--color-text-placeholder;
    }
  }

  @include e(search-only) {
    width: calc(100% - 0px);
    padding-left: 12px;
    height: 100%;
    margin: 1px;
    color: $--cascader-menu-font-color;
    border: none;
    outline: none;
    box-sizing: border-box;
    font-size: $--font-size-body-3;

    &::placeholder {
      color: $--color-text-placeholder;
    }
  }
}
