
import React from 'react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';

const PdfPreviewDialog = ({ open, onOpenChange, title, fileUrl }) => {
  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent className="max-w-5xl w-[95vw] h-[90vh] flex flex-col p-0 gap-0">
        <DialogHeader className="px-6 py-4 border-b shrink-0">
          <DialogTitle className="truncate pr-8 text-lg font-semibold">
            {title}
          </DialogTitle>
        </DialogHeader>
        <div className="flex-1 w-full bg-muted overflow-hidden relative">
          <object data={fileUrl} type="application/pdf" className="w-full h-full">
            <div className="flex flex-col items-center justify-center h-full text-muted-foreground p-8 text-center">
              <p className="mb-4">This browser does not support inline PDF viewing.</p>
              <a href={fileUrl} target="_blank" rel="noreferrer" className="px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors">
                Download PDF
              </a>
            </div>
          </object>
        </div>
      </DialogContent>
    </Dialog>
  );
};

export default PdfPreviewDialog;
