@import './../theme/vars.scss';

$badgePrefixCls: #{$vender-prefix}-badge;

.#{$badgePrefixCls} {
  position: relative;
  display: inline-block;
  line-height: 1;
  vertical-align: middle;

  span.#{$badgePrefixCls}-count {
    position: absolute;
    top: -10px;
    height: 18px;
    min-width: 18px;
    padding: 0 5px;
    font-family: 'tahoma', serif;
    font-size: 12px;
    line-height: 18px;
    color: white;
    text-align: center;
    white-space: nowrap;
    background: $danger-color;
    border-radius: 10px;
    transform: translateX(-50%);
    transform-origin: -10% center;
    box-shadow: 0 0 0 1px white;

    &.#{$badgePrefixCls}-count-animate {
      &::before {
        position: absolute;
        top: 8px;
        left: 10px;
        z-index: -1;
        width: 0;
        height: 0;
        background-color: red;
        border-radius: 50%;
        content: ' ';
        opacity: 0.75;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.3) inset;
        animation-delay: 0s;
        animation-duration: 0.8s;
        animation-iteration-count: 1;
        animation-name: badgeRippleAnim;
        animation-timing-function: ease;
        animation-direction: normal;
      }
    }
  }

  &.nowrap {
    span.#{$badgePrefixCls}-count {
      position: relative;
      top: auto;
      display: block;
      overflow: hidden;
      transform: none;
    }
  }

  span.amos-dot {
    position: absolute;
    top: -4px;
    z-index: 10;
    width: 8px;
    height: 8px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    background: $danger-color;
    border-radius: 100%;
    transform: translateX(-50%);
    transform-origin: 0 center;
    box-shadow: 0 0 0 1px white;
  }

  &-status {
    font-size: 14px;
    line-height: inherit;
    vertical-align: baseline;
  }

  &-status &-dot {
    position: relative;
    top: -1px;
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 50%;
  }

  &-status-success &-dot {
    background-color: $success-color;
  }

  &-status-processing &-dot {
    position: relative;
    background-color: $primary-color-deeper;

    &::after {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: 1px solid var(--primary-color);
      border-radius: 50%;
      content: '';
      animation: amosStatusProcessing 1.2s infinite ease-in-out;
    }
  }

  &-status-default &-dot {
    background-color: $badge-default-dot-bg;
  }

  &-status-error &-dot {
    background-color: $error-color;
  }

  &-status-warning &-dot {
    background-color: $warning-color;
  }
}

@keyframes amosStatusProcessing {
  0% {
    opacity: 0.5;
    transform: scale(0.8);
  }

  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}

@keyframes badgeRippleAnim {
  0% {
    top: 8px;
    left: 10px;
    width: 0;
    height: 0;
    opacity: 0.95;
  }

  99% {
    top: -30px;
    left: -30px;
    width: 80px;
    height: 80px;
    opacity: 0.3;
  }

  100% {
    opacity: 0;
  }
}
