%button-block{
  display: block;
}
%button-large{
  padding: $gap 2*$gap !important;
  //@include small;
  font-size: inherit !important;
  &.icon{
    padding-left: 4*$gap !important;
    &:before{
      width: 4*$gap;
      font-size: 1.2em;
    }
  }
}
%button-small{
  padding: 0.25*$gap .5*$gap !important;
  @include small;
  &.icon{
    padding-left: 3*$gap !important;
    &:before{
      width: 3*$gap !important;
      font-size: 1.1em;
    }
  }
  #sidebar &,#easy_grid_sidebar &{
    display: inline-block !important;
  }
}
%button-mini{
  padding: 0.25*$gap 0.5*$gap !important;
  @include smaller;
  &.icon{
    padding-left: 2*$gap !important;
    &:before{
      width: 2*$gap !important;
      font-size: 1em;
    }
  }
  #sidebar &,#easy_grid_sidebar &{
    display: inline-block !important;
  }
}

%button-with-icon{
  &:before{
    position: absolute;
    left: 0;
    width: 3*$gap;
    text-align: center;
    font-size: 1.2em;
    line-height: 1;
    color: inherit;
    top: 50%;
    margin-top: -0.5em;
  }
}
%button-with-icon-insidebar{
  padding-left: 4*$gap !important;
  &:before{
    width: 4*$gap !important;
  }
}
%button{
  @include small;
  font-weight: bold;
  display: inline-block;
  border: 1px solid transparent;
  padding: 0.5*$gap $gap;
  text-align: left;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  @extend %border-radius;
  &.icon{
    padding-left: 3*$gap;
    @extend %button-with-icon;
  }
  //@include respond-to(max-small-screen){
  //  display: block;
  //}
  #sidebar &,#easy_grid_sidebar &{
    display: block;
    position: relative !important;
    z-index: 2;
    padding-left: 2*$gap;
    margin-bottom: 3px;
    &.icon{
     @extend %button-with-icon-insidebar;
    }
    @include respond-to(min-sidebar-collapse){
      .nosidebar &{
        &:hover {
          @include animation(sidebar-buttons-slide-left 0.25s forwards);
        }
      }
    }
  }
  .form-actions &{
    margin: 3px 0;
  }
  &.active,&:active{
    @extend %box-shadow-inset-active;
  }
  .splitcontent .contextual &{
    @extend %button-small;
  }
}
@include keyframes(sidebar-buttons-slide-left) {
  from {
    @include translate(0,0);
  }
  to {
    @include translate(-$sidebar-width + 4*$box-margin, 0)
  }
}

@mixin button($background:$button-base-background,$color:$button-base-color,$height:$button-height){
  @extend %button;
  line-height: $height - $gap - 2;
  min-height: $height - $gap - 2;
  background: $background;
  //border-color: background-to-border($background);
  border-color: darken($background, 15%);
  color: $color;
  &:hover{
    color: $color;
	  text-decoration: none;
    background: darken($background,5%);
  }
  &.selected{
    background: darken($background,5%);
    color: rgba($color,.75);
  }
  .ui-widget-content & { //hack to overide jui ****
    color: $color;
  }
}

@mixin button-small($background:$button-base-background,$color:$button-base-color,$height:$button-height){
  @include button($background, $color, $height);
  @extend %button-small;
}
@mixin button-mini($background:$button-base-background,$color:$button-base-color,$height:$button-height){
  @include button($background, $color, $height);
  @extend %button-mini;
}

%button-base{
  @include button($button-base-background,$button-base-color,$button-height);
}
%button-main{
  @include button($button-main-background,$button-main-color,$button-height);
}
%button-important{
  @include button($button-important-background,$button-important-color,$button-height);
}
%button-positive{
  @include button($button-positive-background,$button-positive-color,$button-height);
}
%button-negative{
  @include button($button-negative-background,$button-negative-color,$button-height);
}
%button-mini{
  @include button-mini($button-base-background,$button-base-color,$button-mini-height);
}
%button-mini-positive{
  @include button-mini($button-positive-background,$button-positive-color,$button-mini-height);
}
%button-mini-negative{
  @include button-mini($button-negative-background,$button-negative-color,$button-mini-height);
}
%button-light{
  $bg: lighten($button-base-background,3%);
  @extend %button-base;
  background: $bg;
  &:hover{
    background: darken($bg,5%);
  }
}
%button-reset{
  background: none;
  border: none;
  padding: 0;
  line-height: normal;
}

%button-group{
  display: inline-block;
  margin-bottom: $gap;
  [class*=button-]{
    @extend %border-radius-none;
    &:last-child{
      @include border-radius(0 $border-radius $border-radius 0);
    }
    &:first-child{
      @include border-radius($border-radius 0 0 $border-radius);
    }
    &:only-child{
      @include border-radius($border-radius);
    }
    & + & {
      margin-left: -1px;
    }
  }
}
%button-append{
  display: inline-block;
  @extend %box-sizing-border-box;
  @extend %button-base;
  @extend %truncate;
  @include border-radius(0);
  width: 1.5*$box-padding + 2;
  //max-width: 25%;
  line-height: $tab-height;
  height: $tab-height;
  text-align: center;
  padding: 0 .5*$gap !important;
  margin: 0;
  margin-left: -1px;
  position: relative;
  z-index: 1;
  vertical-align: middle;
  &:before{
    width: 100% !important;
  }
}
%button-rounded{
  @extend %button-base;
  @include border-radius(50px !important);
}
%button-icon {
  text-decoration: none;
  //background: $color-foreground;
  color: $button-base-color;
  border: 1px solid transparent;
  width: 1.5em !important;
  font-size: 1.125em;
  line-height: 1.5em;
  text-align: center;
  @extend %border-radius-infinite;
  &.icon-add{
    color: $color-positive;
  }
  &:hover{
    background: darken($color-positive,5%);;
    color: $white;
    border-color: darken($color-positive,10%);
    cursor: pointer;
  }
  &.active{
    background: darken($color-important,5%);;
    color: $white;
    border-color: darken($color-important,10%);
    &:hover{
      background: darken($color-positive,5%);;
      border-color: darken($color-positive,10%);
    }
  }
}
%button-link{
  @extend %base-font;
  text-decoration: underline;
  @include small;
  color: $color-text;
  &:before{
    @extend %button-icon;
  }
  &+&{
    //margin-left: $gap;
  }
}

%button-icon-only{
  @extend %button-base;
  padding-right: 0;
}

