/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@progress-prefix-cls: ~'@{css-prefix}progress';

.@{progress-prefix-cls} {
  .inject-Progress-vars();

  position: relative;
  display: flex;
  align-items: center;
  line-height: 1;

  /** 横向条自身默认场景 */
  &-bar {
    width: 100%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;

    &__outer {
      position: relative;
      height: 6px;
      overflow: hidden;
      vertical-align: middle;
      background-color: var(--tv-Progress-outer-bg-color);
    }

    &__inner {
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      line-height: 1;
      text-align: right;
      white-space: nowrap;
      background-color: var(--tv-Progress-inner-bg-color);
      transition: width 0.6s ease;

      &::after {
        content: '';
        height: 100%;
      }
    }

    &__innerText {
      margin: 0 5px;
      font-size: var(--tv-Progress-inner-font-size);
      color: var(--tv-Progress-inner-text-color);
    }

    &,
    &__inner::after,
    &__innerText {
      display: inline-block;
      vertical-align: middle;
    }
  }

  /** 横向条状态场景 */
  .progress-status(@color) {
    .@{progress-prefix-cls}-bar__inner {
      background-color: @color;
    }

    .@{progress-prefix-cls}__text svg {
      fill: @color;
    }
  }

  &.is-success {
    .progress-status(var(--tv-Progress-bg-color-success));
  }

  &.is-warning {
    .progress-status(var(--tv-Progress-bg-color-warning));
  }

  &.is-exception {
    .progress-status(var(--tv-Progress-bg-color-exception));
  }

  /** 右侧文字场景 */
  &__text {
    display: inline-block;
    margin-left: var(--tv-Progress-right-text-margin-left);
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
    color: var(--tv-Progress-right-text-color);

    i {
      display: inline-block;
      vertical-align: middle;
    }
  }

  /** 内侧文字场景 */
  &--text-inside &-bar {
    margin-right: 0;
    padding-right: 0;
  }

  /** 隐藏文字场景 */
  &--without-text &__text {
    display: none;
  }

  &--without-text &-bar {
    padding-right: 0;
    margin-right: 0;
    display: block;
  }

  /** 圆环类型场景 */
  &--circle,
  &--dashboard {
    display: inline-block;

    .@{progress-prefix-cls}__text {
      position: absolute;
      left: 0;
      top: 50%;
      transform: translate(0, -50%);
      margin: 0;
      width: 100%;
      text-align: center;

      i {
        display: inline-block;
        vertical-align: middle;
      }
    }
  }
}

@-webkit-keyframes progress {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 32px 0;
  }
}

@keyframes progress {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 32px 0;
  }
}
