import { useState } from 'react';
import { 
  Plus, 
  Eye,
  KeyRound,
  Search,
  
} from "lucide-react";
import Button from "@/components/common/button";
import Table from '@/components/common/dataTable';
import { userHeaders, userRows } from '@/constants/adminTableData';




export default function UserPortal() {
  const [searchQuery, setSearchQuery] = useState('');

  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 uppercase font-mono">
            <span className="text-gray-400">PLATFORM</span>
            <span className="text-gray-600">•</span>
            <span className="text-gray-400">USERS</span>
          </div>
          <h1 className="text-2xl font-bold text-white tracking-tight mt-1">
            Users
          </h1>
          <p className="text-sm font-medium text-slate-400 mt-1 max-w-2xl leading-relaxed">
            All platform user accounts. Create credentials, assign tenants, and manage passwords. This is the single account store — Operations role access reads from here.
          </p>
        </div>

        {/* --- HEADER BUTTON --- */}
        <div className="flex items-center gap-3 self-start md:mt-2">
          <Button className="bg-emerald-400 hover:bg-emerald-300 text-slate-950 font-semibold text-xs px-4 py-2.5 rounded-lg flex items-center gap-1.5 transition-colors shadow-lg shadow-emerald-500/10">
            <Plus className="w-4 h-4 text-slate-950 stroke-[3]" />
            <span>Add user</span>
          </Button>
        </div>
      </div>

      {/* --- TABLE CONTAINER WITH UPPER BAR --- */}
      <div className="bg-slate-900/60 border border-slate-800/80 rounded-xl p-4 space-y-4">
        {/* Table Upper UI (Full-width Search Bar matching screenshot) */}
        <div className="flex items-center w-full">
          <div className="relative w-full">
            <Search className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
            <input
              type="text"
              value={searchQuery}
              onChange={(e) => setSearchQuery(e.target.value)}
              placeholder="Search users by name, email or ID..."
              className="w-full pl-10 pr-4 py-2.5 bg-slate-950/80 border border-slate-800 rounded-lg text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-slate-700 transition"
            />
          </div>
        </div>

        {/* --- TABLE --- */}
        <Table headers={userHeaders} rows={userRows} />

        {/* Footer Record Count */}
        <div className="text-xs text-slate-500 font-mono pt-1">
          {userRows.length} records
        </div>
      </div>

     
    </div>
  );
}