import { ArrowUp, BookOpenCheck } from "lucide-react";

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { helpSections } from "../help-content";

export function FaqPage() {
  return (
    <div id="top" className="space-y-5">
      <div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
        <div>
          <h2 className="text-2xl font-semibold tracking-normal">FAQ und Anleitung</h2>
          <p className="text-sm text-muted-foreground">Ausführliche Anleitung für Timer, Auswertung, Teamspace, fixe Abrechnungen, Monatsabschluss und Adminfunktionen.</p>
        </div>
        <Badge variant="outline">{helpSections.length} Abschnitt(e)</Badge>
      </div>

      <Card>
        <CardHeader className="p-4">
          <div className="flex items-center gap-2">
            <BookOpenCheck className="size-5 text-muted-foreground" />
            <CardTitle>Schnellnavigation</CardTitle>
          </div>
          <CardDescription>Die Fragezeichen in der App öffnen eine Kurzfassung. Von dort gelangst du direkt zum passenden ausführlichen Abschnitt.</CardDescription>
        </CardHeader>
        <CardContent className="flex flex-wrap gap-2 px-4 pb-4">
          {helpSections.map((section) => (
            <Button key={section.id} asChild variant="secondary" size="sm">
              <a href={`#${section.id}`}>{section.title}</a>
            </Button>
          ))}
        </CardContent>
      </Card>

      <div className="grid gap-3 xl:grid-cols-2">
        {helpSections.map((section) => (
          <Card key={section.id} id={section.id} className="scroll-mt-16">
            <CardHeader className="p-4">
              <CardTitle>{section.title}</CardTitle>
              <CardDescription>{section.description}</CardDescription>
            </CardHeader>
            <CardContent className="space-y-4 px-4 pb-4">
              <div className="rounded-md border bg-muted/20 p-3">
                <p className="mb-2 text-sm font-medium">Kurzfassung</p>
                <ul className="space-y-2 text-sm text-muted-foreground">
                  {section.quickItems.map((item) => (
                    <li key={item} className="flex gap-2">
                      <span className="mt-2 size-1.5 shrink-0 rounded-full bg-primary" />
                      <span>{item}</span>
                    </li>
                  ))}
                </ul>
              </div>
              <div>
                <p className="mb-2 text-sm font-medium">Details</p>
                <ul className="space-y-2 text-sm text-muted-foreground">
                  {section.details.map((item) => (
                    <li key={item} className="flex gap-2">
                      <span className="mt-2 size-1.5 shrink-0 rounded-full bg-primary/70" />
                      <span>{item}</span>
                    </li>
                  ))}
                </ul>
              </div>
              <div className="flex justify-end">
                <Button asChild variant="ghost" size="sm">
                  <a href="#top">
                    <ArrowUp className="size-4" />
                    Nach oben
                  </a>
                </Button>
              </div>
            </CardContent>
          </Card>
        ))}
      </div>
    </div>
  );
}
