@import '../../style/variables';
@import '../../style/mixins';
@import './mixin';

$btn-prefix: #{$prefix}btn;

.#{$btn-prefix} {
  box-sizing: border-box;
  border: 1px solid #d0d0d5;
  outline: none;
  border-radius: $btn-border-radius;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
  transition: all 400ms;
  font-family: $font-family;
  display: inline-block;
  min-width: 50px;
  background-color: #fff;
  color: #4c5161;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;

  & > span {
    display: inline-block;
    pointer-events: none;
    line-height: 1.5;
    vertical-align: middle;
  }

  & + .#{$btn-prefix} {
    margin-left: 10px;
  }

  &:hover {
    color: $primary-color;
    border-color: $primary-color;
  }

  &:active {
    background-color: #f7f9fa;
    color: darken($primary-color, 10%);
    border-color: darken($primary-color, 10%);
  }

  &__loader {
    @include loader(14px, #888);

    & + span {
      margin-left: 5px;
    }
  }

  &_primary {
    @include btn-color($primary-color);
  }

  &_blue {
    @include btn-color($blue-color);
  }

  &_green {
    @include btn-color($green-color);
  }

  &_yellow {
    @include btn-color($yellow-color);
  }

  &_red {
    @include btn-color($red-color);
  }

  &_primary,
  &_blue,
  &_green,
  &_yellow,
  &_red {
    .#{$btn-prefix}__loader {
      @include loader-color(#fff);
    }
  }

  &_lg {
    height: $btn-lg-height;
    font-size: $btn-lg-font-size;
    padding: $btn-lg-padding;

    .#{$btn-prefix}__loader {
      @include loader-size(18px);
    }
  }

  &_md {
    height: $btn-md-height;
    font-size: $btn-md-font-size;
    padding: $btn-md-padding;
  }

  &_sm {
    height: $btn-sm-height;
    font-size: $btn-sm-font-size;
    padding: $btn-sm-padding;

    .#{$btn-prefix}__loader {
      @include loader-size(12px);
    }
  }

  &_block {
    width: 100%;

    & + & {
      margin: 0;
    }
  }

  &_round {
    border-radius: 30px;
  }

  &_link {
    color: $primary-color;
    background-color: transparent;
    border: 0;

    &:active {
      background-color: transparent;
    }

    .#{$btn-prefix}__loader {
      @include loader-color($primary-color);
    }
  }

  &_loading {
    opacity: 0.85;
    pointer-events: none;
    cursor: progress;
  }

  &_disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
  }
}

.#{$btn-prefix}-group {
  display: inline-block;

  & + .#{$btn-prefix}-group {
    margin-left: 10px;
  }

  .#{$btn-prefix} {
    position: relative;
    border-radius: 0;
    float: left;

    & + .#{$btn-prefix} {
      margin-left: -1px;
    }

    &:hover {
      z-index: 1;
    }

    &:first-child {
      border-top-left-radius: $btn-border-radius;
      border-bottom-left-radius: $btn-border-radius;
    }

    &:last-child {
      border-top-right-radius: $btn-border-radius;
      border-bottom-right-radius: $btn-border-radius;
    }
  }

  &_round {
    .#{$btn-prefix} {
      &:first-child {
        border-top-left-radius: 30px;
        border-bottom-left-radius: 30px;
      }

      &:last-child {
        border-top-right-radius: 30px;
        border-bottom-right-radius: 30px;
      }
    }
  }

  &_primary,
  &_blue,
  &_green,
  &_yellow,
  &_red {
    .#{$btn-prefix} {
      &:not(:first-child) {
        border-left-color: rgba(255, 255, 255, 0.2);
      }
    }
  }
}
