// sass-lint:disable no-important
// --- SUI Button --- //
// @include sui-button();
// @include sui-button('secondary', 'small');
// @include sui-button('ghost', 'large', 'full');

@mixin sui-button(
  $type: 'primary',
  $size: 'medium',
  $layout: null,
  $background-color: $c-gray-dark,
  $color: $c-white,
  $icon-fill: transparent,
  $icon-stroke: $c-white
) {
  align-items: center;
  border: 0;
  border-radius: $bdrs-button;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  line-height: $lh-button;
  outline: none;
  padding: $p-v $p-h;

  &:disabled {
    cursor: not-allowed;
    opacity: $o-button-disabled;
  }

  @if $type == 'primary' {
    @include sui-button--primary;
  }
  @if $type == 'secondary' {
    @include sui-button--secondary;
  }
  @if $type == 'ghost' {
    @include sui-button--ghost;
  }
  @if $type == 'accent' {
    @include sui-button--accent;
  }
  @if $type == 'flat' {
    @include sui-button--flat;
  }
  @if $type == 'custom' {
    @include sui-button--custom(
      $background-color,
      $color,
      $icon-fill,
      $icon-stroke
    );
  }

  @if $size == 'small' {
    @include sui-button--small;
  }
  @if $size == 'medium' {
    @include sui-button--medium;
  }
  @if $size == 'large' {
    @include sui-button--large;
  }

  @if $layout == 'full' {
    @include sui-button--full;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    @if $size == 'small' {
      @include sui-icon--small;
    }
    @if $size == 'medium' {
      @include sui-icon--small;
    }
    @if $size == 'large' {
      @include sui-icon--large;
    }

    &:first-child {
      margin-right: $m-h-small;
    }

    &:last-child {
      margin-left: $m-h-small;
    }
  }
}

// Button types

@mixin sui-button--primary {
  background-color: $bgc-button-primary;
  color: $c-button-primary;

  &:hover {
    background-color: $bgc-button-primary-hover;
  }

  &:active {
    background-color: $bgc-button-primary-active;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $c-button-primary-icon-fill !important;
    stroke: $c-button-primary-icon-stroke !important;
  }
}

@mixin sui-button--secondary {
  background-color: $bgc-button-secondary;
  box-shadow: 0 0 0 1px $bdc-button-secondary inset;
  color: $c-button-secondary;

  &:hover {
    background-color: $bgc-button-secondary-hover;
    color: $c-button-secondary-hover;
  }

  &:active {
    background-color: $bgc-button-secondary-active;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $c-button-secondary-icon-fill !important;
    stroke: $c-button-secondary-icon-stroke !important;
  }
}

@mixin sui-button--accent {
  background-color: $bgc-button-accent;
  color: $c-button-accent;

  &:hover {
    background-color: $bgc-button-accent-hover;
  }

  &:active {
    background-color: $bgc-button-accent-active;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $c-button-accent-icon-fill !important;
    stroke: $c-button-accent-icon-stroke !important;
  }
}

@mixin sui-button--ghost {
  background-color: transparent;
  box-shadow: 0 0 0 1px $bdc-button-ghost inset;
  color: $c-button-ghost;

  &:hover {
    box-shadow: 0 0 0 1px $bdc-button-ghost-hover inset;
    color: $c-button-ghost-hover;
  }

  &:active {
    background-color: $bgc-button-ghost-active;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $c-button-ghost-icon-fill !important;
    stroke: $c-button-ghost-icon-stroke !important;
  }
}

@mixin sui-button--flat {
  background-color: transparent;
  color: $c-button-flat;

  &:hover {
    color: $c-button-flat-hover;
  }

  &:active {
    background-color: $bgc-button-flat-active;
  }

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $c-button-flat-icon-fill !important;
    stroke: $c-button-flat-icon-stroke !important;
  }
}

@mixin sui-button--custom($background-color, $color, $icon-fill, $icon-stroke) {
  background-color: $background-color;
  color: $color;

  &:hover {
    background-color: lighten($background-color, 15%);
  }

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

  & > [class$='icon'],
  & > [class$='Icon'] {
    fill: $icon-fill !important;
    stroke: $icon-stroke !important;
  }
}

// Button sizes

@mixin sui-button--small {
  font-size: $fz-s;
}

@mixin sui-button--medium {
  font-size: $fz-m;
}

@mixin sui-button--large {
  font-size: $fz-l;
}

// Button layouts

@mixin sui-button--full {
  justify-content: center;
  width: 100%;
}
