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

@alert-prefix-cls: ~'@{ant-prefix}-alert';

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

  position: relative;
  padding: 8px 15px 8px 38px;
  word-wrap: break-word;
  border-radius: @border-radius-base;

  &&-no-icon {
    padding: @alert-no-icon-padding-vertical 19px;
    .@{alert-prefix-cls}-close-icon {
      top: @alert-no-icon-padding-vertical + @font-size-base * @line-height-base / 2 -
        @font-size-base / 2;
    }
  }

  &&-closable {
    padding-right: 30px;
  }

  &-icon {
    position: absolute;
    top: @alert-icon-top;
    left: 15px;
    font-size: @font-size-lg;
  }

  &-description {
    display: none;
    font-size: @font-size-sm;
    line-height: 18px;
  }

  &-success {
    background-color: @alert-success-bg-color;
    border: @border-width-base @border-style-base @alert-success-border-color;
    .@{alert-prefix-cls}-icon {
      color: @alert-success-icon-color;
    }
  }

  &-info {
    background-color: @alert-info-bg-color;
    border: @border-width-base @border-style-base @alert-info-border-color;
    .@{alert-prefix-cls}-icon {
      color: @alert-info-icon-color;
    }
  }

  &-warning {
    background-color: @alert-warning-bg-color;
    border: @border-width-base @border-style-base @alert-warning-border-color;
    .@{alert-prefix-cls}-icon {
      color: @alert-warning-icon-color;
    }
  }

  &-error {
    background-color: @alert-error-bg-color;
    border: @border-width-base @border-style-base @alert-error-border-color;

    .@{alert-prefix-cls}-icon {
      color: @alert-error-icon-color;
    }

    .@{alert-prefix-cls}-description > pre {
      margin: 0;
      padding: 0;
    }
  }

  &-close-icon {
    position: absolute;
    top: 8px + @font-size-base * @line-height-base / 2 - @font-size-base / 2;
    right: 9px;
    padding: 0;
    overflow: hidden;
    color: @grey-6;
    font-size: @font-size-base;
    line-height: @font-size-base;
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;

    .@{iconfont-css-prefix}-close {
      color: @alert-close-color;
      transition: color 0.3s;
      &:hover {
        color: @alert-close-hover-color;
      }
    }
  }

  &-close-text {
    color: @alert-close-color;
    transition: color 0.3s;
    &:hover {
      color: @alert-close-hover-color;
    }
  }

  &-with-description {
    position: relative;
    padding: @alert-with-description-padding;
    color: @grey-7;
    line-height: @line-height-base;
    border-radius: @border-radius-base;
  }

  &-with-description&-no-icon {
    padding: @alert-with-description-no-icon-padding-vertical 10px
      @alert-with-description-no-icon-padding-vertical 15px;
  }

  &-with-description &-icon {
    position: absolute;
    left: 15px;
  }
  &-with-description&-grey-background {
    padding: 10px 10px 10px 34px;
  }
  &-with-description&-grey-background &-icon {
    top: 12px;
    left: 12px;
  }

  &-with-description &-close-icon {
    position: absolute;
    top: 14px;
    right: 9px;
    font-size: @font-size-base;
    cursor: pointer;
  }
  &-with-description&-grey-background &-close-icon {
    top: 15px;
  }
  &-with-description &-message {
    display: block;
    margin-bottom: 4px;
    color: @alert-message-color;
    font-size: @font-size-base;
    line-height: 20px;
  }

  &-message {
    color: @alert-message-color;
  }

  &-with-description &-description {
    display: block;
  }

  &&-closing {
    height: 0 !important;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    transform-origin: 50% 0;
    transition: all 0.3s @ease-in-out-circ;
  }

  &-slide-up-leave {
    animation: antAlertSlideUpOut 0.3s @ease-in-out-circ;
    animation-fill-mode: both;
  }

  &-grey-background {
    padding-top: 9px;
    padding-bottom: 9px;
    background-color: #f5f7fa;

    border-top: none;
    border-right: 1px solid #f5f7fa;
    border-bottom: none;
    border-radius: 0;
  }
  &-grey-background&-no-icon {
    padding-left: 16px;
  }
  &-grey-background &-icon {
    top: 12px;
    left: 12px;
  }
  &-grey-background&-success {
    border-left: 4px @border-style-base @green-4;
  }
  &-grey-background&-info {
    border-left: 4px @border-style-base @blue-4;
  }
  &-grey-background&-warning {
    border-left: 4px @border-style-base @alert-warning-border-color;
  }
  &-grey-background&-error {
    border-left: 4px @border-style-base @red-4;
  }

  &-banner {
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
  }
  &-banner&-success {
    box-shadow: inset 0 -1px 0 0 @green-4;
  }
  &-banner&-info {
    box-shadow: inset 0 -1px 0 0 @blue-4;
  }
  &-banner&-warning {
    box-shadow: inset 0 -1px 0 0 @alert-warning-border-color;
  }
  &-banner&-error {
    box-shadow: inset 0 -1px 0 0 @red-4;
  }
  &-no-background {
    background-color: transparent;
    border: 0;
  }
}

@keyframes antAlertSlideUpIn {
  0% {
    transform: scaleY(0);
    transform-origin: 0% 0%;
    opacity: 0;
  }
  100% {
    transform: scaleY(1);
    transform-origin: 0% 0%;
    opacity: 1;
  }
}

@keyframes antAlertSlideUpOut {
  0% {
    transform: scaleY(1);
    transform-origin: 0% 0%;
    opacity: 1;
  }
  100% {
    transform: scaleY(0);
    transform-origin: 0% 0%;
    opacity: 0;
  }
}

@import './rtl';
