import { useNavigate } from 'react-router-dom'
import { Box, ArrowRight } from 'lucide-react'
import { getTreeNavigatePath } from '@/lib/routing'
import type { SuggestedFlow } from '@/types/copilot'

interface SuggestedFlowCardProps {
  flow: SuggestedFlow
}

export function SuggestedFlowCard({ flow }: SuggestedFlowCardProps) {
  const navigate = useNavigate()

  const handleClick = () => {
    const path = getTreeNavigatePath(flow.tree_id, flow.tree_type)
    navigate(path)
  }

  return (
    <button
      onClick={handleClick}
      className="w-full text-left glass-card-static p-3 rounded-xl hover:border-[rgba(255,255,255,0.12)] transition-colors group"
    >
      <div className="flex items-start gap-2">
        <Box size={14} className="text-primary mt-0.5 shrink-0" />
        <div className="min-w-0 flex-1">
          <div className="flex items-center gap-1.5">
            <span className="text-[0.8125rem] font-medium text-foreground truncate">
              {flow.tree_name}
            </span>
            <span className="font-label text-[0.625rem] uppercase tracking-wider text-muted-foreground">
              {flow.tree_type}
            </span>
          </div>
          <p className="text-[0.75rem] text-muted-foreground mt-0.5 line-clamp-2">
            {flow.relevance_snippet}
          </p>
        </div>
        <ArrowRight size={14} className="text-muted-foreground group-hover:text-primary transition-colors shrink-0 mt-0.5" />
      </div>
    </button>
  )
}
