import Image from "next/image";
import Link from "next/link";
import { WorkspacePanel } from "@/components/workspace-panel";

export default function Home() {
  return (
    <main className="min-h-screen bg-[#f4efe6] text-stone-950">
      <header className="border-b border-stone-300 bg-white/90">
        <div className="mx-auto flex max-w-7xl items-center justify-between px-4 py-4 sm:px-6">
          <div>
            <p className="text-xs font-semibold uppercase tracking-[.18em] text-teal-800">Human Archive</p>
            <h1 className="text-2xl font-semibold tracking-normal">Menschheits-Enzyklopaedie</h1>
          </div>
          <nav className="flex items-center gap-2 text-sm font-medium">
            <Link className="rounded-md px-3 py-2 text-stone-700 hover:bg-stone-100" href="/entries/example">
              Eintrag
            </Link>
            <Link className="rounded-md px-3 py-2 text-stone-700 hover:bg-stone-100" href="/admin">
              Admin
            </Link>
          </nav>
        </div>
      </header>

      <div className="mx-auto grid max-w-7xl gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[1fr_360px]">
        <div className="space-y-6">
          <section className="grid gap-5 rounded-lg border border-stone-300 bg-white p-5 shadow-sm md:grid-cols-[1.1fr_.9fr]">
            <div className="flex flex-col justify-center">
              <p className="mb-3 text-sm font-semibold text-teal-800">Quellenpflichtige Wissensarbeit</p>
              <h2 className="max-w-2xl text-4xl font-semibold leading-tight tracking-normal">
                Fragen stellen, Wissen recherchieren und KI-Entscheidungen auditieren.
              </h2>
              <p className="mt-4 max-w-2xl text-base leading-7 text-stone-700">
                V1 verbindet eine strukturierte Enzyklopaedie mit LiteLLM-gestuetzter Recherche,
                Quellenverwaltung und automatischer Moderation.
              </p>
            </div>
            <div className="relative min-h-64 overflow-hidden rounded-md border border-stone-200 bg-stone-100">
              <Image src="/archive-field.svg" alt="" fill priority className="object-cover" />
            </div>
          </section>

          <WorkspacePanel />
        </div>

        <aside className="space-y-4">
          <StatusPanel />
          <div className="rounded-lg border border-stone-300 bg-white p-4 shadow-sm">
            <h2 className="text-base font-semibold">V1-Grenzen</h2>
            <ul className="mt-3 space-y-3 text-sm leading-6 text-stone-700">
              <li>Keine Massen-Crawls ohne konfigurierte Quellen-APIs.</li>
              <li>Keine Veroeffentlichung ohne gespeicherte Quelle.</li>
              <li>KI-Freigaben bleiben im Admin Center nachvollziehbar.</li>
            </ul>
          </div>
        </aside>
      </div>
    </main>
  );
}

function StatusPanel() {
  const items = [
    ["Datenhaltung", "Postgres + Prisma"],
    ["LLM-Gateway", "LiteLLM-kompatibel"],
    ["Sprachen", "Deutsch / Englisch"],
    ["Container", "Runtime vorbereitet"],
  ];

  return (
    <section className="rounded-lg border border-stone-300 bg-white p-4 shadow-sm">
      <h2 className="text-base font-semibold">Systemstatus</h2>
      <dl className="mt-3 space-y-3">
        {items.map(([label, value]) => (
          <div key={label} className="flex items-center justify-between gap-3 border-b border-stone-200 pb-2 last:border-0">
            <dt className="text-sm text-stone-600">{label}</dt>
            <dd className="text-right text-sm font-semibold text-stone-950">{value}</dd>
          </div>
        ))}
      </dl>
    </section>
  );
}
