@import './theme/default';
@import './theme/font';

$ghost-hover-bg: rgb(239, 239, 239);

@mixin zent-steps-breadcrumb-angle($prop, $number) {
  &::after {
    @include theme-color(border-left-color, $prop, $number);
    content: ' ';
    display: block;
    width: 0;
    height: 0;
    border-top: 28px solid transparent;
    border-bottom: 28px solid transparent;
    border-left-width: 14px;
    border-left-style: solid;
    position: absolute;
    top: 50%;
    margin-top: -28px;
    right: 1px;
    z-index: 0;
  }

  &::before {
    @include theme-color(border-color, $prop, $number);
    content: ' ';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-top-width: 28px;
    border-bottom-width: 28px;
    border-right-width: 1px;
    border-left: 15px solid transparent;
    position: absolute;
    top: 50%;
    margin-top: -28px;
    left: -2px;
  }
}

.zent-steps {
  width: 100%;
  line-height: 1.5;
  font-size: 0;
  display: flex;
  box-sizing: border-box;
}

.zent-steps-tail {
  position: absolute;
  width: 100%;
  left: 0;
  top: 13px;
  box-sizing: border-box;
  margin-left: 75px;

  i {
    @include theme-color(background-color, stroke, 6);
    display: inline-block;
    position: relative;
    width: 100%;
    border-radius: 1px;
    height: 3px;
    vertical-align: top;
    transform: scaleY(0.5) translateY(4px);

    &::after {
      @include theme-color(background-color, stroke, 6);
      content: '';
      position: absolute;
      top: 0;
      width: 0;
      height: 100%;
      opacity: 0;
    }
  }
}

.zent-steps-step {
  position: relative;

  .zent-step-head {
    @include theme-color(background-color, stroke, 9);
    position: relative;
    display: inline-block;
    vertical-align: top;
    margin-left: 60px;
    box-sizing: border-box;
  }

  .zent-step-main {
    @include theme-color(color, stroke, 3);
    position: relative;
    vertical-align: top;
    width: 160px;
    text-align: center;

    .zent-step-title {
      font-size: $font-size-normal;
      font-weight: 500;
      max-width: 160px;
      line-height: 14px;
      margin-top: 10px;
      word-wrap: break-word;
      word-break: break-all;
    }

    .zent-step-description {
      max-width: 160px;
      font-size: $font-size-small;
      line-height: 16px;
      margin-top: 8px;
      word-wrap: break-word;
      word-break: break-all;
    }
  }
}

.zent-step-head-inner {
  @include theme-color(color, stroke, 4);

  margin: 0 8px;
  font-size: 30px;
  line-height: 30px;

  .zent-icon {
    @include theme-color(background-color, stroke, 4);
    @include theme-color(color, stroke, 9);

    display: inline-block;
    vertical-align: middle;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 50%;
    text-align: center;
    font-size: $font-size-normal;

    &.zent-steps-sequence {
      width: 24px;
      height: 24px;
      line-height: 24px;
      margin: 3px;
    }
  }

  .zenticon {
    vertical-align: middle;
  }
}

.zent-steps-item {
  position: relative;
  display: inline-block;
  vertical-align: top;
  overflow: visible;
  flex: 1;
  cursor: default;

  &.zent-steps-status-finish {
    &.zent-steps-item--current {
      .zent-steps-tail {
        i {
          &::after {
            width: 0;
          }
        }
      }
    }

    &.zent-steps-item--last-finished {
      .zent-steps-tail {
        i {
          &::after {
            @include theme-color(background-color, primary, 4);

            width: 100%;
          }
        }
      }
    }

    .zent-step-head-inner {
      @include theme-color(color, primary, 4);

      .zent-icon {
        @include theme-color(background-color, primary, 4);
      }
    }

    .zent-step-main {
      .zent-step-title {
        @include theme-color(color, stroke, 1);
      }
    }

    .zent-steps-tail {
      i {
        &::after {
          @include theme-color(background-color, primary, 4);
          width: 100%;
          transition: all 0.2s ease;
          opacity: 1;
        }
      }
    }
  }

  &.zent-steps-status-error {
    .zent-step-head-inner {
      @include theme-color(color, error, 2);
    }

    .zent-step-main {
      .zent-step-title {
        @include theme-color(color, error, 2);
      }
    }
  }

  &.zent-steps-status-process {
    .zent-step-head-inner {
      .zent-icon {
        @include theme-color(background-color, primary, 4);
      }
    }

    .zent-step-main {
      .zent-step-title {
        @include theme-color(color, stroke, 1);
      }
    }
  }

  &:last-child {
    flex: none;

    .zent-steps-tail {
      display: none;
    }
  }

  &__icon {
    font-size: 16px;
    margin-right: 8px;
    height: 20px;
    line-height: 20px;
  }
}

.zent-steps__vertical {
  display: block;

  .zent-steps-item {
    display: block;
    overflow: visible;

    &.zent-steps-status-finish {
      &.zent-steps-item--current {
        .zent-steps-tail {
          i {
            &::after {
              width: 100%;
              height: 0;
            }
          }
        }
      }

      &.zent-steps-item--last-finished {
        .zent-steps-tail {
          i {
            &::after {
              width: 100%;
            }
          }
        }
      }

      .zent-steps-tail {
        i {
          &::after {
            width: 100%;
          }
        }
      }
    }

    &:last-child {
      .zent-steps-step {
        .zent-step-main {
          min-height: auto;
        }
      }
    }
  }

  .zent-steps-tail {
    position: absolute;
    margin-left: 0;
    width: 2px;
    left: 18px;
    top: 0;
    height: 100%;
    padding: 30px 0 4px;

    i {
      height: 100%;
      width: 2px;

      &::after {
        width: 100%;
      }
    }
  }

  .zent-steps-step {
    .zent-step-head {
      float: left;
      margin-left: 0;
    }

    .zent-step-main {
      display: block;
      overflow: hidden;
      min-height: 120px;
      text-align: left;
      width: inherit;
      padding-left: 5px;

      .zent-step-title {
        margin-top: 2px;
        line-height: 22px;
        max-width: initial;
      }

      .zent-step-description {
        margin-top: 2px;
        padding-bottom: 15px;
        max-width: initial;
      }
    }
  }

  .zent-step-head-inner {
    margin-right: 8px;
  }
}

.zent-steps-card {
  .zent-steps-item {
    box-sizing: border-box;
    padding: 0 1px;

    &.zent-steps-item--clickable {
      cursor: pointer;
    }

    &:first-child {
      padding-left: 0;
    }

    &:last-child {
      padding-right: 0;
    }

    .zent-steps-step {
      @include theme-color(color, stroke, 1);
      @include theme-color(background-color, stroke, 8);
      height: 50px;
      line-height: 50px;
      font-size: $font-size-normal;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding: 0 10px;
    }

    &.zent-steps-item--current {
      &:hover {
        .zent-steps-step {
          @include theme-color(background-color, primary, 5);
        }
      }

      &:active {
        .zent-steps-step {
          @include theme-color(background-color, primary, 3);
        }
      }

      .zent-steps-step {
        @include theme-color(background-color, primary, 4);
        @include theme-color(color, stroke, 9);
      }
    }
  }
}

.zent-steps-breadcrumb {
  overflow: hidden;

  .zent-steps-item {
    padding: 0 14px;
    box-sizing: border-box;

    &.zent-steps-item--clickable {
      cursor: pointer;
    }

    &:first-child {
      padding-left: 0;

      .zent-steps-step {
        &::before {
          display: none;
        }
      }
    }

    &:last-child {
      padding-right: 0;

      .zent-steps-step {
        &::after {
          display: none;
        }
      }
    }

    .zent-steps-step {
      @include theme-color(color, stroke, 1);
      @include theme-color(background-color, stroke, 8);
      height: 48px;
      line-height: 48px;
      font-size: $font-size-normal;
      text-align: center;
      padding: 0 10px;

      &::after {
        @include theme-color(border-left-color, stroke, 8);
        content: ' ';
        display: block;
        width: 0;
        height: 0;
        border-top: 24px solid transparent;
        border-bottom: 24px solid transparent;
        border-left-width: 12px;
        border-left-style: solid;
        position: absolute;
        top: 50%;
        margin-top: -24px;
        right: -12px;
        z-index: 1;
      }

      &::before {
        @include theme-color(border-top-color, stroke, 8);
        @include theme-color(border-bottom-color, stroke, 8);

        content: ' ';
        display: block;
        width: 0;
        height: 0;
        border-top-width: 24px;
        border-top-style: solid;
        border-bottom-width: 24px;
        border-bottom-style: solid;
        border-left: 12px solid transparent;
        position: absolute;
        top: 50%;
        margin-top: -24px;
        left: -12px;
      }

      .zent-steps-sequence {
        @include theme-color(background-color, stroke, 4);
        @include theme-color(color, stroke, 9);
        font-size: $font-size-normal;
        display: inline-block;
        vertical-align: middle;
        width: 16px;
        height: 16px;
        line-height: 16px;
        border-radius: 50%;
        text-align: center;
        margin-right: 8px;
        margin-bottom: 2px;
      }
    }

    &.zent-steps-item--finished {
      .zent-steps-sequence {
        @include theme-color(background-color, primary, 4);
      }
      &:hover {
        .zent-steps-step {
          @include theme-color(background-color, primary, 5);

          &::after {
            @include theme-color(border-left-color, primary, 5);
          }

          &::before {
            @include theme-color(border-top-color, primary, 5);
            @include theme-color(border-bottom-color, primary, 5);
          }
        }
      }

      &:active {
        .zent-steps-step {
          @include theme-color(background-color, primary, 3);

          &::after {
            @include theme-color(border-left-color, primary, 3);
          }

          &::before {
            @include theme-color(border-top-color, primary, 3);
            @include theme-color(border-bottom-color, primary, 3);
          }
        }
      }

      .zent-steps-step {
        @include theme-color(background-color, primary, 4);
        @include theme-color(color, stroke, 9);

        &::after {
          @include theme-color(border-left-color, primary, 4);
        }

        &::before {
          @include theme-color(border-top-color, primary, 4);
          @include theme-color(border-bottom-color, primary, 4);
        }
      }
    }
  }

  &-ghost .zent-steps-item {
    .zent-steps-step {
      @include theme-color(background-color, stroke, 9);
      @include theme-color(color, stroke, 1);
      font-weight: $font-weight-bold;
      z-index: 1;

      &::before {
        @include theme-color(border-top-color, stroke, 9);
        @include theme-color(border-bottom-color, stroke, 9);
      }

      &::after {
        @include theme-color(border-left-color, stroke, 9);
      }
    }

    &.zent-steps-item--finished {
      .zent-steps-step {
        @include theme-color(color, primary, 4);
        @include theme-color(background-color, stroke, 9);
        box-sizing: border-box;

        &::after {
          @include theme-color(border-left-color, stroke, 9);
        }

        &::before {
          @include theme-color(border-top-color, stroke, 9);
          @include theme-color(border-bottom-color, stroke, 9);
        }
      }
    }

    &.zent-steps-item--current {
      @include zent-steps-breadcrumb-angle(primary, 4);

      .zent-steps-step {
        @include theme-color(border-top-color, primary, 4);
        @include theme-color(border-bottom-color, primary, 4);
        border-top-width: 1px;
        border-bottom-width: 1px;
        border-top-style: solid;
        border-bottom-style: solid;
        line-height: 46px;

        &::before {
          border-top-width: 23px;
          border-bottom-width: 23px;
          margin-top: -23px;
        }
      }
    }

    &,
    &.zent-steps-item--finished {
      &.zent-steps-item--disabled:hover,
      &.zent-steps-item--disabled:active {
        .zent-steps-step {
          @include theme-color(background-color, stroke, 7);

          &::after {
            @include theme-color(border-left-color, stroke, 7);
          }

          &::before {
            @include theme-color(border-top-color, stroke, 7);
            @include theme-color(border-bottom-color, stroke, 7);
          }
        }
      }

      &:not(.zent-steps-item--disabled):hover {
        .zent-steps-step {
          background-color: $ghost-hover-bg;

          &::after {
            border-left-color: $ghost-hover-bg;
          }

          &::before {
            border-top-color: $ghost-hover-bg;
            border-bottom-color: $ghost-hover-bg;
          }
        }
      }

      &:not(.zent-steps-item--disabled):active {
        .zent-steps-step {
          @include theme-color('background-color', stroke, 6);

          &::after {
            @include theme-color('border-left-color', stroke, 6);
          }

          &::before {
            @include theme-color('border-top-color', stroke, 6);
            @include theme-color('border-bottom-color', stroke, 6);
          }
        }
      }
    }

    &.zent-steps-item--disabled {
      cursor: not-allowed;
      @include zent-steps-breadcrumb-angle(stroke, 4);

      .zent-steps-step {
        @include theme-color(background-color, stroke, 7);
        @include theme-color(border-top-color, stroke, 4);
        @include theme-color(border-bottom-color, stroke, 4);
        @include theme-color(color, stroke, 1);
        border-top-width: 1px;
        border-bottom-width: 1px;
        border-top-style: solid;
        border-bottom-style: solid;
        line-height: 46px;
        box-sizing: border-box;

        &::after {
          @include theme-color(border-left-color, stroke, 7);
        }

        &::before {
          border-top-width: 23px;
          border-bottom-width: 23px;
          margin-top: -23px;
          @include theme-color(border-top-color, stroke, 7);
          @include theme-color(border-bottom-color, stroke, 7);
        }
      }
    }

    &:first-child {
      border-left-width: 1px;
      border-left-style: solid;
      border-left-color: transparent;

      &.zent-steps-item--current {
        @include theme-color(border-left-color, primary, 4);
      }

      &.zent-steps-item--disabled {
        @include theme-color(border-left-color, stroke, 4);
      }
    }

    &:last-child {
      border-right-width: 1px;
      border-right-style: solid;
      border-right-color: transparent;

      &.zent-steps-item--current {
        @include theme-color(border-right-color, primary, 4);
      }

      &.zent-steps-item--disabled {
        @include theme-color(border-right-color, stroke, 4);
      }
    }
  }
}

.zent-steps-tabs {
  position: relative;

  .zent-steps-item {
    @include theme-color(color, stroke, 8);
    @include theme-color(color, stroke, 1);
    @include theme-color(border-right-color, stroke, 5);
    @include theme-color(border-top-color, stroke, 5);
    @include theme-color(border-bottom-color, stroke, 5);
    position: relative;
    box-sizing: border-box;
    display: inline-block;
    border-right-width: 1px;
    border-right-style: solid;
    border-top-width: 1px;
    border-top-style: solid;
    border-bottom-width: 1px;
    border-bottom-style: solid;

    &.zent-steps-item--clickable {
      cursor: pointer;
    }

    &:first-child {
      @include theme-color(border-left-color, stroke, 5);
      border-left-width: 1px;
      border-left-style: solid;
    }

    .zent-steps-step {
      height: 46px;
      line-height: 46px;
      font-size: $font-size-normal;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding: 0 10px;
    }

    &.zent-steps-item--current {
      @include theme-color(background-color, stroke, 9);
      border-bottom-color: transparent;
    }

    &:not(.zent-steps-item--current) {
      @include theme-color(background-color, stroke, 8);

      &:hover {
        @include theme-color(background-color, stroke, 7);
      }

      &:active {
        @include theme-color(background-color, stroke, 6);
      }
    }
  }
}
