@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);
      }
    }
  }
}

@include b(tag) {
  @include genTheme(20%, 0%, 100%, 100%);
  display: inline-block;
  height: 32px;
  padding: $--tag-padding;
  line-height: 30px;
  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;

  .el-icon-close {
    border-radius: 50%;
    text-align: center;
    position: relative;
    cursor: pointer;
    font-size: 12px;
    height: 16px;
    width: 16px;
    line-height: 16px;
    vertical-align: middle;
    top: -1px;
    right: -5px;

    &::before {
      display: block;
    }
  }
  @include m(dark) {
    @include genTheme(100%, 100%, 0, 80%);
  }
  @include m(plain) {
    @include genTheme(0, 100%, 100%, 100%);
  }
  @include m(round) {
    border-radius: 16px;
  }
  
  @include m(circle) {
    border-radius: 50%;
    padding: 0;
    text-align: center;
    width: 32px;
    &.el-tag--medium{
      width: 28px;
    }
    &.el-tag--small{
      width: 24px;
    }
    &.el-tag--mini{
      width: 20px;
    }
  }
  @include m(haveSubscript) {
    position: relative;
    &::after{
      content: "";
      display: block;
      position: absolute;
      right: 0;
      border: 4px solid transparent;
      border-bottom: 4px solid;
      border-right: 4px solid;
      bottom: 0;
    }
  }
  

  @include m(vertical) {
    writing-mode: vertical-lr;
    padding: $--tag-vertical;
    height: fit-content;
    letter-spacing: 3px;
    &.el-tag--small{
      padding: 8px 0;
    }
    &.el-tag--mini{
      padding: 5px 0;
    }
  }

  
  
  @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: 18px;
    padding: 0 3px;
    line-height: 18px;

    .el-icon-close {
      margin-left: -3px;
      transform: scale(.7);
    }
  }
  &.el-tag--light {
    border-color: transparent;
  }
}
