$btn-border-color: #dbdbdb;

.btn {
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
  font-size: 1rem;
  text-align: center;
  padding: calc(.5em - 1px) 1em;
  background-color: #fff;
  border: 1px solid $btn-border-color;
  border-radius: 4px;
  cursor: pointer;
  position: relative;

  &:hover:not([disabled]) {
    border-color: darken($btn-border-color, 20%);
  }

  &:focus:not([disabled]) {
    border-color: darken($btn-border-color, 40%);
    outline: none;
  }

  &:active:not([disabled]) {
    border-color: darken($btn-border-color, 40%);
  }

  &[disabled] {
    opacity: .5;
    cursor: not-allowed;
  }

  & .icon {
    margin-right: .1875em;
  }
}

@each $color, $value in $colors {
  .btn-#{$color} {
    background-color: $value;
    color: #fff;
    border: none;

    &:hover:not([disabled]) {
      background-color: darken($value, 5%);
    }

    &:focus:not([disabled]) {
      background-color: darken($value, 8%);
    }

    &:active:not([disabled]) {
      background-color: darken($value, 8%);
    }
  }
}

.btn-static {
  background-color: #f5f5f5;
  border-color: #dbdbdb;
  color: #7a7a7a;
  box-shadow: none;
  pointer-events: none;
}

@each $color, $value in $colors {
  .btn-outline-#{$color} {
    color: $value;
    border: 1px solid $value;

    &:hover {
      color: #fff;
      background-color: $value;
      border-color: $value !important;
    }
  }
}

.btn-sm {
  font-size: .75rem;
}

.btn-lg {
  font-size: 1.5rem;
}

@keyframes spinAround {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(359deg);
  }
}

.btn-loading {
  color: transparent;
  cursor: default;
  pointer-events: none;

  &:after {
    left: calc(50% - (1em / 2));
    top: calc(50% - (1em / 2));
    position: absolute !important;
    animation: spinAround .5s infinite linear;
    border: 2px solid #dbdbdb;
    border-radius: 290486px;
    border-right-color: transparent;
    border-top-color: transparent;
    content: "";
    display: block;
    height: 1em;
    position: relative;
    width: 1em;
  }
}

.btn-rounded {
  border-radius: 100rem;
  padding-left: 1em;
  padding-right: 1em;
}

.btn-group {
  display: inline-flex;

  & .btn:not(:first-child):not(:last-child) {
    border-radius: 0;
  }

  & .btn:first-child {
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
  }

  & .btn:last-child {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
  }
}
