button {
  background: transparent;
  display: inline-block;
  vertical-align: top;
  text-align: center;
  touch-action: manipulation;
  border: none;

  &::-moz-focus-inner {
    outline: none;
  }
}

.Button {
  $this: &;
  display: inline-block;
  vertical-align: top;
  box-shadow: 0 2px 0 0 rgba(0, 0, 20, 0.04);
  outline: inherit;
  border-radius: 4px;
  user-select: none;
  transition-property: background, border-color;
  transition-duration: 0.2s;
  transition-timing-function: $motion-quint-easeinout;
  text-decoration: none;
  padding: 0;
  font-weight: 400;

  &--unstyled {
    background: none;
    color: inherit;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;
  }

  &--isLink {
    text-align: center;
  }

  &--full-width {
    width: 100%;

    #{$this}__text {
      text-align: center;
      flex-grow: 1;
    }
  }
  &--has-icon,
  &--checkbox {
    #{$this}__content {
      display: flex;
    }
  }

  &:hover {
    text-decoration: none;
  }
  &:disabled,
  &#{$this}--disabled {
    cursor: not-allowed;
  }

  &:focus {
    border-width: 2px;
    border-style: solid;
  }
  &--has-icon-left,
  &--checkbox {
    padding-left: 0;
  }

  &--has-icon-right {
    padding-right: 0;
  }
  &--icon-only {
    padding: 0;
  }
  &--secondary,
  &--destructiveMinor,
  &--reversed {
    border-width: 1px;
    border-style: solid;

    &#{$this}--has-icon {
      &:focus {
        border-width: 2px;
      }
    }
  }

  & + #{$this} {
    margin-left: 8px;
  }

  /********** SIZE SPECIFIC STYLES **********/
  &:not(#{$this}--small):not(#{$this}--minimal):not(#{$this}--unstyled) {
    font-size: 14px;
    line-height: 20px;
    padding: 9px 16px 7px;

    &:focus {
      padding: 7px 14px 5px;
    }

    &#{$this}--has-icon {
      padding-top: 0;
      padding-bottom: 0;

      &#{$this}--has-icon-left {
        padding-left: 0;
      }

      &#{$this}--has-icon-right {
        padding-right: 0;
      }

      #{$this}__icon {
        padding: 10px;
      }

      #{$this}__text {
        padding: 9px 0 7px;
      }

      &:focus {
        #{$this}__icon {
          padding: 8px;

          &--left {
            padding-right: 10px;
          }
          &--right {
            padding-left: 10px;
          }
        }

        #{$this}__text {
          padding: 7px 0 5px;
        }
      }
    }
    &#{$this}--icon-only {
      padding: 0;

      &:focus #{$this}__icon {
        padding: 8px;
      }

      &#{$this}--has-icon-left#{$this}--has-icon-right {
        #{$this}__icon--right {
          margin-left: -16px;
        }

        &:focus {
          #{$this}__icon--left {
            padding-right: 10px;
          }
          #{$this}__icon--right {
            padding-left: 10px;
          }
        }
      }
    }

    &#{$this}--secondary,
    &#{$this}--destructiveMinor,
    &#{$this}--reversed {
      padding: 8px 15px 6px;

      &:focus {
        padding: 7px 14px 5px;
      }
      &#{$this}--has-icon {
        padding-top: 0;
        padding-bottom: 0;

        &#{$this}--has-icon-left {
          padding-left: 0;
        }

        &#{$this}--has-icon-right {
          padding-right: 0;
        }

        #{$this}__icon {
          padding: 9px;
        }

        #{$this}__text {
          padding: 8px 0 6px;
        }

        &:focus {
          padding-top: 0;
          padding-bottom: 0;

          #{$this}__icon {
            padding: 8px;

            &--left {
              padding-right: 9px;
            }
            &--right {
              padding-left: 9px;
            }
          }

          #{$this}__text {
            padding: 7px 0 5px;
          }
        }
      }
      &#{$this}--icon-only {
        padding: 0;

        &:focus #{$this}__icon {
          padding: 8px;
        }

        &#{$this}--has-icon-left#{$this}--has-icon-right {
          #{$this}__icon--right {
            margin-left: -16px;
          }

          &:focus {
            #{$this}__icon--left {
              padding-right: 9px;
            }
            #{$this}__icon--right {
              padding-left: 9px;
            }
          }
        }
      }
      &#{$this}--checkbox {
        padding: 0;

        #{$this}__checkbox {
          padding: 9px 10px;
        }
        #{$this}__text {
          padding: 8px 16px 5px;
          border-left: 1px solid $color-gray-100;
          transition-property: background, border-color;
          transition-duration: 0.2s;
          transition-timing-function: $motion-quint-easeinout;
        }

        &#{$this}:hover {
          #{$this}__text {
            border-right-color: $color-gray-90;
          }
        }

        &#{$this}:active {
          #{$this}__text {
            border-right-color: $color-gray-80;
          }
        }

        &#{$this}:focus {
          #{$this}__checkbox {
            padding-top: 8px;
            padding-bottom: 8px;
            padding-left: 9px;
          }
          #{$this}__text {
            padding-top: 7px;
            padding-right: 15px;
            padding-bottom: 5px;
          }
        }
      }
    }
  }

  &--small {
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 7px 16px 5px 16px;

    &:focus {
      padding: 5px 14px 3px 14px;
    }

    &#{$this}--has-icon {
      padding-top: 0;
      padding-bottom: 0;

      &#{$this}--has-icon-left:not(#{$this}--icon-only) {
        padding-left: 0;

        #{$this}__text {
          padding-left: 5px;
        }
      }

      &#{$this}--has-icon-right {
        padding-right: 0;
      }

      #{$this}__icon {
        padding: 6px;
      }

      #{$this}__text {
        padding: 7px 0 5px;
      }

      &:focus {
        #{$this}__icon {
          &--left {
            padding: 4px 6px 2px 4px;
          }
          &--right {
            padding: 4px 4px 2px 6px;
          }
        }

        #{$this}__text {
          padding: 5px 0 3px;
        }
        &#{$this}--has-icon-left:not(#{$this}--icon-only) #{$this}__text {
          padding-left: 5px;
        }
      }
    }
    &#{$this}--icon-only {
      padding: 0;

      &:focus #{$this}__icon {
        padding: 4px;
      }

      &#{$this}--has-icon-left#{$this}--has-icon-right {
        #{$this}__icon--right {
          margin-left: -8px;
        }

        &:focus {
          #{$this}__icon--left {
            padding-right: 6px;
          }
          #{$this}__icon--right {
            padding-left: 6px;
          }
        }
      }
    }

    &#{$this}--secondary,
    &#{$this}--destructiveMinor,
    &#{$this}--reversed {
      padding-top: 6px;
      padding-bottom: 4px;

      &:focus {
        padding: 5px 15px 3px;
      }
      &#{$this}--has-icon {
        padding-top: 0;
        padding-bottom: 0;

        &#{$this}--has-icon-left:not(#{$this}--icon-only) {
          padding-left: 0;

          #{$this}__text {
            padding-left: 5px;
          }
        }

        &#{$this}--has-icon-right {
          padding-right: 0;
        }

        #{$this}__icon {
          padding: 5px;
        }

        #{$this}__text {
          padding: 6px 0 3px;
        }

        &:focus {
          #{$this}__icon {
            padding-top: 4px;
            padding-bottom: 4px;

            &--left {
              padding-left: 4px;
            }
            &--right {
              padding-right: 4px;
            }
          }

          #{$this}__text {
            padding: 5px 0 3px;
          }
          &#{$this}--has-icon-left:not(#{$this}--icon-only) #{$this}__text {
            padding-left: 5px;
          }
        }
      }
      &#{$this}--icon-only {
        padding: 0;

        &:focus #{$this}__icon {
          padding: 4px;
        }

        &#{$this}--has-icon-left#{$this}--has-icon-right {
          #{$this}__icon--right {
            margin-left: -8px;
          }

          &:focus {
            #{$this}__icon--left {
              padding-right: 5px;
            }
            #{$this}__icon--right {
              padding-left: 5px;
            }
          }
        }
      }
    }
  }

  &--minimal {
    @extend .Font__caption;
    @extend .Font__caption--10;
    background: none;
    color: $color-indigo;
    display: initial;
    padding: 0;
    box-shadow: none;
    border-radius: initial;
    text-decoration: underline;
    &:hover,
    &:focus {
      text-decoration: underline;
      color: $color-indigo-dark;
      border: none;
      padding: 0;
    }
  }

  /********** TYPE SPECIFIC STYLES **********/
  &--primary {
    background: #8008f7;
    border-color: #8008f7;
    color: $color-white;
    box-shadow: 0 2px 0 0 rgba(0, 0, 40, 0.08);

    &:hover {
      background: #6606c6;

      #{$this}__text {
        color: $color-white;
      }
    }
    &:active {
      background: #4c0198;
    }
    &:focus {
      background: #6606c6;
      box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px #00040f;
    }
    &:disabled,
    &#{$this}--disabled {
      background: #e9ccff;
      box-shadow: none;
    }
  }
  &--transactional {
    background: $color-green;
    border-color: $color-green-dark;
    color: $color-white;
    box-shadow: 0 2px 0 0 rgba(0, 40, 0, 0.08);

    &:hover {
      background: $color-green-mid;

      #{$this}__text {
        color: $color-white;
      }
    }
    &:active {
      background: $color-green-dark;
    }
    &:focus {
      background: $color-green;
      border-color: $color-green-darker;
    }
    &:disabled,
    &#{$this}--disabled {
      background: $color-green-light;
      box-shadow: none;
    }
  }
  &--secondary {
    border-color: $color-gray-100;
    background: $color-white;
    color: $color-gray-00;

    &:hover {
      background: $color-gray-140;
      border-color: $color-gray-90;

      #{$this}__text {
        color: $color-gray-00;
      }
    }
    &:active {
      background: $color-gray-130;
      border-color: $color-gray-80;
    }
    &:focus {
      border-color: $color-gray-50;
    }
    &:disabled,
    &#{$this}--disabled {
      border-color: $color-gray-100;
      background: $color-white;
      box-shadow: none;

      #{$this}__text {
        color: $color-gray-80;
      }
    }
  }
  &--destructiveMajor {
    background: $color-red;
    border-color: $color-red;
    color: $color-white;
    box-shadow: 0 2px 0 0 rgba(40, 0, 0, 0.08);

    &:hover {
      background: $color-red-mid;

      #{$this}__text {
        color: $color-white;
      }
    }
    &:active {
      background: $color-red-dark;
    }
    &:focus {
      background: $color-red-mid;
      border-color: $color-red-darker;
    }
    &:disabled,
    &#{$this}--disabled {
      background: $color-red-light;
      box-shadow: none;
    }
  }
  &--destructiveMinor {
    background: $color-white;
    border-color: $color-red;
    color: $color-red-dark;
    box-shadow: 0 2px 0 0 rgba(40, 0, 0, 0.08);

    &:hover {
      background: $color-red-lighter;
      border-color: $color-red;

      #{$this}__text {
        color: $color-red-dark;
      }
    }
    &:active {
      background: $color-red-light;
      border-color: $color-red-dark;
    }
    &:focus {
      border-color: $color-red-dark;
    }
    &:disabled,
    &#{$this}--disabled {
      border-color: $color-red-light;
      background: $color-white;
      box-shadow: none;

      #{$this}__text {
        color: $color-red-light;
      }
    }
  }
  &--reversed {
    background: $color-gray-30;
    border-color: $color-gray-50;
    color: $color-white;
    box-shadow: 0 2px 0 0 rgba(0, 0, 40, 0.4);

    &:hover {
      border-color: $color-gray-70;

      #{$this}__text {
        color: $color-white;
      }
    }
    &:active {
      background: $color-gray-20;
      border-color: $color-gray-70;
    }
    &:focus {
      border-color: $color-gray-80;
    }
    &:disabled,
    &#{$this}--disabled {
      border-color: $color-gray-30;
      color: $color-gray-80;
      box-shadow: none;

      #{$this}__text {
        color: $color-gray-80;
      }
    }
  }
  &--loading {
    background: $color-gray-30;
    position: relative;
    color: $color-gray-80;
    box-shadow: none;
    cursor: not-allowed;
  }
  &__loader {
    top: 0;
    left: 0;
  }
  &__companion-link {
    display: inline-block;
    padding-top: 10px;
    padding-left: 12px;
  }
  &--small + #{$this}__companion-link {
    padding-top: 5px;
    padding-left: 7px;
  }
}

.DeleteButton {
  background: $color-red;
  color: $color-white;
  width: 185px;
  height: 44px;
  display: block;
  font-size: 18px;
  transition: all 0.1s ease-in;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0 10px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
  position: relative;
  border: none;

  &:hover {
    background: $color-red-mid;
  }
  &:active {
    background: $color-red-dark;
  }

  &:focus {
    background: $color-red-mid;
    outline: none;
  }
  &:disabled {
    background: $color-red-light;
    cursor: not-allowed;
  }
  &__container {
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    transition: margin 0.1s ease-in;
    width: 185px;
    height: 44px;
    box-shadow: 0 2px 0 0 rgba(40, 0, 0, 0.08);

    &--in-progress {
      margin-bottom: 1px;
      margin-left: 4px;
      box-shadow: none;
    }
  }
  &__text {
    position: relative;
  }
  &--in-progress {
    width: 177px;
    height: 42px;
  }

  &:after {
    background-color: $color-gray-10;
    border-radius: 4px 4px 0 0;
    content: '';
    height: 2px;
    left: 0;
    position: absolute;
    top: 0;
    transition: width 2s linear;
    width: 0;
  }

  &:before {
    background-color: $color-gray-10;
    border-radius: 4px;
    content: '';
    height: 0;
    left: 0;
    position: absolute;
    top: 0;
    transition: height 200ms;
    width: 100%;
  }

  &:active,
  &--completed {
    &:after {
      width: 100%;
    }
  }

  &--completed {
    cursor: default;
    &:before {
      height: 100%;
    }
  }
}
