// Buttons
.btn {
  @include control-transition();
  @include flex-centered();

  appearance: none;
  background: transparent;
  border: $border-width solid $primary-color;
  border-radius: $border-radius-sm;
  color: $primary-color;
  cursor: pointer;
  display: inline-flex;
  font-size: $font-size;
  height: $control-size;
  outline: none;
  padding: 0 $control-padding / 2;
  text-align: center;
  text-decoration: none;
  user-select: none;
  vertical-align: middle;
  white-space: nowrap;
  font-weight: 500;

  &:focus,
  &:hover {
    border-color: $primary-color-dark;
    text-decoration: none;
  }

  &:active,
  &.active {
    background:  rgba($primary-color-dark, .2);
    border-color: lighten($primary-color-dark, 5%);
    color: $light-color;
    text-decoration: none;

    &.loading {
      &::after {
        border-bottom-color: $light-color;
        border-left-color: $light-color;
      }
    }
  }

  &[disabled],
  &:disabled,
  &.disabled {
    @include disabled();
  }

  &.btn-square {
    height: $control-size;
    width: $control-size;

    &.btn-xs {
      height: $control-size-xs;
      width: $control-size-xs;
    }

    &.btn-sm {
      height: $control-size-sm;
      width: $control-size-sm;
    }

    &.btn-lg {
      height: $control-size-lg;
      width: $control-size-lg;
    }
  }

  // Button Primary
  &.btn-primary {
    background: $primary-color;
    border-color: $primary-color-dark;
    color: $light-color;

    &:focus,
    &:hover {
      background: darken($primary-color-dark, 2%);
      border-color: darken($primary-color-dark, 5%);
      color: $light-color;
    }

    &:active,
    &.active {
      background: darken($primary-color-dark, 4%);
      border-color: darken($primary-color-dark, 7%);
      color: $light-color;
    }

    &.loading {
      &::after {
        border-bottom-color: $light-color;
        border-left-color: $light-color;
      }
    }
  }

  // Button Colors
  &.btn-success {
    @include button-variant($success-color);
  }

  &.btn-error {
    @include button-variant($error-color);
  }

  &.btn-warning {
    @include button-variant($warning-color);
  }

  &.btn-attention {
    @include button-variant($yellow-color);
  }

  &.btn-versa {
    @if $theme == "default" {
      @include button-variant($font-color, $light-color);
    } @else {
      @include button-variant($font-color, $dark-color);
    }
   
  }

  // Button Link
  &.btn-link {
    background: transparent;
    border-color: transparent;
    color: $link-color;

    &:focus,
    &:hover,
    &:active,
    &.active {
      //color: $primary-color-dark;
    }
  }

  // Button Default
  &.btn-default {
    background: $bg-2-color;
    border-color: $bg-2-color;
    color: rgba($font-color, .8);

    &:focus,
    &:hover,
    &.active {
      background: darken($primary-color-dark, 2%);
      border-color: darken($primary-color-dark, 5%);
      color: $light-color;
    }
  }

  // Button Sizes
  &.btn-xs {
    line-height: initial;
    font-size: $font-size-sm;
    height: $control-size-xs;
    padding: 0 $control-padding-x-sm;
  }

  &.btn-sm {
    font-size: $font-size-sm;
    height: $control-size-sm;
    padding: 0 $control-padding-x-sm;
  }

  &.btn-lg {
    font-size: $font-size;
    height: $control-size-lg;
    padding: $control-padding-y-lg $control-padding-x-lg;
  }

  // Button Block
  &.btn-block {
    display: inline-flex;
    width: 100%;
    padding: 0;
  }

  &.btn-filled {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  // Button Action
  &.btn-action {
    width: $control-size;
    padding-left: 0;
    padding-right: 0;

    &.btn-xs {
      width: $control-size-xs;
    }

    &.btn-sm {
      width: $control-size-sm;
    }

    &.btn-lg {
      width: $control-size-lg;
    }
  }
}

// Button groups
.btn-group {
  display: inline-flex;
  // flex-wrap: wrap;

  .btn {
    flex: 1 0 auto;

    &:first-child:not(:last-child) {
      border-bottom-right-radius: 0;
      border-top-right-radius: 0;
    }

    &:not(:first-child):not(:last-child) {
      border-radius: 0;
      margin-left: -$border-width;
    }

    &:last-child:not(:first-child) {
      border-bottom-left-radius: 0;
      border-top-left-radius: 0;
      margin-left: -$border-width;
    }

    &:focus,
    &:hover,
    &:active,
    &.active {
      z-index: $zindex-0;
    }
  }

  &.btn-group-block {
    display: flex;

    .btn {
      flex: 1 0 0;
    }
  }
}

.btn-group-horizontal {
  display: flex;
  flex-direction: column;

  .btn {
    &:first-child:not(:last-child) {
      border-bottom-right-radius: 0;
      border-bottom-left-radius: 0;
    }

    &:not(:first-child):not(:last-child) {
      border-radius: 0;
      margin-top: -$border-width;
    }

    &:last-child:not(:first-child) {
      border-top-left-radius: 0;
      border-top-right-radius: 0;
      margin-top: -$border-width;
    }
  }
}

// FABs
.btn-fab {
  @include button-variant();

  @include flex-centered();

  cursor: pointer;
  border-color: transparent;
  border-radius: 50%;
  font-size: $font-size;
  height: $button-fab-size;
  margin: auto;
  min-width: $button-fab-size;
  width: $button-fab-size;
  padding: 0;
  overflow: hidden;
  background: $primary-color;
  box-shadow: 0 1px 1.5px 0 rgba(0, 0, 0, 0.12), 0 1px 1px 0 rgba(0, 0, 0, 0.24);
  position: relative;
  line-height: normal;
  color: $light-color;

  &.btb-fab-with-nav {
    bottom: $unit-10 + $nav-height;
  }

  &.btn-fab-container {
    position: fixed;
    display: block;
    right: $unit-10;
    bottom: $unit-10;
    z-index: $zindex-4;
  }

  &.btn-fab-sm {
    height: $button-fab-size-sm;
    min-width: $button-fab-size-sm;
    width: $button-fab-size-sm;
  }
}

.fab-container {
  position: fixed;
  display: block;
  right: $unit-10;
  bottom: $unit-10;
  z-index: $zindex-4;

  &.fab-container-with-nav {
    bottom: $unit-10 + $nav-height !important;
  }

  .fab-menu {
    opacity: 0;
    visibility: hidden;

    text-align: center;
    position: absolute;
    bottom: $button-fab-size + $control-padding;
    width: 100%;

    .fab-menu-item {
      margin-bottom: $control-padding;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  .btn-fab:focus + .fab-menu, .fab-menu:active {
    opacity: 1;
    visibility: visible;
  }

}

@media (max-width: $size-xs) {
  .btn-fab {
    height: $button-fab-size-sm;
    min-width: $button-fab-size-sm;
    width: $button-fab-size-sm;

    &.btb-fab-with-nav {
      bottom: $unit-5 + $nav-height !important;
    }

    &.btn-fab-container {
      right: $unit-5;
      bottom: $unit-5;
    }
  }

  .fab-container {
    right: $unit-5;
    bottom: $unit-5;

    .fab-menu {
      bottom: $button-fab-size-sm + $control-padding;
    }

    &.fab-container-with-nav {
      bottom: $unit-5 + $nav-height !important;
    }
  }
}