// mixins for button
// ------------------------
.button-size(@height; @padding; @font-size; @border-radius) {
  padding: @padding;
  font-size: @font-size;
  border-radius: @border-radius;
  height: @height;
}

.button-disabled(@color; @bg;) {
  &.disabled,
  &[disabled] {
    &,
    &:hover,
    &:focus,
    &:active,
    &.active {
      .button-color(@color; @bg; @bg);
    }
  }
}

.button-color(@color; @background; @border) {
  color: @color;
  background-color: @background;
  border-color: @border;
  // a inside Button which only work in Chrome
  // http://stackoverflow.com/a/17253457
  > a:only-child {
    color: currentColor;
    &:after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      background: transparent;
    }
  }
}

// primary button style
.btn-primary() {
  .button-color(#fff; @btn-primary-bg; @btn-primary-bg);
  &:hover,
  &:focus {
    .button-color(#fff; @btn-primary-hover-bg; @btn-primary-hover-bg);
  }

  &:active,
  &.active {
    .button-color(#fff; @btn-primary-active-bg; @btn-primary-active-bg);
  }

  .button-disabled(#fff, @btn-primary-disabled-bg);

}

// default button style
.btn-default() {
  .button-color(@btn-default-color; @btn-default-bg; @btn-default-border);

  &:hover,
  &:focus {
    .button-color(@btn-default-color; #fff; @text-color-assit);
  }

  &:active,
  &.active {
    .button-color(@text-color-assit; #fff; @text-color-assit);
  }

  .button-disabled(@text-color-assit, @btn-default-border);

  &-clicked:after {
    border-color: @btn-default-color;
  }
}

// danger button style
.btn-danger() {
  .button-color(#fff; @btn-danger-bg; @btn-danger-bg);

  &:hover,
  &:focus {
    .button-color(#fff; @btn-danger-active-bg; @btn-danger-active-bg);
  }

  &:active,
  &.active {
    .button-color(#fff; @btn-danger-active-bg; @btn-danger-active-bg);
  }

  .button-disabled(#fff, @btn-danger-disabled-bg);
}

// circle button: the content only contains icon
.btn-circle(@btnClassName: btn) {
  .square(@btn-circle-size);
  .button-size(@btn-circle-size; 0; @font-size-base + 2px; 50%);

  &.@{btnClassName}-lg {
    .square(@btn-circle-size-lg);
    .button-size(@btn-circle-size-lg; 0; @btn-font-size-lg + 2px; 50%);
  }

  &.@{btnClassName}-sm {
    .square(@btn-circle-size-sm);
    .button-size(@btn-circle-size-sm; 0; @font-size-base; 50%);
  }
}

.button-variant-default(@color; @background; @border) {
  
}

// Horizontal button groups styl
// --------------------------------------------------
.btn-group(@btnClassName: btn) {
  .button-group-base(@btnClassName);

  .@{btnClassName} + .@{btnClassName},
  .@{btnClassName} + &,
  span + .@{btnClassName},
  .@{btnClassName} + span,
  & + .@{btnClassName},
  & + & {
    margin-left: -1px;
  }

  .@{btnClassName}:not(:first-child):not(:last-child) {
    border-radius: 0;
  }

  > .@{btnClassName}:first-child,
  > span:first-child > .@{btnClassName} {
    margin-left: 0;
  }

  > .@{btnClassName}:first-child:not(:last-child),
  > span:first-child:not(:last-child) > .@{btnClassName} {
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
  }

  > .@{btnClassName}:last-child:not(:first-child),
  > span:last-child:not(:first-child) > .@{btnClassName} {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
  }

  & > & {
    float: left;
  }

  & > &:not(:first-child):not(:last-child) > .@{btnClassName} {
    border-radius: 0;
  }

  & > &:first-child:not(:last-child) {
    > .@{btnClassName}:last-child {
      border-bottom-right-radius: 0;
      border-top-right-radius: 0;
      padding-right: 8px;
    }
  }

  & > &:last-child:not(:first-child) > .@{btnClassName}:first-child {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    padding-left: 8px;
  }
}
