import { createFileRoute } from "@tanstack/react-router";
import { AppShell } from "@/components/layout/AppShell";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { Badge } from "@/components/ui/badge";

export const Route = createFileRoute("/app/settings")({
  head: () => ({ meta: [{ title: "Settings — warpbox.dev" }] }),
  component: Settings,
});

function Settings() {
  return (
    <AppShell variant="user" title="Settings">
      <div className="mx-auto max-w-2xl space-y-6">
        <Card>
          <CardContent className="p-6">
            <h2 className="font-medium">Profile</h2>
            <p className="text-sm text-muted-foreground">Your account info.</p>
            <div className="mt-4 grid gap-4 sm:grid-cols-2">
              <div className="space-y-1.5"><Label>Email</Label><Input defaultValue="alice@acme.dev" /></div>
              <div className="space-y-1.5"><Label>Display name</Label><Input defaultValue="Alice" /></div>
            </div>
            <div className="mt-4"><Button>Save changes</Button></div>
          </CardContent>
        </Card>

        <Card>
          <CardContent className="p-6">
            <h2 className="font-medium">Password</h2>
            <div className="mt-4 grid gap-4 sm:grid-cols-2">
              <div className="space-y-1.5"><Label>Current</Label><Input type="password" /></div>
              <div className="space-y-1.5"><Label>New</Label><Input type="password" /></div>
            </div>
            <div className="mt-4"><Button variant="outline">Update password</Button></div>
          </CardContent>
        </Card>

        <Card>
          <CardContent className="p-6">
            <h2 className="font-medium">API tokens</h2>
            <p className="text-sm text-muted-foreground">Use for curl, CLI, or ShareX uploads.</p>
            <Separator className="my-4" />
            <div className="space-y-2">
              {["cli-laptop", "sharex-desktop"].map((t) => (
                <div key={t} className="flex items-center justify-between rounded-md border p-3">
                  <div>
                    <div className="font-medium text-sm">{t}</div>
                    <div className="text-xs text-muted-foreground">Created 12 days ago · last used 2h ago</div>
                  </div>
                  <div className="flex items-center gap-2">
                    <Badge variant="secondary">read+write</Badge>
                    <Button variant="ghost" size="sm" className="text-destructive">Revoke</Button>
                  </div>
                </div>
              ))}
            </div>
            <div className="mt-4 flex gap-2">
              <Button>Create token</Button>
              <Button variant="outline">Download ShareX config</Button>
            </div>
          </CardContent>
        </Card>
      </div>
    </AppShell>
  );
}