@use '../../scss/_bootstrap-extended/include' as light;
@use '../../scss/_bootstrap-extended/include-dark' as dark;
@import 'bs-stepper/dist/css/bs-stepper';
@import '../../scss/_custom-variables/libs';

$bs-stepper-header-padding-y: 1.5rem !default;
$bs-stepper-header-padding-x: $bs-stepper-header-padding-y !default;
$bs-stepper-content-padding-x: 1.5rem !default;
$bs-stepper-content-padding-y: $bs-stepper-content-padding-x !default;
$bs-stepper-trigger-padding: 1.25rem !default;
$bs-stepper-trigger-padding-vertical: 0.63rem !default;
$bs-stepper-label-max-width: 224px !default;
$bs-stepper-svg-icon-height: 3.5rem !default;
$bs-stepper-svg-icon-width: 3.5rem !default;
$bs-stepper-icon-font-size: 1.6rem !default;
$bs-stepper-vertical-separator-height: 1.55rem !default;
$bs-stepper-vertical-header-min-width: 18rem !default;

// Default Styles
.bs-stepper {
  border-radius: light.$border-radius;

  .line {
    flex: 0;
    min-width: auto;
    min-height: auto;
    background-color: transparent;
    margin: 0;

    i {
      font-size: 1.375rem;
    }
  }

  .bs-stepper-header {
    padding: $bs-stepper-header-padding-y $bs-stepper-header-padding-x;

    .step.crossed + .line {
      i {
        color: light.$primary;
      }
    }
    .step {
      .step-trigger {
        padding: 0;
        flex-wrap: nowrap;
        gap: 0.5rem;
        font-weight: light.$font-weight-medium;
        .bs-stepper-label {
          margin: 0;
          max-width: $bs-stepper-label-max-width;
          overflow: hidden;
          text-overflow: ellipsis;
          text-align: start;
          display: inline-grid;
          font-weight: light.$font-weight-medium;
          font-size: light.$h6-font-size;
          .bs-stepper-title {
            line-height: light.$h6-line-height;
            font-weight: light.$font-weight-medium;
          }
          .bs-stepper-subtitle {
            font-size: light.$font-size-sm;
            font-weight: light.$font-weight-normal;
          }
        }

        &:hover {
          background-color: transparent;
        }
        @include light.media-breakpoint-down(lg) {
          padding: calc($bs-stepper-trigger-padding * 0.5) 0;
        }
      }
      .bs-stepper-circle {
        height: 2.375rem;
        width: 2.375rem;
        font-weight: light.$font-weight-medium;
        font-size: light.$h5-font-size;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: light.$border-radius;
        i {
          font-size: 1.375rem;
        }
      }
    }
  }

  .bs-stepper-content {
    padding: $bs-stepper-content-padding-y $bs-stepper-content-padding-x;
  }

  &.vertical {
    .bs-stepper-header {
      min-width: $bs-stepper-vertical-header-min-width;
      .step {
        .step-trigger {
          padding: $bs-stepper-trigger-padding-vertical 0;
        }
        &:first-child {
          .step-trigger {
            padding-top: 0;
          }
        }
        &:last-child {
          .step-trigger {
            padding-bottom: 0;
          }
        }
      }
    }
    .bs-stepper-content {
      width: 100%;
      .content {
        &:not(.active) {
          display: none;
        }
      }
    }

    &.wizard-icons {
      .step {
        text-align: center;
        padding: 0.75rem 0;
      }
    }
  }

  &.wizard-icons {
    .bs-stepper-header {
      .step-trigger {
        padding: $bs-stepper-trigger-padding;
        flex-direction: column;
        gap: 0.5rem;
        .bs-stepper-icon {
          svg {
            height: $bs-stepper-svg-icon-height;
            width: $bs-stepper-svg-icon-width;
          }
          i {
            font-size: $bs-stepper-icon-font-size;
          }
        }
      }
      @include light.media-breakpoint-up(lg) {
        justify-content: space-around;
        gap: 1rem;
      }
    }
  }

  // Remove borders from wizard modern
  &.wizard-modern {
    .bs-stepper-header {
      border-bottom: none !important;
    }

    .bs-stepper-content {
      border-radius: light.$border-radius;
    }

    &.vertical {
      .bs-stepper-header {
        border-right: none !important;
      }
    }
  }

  &:not(.vertical):not(.wizard-icons) .bs-stepper-header {
    @include light.media-breakpoint-up(lg) {
      gap: 1.5rem;
    }
  }
}

@include app-rtl(false) {
  .bs-stepper.wizard-icons .bs-stepper-header .step-trigger {
    @include light.media-breakpoint-down(lg) {
      padding-right: 0;
    }
  }
}
@include app-ltr(false) {
  .bs-stepper.wizard-icons .bs-stepper-header .step-trigger {
    @include light.media-breakpoint-down(lg) {
      padding-left: 0;
    }
  }
}
// Styles for Modal example Create App wizard
#wizard-create-app {
  &.vertical {
    .bs-stepper-header {
      min-width: $bs-stepper-vertical-header-min-width - 3;
    }
  }
}

// Light style
@if $enable-light-style {
  .light-style {
    .bs-stepper {
      background-color: light.$card-bg;
      &:not(.wizard-modern) {
        box-shadow: light.$card-box-shadow;
      }

      .bs-stepper-header {
        border-bottom: 1px solid light.$border-color;

        .line {
          i {
            color: light.$body-color;
          }
        }

        .bs-stepper-title,
        .bs-stepper-label {
          color: light.$headings-color;
        }

        .bs-stepper-label {
          .bs-stepper-subtitle {
            color: light.$body-color;
          }
        }

        .step {
          &:not(.active) {
            .bs-stepper-circle {
              background-color: light.$gray-60;
              color: light.$body-color;
            }
            .bs-stepper-subtitle {
              color: light.$text-muted;
            }
          }
          &.crossed .step-trigger {
            .bs-stepper-label .bs-stepper-subtitle,
            .bs-stepper-title {
              color: light.$text-muted;
            }
          }
        }
      }

      &.vertical {
        .bs-stepper-header {
          border-bottom: none;

          @include light.media-breakpoint-down(lg) {
            border-right: none !important;
            border-left: none !important;
            border-bottom: 1px solid light.$border-color;
          }
        }
      }

      &.wizard-modern {
        background-color: transparent;
        .bs-stepper-content {
          background-color: light.$card-bg;
          box-shadow: light.$card-box-shadow;
        }
      }

      &.wizard-icons {
        .bs-stepper-header {
          .bs-stepper-icon {
            svg {
              fill: light.$body-color;
            }
            i {
              fill: light.$body-color;
            }
          }
          .bs-stepper-label {
            color: light.$body-color;
          }
        }
      }
    }
  }

  // ! FIX: Vertical border issue in rtl and ltr
  @include app-rtl(false) {
    .light-style {
      .bs-stepper {
        &.vertical {
          .bs-stepper-header {
            border-left: 1px solid light.$border-color;
          }
        }
      }
    }
  }
  @include app-ltr(false) {
    .light-style {
      .bs-stepper {
        &.vertical {
          .bs-stepper-header {
            border-right: 1px solid light.$border-color;
          }
        }
      }
    }
  }
}

// Dark Style
@if $enable-dark-style {
  .dark-style {
    .bs-stepper {
      background-color: dark.$card-bg;
      .bs-stepper-header {
        border-bottom: 1px solid dark.$border-color;
        .line {
          i {
            color: dark.$body-color;
          }
        }

        .bs-stepper-label,
        .bs-stepper-title {
          color: dark.$headings-color;
        }

        .bs-stepper-label {
          .bs-stepper-subtitle {
            color: dark.$body-color;
          }
        }

        .step {
          &:not(.active) {
            .bs-stepper-circle {
              background-color: dark.$gray-60;
              color: dark.$body-color;
            }
            .bs-stepper-subtitle {
              color: dark.$text-muted;
            }
          }
          &.crossed .step-trigger {
            .bs-stepper-label .bs-stepper-subtitle,
            .bs-stepper-title {
              color: dark.$text-muted;
            }
          }
        }
      }

      &.vertical {
        .bs-stepper-header {
          border-bottom: none;

          @include light.media-breakpoint-down(lg) {
            border-right: none !important;
            border-left: none !important;
            border-bottom: 1px solid dark.$border-color;
          }
        }
      }

      &.wizard-modern {
        background-color: transparent;
        .bs-stepper-content {
          background-color: dark.$card-bg;
          box-shadow: dark.$card-box-shadow;
        }
      }

      &.wizard-icons {
        .bs-stepper-header {
          .bs-stepper-icon {
            i {
              color: dark.$body-color;
            }

            svg {
              fill: dark.$body-color;
            }
          }
          .bs-stepper-label {
            color: dark.$body-color;
          }
        }
      }
    }
  }

  // ! FIX: Vertical border issue in rtl and ltr
  @include app-rtl(false) {
    .dark-style {
      .bs-stepper {
        &.vertical {
          .bs-stepper-header {
            border-left: 1px solid dark.$border-color;
          }
        }
      }
    }
  }
  @include app-ltr(false) {
    .dark-style {
      .bs-stepper {
        &.vertical {
          .bs-stepper-header {
            border-right: 1px solid dark.$border-color;
          }
        }
      }
    }
  }
}

// RTL
@include app-rtl(false) {
  .bs-stepper {
    .bs-stepper-content {
      .btn-next,
      .btn-prev {
        i {
          transform: rotate(180deg);
        }
      }
    }

    // Remove borders from wizard modern
    &.wizard-modern {
      &.vertical {
        .bs-stepper-header {
          border-left: none !important;
        }
      }
    }

    @include light.media-breakpoint-up(lg) {
      .bs-stepper-header {
        .line {
          i {
            transform: rotate(180deg);
          }
        }
      }
    }

    @include light.media-breakpoint-down(lg) {
      .bs-stepper-header {
        .step {
          .step-trigger {
            .bs-stepper-label {
              margin-left: 0;
              margin-right: 0.25rem;
            }
          }
        }
      }
    }
  }
}

// Media Queries
@include light.media-breakpoint-down(lg) {
  .bs-stepper {
    .bs-stepper-header {
      flex-direction: column;
      align-items: flex-start;
      .step {
        .step-trigger {
          flex-direction: row;
          .bs-stepper-label {
            margin-left: 0.35rem;
          }
        }
        &:first-child {
          .step-trigger {
            padding-top: 0;
          }
        }
        &:last-child {
          .step-trigger {
            padding-bottom: 0;
          }
        }
      }
    }
    &.vertical {
      flex-direction: column;
      .bs-stepper-header {
        align-items: flex-start;
      }
    }
    &:not(.vertical) {
      .bs-stepper-header {
        .line {
          i {
            display: none;
          }
        }
      }
    }
    &.wizard-icons {
      .bs-stepper-header .step:not(:first-child) {
        .bs-stepper-icon {
          svg {
            margin-top: 0.5rem;
          }
        }
      }
    }
  }
}

@media (max-width: 520px) {
  .bs-stepper-header {
    margin: 0;
  }
}

// Styles for Create App Modal Wizard
#wizard-create-app {
  &.vertical {
    .bs-stepper-header {
      min-width: $bs-stepper-vertical-header-min-width - 3;
    }
  }
}
