@layer components {
  /* ============================================================================
   * TOAST NOTIFICATION COMPONENT
   * Temporary notification messages
   * ========================================================================= */

  /* Toast container - fixed position */
  .toast-container {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
    max-width: 24rem;
  }

  /* Position variants */
  .toast-container--top-right {
    top: var(--space-5);
    right: var(--space-5);
  }

  .toast-container--top-left {
    top: var(--space-5);
    left: var(--space-5);
  }

  .toast-container--bottom-right {
    bottom: var(--space-5);
    right: var(--space-5);
  }

  .toast-container--bottom-left {
    bottom: var(--space-5);
    left: var(--space-5);
  }

  /* Individual toast */
  .toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-width: 20rem;
    max-width: 28rem;
    padding: var(--space-4);
    background-color: var(--surface);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius-3);
    box-shadow: var(--shadow-3);
    pointer-events: auto;
    animation: toast-slide-in var(--transition-normal) ease-out;
  }

  /* Slide in animation */
  @keyframes toast-slide-in {
    from {
      opacity: 0;
      transform: translateX(100%);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  /* Slide out animation */
  .toast--leaving {
    animation: toast-slide-out var(--transition-normal) ease-in;
  }

  @keyframes toast-slide-out {
    from {
      opacity: 1;
      transform: translateX(0);
    }

    to {
      opacity: 0;
      transform: translateX(100%);
    }
  }

  /* Toast content */
  .toast__content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    flex: 1;
  }

  /* Icon */
  .toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }

  .toast__icon svg {
    width: 100%;
    height: 100%;
  }

  /* Body */
  .toast__body {
    flex: 1;
    min-width: 0;
  }

  /* Title */
  .toast__title {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--fg);
    margin-bottom: var(--space-1);
  }

  /* Message */
  .toast__message {
    font-size: var(--text-xs);
    color: var(--fg);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Close button */
  .toast__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-1);
    color: var(--neutral-400);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
  }

  .toast__close:hover {
    background-color: var(--neutral-100);
    color: var(--fg);
  }

  .toast__close:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }

  /* ============================================================================
   * VARIANT COLORS
   * ========================================================================= */

  .toast--success {
    border-left-color: var(--brand);
  }

  .toast--success .toast__icon {
    color: var(--brand);
  }

  .toast--error {
    border-left-color: var(--danger);
  }

  .toast--error .toast__icon {
    color: var(--danger);
  }

  .toast--warning {
    border-left-color: var(--caution);
  }

  .toast--warning .toast__icon {
    color: var(--caution);
  }

  .toast--info {
    border-left-color: var(--brand);
  }

  .toast--info .toast__icon {
    color: var(--brand);
  }

  /* ============================================================================
   * RESPONSIVE BEHAVIOR
   * ========================================================================= */

  @media (width <= 768px) {
    .toast-container {
      left: var(--space-4);
      right: var(--space-4);
      max-width: none;
    }

    .toast {
      min-width: auto;
      width: 100%;
    }
  }

  /* ============================================================================
   * DARK MODE ADJUSTMENTS
   * ========================================================================= */

  @media (prefers-color-scheme: dark) {
    .toast {
      background-color: var(--surface-sunken);
    }

    .toast__close:hover {
      background-color: var(--neutral-100);
    }
  }
}
