import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Bell, CheckCircle, XCircle } from 'lucide-react';

interface NotificationStatusModalProps {
  open: boolean;
  onClose: () => void;
  success: boolean;
  message?: string;
}

export function NotificationStatusModal({ 
  open, 
  onClose, 
  success,
  message 
}: NotificationStatusModalProps) {
  return (
    <Dialog open={open} onOpenChange={onClose}>
      <DialogContent className="sm:max-w-md">
        <DialogHeader>
          <DialogTitle className="flex items-center gap-2">
            <Bell className="w-5 h-5 text-blue-600" />
            Push Notifications
          </DialogTitle>
          <DialogDescription className="sr-only">
            {success 
              ? 'Push notifications have been successfully enabled for your account.'
              : 'There was an error enabling push notifications. Please review the details below.'}
          </DialogDescription>
        </DialogHeader>
        
        <div className="py-6">
          <div className="flex flex-col items-center text-center">
            {success ? (
              <>
                <div className="w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mb-4">
                  <CheckCircle className="w-8 h-8 text-green-600" />
                </div>
                <h3 className="text-lg font-semibold text-gray-900 mb-2">
                  Notifications Enabled!
                </h3>
                <p className="text-sm text-gray-600 max-w-sm">
                  {message || 'You will now receive push notifications for workflow updates, approvals, and TAT alerts.'}
                </p>
              </>
            ) : (
              <>
                <div className="w-16 h-16 rounded-full bg-red-100 flex items-center justify-center mb-4">
                  <XCircle className="w-8 h-8 text-red-600" />
                </div>
                <h3 className="text-lg font-semibold text-gray-900 mb-2">
                  Subscription Failed
                </h3>
                <p className="text-sm text-gray-600 max-w-sm mb-4 whitespace-pre-line">
                  {message || 'Unable to enable push notifications. Please check your browser settings and try again.'}
                </p>
                <div className="bg-amber-50 border border-amber-200 rounded-lg p-3 text-left w-full">
                  <p className="text-xs text-amber-800 font-medium mb-2">💡 Troubleshooting Tips:</p>
                  <ul className="text-xs text-amber-700 space-y-1 list-disc list-inside">
                    <li>Check if notifications are blocked in browser settings</li>
                    <li>Ensure your browser supports push notifications</li>
                    <li>Try refreshing the page and enabling again</li>
                  </ul>
                </div>
              </>
            )}
          </div>
        </div>
        
        <DialogFooter>
          <Button onClick={onClose} className="w-full">
            {success ? 'Done' : 'Close'}
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}

