@layer components {
  :root {
    --toast-radius: 16px;
    --toast-padding-y: 12px;
    --toast-padding-x: 16px;
    --toast-gap: 8px;
    --toast-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    --toast-title-color: var(--color-text);
    --toast-message-color: var(--color-gray-600);
    --toast-success-from: #f0fdf4;
    --toast-success-to: #dcfce7;
    --toast-success-icon: var(--color-success);
    --toast-error-from: #fefcfc;
    --toast-error-to: #fef2f2;
    --toast-error-icon: var(--color-danger);
    --toast-info-from: #fafbfc;
    --toast-info-to: #f1f5f9;
    --toast-info-icon: var(--color-primary);
    --toast-warning-from: #fefdf9;
    --toast-warning-to: #fef9e7;
    --toast-warning-icon: var(--color-warning);
    --toast-neutral-from: rgba(255, 255, 255, 0.98);
    --toast-neutral-to: rgba(252, 252, 253, 0.99);
    --toast-neutral-icon: var(--color-gray-500);
  }

  @keyframes slide-in-from-right {
    from {
      transform: translateX(calc(100% + 2rem));
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @keyframes slide-out-to-right {
    from {
      transform: translateX(0);
      opacity: 1;
    }
    to {
      transform: translateX(calc(100% + 2rem));
      opacity: 0;
    }
  }

  .toast-container {
    position: fixed;
    top: 5.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;

    @media (max-width: 640px) {
      top: auto;
      bottom: 1rem;
      left: 1rem;
      right: 1rem;
      align-items: flex-end;
    }
  }

  .toast {
    min-width: 280px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: var(--toast-gap);
    padding: var(--toast-padding-y) var(--toast-padding-x);
    border-radius: var(--toast-radius);
    box-shadow: var(--toast-shadow);
    color: var(--toast-message-color);
    font-size: 0.875rem;
    line-height: 1.4;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    animation: slide-in-from-right 0.25s cubic-bezier(0.16, 1, 0.3, 1), fade-in 0.25s ease-out;

    @media (min-width: 641px) {
      min-width: 360px;
      max-width: 480px;
      padding: 16px 20px;
      font-size: 1rem;
    }

    &.toast--removing {
      animation: none;
      animation: slide-out-to-right 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .toast__icon {
      flex: 0 0 auto;
      width: 28px;
      height: 28px;
      border-radius: 999px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.75rem;
      font-weight: 500;
      background-color: transparent;
      border: 1.5px solid;

      @media (min-width: 641px) {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
      }

      span {
        display: inline-block;
      }
    }

    .toast__content {
      flex: 1 1 auto;
      min-width: 0;
    }

    .toast__title {
      margin: 0;
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--toast-title-color);

      @media (min-width: 641px) {
        font-size: 1rem;
      }
    }

    .toast__message {
      margin: 2px 0 0;
      font-size: 0.875rem;
      color: var(--toast-message-color);
      word-wrap: break-word;
      overflow-wrap: break-word;

      @media (min-width: 641px) {
        font-size: 1rem;
      }
    }

    .toast__close {
      flex: 0 0 auto;
      border: none;
      background: transparent;
      font-family: system-ui, -apple-system, sans-serif;
      font-size: 24px;
      font-weight: 300;
      line-height: 0.8;
      padding: 0;
      margin-left: 4px;
      color: var(--color-gray-400);
      cursor: pointer;
      transition: color 0.15s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 2rem;
      height: 2rem;
    }

    .toast__close:hover {
      color: var(--color-gray-600);
    }

    &.toast--success {
      background: linear-gradient(135deg, var(--toast-success-from), var(--toast-success-to));

      .toast__icon {
        color: var(--toast-success-icon);
        border-color: rgba(22, 163, 74, 0.3);
      }
    }

    &.toast--error {
      background: linear-gradient(135deg, var(--toast-error-from), var(--toast-error-to));

      .toast__icon {
        color: var(--toast-error-icon);
        border-color: rgba(220, 38, 38, 0.3);
      }
    }

    &.toast--info {
      background: linear-gradient(135deg, var(--toast-info-from), var(--toast-info-to));

      .toast__icon {
        color: var(--toast-info-icon);
        border-color: rgba(99, 102, 241, 0.3);
      }
    }

    &.toast--warning {
      background: linear-gradient(135deg, var(--toast-warning-from), var(--toast-warning-to));

      .toast__icon {
        color: var(--color-warning-hover);
        border-color: rgba(234, 179, 8, 0.6);
      }
    }

    &.toast--neutral {
      background: linear-gradient(135deg, var(--toast-neutral-from), var(--toast-neutral-to));

      .toast__icon {
        color: var(--toast-neutral-icon);
        border-color: rgba(107, 114, 128, 0.2);
      }
    }

    @media (max-width: 640px) {
      width: 100%;
      max-width: none;
    }
  }
}
