//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@import '../../globals/scss/vars';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/typography';
@import '../../globals/scss/vendor/@rocketsoftware/elements/scss/import-once/import-once';
@import '../button/button';

/// Progress indicator styles
/// @access private
/// @group progress-indicator
@mixin progress-indicator {
  .#{$prefix}--progress {
    @include reset;

    display: flex;
    list-style: none;
  }

  .#{$prefix}--progress-step {
    position: relative;
    display: inline-flex;
    flex-direction: row;
    width: rem(128px);
    min-width: 7rem;
    overflow: visible;

    .#{$prefix}--tooltip__label {
      display: block;
    }
  }

  .#{$prefix}--progress--space-equal .#{$prefix}--progress-step {
    flex-grow: 1;
    min-width: 8rem;
  }

  .#{$prefix}--progress-line {
    position: absolute;
    left: 0;
    width: rem(128px);
    height: 1px;
    border: $progress-indicator-bar-width;
  }

  .#{$prefix}--progress--space-equal .#{$prefix}--progress-line {
    width: 100%;
    min-width: rem(128px);
  }

  .#{$prefix}--progress-step svg {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: $carbon--spacing-05;
    height: $carbon--spacing-05;
    margin: rem(10px) $carbon--spacing-03 0 0;
    border-radius: 50%;
    fill: $interactive-04;
  }

  .#{$prefix}--progress-label {
    @include type-style('body-short-01');

    max-width: rem(88px);
    margin: $carbon--spacing-03 0 0 0;
    overflow: hidden;
    color: $text-01;
    line-height: 1.45;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: box-shadow $duration--fast-02 motion(standard, productive),
      color $duration--fast-02 motion(standard, productive);

    &::before {
      display: block;
      content: '';
    }
  }

  .#{$prefix}--progress-label:hover {
    color: $link-01;
    box-shadow: 0 rem(1px) $link-01;
    cursor: pointer;
  }

  .#{$prefix}--progress-label:focus {
    color: $link-01;
    outline: none;
    box-shadow: 0 rem(3px) 0 0 $link-01;
  }

  .#{$prefix}--progress--space-equal .#{$prefix}--progress-label {
    max-width: 100%;
    margin-right: 0.75rem;
  }

  .#{$prefix}--progress-label:active {
    color: $interactive-01;
    box-shadow: 0 rem(3px) 0 0 $interactive-01;
  }

  //OVERFLOW STYLING
  .#{$prefix}--progress-label-overflow:hover ~ .#{$prefix}--tooltip,
  .#{$prefix}--progress-label-overflow:focus ~ .#{$prefix}--tooltip {
    visibility: inherit;
  }

  .#{$prefix}--progress-step .#{$prefix}--tooltip .#{$prefix}--tooltip__caret {
    margin-left: rem(10px);
  }

  .#{$prefix}--tooltip__text {
    margin: 0;
    padding: 0;
    font-weight: normal;
  }

  //single line tooltip
  .#{$prefix}--progress-step .#{$prefix}--tooltip {
    @include type-style('body-long-01');

    display: block;
    width: rem(125px);

    min-width: rem(115px);
    min-height: $carbon--spacing-06;
    margin-top: rem(40px);
    margin-left: rem(22px);
    padding: $carbon--spacing-03 $carbon--spacing-05;
    color: $inverse-01;
    visibility: hidden;
  }

  //multiline tooltip
  .#{$prefix}--progress-step .#{$prefix}--tooltip_multi {
    @include type-style('body-long-01');

    width: rem(150px);
    height: auto;
    color: $inverse-01;
  }

  //OPTIONAL HELPER TEXT STYLING
  .#{$prefix}--progress-optional {
    @include type-style('label-01');

    position: absolute;
    left: 0;
    margin-top: rem(28px);
    margin-left: $carbon--spacing-06;
    color: $text-02;
    text-align: start;
  }

  //CURRENT STYLING
  .#{$prefix}--progress-step--current {
    .#{$prefix}--progress-line {
      background-color: $interactive-04;
    }
  }

  //INCOMPLETE STYLING
  .#{$prefix}--progress-step--incomplete {
    svg {
      fill: $ui-05;
    }

    .#{$prefix}--progress-line {
      background-color: $ui-03;
    }
  }

  //COMPLETED STYLING
  .#{$prefix}--progress-step--complete {
    .#{$prefix}--progress-line {
      background-color: $interactive-04;
    }
  }

  //interactive button
  .#{$prefix}--progress-step-button {
    @include button-reset();

    display: flex;
    text-align: left;
  }

  //unclickable button
  .#{$prefix}--progress-step-button--unclickable {
    outline: none;
    cursor: default;
  }

  .#{$prefix}--progress-step-button--unclickable
    .#{$prefix}--progress-label:hover {
    color: $text-01;
    box-shadow: none;
    cursor: default;
  }

  .#{$prefix}--progress-step-button--unclickable
    .#{$prefix}--tooltip__label:hover {
    color: $link-01;
    box-shadow: 0 rem(1px) $link-01;
    cursor: pointer;
  }

  //DISABLED STYLING
  .#{$prefix}--progress-step--disabled {
    cursor: not-allowed;
    pointer-events: none;

    svg {
      cursor: not-allowed;
      fill: $disabled;
    }

    .#{$prefix}--progress-label,
    .#{$prefix}--progress-label:hover {
      color: $disabled;
      box-shadow: none;
      cursor: not-allowed;
    }

    .#{$prefix}--progress-label:focus,
    .#{$prefix}--progress-label:active {
      outline: none;
      box-shadow: none;
    }

    .#{$prefix}--progress-line {
      cursor: not-allowed;
    }

    .#{$prefix}--progress-label-overflow:hover
      ~ .#{$prefix}--tooltip--definition
      .#{$prefix}--tooltip--definition__bottom {
      display: none;
    }
  }

  //ERROR STYLING
  .#{$prefix}--progress__warning > * {
    fill: $support-01;
  }

  // Skeleton State
  .#{$prefix}--progress.#{$prefix}--skeleton .#{$prefix}--progress-label {
    @include skeleton;

    width: rem(40px);

    height: rem(12px);
  }

  // Vertical Variant

  .#{$prefix}--progress--vertical {
    display: flex;
    flex-direction: column;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-step,
  .#{$prefix}--progress--vertical .#{$prefix}--progress-step-button {
    flex-wrap: wrap;
    align-content: flex-start;
    width: initial;
    min-width: initial;
    min-height: 3.625rem;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-step svg,
  .#{$prefix}--progress--vertical .#{$prefix}--progress-step-button svg {
    display: inline-block;
    // 1px top margin based on visual review
    margin: rem(1px) $carbon--spacing-03 0;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-label {
    display: inline-block;
    width: initial;
    max-width: rem(160px);
    margin: 0;
    white-space: initial;
    vertical-align: top;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-step .bx--tooltip {
    margin-top: 0.5rem;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-optional {
    position: static;
    width: 100%;
    margin-top: auto;
    margin-left: $carbon--spacing-07;
  }

  .#{$prefix}--progress--vertical .#{$prefix}--progress-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
  }
}

@include exports('progress-indicator') {
  @include progress-indicator;
}
