import { Link } from "@tanstack/react-router";
import { FileText } from "lucide-react";
import type { Report } from "@/lib/reports";

export function ReportCard({ report }: { report: Report }) {
  return (
    <Link
      to="/laporan/$id"
      params={{ id: report.id }}
      className="group flex flex-col overflow-hidden rounded-lg border border-border bg-card shadow-card transition duration-300 hover:-translate-y-1 hover:shadow-lift"
    >
      <div className="relative aspect-[3/4] overflow-hidden bg-muted">
        {report.coverUrl ? (
          <img
            src={report.coverUrl}
            alt={`Cover ${report.title}`}
            loading="lazy"
            className="h-full w-full object-cover object-top transition duration-500 group-hover:scale-105"
          />
        ) : (
          <div className="flex h-full items-center justify-center text-muted-foreground">
            <FileText className="h-12 w-12" />
          </div>
        )}
        {report.year && (
          <span className="absolute left-3 top-3 rounded-full bg-gold px-3 py-1 text-xs font-semibold text-gold-foreground">
            {report.year}
          </span>
        )}
      </div>
      <div className="flex flex-1 flex-col gap-2 p-4">
        <h3 className="font-display text-base font-semibold leading-snug text-card-foreground">
          {report.title}
        </h3>
        <span className="mt-auto text-sm font-medium text-primary group-hover:underline">
          Lihat laporan →
        </span>
      </div>
    </Link>
  );
}
