"use client";

import React from 'react';
import { AlertTriangle, X } from 'lucide-react';
import { Button } from '@/components/ui/button';

interface ConfirmDeleteModalProps {
  isOpen: boolean;
  onClose: () => void;
  onConfirm: () => void;
  title: string;
  message: string;
  itemName?: string;
}

export default function ConfirmDeleteModal({
  isOpen,
  onClose,
  onConfirm,
  title,
  message,
  itemName,
}: ConfirmDeleteModalProps) {
  if (!isOpen) return null;

  const handleConfirm = () => {
    onConfirm();
    onClose();
  };

  return (
    <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
      <div className="bg-background rounded-lg shadow-lg border max-w-[95vw] sm:max-w-[500px] w-full">
        {/* 헤더 */}
        <div className="flex items-center justify-between px-6 py-4 border-b">
          <div className="flex items-center gap-2">
            <AlertTriangle className="w-5 h-5 text-destructive" />
            <h2 className="text-base sm:text-lg font-semibold">{title}</h2>
          </div>
          <button
            onClick={onClose}
            className="text-muted-foreground hover:text-foreground rounded-md p-1 transition-colors"
          >
            <X className="w-4 h-4" />
          </button>
        </div>

        {/* 내용 */}
        <div className="px-6 py-4 space-y-3">
          <p className="text-sm sm:text-base text-foreground">{message}</p>
          {itemName && (
            <div className="bg-destructive/10 border border-destructive/20 rounded-md p-3">
              <p className="text-xs sm:text-sm font-medium text-destructive">
                삭제 대상: <span className="font-bold">{itemName}</span>
              </p>
            </div>
          )}
          <p className="text-xs sm:text-sm text-muted-foreground">
            이 작업은 되돌릴 수 없습니다. 계속하시겠습니까?
          </p>
        </div>

        {/* 버튼 */}
        <div className="flex gap-2 px-6 pb-6">
          <Button
            onClick={onClose}
            variant="outline"
            className="h-8 flex-1 text-xs sm:h-10 sm:text-sm"
          >
            취소
          </Button>
          <Button
            onClick={handleConfirm}
            variant="destructive"
            className="h-8 flex-1 text-xs sm:h-10 sm:text-sm"
          >
            삭제
          </Button>
        </div>
      </div>
    </div>
  );
}

