@import "mixins/mixins";
@import "common/var";

@include b(step) {
  position: relative;
  flex-shrink: 1;

  @include pseudo(last-of-type) {
    @include e(line) {
      display: none;
    }

    // 只有未设置 space 的情况下才自适应宽度
    @include when(flex) {
      flex-basis: auto !important;
      flex-shrink: 0;
      flex-grow: 0;
    }

    @include e((main, description)) {
      padding-right: 0;
    }
  }

  @include e(head) {
    position: relative;
    width: 100%;

    @include when(process) {
      color: $--color-primary;
      border-color: $--color-primary;
      .el-step__icon:not(.is-icon) {
        background-color: $--color-primary;
        .el-step__icon-inner {
          color: $--color-white;
        }
      }
      .el-step__icon.is-icon {
        background-color: $--color-white;
      }
    }

    @include when(wait) {
      color: $--color-text-placeholder;
      border-color: $--color-text-placeholder;
      .el-step__icon:not(.is-icon) {
        background-color: $--disabled-fill-base;
      }
    }

    @include when(success) {
      color: $--color-white;
      border-color: $--color-primary;
      .el-step__icon {
        background-color: $--color-primary;
      }
    }

    @include when(error) {
      color: $--color-danger;
      border-color: $--color-danger;
    }

    @include when(finish) {
      color: $--color-primary;
      border-color: $--color-primary;
      .el-step__icon {
        background-color: $--color-white;
      }
    }
  }

  @include e(icon) {
    position: relative;
    z-index: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    font-size: 14px;
    box-sizing: border-box;
    background: $--color-white;
    transition: .15s ease-out;

    @include when(text) {
      border-radius: 50%;
      border: 2px solid;
      border-color: inherit;
    }

    @include when(icon) {
      width: 40px;
    }
  }

  @include e(icon-inner) {
    display: inline-block;
    user-select: none;
    text-align: center;
    font-weight: bold;
    line-height: 1;
    color: inherit;

    &[class*=el-icon]:not(.is-status) {
      font-size: 25px;
      font-weight: normal;
    }

    // 组件自身表示状态的图标
    @include when(status) {
      transform: translateY(1px);
    }
  }

  @include e(line) {
    position: absolute;
    border-color: inherit;
    background-color: #F2F3F5;
  }

  @include e(line-inner) {
    display: block;
    border-width: 1px;
    border-style: solid;
    border-color: inherit;
    transition: .15s ease-out;
    box-sizing: border-box;
    width: 0;
    height: 0;
  }

  @include e(main) {
    white-space: normal;
    text-align: left;
  }

  @include e(title) {
    font-size: 14px;
    line-height: 38px;

    @include when(process) {
      font-family: PingFangSC-Medium, PingFang SC;
      color: $--color-primary;
      font-weight: 500;
    }

    @include when(wait) {
      color: $--color-gray;
    }

    @include when(success) {
      color: $--color-text-regular;
    }

    @include when(error) {
      color: $--color-danger;
    }

    @include when(finish) {
      color: $--color-primary;
    }
  }

  @include e(description) {
    padding-right: 10%;
    margin-top: -5px;
    font-size: 12px;
    line-height: 20px;
    font-weight: normal;

    @include when(process) {
      font-size: 12px;
      color: $--color-info;
    }

    @include when(wait) {
      color: $--color-info;
    }

    @include when(success) {
      color: $--color-info;
    }

    @include when(error) {
      color: $--color-danger;
    }

    @include when(finish) {
      color: $--color-primary;
    }
  }

  @include when(horizontal) {
    display: inline-block;

    @include e(line) {
      height: 2px;
      top: 11px;
      left: 30px;
      right: 10px;
    }
  }

  @include when(vertical) {
    display: flex;

    @include e(head) {
      flex-grow: 0;
      width: 24px;
    }

    @include e(main) {
      padding-left: 10px;
      flex-grow: 1;
    }

    @include e(title) {
      line-height: 24px;
      padding-bottom: 8px;
    }

    @include e(line) {
      width: 2px;
      top: 35px;
      bottom: 20px;
      left: 11px;
    }

    @include e(icon) {
      @include when(icon) {
        width: 24px;
      }
    }
  }

  @include when(center) {

    @include e(head) {
      text-align: center;
    }

    @include e(main) {
      text-align: center;
    }

    @include e(description) {
      padding-left: 20%;
      padding-right: 20%;
    }

    @include e(line) {
      left: calc(50% + 20px);
      right: calc(-50% + 20px);
    }
  }

  @include when(simple) {
    display: flex;
    align-items: center;

    @include e(head) {
      width: auto;
      font-size: 0;
      padding-right: 10px;
    }

    @include e(icon) {
      background: transparent;
      width: 16px;
      height: 16px;
      font-size: 12px;
    }

    @include e(icon-inner) {
      &[class*=el-icon]:not(.is-status) {
        font-size: 18px;
      }

      &.is-status {
        transform: scale(.8) translateY(1px);
      }
    }

    @include e(main) {
      position: relative;
      display: flex;
      align-items: stretch;
      flex-grow: 1;
    }

    @include e(title) {
      font-size: 16px;
      line-height: 20px;
    }

    @include pseudo('not(:last-of-type)') {
      @include e(title) {
        max-width: 50%;
        word-break: break-all;
      }
    }

    @include e(arrow) {
      flex-grow: 1;
      display: flex;
      align-items: center;
      justify-content: center;

      &::before,
      &::after {
        content: '';
        display: inline-block;
        position: absolute;
        height: 15px;
        width: 1px;
        background: $--color-text-placeholder;
      }

      &::before {
        transform: rotate(-45deg) translateY(-4px);
        transform-origin: 0 0;
      }

      &::after {
        transform: rotate(45deg) translateY(4px);
        transform-origin: 100% 100%;
      }
    }

    @include pseudo(last-of-type) {
      @include e(arrow) {
        display: none;
      }
    }
  }
}

.el-step--txt-right {
  &.is-horizontal {
    display: flex;
    align-items: center;
  }
  &:not(:last-child) {
    margin-right: 8px !important;
  }
  &:last-child {
    .el-step__right-line {
      display: none;
    }
  }
  .el-step__head {
    flex: 1;
    display: flex;
    .el-step__title {
      line-height: unset;
      margin-left: 8px;
    }
  }
  .el-step__right-line {
    width: 100%;
    height: 2px;
    margin-left: 8px;
    margin-right: 16px;
    background-color: #F2F3F5;
    .el-step__line-inner {
      border-color: $--color-primary;
    }
  }
}