@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 when(wrap) {
    margin-bottom: 17px;
  }

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

  @include e(icon) {
    position: relative;
    z-index: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    font-size: 14px;
    box-sizing: border-box;
    background: $--steps-bg-color;
    color: $--steps-wait-color;
    border-color: $--steps-wait-color;
    transition:  0.15s ease-out;
    transition-property: background, color, border;

    @include when(process) {
      color: $--steps-active-color;
      border-color: $--steps-active-color;

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

    @include when(wait) {
      color: $--steps-wait-color;
      border-color: $--steps-wait-color;

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

    @include when(success) {
      color: $--steps-active-color;
      border-color: $--steps-active-color;
      font-size: 19px;
    }

    @include when(error) {
      color: $--steps-error-color;
      border-color: $--steps-error-color;
      font-size: 19px;

      @include when(text) {
        color: $--steps-font-color-active;
        background: $--steps-error-color;
      }
    }

    @include when(finish) {
      color: $--steps-active-color;
      border-color: $--steps-active-color;
    }

    @include when(text) {
      border-radius: 50%;
      border-width: 2px;
      border-style: solid;

      @include when(process) {
        color: $--steps-font-color-active;
        background: $--steps-active-color;
      }

      @include when(wait) {
        color: $--steps-font-color-active;
        background: $--steps-wait-color;
      }

      @include when(danger) {
        color: $--steps-font-color-active;
        background: $--steps-error-color;
      }
    }

    @include when(icon) {
      width: 40px;
      background: $--steps-bg-color;
    }

    @include when(show) {
      border: none;
      width: 70px;
      height: 70px;
      margin-bottom: 10px;
    }
  }

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

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

    // 组件自身表示状态的图标
    @include when(status) {
      font-size: 14px;
      font-weight: bold;
    }

    // 展示型步骤条
    @include when(show) {
      font-weight: normal;
      font-size: 70px;
    }

    &.el-icon-check {
      font-size: 16px;
    }
  }

  @include e(line) {
    position: absolute;
    border-color: inherit;
    background-color: $--steps-wait-color;
  }

  @include e(line-inner) {
    display: block;
    transition:  0.15s ease-out;
    box-sizing: border-box;
    width: 0;
    height: 0;

    @include when(process) {
      background: $--steps-active-color;

      @include when(show) {
        background: $--steps-wait-color;
      }
    }

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

    @include when(success) {
      background: $--steps-active-color;
    }

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

    @include when(finish) {
      background: $--steps-active-color;
    }
  }

  @include e(line-step) {
    position: absolute;
    display: inline-block;
    width: 9px;
    height: 9px;
    left: 50%;
    top: -4px;
    margin-left: -4px;
    border-radius: 50%;
    background: $--steps-wait-color;

    @include when(process) {
      background: $--steps-active-color;
    }

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

    @include when(success) {
      background: $--steps-active-color;
    }

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

    @include when(finish) {
      background: $--steps-active-color;
    }
  }

  @include e(line-step-tip) {
    position: absolute;
    display: inline-block;
    left: 50%;
    transform: translate(-50%, -100%);
    margin-top: -9px;
    font-size: 12px;

    @include when(process) {
      color: $--steps-active-color;
    }

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

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

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

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

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

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

    @include when(process) {
      color: $--steps-title-active-color;
    }

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

    @include when(success) {
      color: $--steps-title-active-color;

      @include when(show) {
        color: $--steps-title-active-color;
      }
    }

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

    @include when(finish) {
      color: $--steps-title-active-color;
    }

    @include when(show) {
      color: $--steps-title-active-color;
    }
  }

  @include e(description) {
    padding-right: 10%;
    margin-top: -5px;
    font-size: 12px;
    font-weight: normal;
    color: $--steps-font-desc-color;

    @include when(process) {
      color: $--steps-font-desc-active-color;
    }

    @include when(wait) {
      color: $--steps-font-color-wait;

      @include when(show) {
        color: $--steps-font-desc-color;
      }
    }

    @include when(success) {
      color: $--steps-font-desc-active-color;
    }

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

    @include when(finish) {
      color: $--steps-font-desc-active-color;
    }

    @include when(show) {
      color: $--steps-font-desc-color;
    }
  }

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

    @include e(line) {
      height: 1px;
      top: 14px;
      left: 0;
      right: 0;

      @include when(show) {
        height: 2px;
        top: 34px;
      }
    }
  }

  @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: 30px;
    }

    @include e(line) {
      width: 1px;
      top: 0;
      bottom: 0;
      left: 14px;

      @include when(show) {
        width: 2px;
        left: 34px;
      }
    }

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

  @include when(center) {
    @include e(head) {
      text-align: center;
    }
    @include e(description) {
      padding-left: 20%;
      padding-right: 20%;
      @include when(custom-space) {
        padding: 0;
      }
    }
    @include e(main) {
      text-align: center;
    }

    @include e(line) {
      left: 50%;
      right: -50%;
    }
  }
  //简洁风格步骤条
  @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(0.8) translateY(1px);
      }
      &.el-icon-check {
        font-size: 14px;
      }
    }

    @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: $--steps-simple-bg-color;
      }

      &::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;
      }
    }
  }
}
