"use client";

import { motion } from 'framer-motion';
import { Plus, Search, GripVertical, Settings2, Trash2 } from 'lucide-react';

const mockTargets = [
  { id: 1, term: 'ThinkPad T14 Gen 3', maxPrice: 600, weight: 1.5, status: 'active' },
  { id: 2, term: 'RTX 3080', maxPrice: 350, weight: 2.0, status: 'active' },
  { id: 3, term: 'iPhone 12 Pro Unlocked', maxPrice: 200, weight: 1.0, status: 'paused' },
];

export default function KeywordsPage() {
  return (
    <div className="container mx-auto px-4 py-8">
      <div className="flex justify-between items-end mb-8">
        <div>
          <h1 className="text-3xl font-bold font-mono tracking-tight mb-2">TARGET_<span className="text-accent">VECTORS</span></h1>
          <p className="text-muted-foreground">Define what the AI agents should hunt for.</p>
        </div>
        <button className="flex items-center gap-2 px-4 py-2 bg-accent hover:bg-accent/90 text-accent-foreground rounded font-mono text-sm font-bold shadow-[0_0_15px_rgba(251,191,36,0.3)]">
          <Plus className="w-4 h-4" /> ADD_TARGET
        </button>
      </div>

      <div className="bg-card border border-border rounded-lg overflow-hidden">
        <div className="grid grid-cols-12 gap-4 p-4 border-b border-border bg-background/50 font-mono text-xs text-muted-foreground">
          <div className="col-span-1">ORDER</div>
          <div className="col-span-5">SEARCH_TERM</div>
          <div className="col-span-2">MAX_PRICE</div>
          <div className="col-span-2">PRIORITY</div>
          <div className="col-span-2 text-right">ACTIONS</div>
        </div>

        <div>
          {mockTargets.map((target, i) => (
            <motion.div 
              key={target.id}
              initial={{ opacity: 0 }}
              animate={{ opacity: 1 }}
              transition={{ delay: i * 0.1 }}
              className="grid grid-cols-12 gap-4 p-4 border-b border-border/50 items-center hover:bg-background/30 transition-colors group"
            >
              <div className="col-span-1 text-muted-foreground">
                <GripVertical className="w-4 h-4 cursor-grab" />
              </div>
              <div className="col-span-5 font-bold flex items-center gap-2">
                <Search className="w-4 h-4 text-primary" />
                {target.term}
              </div>
              <div className="col-span-2 font-mono">
                ${target.maxPrice}
              </div>
              <div className="col-span-2">
                <div className="flex items-center gap-2">
                  <div className="w-16 h-1.5 bg-background rounded-full overflow-hidden">
                    <div className="h-full bg-accent" style={{width: `${(target.weight / 2) * 100}%`}}></div>
                  </div>
                  <span className="font-mono text-xs">{target.weight}x</span>
                </div>
              </div>
              <div className="col-span-2 flex justify-end gap-2">
                <button className="p-2 hover:bg-background rounded text-muted-foreground hover:text-primary transition-colors">
                  <Settings2 className="w-4 h-4" />
                </button>
                <button className="p-2 hover:bg-background rounded text-muted-foreground hover:text-destructive transition-colors">
                  <Trash2 className="w-4 h-4" />
                </button>
              </div>
            </motion.div>
          ))}
        </div>
      </div>
      
      <div className="mt-8 p-6 border border-border border-dashed rounded-lg bg-card/30">
        <h3 className="font-mono text-primary mb-2 flex items-center gap-2"><Settings2 className="w-4 h-4" /> AI_FILTERING_TEMPLATE</h3>
        <p className="text-sm text-muted-foreground mb-4">You can define a natural language description for the LLM to verify against. e.g. "Item must not be broken. Must include power cable. Ignore 'box only' listings."</p>
        <div className="w-full h-24 bg-background border border-border rounded p-3 font-mono text-sm text-muted-foreground cursor-text">
          // Enter custom instructions for the Analyst Agent here...
        </div>
      </div>
    </div>
  );
}
