import { memo } from 'react';
import { Handle, Position, type NodeProps } from '@xyflow/react';
import { Database } from 'lucide-react';

export const DatabaseNode = memo(({ data, selected }: NodeProps) => {
  const label = (data as { label?: string }).label ?? 'Database';
  return (
    <div className={`min-w-[140px] bg-slate-800 border rounded-lg shadow-lg overflow-hidden ${selected ? 'ring-2 ring-teal-500 border-teal-500' : 'border-teal-700'}`}>
      <Handle type="target" position={Position.Top} className="!bg-teal-400 !border-teal-600" />
      <div className="px-3 py-2 flex items-center gap-2">
        <Database size={13} className="text-teal-400 shrink-0" />
        <span className="text-xs font-medium text-slate-100 truncate">{label}</span>
      </div>
      <Handle type="source" position={Position.Bottom} className="!bg-teal-400 !border-teal-600" />
    </div>
  );
});
DatabaseNode.displayName = 'DatabaseNode';
