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

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

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

  position: fixed;
  z-index: @yee-zindex-notification;
  width: @yee-notification-width;
  max-width: ~'calc(100vw - 32px)';
  margin-right: 24px;

  &-topLeft,
  &-bottomLeft {
    margin-right: 0;
    margin-left: 24px;

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

  &-close-icon {
    font-size: @yee-font-size-base;
    cursor: pointer;
  }

  &-notice {
    position: relative;
    margin-bottom: @yee-notification-margin-bottom;
    padding: @yee-notification-padding;
    overflow: hidden;
    line-height: 1.5;
    background: @yee-component-background;
    border-radius: @yee-border-radius-base;
    box-shadow: @yee-shadow-2;

    &-message {
      display: inline-block;
      margin-bottom: 8px;
      color: @yee-heading-color;
      font-size: @yee-font-size-lg;
      line-height: 24px;

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

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

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

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

    &-with-icon &-description {
      margin-left: 48px;
      font-size: @yee-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;
      margin-left: 4px;
      font-size: 24px;
      line-height: 24px;
    }

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

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

      &:hover {
        color: shade(@yee-text-color-secondary, 40%);
      }
    }

    &-btn {
      float: right;
      margin-top: 16px;
    }
  }

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

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

    animation-play-state: paused;
  }

  &-fade-leave {
    .yee-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 {
    animation-name: NotificationFadeOut;
    animation-play-state: running;
  }
}

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

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

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