$base-class: "button";

@mixin button-variant($color, $hover: null, $active: null, $inverse: null) {
  background-color: $color;

  @if $inverse {
    &:hover {
      border: 2px solid $hover;
      color: $hover;
    }

    &:active {
      border: 2px solid $active;
      color: $active;
    }
  } @else {
    &:hover {
      background-color: $hover;
    }

    &:active {
      background-color: $active;
    }
  }
}

.#{$base-class} {
  @include button-variant($core-vibrant-blue);
  transition: color 150ms ease-in-out, background 150ms ease-in-out,
    top 50ms ease-in-out, box-shadow 50ms ease-in-out, border 50ms ease-in-out;
  position: relative;
  color: $core-white;
  text-decoration: none;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: $pad-small $pad-medium;
  border-radius: 4px;
  font-size: $x-small;
  font-family: "Nunito Sans", sans-serif;
  font-weight: $bold;
  display: inline-flex;
  height: 38px;
  top: 0;
  border: 0;
  cursor: pointer;

  &:focus {
    outline: none;
  }

  &--brand {
    @include button-variant(
      $core-vibrant-blue,
      $core-vibrant-blue-over,
      $core-vibrant-blue-down
    );
  }

  &--success {
    @include button-variant($ui-success);
  }

  &--alert {
    @include button-variant(
      $core-vibrant-red,
      $core-vibrant-red-over,
      $core-vibrant-red-down
    );
  }

  &--blue-green {
    @include button-variant($ui-success);
  }

  &--grey {
    @include button-variant(
      $core-fleet-blue,
      $core-fleet-blue-over,
      $core-fleet-blue-down
    );
  }

  &--warning {
    @include button-variant($ui-warning);
  }

  &--link {
    @include button-variant($core-fleet-purple);
  }

  &--label {
    @include button-variant(
      $ui-off-white,
      $core-vibrant-blue-over,
      null,
      $inverse: true
    );
    color: $core-vibrant-blue;
    border: 1px solid $core-vibrant-blue;
    box-sizing: border-box;
    font-size: $xx-small;
    padding: $pad-xsmall 10px;
    height: 24px;
    white-space: nowrap;

    &:active {
      box-shadow: inset 2px 2px 2px rgba(0, 0, 0, 0.25);
    }

    &:hover {
      border: 1px solid $core-vibrant-blue;
    }
  }

  &--text-link {
    @include button-variant(transparent);
    border: 0;
    box-shadow: none;
    color: $core-vibrant-blue;
    font-size: $x-small;
    cursor: pointer;
    margin: 0;
    padding: 0;
    height: auto;
    line-height: normal;

    &:active {
      color: $core-vibrant-blue-down;
      box-shadow: none;
      top: 0;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      color: $core-vibrant-blue-over;
      background-color: transparent;
      box-shadow: none;
      text-decoration: underline;
    }

    &.light-text {
      font-weight: $regular;
    }
  }

  &--text-icon {
    @include button-variant(transparent);
    padding: 0;
    border: 0;
    box-shadow: none;
    color: $core-vibrant-blue;
    font-size: $x-small;
    font-weight: $bold;
    cursor: pointer;

    img {
      transform: scale(0.5);
    }

    &:active {
      color: $core-vibrant-blue-down;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      color: $core-vibrant-blue-over;
    }
  }
  &--small-text-icon {
    @include button-variant(transparent);
    margin-left: $pad-medium;
    padding: 4px;
    border: 1px solid $ui-fleet-black-25;
    box-shadow: none;
    color: $core-fleet-black;
    font-size: $xx-small;
    font-weight: $bold;
    cursor: pointer;
    height: 28px;

    img {
      width: 12px;
      height: 12px;
      padding: $pad-small;
    }

    &:active {
      color: $core-vibrant-blue-down;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      color: $core-vibrant-blue-over;
    }
  }

  &--inverse {
    @include button-variant(
      $core-white,
      $core-vibrant-blue-over,
      $core-vibrant-blue-down,
      $inverse: true
    );
    color: $core-vibrant-blue;
    border: 0;
    box-sizing: border-box;
    padding: 0;

    &:hover {
      border: 0;
    }
  }

  &--inverse-alert {
    @include button-variant(
      $core-white,
      $core-vibrant-red-over,
      $core-vibrant-red-down,
      $inverse: true
    );
    color: $core-vibrant-red;
    border: 0;
    box-sizing: border-box;
    padding: 0;

    &:hover {
      border: 0;
    }
  }

  &--block {
    display: block;
    width: 100%;
  }

  &--disabled {
    opacity: 0.5;
    filter: grayscale(0.5);
    cursor: default;

    &:hover {
      cursor: default;
    }
  }

  &--unstyled {
    @include button-variant(transparent);
    border: 0;
    box-shadow: none;
    color: $core-fleet-black;
    cursor: pointer;
    margin: 0;
    padding: 0;
    height: auto;
    line-height: normal;

    &:active {
      box-shadow: none;
      top: 0;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      background-color: transparent;
      box-shadow: none;
    }
  }

  &--unstyled-modal-query {
    @include button-variant(transparent);
    border: 0;
    box-shadow: none;
    color: $core-fleet-black;
    cursor: pointer;
    margin: 0;
    padding: 15px 12px;
    height: auto;
    line-height: normal;
    display: block;
    width: 100%;
    border-radius: 0px;
    border-bottom: 1px solid $ui-fleet-blue-15;

    &:active {
      box-shadow: none;
      top: 0;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      background-color: $ui-vibrant-blue-10;
      box-shadow: none;
    }
  }

  &--contextual-nav-item {
    @include button-variant(transparent, $ui-vibrant-blue-10);
    display: flex;
    justify-content: space-between;
  }
}
