@use 'sass:map';

@use 'mixins/mixins' as *;
@use 'mixins/var' as *;
@use 'common/var' as *;

@include b(alert) {
  // @include set-component-css-var('alert', $alert);

  width: 100%;
  padding: 8px 12px;
  margin: 0;
  box-sizing: border-box;
  border-radius: getCssVar('border-radius-md');
  position: relative;
  overflow: hidden;
  opacity: 1;
  display: flex;
  align-items: flex-start;
  transition: opacity getCssVar('transition-duration', 'fast');

  @include when(center) {
    text-align: center;
  }

  @each $type in (success, info, warning, error) {
    $color: map.get($colorStatusMap, $type);

    @include m($type) {
      &.is-light {
        background-color: getCssVar('color', $color, '1');
        color: getCssVar('color', $color, '4');

        .#{$namespace}-alert__description {
          color: getCssVar('color', $color, '4');
        }
      }

      &.is-dark {
        background-color: getCssVar('color', $color, '4');
        color: getCssVar('color-white');
      }
    }
  }

  @include e(content) {
    display: flex;
    flex-direction: column;
    flex-grow: 1;

    &:not(:only-child) {
      margin-top: 3px;
    }
  }

  & .#{$namespace}-alert__icon {
    font-size: 24px;
    width: 24px;
    margin-right: 8px;
  }

  @include e(title) {
    font-size: 14px;
    line-height: 18px;
    font-weight: 600;
  }

  & .#{$namespace}-alert__description {
    font-size: 12px;
    line-height: 16px;
    margin-top: 4px;
    margin-bottom: 0;
  }

  & .#{$namespace}-alert__close-btn {
    margin-left: 8px;
    padding: 4px;
    height: 24px;
    font-size: 16px;
    opacity: 1;
    cursor: pointer;
    border-radius: getCssVar('border-radius-sm');

    &:hover {
      background-color: rgba($color: #000000, $alpha: 0.05);
    }

    @include when(customed) {
      font-size: 12px;
      font-weight: 600;
      line-height: 16px;
      padding: 4px 8px;
    }
  }
}

.#{$namespace}-alert-fade-enter-from,
.#{$namespace}-alert-fade-leave-active {
  opacity: 0;
}
