.nut-button {
  position: relative;
  display: flex;
  display: inline-block;
  /* #ifdef harmony dynamic*/
  width: 80px;
  /* #endif */
  /* #ifndef harmony dynamic*/
  width: auto;
  /* #endif */
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  height: $button-default-height;
  font-size: $button-default-font-size;
  font-weight: $font-weight;
  text-align: center;
  cursor: pointer;
  transition: $button-transition;
  user-select: none;
  touch-action: manipulation;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  color: $button-default-color;
  background: $button-default-background-color;
  border-width: $button-border-width;

  &-text {
    margin-left: $button-text-icon-margin;
    &-right {
      margin-right: $button-text-icon-margin;
    }
  }

  &-children {
    display: flex;
    flex-direction: row;
    background: transparent;
  }

  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-color: $color-mask;
    border: inherit;
    border-color: $color-mask;
    border-radius: inherit;
    transform: translate(-50%, -50%);
    opacity: 0;
    content: ' ';
  }

  &::after {
    border: none;
  }

  &:active::before {
    opacity: 0.1;
  }

  &-wrap {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    /* #ifndef harmony dynamic*/
    background: initial;
    /* #endif */
    .nut-icon {
      font-size: $button-default-font-size;
      width: $button-default-font-size;
      height: $button-default-font-size;
    }
  }

  &-loading,
  &-disabled {
    &::before {
      display: none;
    }
  }

  &-disabled {
    cursor: not-allowed;
    color: #ffffff;
  }

  &.nut-button-icononly {
    width: $button-default-height;
    padding: 0;
  }

  &-round {
    border-radius: $button-border-radius;
  }

  &-default {
    padding: $button-default-padding;
    border-style: solid;
    border-color: $button-default-border-color;

    &-disabled,
    &-solid-disabled {
      color: $button-primary-color;
      background: $button-default-disabled;
      border-color: $button-default-disabled;
    }

    &-none {
      &-disabled {
        color: $button-default-disabled-color;
      }
    }

    &-outline,
    &-dashed {
      &-disabled {
        background: transparent;
        color: $button-default-disabled;
        border-color: $button-default-disabled;
      }
    }
  }

  &-normal {
    padding: $button-normal-padding;
  }

  &-xlarge {
    height: $button-xlarge-height;
    padding: $button-xlarge-padding;
    font-size: $button-xlarge-font-size;
    border-radius: $button-xlarge-border-radius;

    .nut-button-text {
      margin-left: $button-xlarge-text-icon-margin;
      &-right {
        margin-right: $button-xlarge-text-icon-margin;
      }
    }

    .nut-icon {
      font-size: $button-xlarge-font-size;
      width: $button-xlarge-font-size;
      height: $button-xlarge-font-size;
    }
    &-children {
      font-size: $button-xlarge-font-size;
    }
  }

  &-large {
    height: $button-large-height;
    padding: $button-large-padding;
    font-size: $button-large-font-size;
    border-radius: $button-large-border-radius;

    .nut-button-text {
      margin-left: $button-xlarge-text-icon-margin;
      &-right {
        margin-right: $button-xlarge-text-icon-margin;
      }
    }

    .nut-icon {
      font-size: $button-large-font-size;
      width: $button-large-font-size;
      height: $button-large-font-size;
    }

    &-children {
      font-size: $button-large-font-size;
    }
  }

  &-small {
    height: $button-small-height;
    padding: $button-small-padding;
    font-size: $button-small-font-size;
    border-radius: $button-small-border-radius;

    .nut-icon {
      font-size: $button-small-font-size;
      width: $button-small-font-size;
      height: $button-small-font-size;
    }

    &-children {
      font-size: $button-small-font-size;
    }
  }

  &-mini {
    height: $button-mini-height;
    padding: $button-mini-padding;
    font-size: $button-mini-font-size;
    border-radius: $button-mini-border-radius;

    .nut-icon {
      font-size: $button-mini-font-size;
      width: $button-mini-font-size;
      height: $button-mini-font-size;
    }

    &-children {
      font-size: $button-mini-font-size;
    }
  }

  &-primary {
    color: $button-primary-color;
    background-origin: border-box;
    border-color: transparent;

    &-children {
      color: $button-primary-color;
    }

    &-solid {
      background: $button-primary-background-color;
      color: $button-primary-color;
      border-color: transparent;
      font-weight: $font-weight-bold;
      &.nut-button-small,
      &.nut-button-mini {
        font-weight: $font-weight;
      }
    }

    &-disabled,
    &-disabled.nut-button-icononly,
    &-solid-disabled {
      color: $button-primary-color;
      background: $button-primary-disabled;
      border-color: $button-primary-disabled;
    }

    &-none {
      color: $button-primary-border-color;

      &-disabled {
        color: $button-primary-disabled;
      }
    }

    &-outline {
      color: $button-primary-border-color;
      border-color: $button-primary-border-color;

      &-disabled {
        color: $button-primary-disabled;
        border-color: $button-primary-disabled;
      }
    }

    &-dashed {
      color: $button-primary-border-color;
      border-color: $button-primary-border-color;

      &-disabled {
        color: $button-primary-disabled;
        border-color: $button-primary-disabled;
      }
    }
  }
  &-primary.nut-button-solid.nut-button-normal {
    font-weight: $font-weight-bold;
  }

  &-success {
    color: $button-success-color;
    background: $button-success-background-color;
    background-origin: border-box;
    border-color: transparent;

    &-children {
      color: $button-success-color;
    }

    &-solid-disabled {
      background: $button-success-disabled;
      border-color: $button-success-disabled;
    }

    &-outline,
    &-dashed {
      color: $button-success-border-color;
      border-color: $button-success-border-color;

      &-disabled {
        color: $button-primary-disabled;
        border-color: $button-primary-disabled;
      }
    }

    &-none {
      color: $button-success-border-color;
      &-disabled {
        color: $button-success-disabled;
      }
    }
  }

  &-info {
    color: $button-info-color;
    background: $button-info-background-color;
    background-origin: border-box;
    border-color: transparent;

    &-children {
      color: $button-info-color;
    }

    &-solid-disabled {
      background: $button-info-disabled;
      border-color: $button-info-disabled;
    }

    &-outline,
    &-dashed {
      color: $button-info-border-color;
      border-color: $button-info-border-color;

      &-disabled {
        color: $button-info-disabled;
        border-color: $button-info-disabled;
      }
    }

    &-none {
      color: $button-info-border-color;
      &-disabled {
        color: $button-info-disabled;
      }
    }
  }

  &-danger {
    color: $button-danger-color;
    background: $button-danger-background-color;
    background-origin: border-box;
    border-color: transparent;

    &-children {
      color: $button-danger-color;
    }

    &-solid-disabled {
      background: $button-danger-disabled;
      border-color: $button-danger-disabled;
    }

    &-outline,
    &-dashed {
      color: $button-danger-border-color;
      border-color: $button-danger-border-color;

      &-disabled {
        color: $button-danger-disabled;
        border-color: $button-danger-disabled;
      }
    }

    &-none {
      color: $button-danger-border-color;
      &-disabled {
        color: $button-danger-disabled;
      }
    }
  }

  &-warning {
    color: $button-warning-color;
    background: $button-warning-background-color;
    background-origin: border-box;
    border-color: transparent;

    &-children {
      color: $button-warning-color;
    }

    &-disabled,
    &-solid-disabled {
      color: $button-warning-color;
      background: $button-warning-disabled;
      border-color: $button-warning-disabled;
    }

    &-outline,
    &-dashed {
      color: $button-warning-border-color;
      border-color: $button-warning-border-color;

      &-disabled {
        color: $button-warning-disabled;
        border-color: $button-warning-disabled;
      }
    }

    &-none {
      color: $button-warning-border-color;
      &-disabled {
        color: $button-warning-disabled;
      }
    }
  }

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

  &-outline {
    background: transparent;
    border-style: solid;
  }

  &-dashed {
    background: transparent;
    border-style: dashed;
  }

  &-none {
    background: transparent;
    border-color: transparent;
  }

  &-loading {
    cursor: default;
    opacity: 0.9;
  }

  &-square {
    border-radius: $button-square-border-radius;
  }
}

[dir='rtl'] .nut-button,
.nut-rtl .nut-button {
  &-text {
    margin-left: 0;
    margin-right: $button-text-icon-margin;

    &.right {
      margin-left: $button-text-icon-margin;
    }
  }

  &::before {
    left: auto;
    right: 50%;
    transform: translate(50%, -50%);
  }
}


.nut-button-xlarge {
  border-radius: $button-xlarge-border-radius;
  .iconfont {
    font-size: $button-icon-font-size;
  }
}

.nut-button-large {
  border-radius: $button-large-border-radius;
  .iconfont {
    font-size: $button-icon-font-size;
  }
}

.nut-button-default {
  .iconfont {
    font-size: $button-icon-font-size;
  }
}

.nut-button-small {
  border-radius: $button-small-border-radius !important;
  .iconfont {
    font-size: $button-small-icon-font-size;
  }
}

.nut-button-mini {
  border-radius: $radius-1 !important;
  position: relative;
  border-style: none;

  .iconfont {
    font-size: $button-mini-icon-font-size;
  }

  &.nut-button-outline,
  &.nut-button-default,
  &.nut-button-dashed {
    &::after {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      box-sizing: border-box;
      width: 200%;
      height: 200%;
      border: 1px solid;
      border-radius: calc($radius-1 * 2);
      transform: scale(0.5);
      content: '';
    }
  }

  &.nut-button-dashed {
    border: 0;
    &::after {
      border: 1px dashed inherit;
    }
  }
  &.nut-button-default {
    &::after {
      border-color: $button-default-border-color;
    }
  }
}
.nut-button-round-mini {
  &::after {
    border-radius: 24px !important;
  }
}

.nut-button-disabled {
  opacity: $color-disabled-opacity;
}

.nut-button-none {
  border: transparent !important;
}

.nut-button-dashed {
  border: $button-border-width dashed;
}

.nut-button-square {
  border-radius: 0 !important;
}

.nut-button-round {
  border-radius: $radius-circle !important;
}

.nut-button-solid.nut-button-disabled {
  color: $white !important;
}

.nut-button {
  &:active::before {
    opacity: 0.08;
  }
}

.nut-button-default-outline-disabled,
.nut-button-default-dashed-disabled {
  color: $button-default-color;
}

.nut-button.nut-button-icononly {
  width: auto;
  padding: $button-large-padding;
}

.mj-button {
  border-radius: $button-border-radius;
  // 设置inline-block父元素高度会变大
  vertical-align: bottom;
  font-weight: $font-weight-bold !important;
}
