// Shared styles
.btn {
  position: relative;
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  line-height: 20px;
  color: #333;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  background-color: #eee;
  background-image: linear-gradient(#fcfcfc, #eee);
  border: 1px solid #d5d5d5;
  border-radius: 3px;
  user-select: none;
  -webkit-appearance: none; // Corrects inability to style clickable `input` types in iOS.

  i {
    font-style: normal;
    font-weight: 500;
    opacity: 0.6;
  }

  .octicon {
    vertical-align: text-top;
  }

  // Darken for just a tad more contrast against the button background
  .counter {
    text-shadow: none;
    background-color: #e5e5e5;
  }

  &:focus {
    text-decoration: none;
    border-color: #51a7e8;
    outline: none;
    box-shadow: 0 0 5px rgba(81, 167, 232, 0.5);
  }

  &:focus:hover,
  &.selected:focus {
    border-color: #51a7e8;
  }

  &:hover,
  &:active,
  &.zeroclipboard-is-hover,
  &.zeroclipboard-is-active {
    text-decoration: none;
    background-color: #ddd;
    background-image: linear-gradient(#eee, #ddd);
    border-color: #ccc;
  }

  &:active,
  &.selected,
  &.zeroclipboard-is-active {
    background-color: #dcdcdc;
    background-image: none;
    border-color: #b5b5b5;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
  }

  &.selected:hover {
    background-color: darken(#dcdcdc, 5%);
  }

  &:disabled,
  &.disabled {
    &,
    &:hover {
      color: rgba(102, 102, 102, 0.5);
      cursor: default;
      background-color: rgba(229, 229, 229, 0.5);
      background-image: none;
      border-color: rgba(197, 197, 197, 0.5);
      box-shadow: none;
    }
  }
}

// Green primary button
.btn-primary {
  color: #fff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.15);
  background-color: #60b044;
  background-image: linear-gradient(#8add6d, #60b044);
  border-color: darken(#60b044, 2%);

  .counter {
    color: #60b044;
    background-color: #fff;
  }

  &:hover {
    color: #fff;
    background-color: darken(#60b044, 5%);
    background-image: linear-gradient(darken(#8add6d, 5%), darken(#60b044, 5%));
    border-color: #4a993e;
  }

  &:active,
  &.selected {
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
    background-color: darken(#60b044, 5%);
    background-image: none;
    border-color: darken(#4a993e, 5%);
  }

  &.selected:hover {
    background-color: darken(#60b044, 10%);
  }

  &:disabled,
  &.disabled {
    &,
    &:hover {
      color: #fefefe;
      background-color: #add39f;
      background-image: linear-gradient(#c3ecb4, #add39f);
      border-color: #b9dcac #b9dcac #a7c89b;
    }
  }
}

// Red danger button
.btn-danger {
  color: #900;

  &:hover {
    color: #fff;
    background-color: #b33630;
    background-image: linear-gradient(#dc5f59, #b33630);
    border-color: #cd504a;
  }

  &:active,
  &.selected {
    color: #fff;
    background-color: #b33630;
    background-image: none;
    border-color: darken(#cd504a, 15%);
  }

  &.selected:hover {
    background-color: darken(#b33630, 5%);
  }

  &:disabled,
  &.disabled {
    &,
    &:hover {
      color: #cb7f7f;
      background-color: #efefef;
      background-image: linear-gradient(#fefefe, #efefef);
      border-color: #e1e1e1;
    }
  }

  &:hover,
  &:active,
  &.selected {
    .counter {
      color: #b33630;
      background-color: #fff;
    }
  }
}

// Outline button
//
// For when we need a linky-action that's not too heavy in busier
// areas like conversation timelines.
.btn-outline {
  color: $brand-blue;
  background-color: #fff; // Reset default gradient backgrounds and colors
  background-image: none;
  border: 1px solid #e5e5e5;

  .counter {
    background-color: #eee;
  }

  &:hover,
  &:active,
  &.selected,
  &.zeroclipboard-is-hover,
  &.zeroclipboard-is-active {
    color: #fff;
    background-color: $brand-blue;
    background-image: none;
    border-color: $brand-blue;

    .counter {
      color: $brand-blue;
      background-color: #fff;
    }
  }

  &.selected:hover {
    background-color: darken($brand-blue, 5%);
  }

  &:disabled,
  &.disabled {
    &,
    &:hover {
      color: $brand-gray;
      background-color: #fff;
      background-image: none;
      border-color: #e5e5e5;
    }
  }
}

// Social button count
.btn-with-count {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}


// Minibutton overrides
//
// Tweak `line-height` to make them smaller.
.btn-sm {
  padding: 2px 10px;
}


// Hidden text button
//
// Use `.hidden-text-expander` to indicate and expand hidden text.
.hidden-text-expander {
  display: block;

  &.inline {
    position: relative;
    top: -1px;
    display: inline-block;
    margin-left: 5px;
    line-height: 0;
  }

  a {
    display: inline-block;
    height: 12px;
    padding: 0 5px;
    font-size: 12px;
    font-weight: bold;
    line-height: 6px;
    color: #555;
    text-decoration: none;
    vertical-align: middle;
    background: #ddd;
    border-radius: 1px;

    &:hover {
      text-decoration: none;
      background-color: #ccc;
    }

    &:active {
      color: #fff;
      background-color: #4183c4;
    }
  }
}


// Social count bubble
//
// A container that is used for social bubbles counts.
.social-count {
  padding: 7px;
  font-size: 10px;
  font-weight: bold;
  line-height: 20px;
  color: $brand-gray-dark;
  vertical-align: middle;
  background-color: #fff;
  border: 1px solid #ddd;
  border-left: 0;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;

  &:hover,
  &:active {
    text-decoration: none;
  }

  &:hover {
    color: $brand-blue;
    cursor: pointer;
  }
}


// Full-width button
//
// These buttons expand to the full width of their parent container
.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}


// Button group
//
// A button group is a series of buttons laid out next to each other, all part
// of one visual button, but separated by rules to be separate.
.btn-group {
  display: inline-block;
  vertical-align: middle;
  @include clearfix();

  .btn {
    position: relative;
    float: left;

    &:not(:first-child):not(:last-child) {
      border-radius: 0;
    }

    &:first-child:not(:last-child) {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    &:last-child:not(:first-child) {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }

    // Bring any button into forefront for proper borders given negative margin below
    &:hover,
    &:active,
    &.selected {
      z-index: 2;
    }

    &:focus {
      z-index: 3;
    }

    // Tuck buttons into one another to prevent double border
    + .btn {
      margin-left: -1px;
    }
  }

  .btn + .button_to,
  .button_to + .btn,
  .button_to + .button_to {
    margin-left: -1px;
  }

  .button_to {
    float: left;

    .btn {
      border-radius: 0;
    }

    &:first-child {
      .btn {
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
      }
    }

    &:last-child {
      .btn {
        border-top-right-radius: 3px;
        border-bottom-right-radius: 3px;
      }
    }
  }
}

// Proper spacing for multiple button groups (a la, gollum editor)
.btn-group + .btn-group,
.btn-group + .btn {
  margin-left: 5px;
}


// Radio buttons
//
// Buttons backed by radio or checkbox control. Requires the use of `.hidden`
// on the `input` to properly hide it.
.btn-link {
  display: inline-block;
  padding: 0;
  font-size: inherit;
  color: $brand-blue;
  white-space: nowrap;
  cursor: pointer;
  background-color: transparent;
  border: 0;
  user-select: none;
  -webkit-appearance: none; // Corrects inability to style clickable `input` types in iOS.

  &:hover,
  &:focus {
    text-decoration: underline;
  }

  &:focus {
    outline: none; // Prevents the blue ring when clicked.
  }
}
