'use client';

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from '@/components/ui/alert-dialog';

/**
 * DeleteConfirmDialog - Confirmation dialog for destructive actions
 *
 * Story 3.2: Delete confirmation dialog for drafts/posts
 *
 * Uses ShadCN AlertDialog for critical interruptions like deletion.
 * - Clear warning text: "This cannot be undone"
 * - Two buttons: Cancel (secondary), Delete (destructive/red)
 * - Accessible: proper aria labels, focus management, keyboard navigation
 */

interface DeleteConfirmDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  onConfirm: () => void;
  draftTitle: string;
}

export function DeleteConfirmDialog({
  open,
  onOpenChange,
  onConfirm,
  draftTitle
}: DeleteConfirmDialogProps) {
  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle className="text-destructive">
            Delete this post?
          </AlertDialogTitle>
          <AlertDialogDescription>
            You are about to delete <strong>"{draftTitle}"</strong>.
          </AlertDialogDescription>
          <AlertDialogDescription className="text-sm text-muted-foreground mt-2">
            This action cannot be undone. The post will be permanently removed.
          </AlertDialogDescription>
        </AlertDialogHeader>

        <AlertDialogFooter>
          <AlertDialogCancel>Cancel</AlertDialogCancel>
          <AlertDialogAction
            onClick={onConfirm}
            className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
          >
            Delete
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
