@import '../../style/themes/index';
@import '../../style/mixins/index';
@import './customize.less';

@notification-prefix-cls: ~'@{ant-prefix}-notification';
@notification-width: 384px;
@notification-padding: @notification-padding-vertical @notification-padding-horizontal;
@notification-margin-bottom: 16px;
@notification-margin-edge: 30px;

.@{notification-prefix-cls} {
  .reset-component;

  position: fixed;
  z-index: @zindex-notification;
  margin-right: @notification-margin-edge;

  &-topLeft,
  &-bottomLeft {
    margin-right: 0;
    margin-left: @notification-margin-edge;

    .@{notification-prefix-cls}-fade-enter.@{notification-prefix-cls}-fade-enter-active,
    .@{notification-prefix-cls}-fade-appear.@{notification-prefix-cls}-fade-appear-active {
      animation-name: NotificationLeftFadeIn;
    }
  }

  &-close-icon {
    color: @grey-6;
    font-size: @font-size-lg;
    cursor: pointer;
  }

  &-hook-holder,
  &-notice {
    position: relative;
    width: @notification-width;
    max-width: ~'calc(100vw - @{notification-margin-edge} * 2)';
    margin-bottom: @notification-margin-bottom;
    margin-left: auto;
    background: @notification-bg;
    border-radius: @border-radius-base;
    box-shadow: @shadow-2;

    .@{notification-prefix-cls}-topLeft &,
    .@{notification-prefix-cls}-bottomLeft & {
      margin-right: auto;
      margin-left: 0;
    }
    &-content {
      overflow: hidden;
    }
  }

  &-hook-holder > &-notice {
    margin-bottom: 0;
    box-shadow: none;
  }

  &-notice {
    line-height: @line-height-base;
    border: 1px solid #dadfe6;

    &-message {
      display: inline-block;
      margin-bottom: 12px;
      color: @heading-color;
      font-weight: 600;
      font-size: @font-size-lg;
      line-height: 22px;

      // https://github.com/ant-design/ant-design/issues/5846#issuecomment-296244140
      &-single-line-auto-margin {
        display: block;
        width: ~'calc(@{notification-width} - @{notification-padding-horizontal} * 2 - 24px - 48px - 100%)';
        max-width: 4px;
        background-color: transparent;
        pointer-events: none;
        &::before {
          display: block;
          content: '';
        }
      }
    }

    &-description {
      font-size: @font-size-base;
    }

    &-closable &-message {
      padding-right: 24px;
    }

    &-main {
      padding: @notification-padding;
      &-success {
        border-left: 2px solid @success-color;
      }
      &-info {
        border-left: 2px solid @info-color;
      }
      &-warning {
        border-left: 2px solid @warning-color;
      }
      &-error {
        border-left: 2px solid @error-color;
      }
    }

    // &-with-icon &-message {
    //   margin-bottom: 4px;
    //   margin-left: 48px;
    //   font-size: @font-size-lg;
    // }

    // &-with-icon &-description {
    //   margin-left: 48px;
    //   font-size: @font-size-base;
    // }

    // Icon & color style in different selector level
    // https://github.com/ant-design/ant-design/issues/16503
    // https://github.com/ant-design/ant-design/issues/15512
    &-icon {
      position: absolute;
      top: 16px;
      left: -15px;
      width: 30px;
      height: 30px;
      color: #fff;
      font-size: 16px;
      line-height: 30px;
      border-radius: 30px;
    }

    .@{iconfont-css-prefix}&-icon {
      &-success {
        background-color: @success-color;
      }
      &-info {
        background-color: @info-color;
      }
      &-warning {
        background-color: @warning-color;
      }
      &-error {
        background-color: @error-color;
      }
    }

    &-close {
      position: absolute;
      top: 14px;
      right: 16px;
      color: @text-color-secondary;
      outline: none;

      &:hover {
        .anticon {
          color: @grey-8;
        }
      }
    }

    &-btn {
      display: inline-block;
      margin-top: 20px;
    }
  }

  .notification-fade-effect {
    animation-duration: 0.24s;
    animation-timing-function: @ease-in-out;
    animation-fill-mode: both;
  }

  &-fade-enter,
  &-fade-appear {
    opacity: 0;
    .notification-fade-effect();

    animation-play-state: paused;
  }

  &-fade-leave {
    .notification-fade-effect();

    animation-duration: 0.2s;
    animation-play-state: paused;
  }

  &-fade-enter&-fade-enter-active,
  &-fade-appear&-fade-appear-active {
    animation-name: NotificationFadeIn;
    animation-play-state: running;
  }

  &-fade-leave&-fade-leave-active {
    .@{notification-prefix-cls}-notice-content {
      animation-name: NotificationContentFadeOut;
      animation-duration: 0.2s;
      animation-play-state: running;
    }
    animation-name: NotificationFadeOut;
    animation-play-state: running;
  }
}

@keyframes NotificationFadeIn {
  0% {
    left: @notification-width;
    opacity: 0;
  }
  100% {
    left: 0;
    opacity: 1;
  }
}

@keyframes NotificationLeftFadeIn {
  0% {
    right: @notification-width;
    opacity: 0;
  }
  100% {
    right: 0;
    opacity: 1;
  }
}

@keyframes NotificationFadeOut {
  0% {
    max-height: 150px;
    margin-bottom: @notification-margin-bottom;
    opacity: 1;
  }
  100% {
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
  }
}
@keyframes NotificationContentFadeOut {
  0% {
    max-height: 150px;
    opacity: 1;
  }
  100% {
    max-height: 0;
    opacity: 0;
  }
}

@import './rtl';
