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

@include b(message-box) {
  position: relative;
  display: inline-block;
  width: $--msgbox-width;
  background-color: $--color-white;
  border-radius: $--msgbox-border-radius;
  box-shadow: $--box-shadow-base;
  font-size: $--messagebox-font-size;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  backface-visibility: hidden;

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

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

  @include e(header) {
    padding: 16px 24px;
    padding-right: 100px;
    position: relative;
    background-color: $--color-black-4;
    border-radius: $--border-radius-base $--border-radius-base 0 0;
  }

  @include e(title) {
    font-size: $--messagebox-font-size;
    color: $--messagebox-title-color;
    line-height: 1.2;
    font-family: $--font-family-title;
  }

  @include e(titleplace) {
    width: 20px;
    height: 24px;
  }

  @include e(headerbtn) {
    position: absolute;
    top: ($--dialog-padding-primary - 4px);
    right: ($--dialog-padding-primary + 8px);
    padding: 0;
    width: $--dialog-headerbtn-width;
    height: $--dialog-headerbtn-height;
    border: $--border-base;
    border-color: $--button-default-border-color;
    border-radius: 4px;
    outline: none;
    background: transparent;
    font-family: $--font-family-XBS;
    font-size: $--message-close-size;
    cursor: pointer;

    .el-message-box__close {
      color: $--color-black-45;
      &:focus, &:hover {
        color: $--color-black-65;
      }
    }
    &:hover {
      background: $--color-black-6;
    }

  }

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

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

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

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

  @include e(status) {
    position: absolute;
    // top: 50%;
    // transform: translateY(-50%);
    font-size: 22px !important;
    height: 26px;
    line-height: 26px;

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

    + .el-message-box__message {
      padding-left: 32px;
    }

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

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

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

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

  @include e(message) {
    margin: 0;

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

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



  @include e(btns) {
    padding: 10px 24px;
    text-align: right;
    & button {
      font-size: $--font-size-base;
    }
    .el-button {
      margin: 0 !important;
      margin-left: 12px !important;
      padding: 10px 16px;
    }

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

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

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

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

    @include e(status) {
      position: relative;
      top: auto;
      padding-right: 5px;
      text-align: center;
      transform: translateY(-1px);
    }

    @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;
  }
}
