.hover-mixin(@background-color) {
  &:hover {
    background: @background-color;
  }

  &:active,
  &:focus {
    background: @background-color;
  }
}

.disabled-states() {
  .disabled &,
  &[disabled],
  &.disabled {
    background: @gray-2;
    color: @gray-7;
    border: 1px solid @gray-3;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;

    .hover-mixin(@gray-2);
  }
}

@colors: @green, @blue-dark, @red, @purple, transparent;
@names: green, blue, red, purple, transparent;
@length: length(@colors);

.button-variations(@names; @colors; @index)
  when
  (iscolor(extract(@colors, @index)))
  and
  (@index > 0) {
  .button-variations(@names; @colors; (@index - 1)); //decrement loop

  @name: extract(@names, @index);
  @color: extract(@colors, @index);

  &.button--@{name} {
    background: @color;
    border-color: @color;
    color: @white;

    &:hover {
      background: darken(@color, 2%);
    }

    &:active,
    &:focus {
      background: darken(@color, 1%);
    }

    &.button {
      &--pill {
        border-radius: 29px;
      }
      &--outline {
        background: @white;
        border-width: 2px;
        color: @color;
        &:hover {
          background: @color;
          color: @white;
        }
        .disabled-states();
      }
    }

    .disabled-states();
  }
}

.button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  .border-radius(6px);
  .appearance(none);
  .transition(background-color 100ms ease-out);
  .transition(box-shadow 100ms ease-out);
  margin: 0;
  cursor: pointer;
  height: 30px;
  background: @white;
  color: @blue-dark;
  display: inline-block;
  padding: 0 13px;
  outline: none;
  border: 2px solid @blue-dark;
  box-shadow: none;
  font-size: @font-size-small;
  font-family: @font-primary;
  text-decoration: none;
  font-style: normal;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: initial;
  box-shadow: 0 0 4px 1px #deedfe;

  [class^="icon-"],
  [class*=" icon-"] {
    position: relative;
    top: 0;
    font-size: 16px;
  }

  &:hover {
    background: @blue-1;
  }

  &:active {
    background: darken(@blue-1, 2%);
    box-shadow: none;
    outline: none;
  }

  .mt-button__label {
    margin: 0 0 0 8px;

    &:first-child:last-child {
      margin: 0;
    }
  }

  &.button {
    &--outline {
      background: @white;
      border-width: 2px;

      .hover-mixin(@gray-3);
    }

    &--pill {
      border-radius: 29px;
    }

    &--transparent {
      box-shadow: none;
    }

    &--icon {
      background: transparent;
      border-color: transparent;
      box-shadow: none;
      color: @blue-dark;
      height: initial;
      padding: 0;

      .hover-mixin(transparent);

      &[disabled] {
        border-color: transparent;
        background: transparent;

        .hover-mixin(transparent);
      }

      [class^="icon-"],
      [class*=" icon-"] {
        position: relative;
        top: -1px;
        font-size: 16px;
      }
    }

    &--sm {
      height: 26px;
      padding: 0 7px;
    }

    &--wide {
      padding: 0 40px;
    }
  }

  .button-variations(@names; @colors; @length);

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

  .disabled-states();
}

.upload-button {
  margin: 0;
  .border-radius(6px);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: @white;
  color: @blue-dark;
  display: inline-block;
  padding: 5px 13px 4px;
  outline: none;
  border: 2px solid @blue-dark;
  transition: background-color 100ms ease-out;
  box-shadow: none;
  font-size: @font-size-small;
  text-decoration: none;
  font-weight: bold;
  font-style: normal;
  cursor: pointer;
  box-shadow: 0 0 4px 1px #deedfe;

  input[type="file"] {
    position: fixed;
    top: -1000px;
  }

  &:hover {
    background: @blue-1;
  }

  &:active {
    background: darken(@blue-1, 2%);
    box-shadow: none;
    outline: none;
  }

  &.is-green {
    background: @green;
    color: @white;
    border: 1px solid @green;
  }
}
