/**Variable**/
@import './helpers/mixin.scss';

%ButtonHover {
  color: lighten($vxe-primary-color, 6%);
  border-color: lighten($vxe-primary-color, 10%);
}

%ButtonPrimaryHover {
  color: #fff;
  background-color: lighten($vxe-primary-color, 4%);
  border-color: lighten($vxe-primary-color, 4%);
}

%ButtonInterval {
  margin-left: 10px;
  &.size--medium {
    margin-left: 8px;
  }
  &.size--small {
    margin-left: 6px;
  }
  &.size--mini {
    margin-left: 4px;
  }
}

.vxe-button {
  position: relative;
  text-align: center;
  background-color: #fff;
  outline: 0;
  font-size: $vxe-font-size;
  white-space: nowrap;
  user-select: none;
  &.is--disabled {
    color: $vxe-disabled-color;
    &:not(.is--loading) {
      cursor: no-drop;
    }
  }
  &:not(.is--disabled) {
    color: $vxe-font-color;
    cursor: pointer;
  }
  &.is--loading {
    &:before {
      content: "";
      position: absolute;
      left: -1px;
      top: -1px;
      right: -1px;
      bottom: -1px;
      border-radius: inherit;
      background-color: hsla(0,0%,100%,.35);
      pointer-events: none;
    }
  }
  &.type--text {
    text-decoration: none;
    border: 0;
    background-color: transparent;
    &:not(.is--disabled) {
      &:hover {
        color: lighten($vxe-primary-color, 10%);
      }
    }
  }
  &.type--button {
    padding: 0 16px;
    line-height: 30px;
    border: 1px solid $vxe-input-border-color;
    border-radius: 4px;
    &.theme--primary {
      color: #fff;
      .vxe-button--icon {
        border-color: #fff;
      }
      &:not(.is--disabled) {
        border-color: $vxe-primary-color;
        background-color: $vxe-primary-color;
        &:hover {
          @extend %ButtonPrimaryHover;
        }
        &:active {
          color: #fff;
          background-color: darken($vxe-primary-color, 2%);
          border-color: darken($vxe-primary-color, 2%);
        }
      }
      &.is--disabled {
        border-color: #a0cfff;
        background-color: #a0cfff;
      }
      &.is--loading {
        border-color: $vxe-primary-color;
        background-color: $vxe-primary-color;
      }
    }
    &:not(.theme--primary) {
      &:not(.is--disabled) {
        &:hover {
          @extend %ButtonHover;
        }
        &:active {
          color: darken($vxe-primary-color, 2%);
          border-color: darken($vxe-primary-color, 2%);
        }
      }
    }
    &.size--medium {
      padding: 0 14px;
      line-height: 28px;
    }
    &.size--small {
      padding: 0 12px;
      line-height: 26px;
    }
    &.size--mini {
      padding: 0 10px;
      line-height: 24px;
    }
  }
  &+.vxe-button,
  &+.vxe-button--dropdown {
    @extend %ButtonInterval;
  }
  &.size--small,
  &.size--mini {
    font-size: 12px;
  }
}
.vxe-button--loading-icon,
.vxe-button--icon {
  margin-right: 5px;
}
.vxe-button--wrapper,
.vxe-button--dropdown {
  display: inline-block;
}
.vxe-button--dropdown {
  position: relative;
  &+.vxe-button,
  &+.vxe-button--dropdown {
    @extend %ButtonInterval;
  }
  &.is--active {
    & > .vxe-button {
      &.theme--primary {
        @extend %ButtonPrimaryHover;
      }
      &:not(.is--disabled) {
        &:not(.theme--primary) {
          @extend %ButtonHover;
        }
      }
    }
    .vxe-button--dropdown-wrapper {
      display: block;
    }
    .vxe-button--dropdown-arrow {
      transform: rotate(315deg);
      &.vxe-icon--arrow-bottom {
        margin-top: -2px;
      }
    }
  }
  .vxe-button--dropdown-arrow {
    font-size: 12px;
    margin-left: 5px;
    @include animatTransition(transform, .2s);
  }
  .vxe-button--dropdown-wrapper {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 5px;
    z-index: 100;
    padding: 5px;
    background-color: #fff;
    border-radius: 4px;
    border: 1px solid $vxe-input-border-color;
    box-shadow: 0 1px 6px rgba(0,0,0,.2);
    & > .vxe-button {
      margin: 0;
      display: block;
      width: 100%;
      border: 0;
      &.type--text {
        padding: 2px 8px;
      }
    }
  }
}