.toast {
  position: fixed;
  display: flex;
  background-color: #333;
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition-property: opacity, transform;
  transition-timing-function: ease-in-out;
  transition-duration: 300ms;

  &--visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  &--top-left {
    top: 20px;
    left: 20px;
  }

  &--top-right {
    top: 20px;
    right: 20px;
  }

  &--top-right-plus-60 {
    top: 80px;
    right: 20px;
  }

  &--bottom-left {
    bottom: 20px;
    left: 20px;
  }

  &--bottom-right {
    bottom: 20px;
    right: 20px;
  }

  &--center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  &--vertical {
    flex-direction: column;
    align-items: flex-start;
  }

  &--horizontal {
    flex-direction: row;
    align-items: center;
  }

  &--success {
    background-color: #4caf50;
  }

  &--error {
    background-color: #f44336;
  }

  &--warning {
    background-color: #ff9800;
  }

  &--info {
    background-color: #2196f3;
  }

  &__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
  }

  &__message {
    font-size: 16px;
    font-weight: 500;
    margin-right: 16px;
  }

  &__additionalText {
    font-size: 14px;
    color: #999;
    margin-right: 16px;
  }

  &__actions {
    display: flex;
    align-items: center;
    margin-right: 16px;
  }

  &__buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  &__close {
    background-color: transparent;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    transition: opacity 0.3s ease-in-out;

    &:hover {
      opacity: 0.8;
    }
  }

  &__group {
    position: fixed;
    display: flex;
    flex-direction: column;
    gap: var(--toast-group-spacing);
    z-index: 9999;

    &--top-left {
      top: 20px;
      left: 20px;
    }

    &--top-right {
      top: 20px;
      right: 20px;
    }

    &--top-right-plus-60 {
      top: 80px;
      right: 20px;
    }

    &--bottom-left {
      bottom: 20px;
      left: 20px;
    }

    &--bottom-right {
      bottom: 20px;
      right: 20px;
    }

    &--center {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    &--vertical {
      flex-direction: column;
    }

    &--horizontal {
      flex-direction: row;
    }

    &--spacing-16 {
      --toast-group-spacing: 16px;
    }

    &--spacing-24 {
      --toast-group-spacing: 24px;
    }

    &--spacing-32 {
      --toast-group-spacing: 32px;
    }

    &-item {
      flex-shrink: 0;
    }
  }
}

// ======================================== // Media Queries // ========================================
@media (max-width: 1023px) {
  .toast {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 16px;
      right: 16px;
      bottom: 16px;
      left: 16px;
    }

    &__message {
      font-size: 14px;
    }

    &__additionalText {
      font-size: 12px;
    }
  }

  .toast__group {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 16px;
      right: 16px;
      bottom: 16px;
      left: 16px;
    }
  }
}

@media (max-width: 768px) {
  .toast {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 12px;
      right: 12px;
      bottom: unset;
      left: unset;
    }

    &__message {
      font-size: 13px;
    }

    &__additionalText {
      font-size: 11px;
    }
  }

  .toast__group {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 12px;
      right: 12px;
      bottom: unset;
      left: unset;
    }
  }
}

@media (max-width: 480px) {
  .toast {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 8px;
      right: 8px;
      bottom: unset;
      left: unset;
    }

    &__message {
      font-size: 12px;
    }

    &__additionalText {
      font-size: 10px;
    }
  }

  .toast__group {
    &--top-left,
    &--top-right,
    &--top-right-plus-60,
    &--bottom-left,
    &--bottom-right,
    &--center {
      top: 8px;
      right: 8px;
      bottom: unset;
      left: unset;
    }
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@keyframes slideIn {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes swipeLeft {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes swipeRight {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes swipeUp {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-100%);
    opacity: 0;
  }
}

@keyframes swipeDown {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(100%);
    opacity: 0;
  }
}

.toast {
  &.toast--swipe-left {
    animation: swipeLeft 0.3s ease-in-out forwards;
  }

  &.toast--swipe-right {
    animation: swipeRight 0.3s ease-in-out forwards;
  }

  &.toast--swipe-up {
    animation: swipeUp 0.3s ease-in-out forwards;
  }

  &.toast--swipe-down {
    animation: swipeDown 0.3s ease-in-out forwards;
  }

  &.toast--persistent {
    pointer-events: auto;

    &:focus-within {
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
  }
}
