"use client";

import React from "react";
import Link from "next/link";
import { Building2, ChevronRight, FileSpreadsheet } from "lucide-react";
import { toast } from "sonner";

interface HostelBed {
  roomNo: string;
  block: string;
  capacity: number;
  occupants: string;
  year: string;
  status: "Full" | "Available";
}

const hostelRooms: HostelBed[] = [
  { roomNo: "A-101", block: "Boys Hostel Block 1", capacity: 3, occupants: "3 Students", year: "1st Year BHM", status: "Full" },
  { roomNo: "A-102", block: "Boys Hostel Block 1", capacity: 3, occupants: "2 Students", year: "1st Year BHM", status: "Available" },
  { roomNo: "B-201", block: "Girls Hostel Block A", capacity: 2, occupants: "2 Students", year: "2nd Year BHM", status: "Full" },
  { roomNo: "B-202", block: "Girls Hostel Block A", capacity: 2, occupants: "1 Student", year: "2nd Year BHM", status: "Available" },
];

export default function HostelAllocationPage() {
  return (
    <div className="space-y-5 font-sans">
      <div className="flex flex-col lg:flex-row lg:items-center justify-between gap-4">
        <div>
          <nav className="flex items-center gap-1.5 text-[13px] text-[#64748B] mb-1 font-medium font-sans">
            <Link href="/admin/dashboard" className="hover:text-[#1769E8] hover:underline">
              Home
            </Link>
            <ChevronRight className="w-3.5 h-3.5 text-[#94A3B8]" />
            <span className="text-[#071A4D] font-semibold">Hostel Allocation</span>
          </nav>

          <h1 className="text-3xl font-bold font-heading text-[#071A4D] tracking-tight">
            Campus Hostel Allotment
          </h1>
          <p className="text-[15px] text-[#64748B] mt-1 font-normal font-sans">
            Manage residential student room allotment, wardens, and capacity.
          </p>
        </div>

        <button
          onClick={() => toast.success("Exporting Hostel Register...")}
          className="inline-flex items-center gap-1.5 px-3.5 py-2 text-xs font-semibold text-[#071A4D] bg-white border border-[#E5EAF0] rounded-lg hover:bg-slate-50 transition-colors shadow-2xs cursor-pointer"
        >
          <FileSpreadsheet className="w-4 h-4 text-emerald-600" />
          <span>Export Allotment List</span>
        </button>
      </div>

      <div className="rounded-xl bg-white border border-[#E5EAF0] shadow-2xs overflow-hidden">
        <div className="overflow-x-auto">
          <table className="w-full text-left text-xs border-collapse">
            <thead>
              <tr className="bg-[#F8FAFC] border-b border-[#E5EAF0] text-[#64748B] uppercase tracking-wider font-bold text-[11px]">
                <th className="py-3 px-3">Room No</th>
                <th className="py-3 px-3">Hostel Block</th>
                <th className="py-3 px-3 text-center">Capacity</th>
                <th className="py-3 px-3">Occupancy</th>
                <th className="py-3 px-3">Resident Batch</th>
                <th className="py-3 px-3 text-center">Status</th>
              </tr>
            </thead>
            <tbody className="divide-y divide-[#E5EAF0] text-[#334155]">
              {hostelRooms.map((r) => (
                <tr key={r.roomNo} className="hover:bg-[#F8FAFC] transition-colors">
                  <td className="py-3.5 px-3 font-mono font-bold text-[#1769E8]">{r.roomNo}</td>
                  <td className="py-3.5 px-3 font-semibold text-[#071A4D]">{r.block}</td>
                  <td className="py-3.5 px-3 text-center font-bold text-[#071A4D]">{r.capacity} Beds</td>
                  <td className="py-3.5 px-3 text-[#334155]">{r.occupants}</td>
                  <td className="py-3.5 px-3 text-[#64748B]">{r.year}</td>
                  <td className="py-3.5 px-3 text-center">
                    <span
                      className={`inline-block px-2.5 py-0.5 rounded-full text-[11px] font-semibold ${
                        r.status === "Full"
                          ? "bg-slate-100 text-[#475569]"
                          : "bg-[#DCFCE7] text-[#15803D]"
                      }`}
                    >
                      {r.status}
                    </span>
                  </td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </div>
    </div>
  );
}
