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

@include b(alert) {
  @include set-component-css-var('alert', $alert);
  position: relative;
  width: 100%;
  padding: 8px 16px;
  margin: 0;
  box-sizing: border-box;
  border-radius: getCssVar('border-radius-small');
  border-width: getCssVar('border-width');
  border-style: getCssVar('border-style');
  border-color: getCssVar('alert', 'border-color');
  position: relative;
  background-color: getCssVar('color', 'neutral-light-1');
  overflow: hidden;
  opacity: 1;
  display: flex;

  // align-items: center;
  transition: opacity getCssVar('transition-duration', 'fast');

  @include when(light) {
    .#{$namespace}-alert__close-btn {
      color: getCssVar('text-color', 'placeholder');
    }
  }

  @include when(dark) {
    .#{$namespace}-alert__close-btn {
      color: getCssVar('color', 'white');
    }
    .#{$namespace}-alert__description {
      color: getCssVar('color', 'white');
    }
  }

  @include when(center) {
    justify-content: center;
  }

  @each $type in $semantic {
    @include m($type) {
      @include css-var-from-global(('alert', 'bg-color'), ('color', if(sass($type == 'info'): 'neutral' ; else: $type), 'light-1'));
      @include css-var-from-global(('alert', 'border-color'), ('color', if(sass($type == 'info'): 'neutral' ; else: $type), 'light-3'));

      &.is-light {
        background-color: getCssVar('alert', 'bg-color');
        color: getCssVar('color', if(sass($type == 'info'): 'neutral' ; else: $type), 'light-6');

        .#{$namespace}-alert__description {
          color: getCssVar('color', if(sass($type == 'info'): 'neutral' ; else: $type), 'light-6');
          line-height: 14px;
          margin-left: -16px;
        }
      }

      &.is-dark {
        background-color: getCssVar('color', if(sass($type == 'info'): 'neutral' ; else: $type));
        color: getCssVar('color', 'white');
      }

      @include when(light) {
        .#{$namespace}-alert__close-btn {
          color: getCssVar('color', if(sass($type == 'info'): 'neutral' ; else: $type), 'light-6');
        }
      }
    }
  }

  $material-icons-font-family: 'Material Symbols Outlined';

  &::before {
    font-family: $material-icons-font-family !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-style: normal;
    font-variant: normal;
    font-weight: 600;
    speak: never;
    text-transform: none;
    font-size: getCssVar('alert', 'icon-size');
    margin-right: 5px;
    content: 'info';
    font-weight: 500;
    width: 12px;
    height: 18px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .el-alert__title {
    // padding-left: 17px;
  }

  .el-alert__icon {
    display: none;
  }

  @include e(content) {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  & .#{$namespace}-alert__icon {
    font-size: getCssVar('alert', 'icon-size');
    width: getCssVar('alert', 'icon-size');
    margin-right: 8px;
    margin-top: 3px;

    @include when(big) {
      font-size: getCssVar('alert', 'icon-large-size');
      width: getCssVar('alert', 'icon-large-size');
      margin-right: 12px;
      // align-self: center;
    }
  }

  @include e(title) {
    font-size: getCssVar('alert', 'title-font-size');
    line-height: 18px;

    &.with-description {
      font-size: getCssVar('alert', 'title-with-description-font-size');
      line-height: 14px;
      margin-top: 2px;
    }
  }

  & .#{$namespace}-alert__description {
    font-size: getCssVar('alert', 'description-font-size');
    margin: 0;
  }

  & .#{$namespace}-alert__close-btn {
    font-size: getCssVar('alert', 'close-font-size');
    opacity: 1;
    position: absolute;
    top: 11px;
    right: 16px;
    cursor: pointer;

    @include when(customed) {
      font-style: normal;
      font-size: getCssVar('alert', 'close-customed-font-size');
      line-height: 24px;
      top: 8px;
    }
  }
}

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