@import '../common/style/var.less';
@import '../common/style/theme.less';

.van-button {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  height: 44px;
  padding: 0;
  font-size: 16px;
  line-height: 42px;
  text-align: center;
  vertical-align: middle;
  .theme(border-radius, '@button-border-radius');

  -webkit-appearance: none;
  -webkit-text-size-adjust: 100%;

  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: inherit;
    border-radius: inherit; /* inherit parent's border radius */
    transform: translate(-50%, -50%);
    opacity: 0;
    content: ' ';

    .theme(background-color, '@black');
    .theme(border-color, '@black');
  }

  // reset weapp default border
  &::after {
    border-width: 0;
  }

  &--active::before {
    opacity: 0.15;
  }

  &--unclickable::after {
    display: none;
  }

  &--default {
    .theme(color, '@button-default-color');
    .theme(background-color, '@button-default-background-color');
    .theme(border, '1px solid @button-default-border-color');
  }

  &--primary {
    .theme(color, '@button-primary-color');
    .theme(background-color, '@button-primary-background-color');
    .theme(border, '1px solid @button-primary-border-color');
  }

  &--info {
    .theme(color, '@button-info-color');
    .theme(background-color, '@button-info-background-color');
    .theme(border, '1px solid @button-info-border-color');
  }

  &--danger {
    .theme(color, '@button-danger-color');
    .theme(background-color, '@button-danger-background-color');
    .theme(border, '1px solid @button-danger-border-color');
  }

  &--warning {
    .theme(color, '@button-warning-color');
    .theme(background-color, '@button-warning-background-color');
    .theme(border, '1px solid @button-warning-border-color');
  }

  &--plain {
    .theme(background-color, '@white');

    &.van-button--primary {
      .theme(color, '@button-primary-background-color');
    }

    &.van-button--info {
      .theme(color, '@button-info-background-color');
    }

    &.van-button--danger {
      .theme(color, '@button-danger-background-color');
    }

    &.van-button--warning {
      .theme(color, '@button-warning-background-color');
    }
  }

  &--large {
    width: 100%;
    height: 50px;
    line-height: 48px;
  }

  &--normal {
    padding: 0 15px;
    font-size: 14px;
  }

  &--small {
    min-width: 60px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    line-height: 28px;
  }

  /* mini图标默认宽度50px,文字不能超过4个 */
  &--mini {
    display: inline-block;
    width: 50px;
    height: 22px;
    font-size: 10px;
    line-height: 20px;

    & + .van-button--mini {
      margin-left: 5px;
    }
  }

  &--block {
    display: block;
    width: 100%;
  }

  &--round {
    .theme(border-radius, '@button-round-border-radius');
  }

  &--square {
    border-radius: 0;
  }

  &--disabled {
    opacity: 0.5;
  }

  &__text {
    display: inline;
  }

  &__loading-text {
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
  }

  &__icon {
    min-width: 1em;
    line-height: inherit !important;
    vertical-align: top;
  }

  &__icon + &__text:not(:empty) {
    display: inline-block;
    margin-left: 5px;
    vertical-align: top;
  }

  &--hairline {
    padding-top: 1px; // add 1px padding for text vertical align middle
    border-width: 0;

    &::after {
      border-color: inherit;
      border-width: 1px;
      .theme(border-radius, 'calc(@button-border-radius * 2)');
    }

    &.van-button--round::after {
      .theme(border-radius, '@button-round-border-radius');
    }

    &.van-button--square::after {
      border-radius: 0;
    }
  }
}