import { useState } from 'react';
import { 
  FileText, 
  AlertTriangle, 
  Clock, 
  Star, 
  BarChart2, 
  Plus 
} from "lucide-react";
import Button from "@/components/common/button";
import StatCard from "@/components/common/dashStatCard";
import InfoBanner from "@/components/common/infoBanner";
import Table from '@/components/common/dataTable';
import { contractheaders, contractrows } from '@/constants/tabledata';



export default function ContractsPortal() {
  return (
    <div className="my-15 text-slate-100 font-sans">
      {/* --- HEADER SECTION --- */}
      <div className="flex flex-col md:flex-row md:items-start md:justify-between gap-4 mb-6">
        <div>
          <div className="flex items-center gap-2 text-[12px] font-bold tracking-widest text-emerald-400 uppercase font-mono">
            <span>Apple One — HQ Tower</span>
            <span className="text-slate-600">•</span>
            <span className="text-slate-400">COMPLIANCE</span>
            <span className="text-slate-600">•</span>
            <span className="text-slate-400"> Contracts</span>
          </div>
          <h1 className="text-2xl font-bold text-white tracking-tight mt-2">
           Contract management
          </h1>
          <p className="text-sm font-medium text-slate-400 mt-2 max-w-xl leading-relaxed">
            Central vendor-contract repository with SLA tracking, renewal alerts, performance scorecards, e-signature and a full audit trail.
          </p>
        </div>

        {/* --- HEADER BUTTONS --- */}
        <div className="flex items-center gap-3 self-start md:mt-10">
          <Button className="bg-[#0b1727] hover:bg-slate-800/60 text-slate-200 border border-slate-800 text-xs px-4 py-2 rounded-lg flex items-center gap-2 font-semibold transition-colors">
            <BarChart2 className="w-4 h-4 text-slate-300" />
            <span>SLA report</span>
          </Button>

          <Button className="bg-[#2dd4bf] hover:bg-teal-300 text-slate-950 font-bold text-xs px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
            <Plus className="w-4 h-4 stroke-[3]" />
            <span>Dispatch job</span>
          </Button>
        </div>
      </div>

      {/* --- STAT CARDS --- */}
      <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
        {/* Card 1: Active vendors */}
        <StatCard
          variant="icon"
          title="Active vendors"
          value="6"
          icon={FileText}
          badgeText="in force"
          badgeClassName="text-slate-400 lowercase font-mono"
          iconContainerClassName="bg-blue-950/60 border-blue-800/40 text-blue-400"
        />

        {/* Card 2: Avg SLA adherence */}
        <StatCard
          variant="icon"
          title="Avg SLA adherence"
          value="93%"
          icon={AlertTriangle}
          badgeText="this month"
          badgeClassName="text-rose-400 lowercase font-mono font-medium"
          iconContainerClassName="bg-rose-950/50 border-rose-800/30 text-rose-400"
        />

        {/* Card 3: Open field jobs */}
        <StatCard
          variant="icon"
          title="Open field jobs"
          value="12"
          icon={Clock}
          badgeText="renew"
          badgeClassName="text-amber-400 lowercase font-mono"
          iconContainerClassName="bg-amber-950/50 border-amber-800/30 text-amber-400"
        />

        {/* Card 4: Avg response time */}
        <StatCard
          variant="icon"
          title="Avg response time"
          value="2.7h"
          icon={Star}
          badgeText="of 5.0"
          badgeClassName="text-emerald-400 lowercase font-mono"
          iconContainerClassName="bg-emerald-950/60 border-emerald-800/40 text-emerald-400"
        />
      </div>

      <Table headers={contractheaders} rows={contractrows}/>

      <div className="mb-10 mt-10">
        <InfoBanner 
          boldText="Lifecycle: " 
          normalText="repository → SLA monitoring with breach alerts → vendor scorecards → renewal reminders at 90 / 30 days → e-signature → immutable audit trail of every change." 
        />
      </div>
    </div>
  );
}