@import "../styles/mixins/index.less";
@import "../styles/themes/index.less";

.@{wux-prefix}-badge {
    position: relative;
    display: inline-block;
    line-height: 1;
    vertical-align: middle;

    &__count {
        position: absolute;
        transform: translate(50%, -50%);
        top: 0;
        right: 0;
        height: @badge-height;
        border-radius: @badge-height / 2;
        min-width: @badge-height;
        background: @badge-bg;
        // border: 1px solid transparent;
        color: @badge-color;
        line-height: @badge-height;
        text-align: center;
        padding: 0 5px;
        font-size: @badge-font-size;
        white-space: nowrap;
        transform-origin: 100% 0%;
        z-index: 10;
        box-shadow: 0 0 0 1px @shadow-color-inverse;
        box-sizing: border-box;
        text-rendering: optimizeLegibility;
    }

    &__dot {
        .square(@badge-dot-size);

        position: absolute;
        transform: translate(50%, -50%);
        transform-origin: 100% 0%;
        top: 0;
        right: 0;
        border-radius: 100%;
        background: @badge-bg;
        z-index: 10;
        box-shadow: 0 0 0 1px @shadow-color-inverse;
    }

    &--position-topLeft &__count,
    &--position-topLeft &__dot {
        right: 100%;
    }

    &--position-bottomRight &__count,
    &--position-bottomRight &__dot {
        top: 100%;
    }

    &--position-bottomLeft &__count,
    &--position-bottomLeft &__dot {
        top: 100%;
        right: 100%;
    }

    &--hide-shadow &__count,
    &--hide-shadow &__dot {
        box-shadow: none !important;
    }

    &__status {
        line-height: inherit;
        vertical-align: baseline;
    }

    &__status-dot {
        .square(@badge-status-size);

        display: inline-block;
        border-radius: 50%;
        vertical-align: middle;
        position: relative;
        top: -1px;

        &--success {
            background-color: @badge-success-bg;
        }

        &--processing {
            background-color: @badge-processing-bg;
            position: relative;
        }

        &--processing::after {
            position: absolute;
            top: -1px;
            left: -1px;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            border: 1px solid @badge-processing-bg;
            content: "";
            animation: statusProcessing 1.2s infinite ease-in-out;
        }

        &--default {
            background-color: @badge-normal-bg;
        }

        &--error {
            background-color: @badge-error-bg;
        }

        &--warning {
            background-color: @badge-warning-bg;
        }
    }

    &__status-text {
        display: inline-block;
        color: @text-color;
        font-size: @font-size-base;
        margin-left: 8px;
    }
}

@keyframes statusProcessing {
    0% {
        transform: scale(.8);
        opacity: .5;
    }

    to {
        transform: scale(2.4);
        opacity: 0;
    }
}
