@import "mixins/mixins";
@import "common/var";

@include b(badge) {
  position: relative;
  vertical-align: middle;
  display: inline-block;

  @include e(content) {
    background-color: $--badge-background-color;
    border-radius: $--badge-radius;
    color: $--color-white;
    display: inline-block;
    font-size: $--badge-font-size;
    height: $--badge-size;
    line-height: $--badge-size;
    padding: 0 $--badge-padding;
    text-align: center;
    white-space: nowrap;
    border: 1px solid $--color-white;

    @include when(fixed) {
      position: absolute;
      top: 0;
      right: #{1 + $--badge-size / 2};
      transform: translateY(-50%) translateX(100%);

      @include when(dot) {
        right: 5px;
      }
    }

    @include when(dot) {
      height: 8px;
      width: 8px;
      padding: 0;
      right: 0;
      border-radius: 50%;
    }

    @each $type in (primary, success, warning, info, danger) {
      @include m($type) {
        @if $type == primary {
          background-color: $--color-primary;
        } @else if $type == success {
          background-color: $--color-success;
        } @else if $type == warning {
          background-color: $--color-warning;
        } @else if $type == info {
          background-color: $--color-info;
        } @else {
          background-color: $--color-danger;
        }
      }
    }
  }
  
  @include e(status-dot) {
    width: 6px;
    height: 6px;
    display: inline-block;
    border-radius: 50%;
    vertical-align: middle;
    position: relative;
    top: -1px;
  }
  
  @include e(status-text) {
    font-size: 14px;
    margin-left: 8px;
  }
  
  @include e(status-success) {
    background-color: #52c41a;
  }
  
  @include e(status-error) {
    background-color: #f5222d;
  }
  
  @include e(status-default) {
    background-color: #d9d9d9;
  }
  
  @include e(status-processing) {
    background-color: #1890ff;
    position: relative;
    
    &:after {
      position: absolute;
      top: -1px;
      left: -1px;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      border: 1px solid #1890ff;
      content: '';
      -webkit-animation: elStatusProcessing 1.2s infinite ease-in-out;
      animation: elStatusProcessing 1.2s infinite ease-in-out;
    }
    
    @-webkit-keyframes elStatusProcessing {
      0% {
        -webkit-transform: scale(0.8);
                transform: scale(0.8);
        opacity: 0.5;
      }
      100% {
        -webkit-transform: scale(1.8);
                transform: scale(1.8);
        opacity: 0;
      }
    }
    @keyframes elStatusProcessing {
      0% {
        -webkit-transform: scale(0.8);
                transform: scale(0.8);
        opacity: 0.5;
      }
      100% {
        -webkit-transform: scale(1.8);
                transform: scale(1.8);
        opacity: 0;
      }
    }
  }
  
  @include e(status-warning) {
    background-color: #faad14;
  }
}
