import { motion, AnimatePresence } from 'framer-motion';

/**
 * Toast 컴포넌트
 * - 하단 중앙에 표시
 * - type: 'success' | 'error' | 'warning'
 */
function Toast({ toast, onClose }) {
  return (
    <AnimatePresence>
      {toast && (
        <motion.div
          role="alert"
          aria-live="polite"
          initial={{ opacity: 0, y: 50 }}
          animate={{ opacity: 1, y: 0 }}
          exit={{ opacity: 0, y: 50 }}
          onClick={onClose}
          className={`fixed bottom-8 inset-x-0 mx-auto w-fit z-[9999] backdrop-blur-sm text-white px-6 py-3 rounded-xl text-center font-medium shadow-lg cursor-pointer ${
            toast.type === 'error'
              ? 'bg-red-500/90'
              : toast.type === 'warning'
              ? 'bg-amber-500/90'
              : 'bg-emerald-500/90'
          }`}
        >
          {toast.message}
        </motion.div>
      )}
    </AnimatePresence>
  );
}

export default Toast;
