@import "mixins/mixins";
@import "common/var";
@import "common/popup";
@import "button";
@import "input";

@include b(message-box) {
  display: inline-block;
  width: $--msgbox-width;
  padding-bottom: 12px;
  vertical-align: middle;
  background-color: $--color-white;
  border-radius: $--msgbox-border-radius;
  // border: 1px solid $--border-color-lighter;
  font-size: $--messagebox-font-size;
  box-shadow: $--box-shadow-light;
  text-align: left;
  overflow: hidden;
  backface-visibility: hidden;

  &.el-message-box__form {
    .el-message-box__header {
      background-color: $--disabled-fill-base;
      border-bottom: 1px solid $--border-color-light;
      .el-message-box__headerbtn {
        display: block;
      }
    }
    .el-message-box__content {
      padding-top: 24px;
    }
    .el-message-box__btns {
      padding-top: 12px;
      border-top: 1px solid $--border-color-light;
    }
  }

  @include e(wrapper) {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;

    &::after {
      content: "";
      display: inline-block;
      height: 100%;
      width: 0;
      vertical-align: middle;
    }
  }

  @include e(header) {
    position: relative;
    padding: $--msgbox-padding-primary;
    padding-left: 24px;
    padding-bottom: 12px;
  }

  @include e(title) {
    display: flex;
    align-items: center;
    padding-left: 0;
    margin-bottom: 0;
    font-size: $--messagebox-font-size;
    color: $--messagebox-title-color;
    font-weight: 500;
  }

  @include e(headerbtn) {
    display: none;
    position: absolute;
    top: 16px;
    right: 24px;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: $--message-close-size;
    cursor: pointer;

    .el-message-box__close {
      color: $--color-info;
    }

    &:focus,
    &:hover {
      .el-message-box__close {
        color: $--color-primary;
      }
    }

  }

  @include e(content) {
    padding: 0 24px;
    color: $--messagebox-content-color;
    font-size: $--messagebox-content-font-size;
  }

  @include e(container) {
    position: relative;
  }

  @include e(input) {
    padding-top: 15px;

    & input.invalid {
      border-color: $--color-danger;

      &:focus {
        border-color: $--color-danger;
      }
    }
  }

  @include e(status) {
    position: absolute;
    font-size: 24px;

    &::before {
      // 防止图标切割
      padding-left: 1px;
    }

    +.el-message-box__message {
      padding-left: 36px;
      padding-right: 12px;
    }

    &.el-icon-success {
      color: $--messagebox-success-color;
    }

    &.el-icon-info {
      color: $--messagebox-info-color;
    }

    &.el-icon-warning, &.bi-iconfont-error-circle-fill {
      color: $--messagebox-warning-color;
    }

    &.el-icon-error {
      color: $--messagebox-danger-color;
    }

    &.bi-iconfont-close-circle-fill {
      color: $--messagebox-danger-color;
    }

    &.bi-iconfont-info-circle-fill {
      color: $--messagebox-primary-color;
    }

    &+span {
      padding-left: 34px;
    }
  }

  @include e(message) {
    margin: 0;

    & p {
      margin: 0;
      line-height: 24px;
    }
  }

  @include e(errormsg) {
    color: $--color-danger;
    font-size: $--messagebox-error-font-size;
    min-height: 18px;
    margin-top: 2px;
  }

  @include e(btns) {
    padding: 5px 24px 0;
    text-align: right;

    & button:nth-child(2) {
      margin-left: 12px;
    }
  }

  @include e(btns-reverse) {
    flex-direction: row-reverse;
  }

  @include e(icon-wrapper) {
    .el-message-box__header {
      padding: 16px;
      padding-right: 24px;
      padding-bottom: 0;
    }

    .el-message-box__title {
      span {
        font-size: 18px;
        font-weight: 600;
      }
    }

    .el-message-box__content {
      padding: 8px 50px;
    }
  }

  // centerAlign 布局
  @include m(center) {
    padding-bottom: 30px;

    @include e(header) {
      padding-top: 30px;
    }

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

    @include e(status) {
      position: relative;
      padding-right: 5px;
      text-align: center;

      &+span {
        padding-left: 0;
      }
    }

    @include e(message) {
      margin-left: 0;
    }

    @include e((btns, content)) {
      text-align: center;
    }

    @include e(content) {
      $padding-horizontal: $--msgbox-padding-primary + 12px;

      padding-left: $padding-horizontal;
      padding-right: $padding-horizontal;
    }
  }
}

.msgbox-fade-enter-active {
  animation: msgbox-fade-in .3s;
}

.msgbox-fade-leave-active {
  animation: msgbox-fade-out .3s;
}

@keyframes msgbox-fade-in {
  0% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }

  100% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
}

@keyframes msgbox-fade-out {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }

  100% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
}