//
// Base styles
//

.btn {
  font-family: $btn-font-family;
  text-transform: uppercase;
  vertical-align: bottom;
  border: 0;
  box-shadow: $btn-box-shadow;
  font-weight: $btn-font-weight;
  @include button-size-mdb(
    $btn-padding-top,
    $btn-padding-right,
    $btn-padding-bottom,
    $btn-padding-left,
    $btn-font-size,
    $btn-line-height
  );

  &:hover {
    box-shadow: $btn-hover-box-shadow;
  }

  &:focus,
  &.focus {
    box-shadow: $btn-focus-box-shadow;
  }

  &:active,
  &.active {
    box-shadow: $btn-hover-box-shadow;

    &:focus {
      box-shadow: $btn-hover-box-shadow;
    }
  }

  &:disabled,
  &.disabled,
  fieldset:disabled & {
    box-shadow: $btn-box-shadow;
    border: 0;
  }

  .btn-check:focus + &,
  &:focus {
    outline: 0;
    box-shadow: $btn-focus-box-shadow;
  }
}

//
// Button block
//

.btn-block {
  display: block;
  width: 100%;

  // Vertically space out multiple block buttons
  + .btn-block {
    margin-top: $btn-block-spacing-y;
  }
}

//
// Outline option
//

[class*='btn-outline-'] {
  border-width: $btn-border-width;
  border-style: solid;
  box-shadow: none;
  @include button-outline-size-mdb(
    $btn-outline-padding-top,
    $btn-outline-padding-right,
    $btn-outline-padding-bottom,
    $btn-outline-padding-left
  );

  &:hover {
    box-shadow: none;
    text-decoration: none;
  }

  &:focus,
  &.focus {
    box-shadow: none;
    text-decoration: none;
  }

  &:active,
  &.active {
    box-shadow: none;

    &:focus {
      box-shadow: none;
    }
  }

  &:disabled,
  &.disabled,
  fieldset:disabled & {
    box-shadow: none;
  }

  &.btn-lg {
    @include button-outline-size-mdb(
      $btn-outline-padding-top-lg,
      $btn-outline-padding-right-lg,
      $btn-outline-padding-bottom-lg,
      $btn-outline-padding-left-lg
    );
  }

  &.btn-sm {
    @include button-outline-size-mdb(
      $btn-outline-padding-top-sm,
      $btn-outline-padding-right-sm,
      $btn-outline-padding-bottom-sm,
      $btn-outline-padding-left-sm
    );
  }
}

//
// Alternate buttons
//

@each $color, $value in $theme-colors {
  .btn-#{$color} {
    @include button-variant-mdb($value);
  }
}

//
// Alternate buttons outline
//

@each $color, $value in $theme-colors {
  .btn-outline-#{$color} {
    @include button-outline-variant-mdb($value);
  }
}

//
// Button Sizes
//

.btn-lg {
  @include button-size-mdb(
    $btn-padding-top-lg,
    $btn-padding-right-lg,
    $btn-padding-bottom-lg,
    $btn-padding-left-lg,
    $btn-font-size-lg,
    $btn-line-height-lg
  );
}

.btn-sm {
  @include button-size-mdb(
    $btn-padding-top-sm,
    $btn-padding-right-sm,
    $btn-padding-bottom-sm,
    $btn-padding-left-sm,
    $btn-font-size-sm,
    $btn-line-height-sm
  );
}

// Link buttons
//
// Make a button look and behave like a link

.btn-link {
  box-shadow: none;
  text-decoration: none;

  &:hover {
    box-shadow: none;
    text-decoration: none;
    background-color: $btn-link-bgc;
  }

  &:focus,
  &.focus {
    box-shadow: none;
    text-decoration: none;
    background-color: $btn-link-bgc;
  }

  &:active,
  &.active {
    box-shadow: none;
    background-color: $btn-link-bgc;

    &:focus {
      box-shadow: none;
      background-color: $btn-link-bgc;
    }
  }

  &:disabled,
  &.disabled,
  fieldset:disabled & {
    box-shadow: none;
  }
}

//
// Rounded option
//

.btn-rounded {
  border-radius: $btn-rounded-border-radius;
}

//
// Floating option
//

.btn-floating,
[class*='btn-outline-'].btn-floating {
  border-radius: $btn-floating-border-radius;
  padding: 0;
  position: relative;
}

.btn-floating {
  width: $btn-floating-width;
  height: $btn-floating-height;

  .fas,
  .far,
  .fab {
    width: $btn-floating-icon-width;
    line-height: $btn-floating-icon-line-height;
  }

  &.btn-lg {
    width: $btn-floating-width-lg;
    height: $btn-floating-height-lg;

    .fas,
    .far,
    .fab {
      width: $btn-floating-icon-width-lg;
      line-height: $btn-floating-icon-line-height-lg;
    }
  }

  &.btn-sm {
    width: $btn-floating-width-sm;
    height: $btn-floating-height-sm;

    .fas,
    .far,
    .fab {
      width: $btn-floating-icon-width-sm;
      line-height: $btn-floating-icon-line-height-sm;
    }
  }
}

[class*='btn-outline-'].btn-floating {
  .fas,
  .far,
  .fab {
    width: $btn-outline-floating-icon-width;
    line-height: $btn-outline-floating-icon-line-height;
  }

  &.btn-lg {
    .fas,
    .far,
    .fab {
      width: $btn-outline-floating-icon-width-lg;
      line-height: $btn-outline-floating-icon-line-height-lg;
    }
  }

  &.btn-sm {
    .fas,
    .far,
    .fab {
      width: $btn-outline-floating-icon-width-sm;
      line-height: $btn-outline-floating-icon-line-height-sm;
    }
  }
}

//
// Fixed option
//

.fixed-action-btn {
  position: fixed;
  right: $fixed-action-btn-right;
  bottom: $fixed-action-btn-bottom;
  z-index: $zindex-fixed-action-button;
  display: flex;
  flex-flow: column-reverse nowrap;
  align-items: center;
  padding: $fixed-action-btn-padding-top 20px 20px 20px;
  margin-bottom: 0;
  height: auto;
  overflow: hidden;

  & > .btn-floating {
    position: relative;
    transform: scale(1.2);
    z-index: 10;
  }

  ul {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    margin-bottom: 0;
    text-align: center;
    opacity: 0;
    transition: transform 0.4s, opacity 0.4s;
    z-index: -1;
    li {
      z-index: 0;
      display: flex;
      margin-right: auto;
      margin-bottom: $fixed-action-btn-li-margin-bottom;
      margin-left: auto;
      &:first-of-type {
        margin-top: $fixed-action-btn-li-margin-bottom / 2;
      }
    }
    a {
      &.btn {
        opacity: 0;
        transition: opacity 0.4s ease-in;
        &.shown {
          opacity: 1;
        }
      }
    }
  }
  &.active ul {
    opacity: 1;
  }
}
