"use client"

import { useState, useEffect } from 'react'
import { Check } from 'lucide-react'

interface ToastProps {
  message: string
  show: boolean
  onHide?: () => void
  duration?: number
}

export function Toast({ message, show, onHide, duration = 3000 }: ToastProps) {
  const [isVisible, setIsVisible] = useState(show)

  useEffect(() => {
    setIsVisible(show)
    
    if (show && duration > 0) {
      const timer = setTimeout(() => {
        setIsVisible(false)
        onHide?.()
      }, duration)
      
      return () => clearTimeout(timer)
    }
  }, [show, duration, onHide])

  if (!isVisible) return null

  return (
    <div className="fixed bottom-4 left-4 z-50 animate-in slide-in-from-bottom-full">
      <div className="bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-2 max-w-md">
        <Check className="h-4 w-4 flex-shrink-0" />
        <span className="text-sm font-medium">{message}</span>
      </div>
    </div>
  )
}