$bg: #333;
$color: white;
$margin: 20px;

$errorBg: #fff3f6;
$errorColor: #cb0037;

@keyframes toastFadeIn {
  0% {
    opacity: 0;
    margin-bottom: -50px;
  }
  100% {
   opacity: 1;
   margin-bottom: 0;
  }
}

@keyframes toastFadeOut {
  0% {
    opacity: 1;
    margin-bottom: 0;
  }
  100% {
    opacity: 0;
    margin-bottom: -50px;
  }
}

.toast {
  display: flex;
  flex-direction: column-reverse;
  z-index: 999;
  position: fixed;
  bottom: $margin;
  right: $margin;
  width: 400px;

  &__alert {
    background: $bg;
    color: $color;
    margin-top: $margin/2;
    padding: $margin/2 $margin;
    width: 100%;
    position: relative;
    animation: toastFadeIn 0.25s ease;
    z-index: 1;
    &--closing {
      animation: toastFadeOut 0.5s forwards ease;
      z-index: 0;
    }
    &--error {
      background-color: $errorBg;
      color: $errorColor;
      border: 1px solid $errorColor;
    }
  }

  &__message {
    width: calc(100% - #{$margin});
  }

  &__close {
    position: absolute; 
    right: 0; 
    bottom: 0;
    top: 0;
    height: $margin;
    width: $margin;
    margin: auto $margin;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;

    &:before, &:after {
      content: "";
      width: calc(100% - 2px); 
      height: 1px;
      background-color: $color;
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0; 
      right: 0;
      margin: auto;
      display: block;
    }
    &:before {
      transform: rotate(45deg);
    }
    &:after {
      transform: rotate(-45deg);
    }

    &--error {
      &:before, &:after {
        background-color: $errorColor;
      }
    }
  }

}