import Link from "next/link";
import { Users, FileText, Newspaper, ShieldAlert } from "lucide-react";
import { Metadata } from "next";
import ParlemenOrganigramForm from "@/components/admin/parlemen-organigram-form";
import { getProfilAktif } from "@/lib/data";

export const dynamic = 'force-dynamic';

export const metadata: Metadata = {
    title: 'Manajemen Parlemen | HMF FPMIPA UPI',
};

export default async function ParlemenDashboard() {
    const profil = await getProfilAktif();

    return (
        <div className="space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700">
            {/* Header */}
            <div>
                <h1 className="text-3xl font-black text-slate-800 tracking-tight">Manajemen Parlemen</h1>
                <p className="text-slate-500 mt-2 font-medium">Pilih modul pengelolaan data Parlemen HMF FPMIPA UPI.</p>
            </div>

            <div className="grid grid-cols-1 md:grid-cols-2 gap-6 pt-4">
                {/* Profil Anggota */}
                <Link href="/admin/parlemen/profil" className="group">
                    <div className="bg-white hover:bg-slate-50 border border-slate-200 rounded-3xl p-8 transition-all duration-300 relative overflow-hidden flex flex-col items-start h-full shadow-sm">
                        <div className="absolute top-0 right-0 w-32 h-32 bg-blue-100 rounded-full blur-[50px] group-hover:bg-blue-200 transition-colors"></div>
                        <div className="w-16 h-16 bg-blue-50 rounded-2xl flex items-center justify-center mb-6 border border-blue-100 group-hover:scale-110 transition-transform shadow-sm">
                            <Users className="w-8 h-8 text-blue-600" />
                        </div>
                        <h2 className="text-2xl font-bold text-slate-800 mb-2 group-hover:text-blue-600 transition-colors">Profil Anggota</h2>
                        <p className="text-slate-500 text-sm leading-relaxed">
                            Kelola daftar anggota parlemen, fraksi, komisi, dan jabatan terstruktur.
                        </p>
                    </div>
                </Link>

                {/* Produk MUMAS */}
                <Link href="/admin/parlemen/produk-mumas" className="group">
                    <div className="bg-white hover:bg-slate-50 border border-slate-200 rounded-3xl p-8 transition-all duration-300 relative overflow-hidden flex flex-col items-start h-full shadow-sm">
                        <div className="absolute top-0 right-0 w-32 h-32 bg-purple-100 rounded-full blur-[50px] group-hover:bg-purple-200 transition-colors"></div>
                        <div className="w-16 h-16 bg-purple-50 rounded-2xl flex items-center justify-center mb-6 border border-purple-100 group-hover:scale-110 transition-transform shadow-sm">
                            <Newspaper className="w-8 h-8 text-purple-600" />
                        </div>
                        <h2 className="text-2xl font-bold text-slate-800 mb-2 group-hover:text-purple-600 transition-colors">Produk MUMAS</h2>
                        <p className="text-slate-500 text-sm leading-relaxed">
                            Kelola dokumen peraturan, ketetapan, TAP MUMAS, GBHO, dan amandemen.
                        </p>
                    </div>
                </Link>
            </div>
            
            {profil && (
                <div className="pt-4">
                    <ParlemenOrganigramForm profilId={profil.id} initialUrl={profil.organigramDpmUrl} />
                </div>
            )}

            <div className="bg-blue-50 border border-blue-100 rounded-2xl p-6 mt-8 flex items-start gap-4">
                <ShieldAlert className="w-6 h-6 text-blue-600 shrink-0" />
                <div>
                    <h3 className="font-bold text-blue-800 mb-1">Akses Pengurus Khusus</h3>
                    <p className="text-blue-700/80 text-sm">Halaman Parlemen diotorisasi secara spesifik. Harap berhati-hati dalam mengubah status atau dokumen produk MUMAS karena akan langsung dipublikasikan secara _real-time_.</p>
                </div>
            </div>
        </div>
    );
}
