"use client";

import { useEffect, useState } from "react";
import Link from "next/link";
import { FileSearch, Home } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useUserStore } from "@/store";

export default function NotFound() {
  const { role } = useUserStore();
  const [dashboardUrl, setDashboardUrl] = useState("/dashboard");

  useEffect(() => {
    if (role === "admin") {
      setDashboardUrl("/admin");
    } else {
      setDashboardUrl("/dashboard");
    }
  }, [role]);

  return (
    <div className="min-h-screen bg-gray-50 dark:bg-gray-950 flex items-center justify-center px-6">
      <div className="max-w-md w-full text-center space-y-6">
        <div className="flex justify-center">
          <div className="flex h-16 w-16 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30">
            <FileSearch className="h-8 w-8 text-blue-600 dark:text-blue-400" />
          </div>
        </div>
        <div className="space-y-2">
          <p className="text-6xl font-bold text-gray-200 dark:text-gray-800">404</p>
          <h1 className="text-2xl font-bold text-gray-900 dark:text-gray-100">Page not found</h1>
          <p className="text-gray-500 dark:text-gray-400 text-sm">
            The page you're looking for doesn't exist or has been moved.
          </p>
        </div>
        <Button asChild className="gap-2">
          <Link href={dashboardUrl}>
            <Home className="h-4 w-4" />
            Back to Dashboard
          </Link>
        </Button>
      </div>
    </div>
  );
}
