import { ChevronDown, ChevronUp, Filter, Search } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { NativeSelect } from '@/components/ui/native-select';
import type { VocationalWorkflow } from '@/components/vocational-opportunities/types';

interface VocationalResultsHeaderProps {
  readonly workflow: VocationalWorkflow;
}

export function VocationalResultsHeader({ workflow }: VocationalResultsHeaderProps) {
  return (
    <div className="bg-slate-800/40 backdrop-blur-sm rounded-2xl border border-slate-700/40 p-5">
      <div className="flex flex-col md:flex-row gap-3 items-start md:items-center justify-between">
        <div>
          <h3 className="font-semibold text-white">
            {workflow.displayResults.length} Opportunit{workflow.displayResults.length !== 1 ? 'ies' : 'y'} Found Near {workflow.zipCode}
          </h3>
          <p className="text-xs text-slate-400 mt-0.5">Showing vocational programs with autism-specific accommodations</p>
        </div>
        <Button
          type="button"
          onClick={workflow.toggleFilters}
          leadingIcon={<Filter size={14} />}
          className="flex items-center gap-2 px-4 py-2 bg-slate-700/50 border border-slate-600/50 rounded-xl text-sm text-slate-300 hover:bg-slate-700 transition-colors"
        >
          Filters
          {workflow.showFilters ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
        </Button>
      </div>

      {workflow.showFilters && (
        <div className="mt-4 pt-4 border-t border-slate-700/40 grid grid-cols-1 md:grid-cols-2 gap-4">
          <label className="block">
            <span className="text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 block">Search</span>
            <div className="relative">
              <Search size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-500" />
              <Input
                type="text"
                value={workflow.searchQuery}
                onChange={(event) => workflow.setSearchQuery(event.target.value)}
                placeholder="Search by company, title, or category..."
                className="w-full pl-9 pr-4 py-2 bg-slate-700/50 border border-slate-600/50 rounded-xl text-sm text-white placeholder-slate-500 focus:ring-2 focus:ring-sky-500/50 outline-none"
              />
            </div>
          </label>
          <label className="block">
            <span className="text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 block">Category</span>
            <NativeSelect
              value={workflow.categoryFilter}
              onChange={(event) => workflow.updateCategoryFilter(event.target.value)}
              className="w-full px-3 py-2 bg-slate-700/50 border border-slate-600/50 rounded-xl text-sm text-white focus:ring-2 focus:ring-sky-500/50 outline-none"
            >
              <option value="all">All Categories</option>
              {workflow.categories.map((category) => (
                <option key={category} value={category}>{category}</option>
              ))}
            </NativeSelect>
          </label>
        </div>
      )}
    </div>
  );
}
