'use client';

import { motion } from 'framer-motion';
import { AlertTriangle, RefreshCw } from 'lucide-react';
import { Button } from '@/components/ui/button';

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  return (
    <div className="flex min-h-screen flex-col items-center justify-center p-6 text-center bg-background">
      <motion.div
        initial={{ opacity: 0, y: 20 }}
        animate={{ opacity: 1, y: 0 }}
        className="max-w-sm"
      >
        <div className="mb-6 flex h-20 w-20 mx-auto items-center justify-center rounded-2xl bg-destructive/10">
          <AlertTriangle className="h-10 w-10 text-destructive" />
        </div>
        <h1 className="font-heading text-xl font-semibold">Terjadi Kesalahan</h1>
        <p className="mt-2 text-sm text-muted-foreground">
          Maaf, terjadi kesalahan yang tidak terduga. Silakan coba lagi.
        </p>
        <Button
          onClick={reset}
          className="mt-6 rounded-xl gap-2"
          variant="outline"
        >
          <RefreshCw className="h-4 w-4" />
          Coba Lagi
        </Button>
      </motion.div>
    </div>
  );
}
