@import '../style/variable.less';
@import '../style/mixins.less';

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

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

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

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

    .@{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 {
    font-size: @font-size-base;
    cursor: pointer;
  }

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

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

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

    &-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;
      margin-left: 4px;
      font-size: 24px;
      line-height: 24px;
      top: 12px;
    }

    .@{iconfont-css-prefix}&-icon {
      height: 20px;
      &-success {
        color: @success-color;
      }
      &-info {
        color: var(--notificationsInfoIcon-foreground);
      }
      &-warning {
        color: var(--notificationsWarningIcon-foreground);
      }
      &-error {
        color: var(--notificationsErrorIcon-foreground);
      }
    }

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

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

    &-btn {
      display: flex;
      flex-flow: wrap;
      align-items: center;
      justify-content: flex-end;
      margin-top: 16px;
    }
  }

  .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 {
    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;
    padding-top: @notification-padding;
    padding-bottom: @notification-padding;
    opacity: 1;
  }
  100% {
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
  }
}

.@{notification-prefix-cls}-wrapper {
  background: var(--notifications-background);
  border-color: var(--notifications-border);
  padding: 12px;
  position: relative;

  .@{iconfont-css-prefix} {
    font-size: 12px;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .@{notification-prefix-cls}-notice {
    &-message,
    &-description {
      width: calc(100% - 48px);
      color: var(--notifications-foreground);
      font-size: 12px;
      margin-left: 24px;
      margin-right: 24px;
      margin-bottom: 0;
      line-height: 20px;

      // Hacking markdown style
      code {
        display: inline-block;
        word-wrap: break-word;
        overflow: hidden;
        width: 100%;
        text-overflow: ellipsis;
      }

      p,
      pre {
        margin-bottom: 0;
      }
    }

    &-description {
      margin-top: 4px;
      margin-bottom: 4px;
    }

    &-close {
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--notifications-foreground);
      font-size: 12px;
      line-height: 20px;
      right: 18px;
      top: 12px;
    }

    &-btn button {
      flex: 0 0 auto;
      margin: 0 0 5px 10px;
      word-break: keep-all;
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding: 0 5px;
      box-sizing: content-box;
      display: inline-block;
    }
  }
}
