@import (reference) "../defs.less";

.split-btn {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: @split-btn-hover-transition-time border linear;

  &.drop-down-shown,
  &.drop-up-shown {
    .split-btn-alternatives {
      opacity: 1;
    }
  }

  &.drop-down-shown {
    border-radius: @btn-border-radius @btn-border-radius 0 0;
    border-bottom-color: transparent;

    .split-btn-alternatives .btn {
      border-bottom: 0;

      &:last-child {
        border-bottom: @btn-border-size solid @btn-border-bottom-color;
        border-radius: 0 0 @btn-border-radius @btn-border-radius;
      }
    }
  }

  &.drop-up-shown {
    border-radius: 0 0 @btn-border-radius @btn-border-radius;
    border-top-color: transparent;

    .split-btn-alternatives .btn {
      border-top: 0;

      &:first-child {
        border-radius: @btn-border-radius @btn-border-radius 0 0;
        border-top: @btn-border-size solid @btn-border-color;
      }
    }
  }
}

.split-btn-alternatives {
  box-shadow: @btn-box-shadow;
  cursor: pointer;
  opacity: 0;
  position: absolute;
  text-align: left;
  transition: @split-btn-hover-transition-time opacity linear;
  white-space: nowrap;

  .btn {
    border-radius: 0;
    display: block;
  }
}

a.btn {
  text-decoration: none;
}

.btn,
input[type="button"],
input[type="submit"] {
  // Button Base
  cursor: pointer;
  display: inline-block;

  border-bottom-color: @btn-border-bottom-color;
  border-radius: @btn-border-radius;
  border: @btn-border-size solid @btn-border-color;
  box-shadow: @btn-box-shadow;
  color: @btn-text-color;
  font-weight: @btn-font-weight;
  font-size: @btn-font-size;
  line-height: normal;
  padding: @btn-padding;
  text-shadow: @btn-text-shadow;
  transition: @btn-transition;

  &[disabled] {
    // disabled pseudo can't be included with .disabled
    // def because IE8 and below will drop it ;_;
    cursor: default;
    background-image: none;
    .ie-reset-gradients();
    opacity: @btn-disabled-opacity;
    box-shadow: @btn-disabled-box-shadow;
  }

  // Active state
  &:active {
    box-shadow: @btn-active-box-shadow;
  }

  &, .btn-segment {
    // Don't use .gradientbar() here since it does a three-color gradient
    #gradient > .vertical-three-colors(@btn-bg-color1, @btn-bg-color1, 25%,
                                       @btn-bg-color2);

    &:hover, &.hover {
      background-position: 0 -15px;
      color: @btn-text-color;
      text-decoration: none;
    }
  }

  &.danger {
    &, .btn-segment {
      color: @btn-danger-text-color !important;
      .gradientBar(@btn-danger-bg-color1, @btn-danger-bg-color2);
    }
  }

  &.disabled {
    cursor: default;
    background-image: none;
    .ie-reset-gradients();
    opacity: @btn-disabled-opacity;
    box-shadow: @btn-disabled-box-shadow;
  }

  // Primary Button Type
  &.primary, &.default {
    color: @btn-primary-text-color;
    text-shadow: @btn-primary-text-shadow;

    &, .btn-segment {
      .gradientBar(@btn-primary-bg-color1, @btn-primary-bg-color2);
    }
  }

  // Button Sizes
  &.large {
    font-size: @btn-large-font-size;
    line-height: normal;
    padding: @btn-large-padding;
    border-radius: @btn-large-border-radius;
  }

  &.small {
    padding: @btn-small-padding;
    font-size: @btn-small-font-size;
  }

  /*
   * Apply this after all the above rules in order to turn off the main
   * background. This will let each segment manage its own background,
   * for the purposes of hovering.
   */
  &.btn-segmented {
    padding: 0;
    background: none;
  }

  .btn-segment {
    border-left: @btn-border-size solid @btn-border-color;
    display: inline-block;
    padding: @btn-padding;

    &:first-child {
      border-left: 0;
      border-top-left-radius: inherit;
      border-bottom-left-radius: inherit;
    }

    &:last-child {
      border-top-right-radius: inherit;
      border-bottom-right-radius: inherit;
    }
  }
}

/*
 * Force Firefox to render our buttons with our chosen font. Otherwise it will
 * be overridden (on macOS at least) with the system font.
 */
input[type="button"],
input[type="submit"] {
  font-family: @font-family;
}

// Help Firefox not be a jerk about adding extra padding to buttons
button,
input[type=submit],
input[type=button] {
  &::-moz-focus-inner {
    padding: 0;
    border: 0;
  }
}
