@import "../base.scss";
@import "../mixins/mixins.scss";

@include b(button) {
  display: inline-block;
  line-height: 1;
  background: $mc4;
  color: $textPrimary;
  border-radius: 4px;
  user-select: none;
  outline: none;
  transition: all 0.3s ease-in-out;
  font-size: 14px;
  border: 1px solid $borderBase;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;

  &:hover {
    background: $mc3;
    border-color: $mc5;
    color: $mc;
  }

  // &:focus {
  //   background: $mc1;
  //   border-color: $mc1;
  // }
  &+& {
    margin-left: 12px;
    // margin-bottom: 12px;;
  }

  &:active {
    background: $mc3;
    border-color: $mc2;
  }

  &.ss-button__medium {
    padding: 0 16px;
    min-width: 74px;
    min-height: 32px;

    &+& {
      margin-left: 12px;
    }
  }

  &.ss-button__small {
    padding: 5px 8px;
    min-width: 58px;
    min-height: 24px;
    font-size: 12px;

    &+& {
      margin-left: 12px;
    }
  }

  &.ss-button__big {
    padding: 12px 24px;
    min-width: 96px;
    min-height: 40px;
    font-size: 16px;

    &+& {
      margin-left: 12px;
    }
  }

  &.ss-button__plain {
    background: $mc4;
    border-radius: 4px;
    border: 1px solid $borderBase;
    color: $textPrimary;

    &:hover {
      color: $mc;
      border-color: $mc;
    }

    // &:hover, &:focus {
    //     color: $mc1;
    //     border-color: $mc1;
    // }
    &:active {
      color: $mc2;
      border-color: $mc2;
    }
    &.ss-button__disabled {
      cursor: not-allowed;
      color: #C0C4CC;
      background: $white;
      border: 1px solid $borderBase;
    }
  }
  &.ss-button__loading {
    color: $textPrimary;
  }

  &.ss-button__text {

    &:hover,
    &:focus {
      color: $mc1;
    }

    &:active {
      color: $mc2;
    }
  }

  &.ss-button__disabled {
    cursor: not-allowed;
    color: #C0C4CC;
    background: $white;
    border: 1px solid $borderBase;
  }

  /* 幽灵状态 */
  &.ss-button-background__ghost {
    opacity: 0.4;
    cursor: not-allowed;
  }

  &.ss-button__primary {
    background: $mc;
    color: $mc4;

    &:hover {
      color: $mc4;
      background: $mc1;
      border-color: $mc1;
    }

    &:active {
      color: $mc4;
      background: $mc2;
      border-color: $mc2;
    }

    &.ss-button__plain {
      background: $mc3;
      border: 1px solid $mc5;
      color: $mc;

      &:hover {
        color: $mc;
        border-color: $mc;
      }

      &:active {
        background: $mc3;
        color: $mc2;
        border-color: $mc2;
      }

      &.ss-button__disabled {
        cursor: not-allowed;
        color: $mc5;
        background: $white;
        border: 1px solid $mc3;
      }
    }

    &.ss-button__disabled {
      cursor: not-allowed;
      color: $white;
      background: $mc5;
      border: 1px solid $mc5;
    }
  }

  &.ss-button__success {
    background: $sc;
    color: $sc4;

    &:hover {
      background: $sc1;
      border-color: $sc1;
    }

    &:active {
      background: $sc2;
      border-color: $sc2;
    }

    &.ss-button__plain {
      background: $sc3;
      border: 1px solid $sc5;
      color: $sc;

      &:hover {
        color: $sc;
        background: $sc3;
        border-color: $sc;
      }

      &:active {
        background: $sc3;
        color: $sc2;
        border-color: $sc2;
      }

      &.ss-button__disabled {
        cursor: not-allowed;
        color: $sc5;
        background: $white;
        border: 1px solid $sc3;
      }
    }

    &.ss-button__disabled {
      cursor: not-allowed;
      color: $white;
      background: $sc5;
      border: 1px solid $sc5;
    }
  }

  &.ss-button__warning {
    background: $wc;
    color: $wc4;

    &:hover {
      background: $wc1;
      border-color: $wc1;
    }

    &:active {
      background: $wc2;
      border-color: $wc2;
    }

    &.ss-button__plain {
      background: $wc3;
      border: 1px solid $wc5;
      color: $wc;

      &:hover {
        color: $wc;
        background: $wc3;
        border-color: $wc;
      }

      &:active {
        background: $wc3;
        color: $wc2;
        border-color: $wc2;
      }

      &.ss-button__disabled {
        cursor: not-allowed;
        color: $wc5;
        background: $white;
        border: 1px solid $wc3;
      }
    }

    &.ss-button__disabled {
      cursor: not-allowed;
      color: $white;
      background: $wc5;
      border: 1px solid $wc5;
    }
  }

  &.ss-button__danger {
    background: $ec;
    color: $ec4;

    &:hover {
      background: $ec1;
      border-color: $ec1;
    }

    &:active {
      background: $ec2;
      border-color: $ec2;
    }

    &.ss-button__plain {
      background: $ec3;
      border: 1px solid $ec5;
      color: $ec;

      &:hover {
        color: $ec;
        background: $ec3;
        border-color: $ec;
      }

      &:active {
        background: $ec3;
        color: $ec2;
        border-color: $ec2;
      }

      &.ss-button__disabled {
        cursor: not-allowed;
        color: $ec5;
        background: $white;
        border: 1px solid $ec3;
      }
    }

    &.ss-button__disabled {
      cursor: not-allowed;
      color: $white;
      background: $ec5;
      border: 1px solid $ec5;
    }
  }

  /*TODO：按钮大小适配*/
  &.ss-button__text {
    border: 0 !important;
    padding: 0;
    min-width: 0px;
    font-weight: 400;
    color: $mc;
    line-height: 32px;
    background: none;

    &.ss-button__disabled {
      background: none;
      border: none;

      &:hover,
      &:focus,
      &:active {
        background: none;
        border: none;
      }
    }
  }



  @include e(content) {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ss-button-loading-icon {
    width: 1em;
    height: 1em;
    margin-right: 6px;
  }

  &.ss-button__loading {
    &.ss-button__medium {
      padding: 0 6px;
    }

    &.ss-button__big {
      padding: 0 21px;
    }
  }
}
