@import url(../var.less);
@import url(../components/common/popup.less);
@import url(./button.less);
@import url(./input.less);

@message-box-prefix: ~"@{prefix}message-box";

.@{message-box-prefix}{
  display: inline-block;
  min-width: @msgbox-min-width;
  max-width: @msgbox-max-width;
  vertical-align: middle;
  background-color: @color-white;
  border-radius: @msgbox-border-radius;
  font-size: @messagebox-font-size;
  box-shadow: @msgbox-box-shadow;
  text-align: left;
  overflow: hidden;
  backface-visibility: hidden;
  padding: @messagebox-padding;
  box-sizing: border-box;

  &__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;
    }
  }

  &__header {
    position: relative;
    padding: 22px;
    padding-bottom: 10px;
  }

  &__title {
    padding-left: 0;
    margin-bottom: 0;
    font-size: @messagebox-font-size;
    font-weight: @messagebox-font-weight;
    line-height: 1;
    color: @messagebox-title-color;
  }

  &__headerbtn {
    position: absolute;
    top: 0px;
    right: 0px;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: @message-close-size;
    cursor: pointer;

    .w-message-box__close {
      color: @info-color;
    }

    &:focus, &:hover {
      .w-message-box__close {
        color: @primary-color;
      }
    }
  }

  &__content {
    color: @messagebox-content-color;
    font-size: @messagebox-content-font-size;
    padding: 0 24px;
    margin-bottom: 30px;
  }

  &__content--icon {
    padding: 0 62px;
  }

  &__container {
    position: relative;
  }

  &__input {
    padding-top: 15px;
    & input.invalid {
      border-color: @danger-color;
      &:focus {
        border-color: @danger-color;
      }
    }
  }

  &__status {
    font-size: 20px !important;
    margin-right: 18px;
    vertical-align: middle;

    &::before {
      // 防止图标切割
      padding-left: 1px;
    }

    + .w-message-box__message {
      padding-left: 36px;
      padding-right: 12px;
    }

    &.w-icon-normal {
      color: @messagebox-normal-color;
    }

    &.w-icon-success {
      color: @messagebox-success-color;
    }

    &.w-icon-info {
      color: @messagebox-info-color;
    }

    &.w-icon-warning {
      color: @messagebox-warning-color;
    }

    &.w-icon-error {
      color: @messagebox-danger-color;
    }
  }

  &__message {
    margin: 0;

    & p {
      margin: 0;
      line-height: 24px;
    }
  }

  &__errormsg {
    color: @danger-color;
    font-size: @messagebox-error-font-size;
    min-height: 18px;
    margin-top: 2px;
  }

  &__btns {
    text-align: right;

    & button:nth-child(2) {
      margin-left: 10px;
    }
  }

  &__btns-reverse {
    flex-direction: row-reverse;
  }

  &--center {

    .w-message-box__header {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .w-message-box__btns, .w-message-box__content {
      text-align: center;
    }
  }
}

.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;
  }
}