@mixin eui-button(
  $radius: 4px,
  $line-height: 35px,
  $font-size: 14px,
  $padding: 0 14px,
  $min-width: 5px,
  $background: rgba(255, 255, 255, 1),
  $background--active: rgba(249, 249, 249, 1),
  $background--disabled: rgba(249, 249, 249, 1),
  $border-background: linear-gradient(to bottom, rgba(0, 0, 0, 0.13) 0%, rgba(0, 0, 0, 0.25) 100%),
  $border-background--active: rgba(0, 107, 255, 0.5),
  $border-background--focus: rgba(0, 107, 255, 0.5),
  $border-background--disabled: linear-gradient(to bottom, rgba(0, 0, 0, 0.13) 0%, rgba(0, 0, 0, 0.25) 100%),
  $box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.1),
  $box-shadow--focus: 0px 0px 4px #0090ff,
  $box-shadow--active: 0px 0px 4px #0090ff,
  $box-shadow--disabled: 0px 1px 1px rgba(0, 0, 0, 0.1),
  $box-shadow__inner: none,
  $box-shadow__inner--active: inset 0px 1px 1px rgba(0, 0, 0, 0.10),
  $box-shadow__inner--disabled: none,
  $color: #6a6a6a,
  $color--focus: inherit,
  $color--active: inherit,
  $color--disabled: rgba(0, 0, 0, 0.3),
  $text-shadow: none,
  $text-shadow--disabled: none,
  $animation--active: eui-button-focus-highlight 0.3s 1,
  $animation--focus: eui-button-focus-highlight 0.4s 1,
  $animation--disabled: none
) {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  user-select: none;
  cursor: pointer;
  margin: 0;
  background: transparent;
  outline: none;
  border: none;
  border-radius: $radius;
  color: $color;
  background: $border-background;
  padding: 1px;
  box-shadow: $box-shadow;
  transition: background 0.2s;

  &::-moz-focus-inner {
    border: 0;
    padding: 0;
  }

  .eui-component-wrapper {
    position: relative;
    text-align: center;
    border-radius: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: $font-size;
    line-height: $line-height;
    padding: $padding;
    min-width: $min-width;
    background: $background;
    box-shadow: $box-shadow__inner;
    text-shadow: $text-shadow;
    transition: background 0.2s, color 0.2s;
  }

  .eui-label {
    font-style: normal;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.5s;
  }

  &:active,
  &.eui-active {
    background: $border-background--active;
    box-shadow: $box-shadow--active;
    z-index: 1;
    animation: $animation--active;

    .eui-component-wrapper {
      background: $background--active;
      box-shadow: $box-shadow__inner--active;
      color: $color--active;
    }

    .eui-label {
      transform: translateY(1px);
    }
  }

  &:focus {
    background: $border-background--focus;
    box-shadow: $box-shadow--focus;
    z-index: 1;
    animation: $animation--focus;

    .eui-component-wrapper {
      color: $color--focus;
    }
  }

  &.eui-disabled {
    pointer-events: none;
    background: $border-background--disabled;
    box-shadow: $box-shadow--disabled;
    animation: $animation--disabled;

    .eui-component-wrapper {
      text-shadow: $text-shadow--disabled;
      background: $background--disabled;
      color: $color--disabled;
      box-shadow: $box-shadow__inner--disabled;
    }
  }

  &.eui-loading {
    pointer-events: none;
  }

  .eui-loading-animation li {
    box-shadow:
      1px 1px 0px rgba(255, 255, 255, 1),
      inset 0px 1px 0px rgba(0, 0, 0, 0.1);
  }
}


/* LOADING */
.eui-button.eui-loading {
  .eui-label {
    opacity: 0;
  }

  .eui-loading-animation {
    display: block;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0 4px;
    box-sizing: border-box;
    list-style: none;
    text-align: center;

    li {
      display: inline-block;
      float: none;
      vertical-align: baseline;
      width: 7px;
      height: 7px;
      padding: 0;
      border: none;
      margin: -4px 0 0 0;
      opacity: 0.4;
      border-radius: 7px;
      box-shadow: 1px 1px rgba(255,255,255,0.1);
      background: rgba(0,0,0,0.2);
      transition: background 0.2s;
      animation: eui-button-loading 1s infinite;

      &:nth-child(3n+2) {
        animation-delay: 0.15s;
      }

      &:nth-child(3n+3) {
        animation-delay: 0.3s;
      }
    }
  }
}

/* error state for selects */
.eui-error .eui-button {
  background: #ff7f7f;
  box-shadow: 0px 0px 4px #ff0000;
  outline: none;
  animation: eui-error-highlight 0.2s 1;
}
