@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;

    &:hover {
      color: $fg;
      border-color: $br;
      background-color: shade($bg, 1.1);
    }

    &:active, &:checked {
      border-color: $selected_bg_color;
      color: $selected_fg_color;
      background-color: $selected_bg_color;

      &:backdrop {
        color: $unfocused_fg_color;
        border-color: gtkshade($unfocused_bg_color, 0.85);
        background-color: gtkshade($unfocused_bg_color, 0.85);
      }
    }

    &:disabled {
      color: gtkmix($fg, $unfocused_disabled_fg_color, 0.1);
      border-color: gtkmix($bg, $disabled_bg_color, 0.6);
      background-color: gtkmix($bg, $disabled_bg_color, 0.1);
      
      &:backdrop {
        color: $unfocused_disabled_fg_color;
        border-color: $unfocused_borders;
        background-color: $unfocused_disabled_bg_color;
      }
    }

    &:backdrop {
      border-color: $unfocused_borders;
      color: $unfocused_fg_color;
      background-color: $unfocused_bg_color;
    }
  }
}

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

    &:hover {
      border-color: $br;
      color: $fg;
      background-color: $bg;
    }

    &:active, &:checked {
      border-color: $selected_bg_color;
      color: $selected_fg_color;
      background-color: $selected_bg_color;
      
      &:backdrop {
        border-color: $unfocused_selected_bg_color;
        color: $unfocused_selected_fg_color;
        background-color: $unfocused_selected_bg_color;
      }
    }

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

    &:backdrop {
      border-color: transparent;
      background-color: transparent;
      color: $unfocused_fg_color;
    }
  }
}

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