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

@include b(message-box) {
  display: inline-block;
  width: 280px;
  padding-bottom: 24px;
  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-heavy;
  text-align: center;
  overflow: hidden;
  backface-visibility: hidden;

  @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-header-padding-primary;
    padding-bottom: 6px;
    padding-top: 6px;
    background-color: #EFF2F7;
    border-bottom: 1px solid #e4e4e4;
  }

  @include e(title) {
    padding-left: 0;
    margin-bottom: 0;
    font-size: $--size-base;
    line-height: 20px;
    text-align: left;
    height: 20px;
    color: $--messagebox-title-color;
  }

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

    .el-message-box__close {
      color: $--color-default-text-plain;
    }

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

  }

  @include e(content) {
    padding: $--dialog-padding-primary;
    color: $--messagebox-content-color;
    font-size: $--messagebox-content-font-size;
    position: relative;
  }
  
  @include e(container) {
    position: relative;
  }

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

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

  @include e(status) {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px !important;

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

    + .el-message-box__message {
      padding-left: 34px;
      padding-right: 8px;
    }

    &.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;
    display: inline-block;
    & p {
      margin: 0;
      text-align: left;
      line-height: 24px;
      & .mes {
        line-height: 32px;display: block; font-size: 14px; color: #333;
      }
      & .tip {
        line-height: 24px;display: block; font-size: 12px; color: #999;
      }
    }
  }

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

  @include e(btns) {
    padding: 0 16px;
    display: inline-block;
    & button{
      padding: 9px 15px;
      font-size: 12px;
      border-radius: 3px;
      margin: 0;
    }
    & button:nth-child(1) {
       color: $--color-text-secondary;
       background-color: $--color-white;
       border-color: $--color-text-placeholder;
       float: right;
       margin-left: 16px;
       &:focus, &:hover {
        color:$--color-primary-text-plain-hover;
        background-color: $--color-primary-background-plain-hover;
        border-color:$--color-primary-border-plain-hover;
      }
    }
    & button:nth-child(2) {
      
    }
  }

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

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

    @include e(header) {
    }

    @include e(title) {
      position: relative;
      background-color: #EFF2F7;
      display: flex;
      align-items: 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;
  }
}
