@use './theme.scss' as *;

$alert: 'alert';
$alert-types: (
  'success': 'success',
  'error': 'error',
  'warning': 'warning',
  'info': 'info',
);

@mixin alert-type-modifiers() {
  @each $type, $color-var in $alert-types {
    &--#{$type} {
      &::before {
        background-image: alert-theme-color($type + '-bar');
      }

      &::after {
        background-image: radial-gradient(
            100% 100% at 0% 0%,
            alert-theme-color($type + '-primary-border'),
            alert-theme-color($type + '-secondary-border')
          ),
          radial-gradient(
            100% 100% at 100% 100%,
            alert-theme-color($type + '-primary-border'),
            alert-theme-color($type + '-secondary-border')
          );
      }
    }
  }
}

.#{$alert} {
  @include alert-theme-modifiers();
  @include alert-type-modifiers();

  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
  padding: 1px;
  background-image: alert-theme-color('background');
  overflow: hidden;

  &::before {
    content: '';
    flex-shrink: 0;
    width: 10px;
    align-self: stretch;
    border-top-left-radius: 9px;
    border-bottom-left-radius: 9px;
  }

  &::after {
    content: '';
    position: absolute;
    z-index: 1;
    inset: 0;
    padding: 1px;
    border-radius: 10px;
    pointer-events: none;
    -webkit-mask: linear-gradient(white 0 0) content-box, linear-gradient(white 0 0);
    mask: linear-gradient(white 0 0) content-box, linear-gradient(white 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
  }

  &--small {
    .#{$alert}__container {
      padding: 15px 12.5px 15px 10px;
      gap: 10px;
    }

    .#{$alert}__icon {
      width: 30px;
      height: 30px;
    }
  }

  &__container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
  }

  &__icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
  }

  &__content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-right: auto;
    overflow-wrap: break-word;
    overflow: hidden;
  }

  &__title,
  &__text {
    max-width: 100%;
  }

  &__action,
  &__close {
    flex-shrink: 0;
  }

  &__link {
    flex-shrink: 0;
    margin-left: 5px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted alert-theme-color('link-border');
  }
}
