@import "mixins/mixins";
@import "common/var";

@mixin genTheme($backgroundColorWeight, $borderColorWeight, $fontColorWeight, $hoverColorWeight) {
  background-color: mix($--tag-primary-color, $--color-white, $backgroundColorWeight);
  border-color: mix($--tag-primary-color, $--color-white, $borderColorWeight);
  color: mix($--tag-primary-color, $--color-white, $fontColorWeight);

  @include when(hit) {
    border-color: $--tag-primary-color;
  }

  .el-tag__close {
    color: mix($--tag-primary-color, $--color-white, $fontColorWeight);

    &:hover {
      color: $--color-white;
      background-color: mix($--tag-primary-color, $--color-white, $hoverColorWeight);
    }
  }

  &.el-tag--info {
    background-color: mix($--tag-info-color, $--color-white, $backgroundColorWeight);
    border-color: mix($--tag-info-color, $--color-white, $borderColorWeight);
    color: mix($--tag-info-color, $--color-white, $fontColorWeight);

    @include when(hit) {
      border-color: $--tag-info-color;
    }

    .el-tag__close {
      color: mix($--tag-info-color, $--color-white, $fontColorWeight);

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-info-color, $--color-white, $hoverColorWeight);
      }
    }
  }

  &.el-tag--success {
    background-color: mix($--tag-success-color, $--color-white, $backgroundColorWeight);
    border-color: mix($--tag-success-color, $--color-white, $borderColorWeight);
    color: mix($--tag-success-color, $--color-white, $fontColorWeight);

    @include when(hit) {
      border-color: $--tag-success-color;
    }

    .el-tag__close {
      color: mix($--tag-success-color, $--color-white, $fontColorWeight);

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-success-color, $--color-white, $hoverColorWeight);
      }
    }
  }

  &.el-tag--warning {
    background-color: mix($--tag-warning-color, $--color-white, $backgroundColorWeight);
    border-color: mix($--tag-warning-color, $--color-white, $borderColorWeight);
    color: mix($--tag-warning-color, $--color-white, $fontColorWeight);

    @include when(hit) {
      border-color: $--tag-warning-color;
    }

    .el-tag__close {
      color: mix($--tag-warning-color, $--color-white, $fontColorWeight);

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-warning-color, $--color-white, $hoverColorWeight);
      }
    }
  }

  &.el-tag--danger {
    background-color: mix($--tag-danger-color, $--color-white, $backgroundColorWeight);
    border-color: mix($--tag-danger-color, $--color-white, $borderColorWeight);
    color: mix($--tag-danger-color, $--color-white, $fontColorWeight);

    @include when(hit) {
      border-color: $--tag-danger-color;
    }

    .el-tag__close {
      color: mix($--tag-danger-color, $--color-white, $fontColorWeight);

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-danger-color, $--color-white, $hoverColorWeight);
      }
    }
  }

  &.el-tag--gray {
    background-color: mix(#ECEFF9, $--color-white, $backgroundColorWeight);
    border-color: mix(#C1C4CC, $--color-white, $borderColorWeight);
    color: $--color-text-regular;

    @include when(hit) {
      border-color: $--tag-info-color;
    }

    i {
      color: mix($--tag-info-color, $--color-white, $fontColorWeight);
    }

    .el-tag__close {
      color: mix($--tag-info-color, $--color-white, $fontColorWeight);

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-info-color, $--color-white, $hoverColorWeight);
      }
    }
  }
}

@include b(tag) {
  @include genTheme(12%, 0, 100%, 100%);
  display: inline-block;
  height: 24px;
  padding: $--tag-padding;
  line-height: 22px;
  font-size: $--tag-font-size;
  color: $--tag-primary-color;
  border-width: 1px;
  border-style: solid;
  border-radius: $--tag-border-radius;
  box-sizing: border-box;
  white-space: nowrap;

  [class^="bi-iconfont-"],
  .bi-iconfont-close {
    text-align: center;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    top: -1px;
  }

  [class^="bi-iconfont-"] {
    font-size: 14px;
  }

  .bi-iconfont-close {
    font-size: 12px;
    border-radius: 50%;
    right: -3px;

    &::before {
      display: block;
    }
  }

  @include m(dark) {
    @include genTheme(100%, 100%, 0, 80%);
  }

  @include m(plain) {
    @include genTheme(0, 100%, 100%, 100%);
  }

  @include m(mix) {
    @include genTheme(10%, 100%, 100%, 100%);
  }

  @include m(circle) {
    display: flex;
    align-items: center;
    background-color: transparent;
    line-height: 20px;
    font-size: 14px;
    color: $--color-gray;
    .el-tag--circle__annulus {
      width: 7px;
      height: 7px;
      margin-right: 4px;
      background-color: #fff;
      border-radius: 50%;
      border: 3px solid $--color-text-secondary;
    }
    &.el-tag--success {
      background-color: transparent;
      color: $--color-gray;
      .el-tag--circle__annulus {
        border-color: $--color-success;
      }
    }
    &.el-tag--info {
      background-color: transparent;
      color: $--color-gray;
      .el-tag--circle__annulus {
        border-color: $--color-text-secondary;
      }
    }
    &.el-tag--gray {
      background-color: transparent;
      color: $--color-gray;
      .el-tag--circle__annulus {
        border-color: $--color-gray;
      }
    }
    &.el-tag--warning {
      background-color: transparent;
      color: $--color-gray;
      .el-tag--circle__annulus {
        border-color: $--color-warning;
      }
    }
    &.el-tag--danger {
      background-color: transparent;
      color: $--color-gray;
      .el-tag--circle__annulus {
        border-color: $--color-danger;
      }
    }
  }

  @include m(medium) {
    height: 28px;
    line-height: 26px;

    .el-icon-close {
      transform: scale(.8);
    }
  }

  @include m(small) {
    height: 24px;
    padding: 0 8px;
    line-height: 22px;

    .el-icon-close {
      transform: scale(.8);
    }
  }

  @include m(mini) {
    height: 20px;
    padding: 0 5px;
    line-height: 19px;

    .el-icon-close {
      margin-left: -3px;
      transform: scale(.7);
    }
  }
}