.xp-button {
  @include inline-flex();
  @include flex-direction(row);
  @include justify-content(space-between);
  @include align-items(center);
  padding: 3px 8px;
  font-size: 14px;
  line-height: 22.4px;
  font-weight: $font-weight-regular;
  transition: $xp-default-transition;
  border-radius: $border-radius-base;
  text-transform: none;
  position: relative;
  cursor: pointer;
  @include user-select(none);
  @include box-shadow();
  svg {
    vertical-align: middle;
    line-height: inherit;
  }

  &:hover {
    @include box-shadow($xp-shadow-lg);
    transition: $xp-default-transition;
  }

  &:active,
  &:focus {
    @include box-shadow();
  }

  &:hover,
  &:active,
  &:focus {
    text-decoration: none;
    outline: none;
  }
}

.xp-button.disabled {
  cursor: not-allowed;
  opacity: 0.5 !important;
}

.xp-button.xp-button--full-width {
  width: 100%;
  @include justify-content(center);
}

.xp-button--underline {
  text-decoration: underline;
  &:hover,
  &:active,
  &:focus {
    text-decoration: underline;
  }
}

.xp-button.xp-button--primary {
  color: $xp-color--white;
  background-color: $xp-color--accent;
  border: thin solid $xp-color--accent;

  &:hover,
  &:active,
  &:focus {
    color: $xp-color--white;
    border: thin solid darken($xp-color--accent, 5%);
    background-color: darken($xp-color--accent, 5%);
  }
}

.xp-button.xp-button--dark {
  color: $xp-color--white;
  background-color: $xp-color--primary-dark;
  border: thin solid $xp-color--primary-dark;

  &:hover,
  &:active,
  &:focus {
    color: $xp-color--white;
    border: thin solid darken($xp-color--primary-dark, 5%);
    background-color: darken($xp-color--primary-dark, 5%);
  }
}

.xp-button.xp-button--light-outline {
  color: $xp-color--text;
  background-color: $xp-color--white;
  box-shadow: 0 0 0 1px rgba(42, 47, 69, 0.1),
    0 2px 5px 0 rgba(42, 47, 69, 0.08), 0 1px 1.5px 0 rgba(0, 0, 0, 0.07),
    0 1px 2px 0 rgba(0, 0, 0, 0.08), 0 0 0 0 transparent;
  &:hover,
  &:active,
  &:focus {
    color: $xp-color--black;
    transform: none;
    box-shadow: 0 0 0 1px rgba(42, 47, 69, 0.1),
      0 2px 5px 0 rgba(42, 47, 69, 0.1), 0 3px 9px 0 rgba(42, 47, 69, 0.08),
      0 1px 1.5px 0 rgba(0, 0, 0, 0.08), 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  }

  &.xp-button--loading {
    @include box-shadow(none);
    color: transparent;
    border: thin solid $xp-color--highlight;
    background-color: $xp-color--highlight;
  }

  .xp-button--loader__dots {
    span {
      background-color: $xp-color--black;
    }
  }
}

.xp-button.xp-button--light {
  color: $xp-color--text;
  background-color: transparent;
  box-shadow: none;
  &:hover,
  &:active,
  &:focus {
    color: $xp-color--black;
    background-color: $xp-color--highlight;
    transform: none;
  }

  &.xp-button--loading {
    @include box-shadow(none);
    color: transparent;
    border: thin solid $xp-color--highlight;
    background-color: $xp-color--highlight;
  }

  .xp-button--loader__dots {
    span {
      background-color: $xp-color--black;
    }
  }
}

.xp-button--text {
  @include inline-flex();
  @include flex-direction(row);
  @include justify-content(flex-start);
  @include align-items(center);
  color: $xp-color--text;
  font-weight: $font-weight-regular;
  transition: $xp-default-transition;

  &:hover,
  &:active,
  &:focus {
    color: $xp-color--black;
  }
}

.xp-button--link {
  @include inline-flex();
  @include flex-direction(row);
  @include justify-content(flex-start);
  @include align-items(center);
  font-size: 14px;
  color: $xp-color--primary-light;
  font-weight: $font-weight-regular;
  transition: $xp-default-transition;

  &:hover,
  &:active,
  &:focus {
    color: $xp-color--primary;
  }
}

.xp-button.xp-button--icon {
  cursor: pointer;
  padding: 0 2px;
  transition: $xp-default-transition;
  opacity: 0.8;
  background-color: transparent;
  box-shadow: none;
  &:hover,
  &:active,
  &:focus {
    text-decoration: none;
    opacity: 1;
  }
}

.xp-button--inner-icon {
  @extend .mlr--xs;
}

.xp-button--loading {
  &:hover,
  &:active,
  &:focus {
    transform: none;
    @include box-shadow();
  }
}

.xp-button--loader {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background-color: inherit;
  position: absolute;
  left: 0;
  top: 0;

  &.xp-button--loader__dots {
    span {
      width: 6px;
      height: 6px;
      background-color: $xp-color--white;
      border-radius: 100%;
      display: inline-block;
      animation: btn-bouncedelay 1s infinite ease-in-out both;
      margin: 0 2px 0 0;

      &:nth-child(1) {
        -webkit-animation-delay: -0.32s;
        animation-delay: -0.32s;
      }

      &:nth-child(2) {
        -webkit-animation-delay: -0.16s;
        animation-delay: -0.16s;
      }
    }
  }
}

@keyframes btn-bouncedelay {
  0%,
  80%,
  100% {
    opacity: 0.1;
  }

  40% {
    opacity: 1;
  }
}

@mixin loader__dots--dark {
  span {
    width: 16px;
    height: 16px;
    background-color: $xp-color--black;
    margin: 0 2px;
  }
}
