@mixin normal_buttons($bg, $fg, $br) {
  padding: 4px 8px;
  border-style: solid;
  border-width: 1px;
  border-radius: $button_radius;
  color: $fg;
  border-color: $br;
  background-color: $bg;
  background-image: linear-gradient(to bottom, gtkshade($bg, 1.05) 5%, $bg 20%, $bg 70%, gtkshade($bg, 0.95) 90%);
  box-shadow: inset -1px 0 gtkshade($bg, 0.65), inset 0 -1px gtkshade($bg, 0.65), inset 1px 0 gtkmix($bg, $light_shadow, 0.7), inset 0 1px gtkmix($bg, $light_shadow, 0.7);
  -gtk-outline-radius: $button_radius;
  outline-color: $fg;
  outline-offset: 0;
  outline-style: solid;

  &:hover {
    background-color: $color_shadow;
    box-shadow: inset -1px 0 gtkshade($color_shadow, 0.65), inset 0 -1px gtkshade($color_shadow, 0.65), inset 1px 0 gtkmix($color_shadow, $light_shadow, 0.7), inset 0 1px gtkmix($color_shadow, $light_shadow, 0.7);
    background-image: linear-gradient(to bottom, gtkshade($color_shadow, 1.05) 5%, $color_shadow 20%, $color_shadow 70%, gtkshade($color_shadow, 0.95) 90%);
  }

  &:active, &:checked {
    color: $fg;
    border-color: $br;
    background-color: $color_shadow;
    box-shadow: none;
    background-image: linear-gradient(to top, gtkshade($color_shadow, 0.95) 5%, gtkshade($color_shadow, 0.9) 20%, gtkshade($color_shadow, 0.9) 70%, gtkshade($color_shadow, 0.85) 90%);

    &:disabled {
      color: gtkmix($fg, $unfocused_disabled_fg_color, 0.1);
      border-color: gtkmix($fg, $disabled_bg_color, 0.85);
      background-color: gtkshade($disabled_bg_color, 0.9);
      background-image: linear-gradient(to top, gtkshade($disabled_bg_color, 0.85) 5%, gtkshade($disabled_bg_color, 0.8) 20%, gtkshade($disabled_bg_color, 0.8) 70%, gtkshade($disabled_bg_color, 0.75) 90%);
    }
  }

  &:disabled {
    color: gtkmix($fg, $unfocused_disabled_fg_color, 0.5);
  }
}

@mixin flat_buttons($bg, $fg, $br)
{
  border-color: transparent;
  border-radius: $button_radius;
  color: $fg;
  box-shadow: none;
  background-image: none;
  background-color: transparent;

  &:hover {
    color: $fg;
    border-color: $br;
    background-color: $bg;
    background-image: linear-gradient(to bottom, gtkshade($bg, 1.05) 5%, $bg 20%, $bg 70%, gtkshade($bg, 0.95) 90%);
    box-shadow: inset -1px 0 gtkshade($bg, 0.65), inset 0 -1px gtkshade($bg, 0.65), inset 1px 0 gtkmix($bg, $light_shadow, 0.7), inset 0 1px gtkmix($bg, $light_shadow, 0.7);
  }

  &:active, &:checked {
    color: $fg;
    border-color: $br;
    background-color: $color_shadow;
    box-shadow: none;
    background-image: linear-gradient(to top, gtkshade($color_shadow, 0.95) 5%, gtkshade($color_shadow, 0.9) 20%, gtkshade($color_shadow, 0.9) 70%, gtkshade($color_shadow, 0.85) 90%);
  }

  &:disabled {
    border-color: transparent;
    color: gtkalpha($fg, 0.8);
    background-color: transparent;
  }
}

@mixin button() {
  button {
    @include normal_buttons($bg_color, $fg_color, $borders);
    
    &.flat {
      @include flat_buttons($bg_color, $fg_color, $borders);
    }
  }
}
