import type { Metadata } from "next";
import { prisma } from "@/lib/prisma";

export const metadata: Metadata = {
    title: "Board & Committees",
    description:
        "Meet the South Forsyth Middle School PTO board and committee volunteers who lead our programs and support SFMS students and teachers.",
};

export default async function BoardCommitteesPage() {
    const members = await prisma.boardMember.findMany({
        orderBy: { order: "asc" }
    });

    return (
        <div className="container" style={{ padding: "4rem 1.5rem" }}>
            <div style={{ textAlign: "center", marginBottom: "4rem" }}>
                <h1 className="animate-fade-in" style={{ fontSize: "3.5rem", marginBottom: "1rem" }}>Board & Committees</h1>
                <p className="animate-fade-in" style={{ fontSize: "1.2rem", color: "var(--text-muted)", maxWidth: "700px", margin: "0 auto" }}>
                    Meet the dedicated parents and staff members who volunteer their time to lead our PTO and support the SFMS community.
                </p>
            </div>

            <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))", gap: "2.5rem" }}>
                {members.length === 0 ? (
                    <div style={{ gridColumn: "1 / -1", textAlign: "center", padding: "4rem", color: "var(--text-muted)" }}>
                        The board roster is currently being updated. Please check back soon!
                    </div>
                ) : members.map((member, index) => (
                    <div key={member.id} className="glass-panel animate-fade-in" style={{ padding: "2rem", textAlign: "center", animationDelay: `${0.1 * index}s` }}>
                        <div style={{ width: "120px", height: "120px", borderRadius: "50%", margin: "0 auto 1.5rem", background: "var(--primary-light)", border: "4px solid white", boxShadow: "0 4px 12px rgba(0,0,0,0.1)", overflow: "hidden" }}>
                            {member.imageUrl ? (
                                <img src={member.imageUrl} alt={`${member.firstName} ${member.lastName}`} style={{ width: "100%", height: "100%", objectFit: "cover" }} />
                            ) : (
                                <div style={{ width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center", fontSize: "3rem" }}>👤</div>
                            )}
                        </div>
                        <h3 style={{ fontSize: "1.25rem", fontWeight: 700, marginBottom: "0.25rem" }}>{member.firstName} {member.lastName}</h3>
                        <div style={{ color: "var(--primary)", fontWeight: 600, fontSize: "1rem" }}>{member.position}</div>
                    </div>
                ))}
            </div>
        </div>
    );
}
