import React from 'react';
import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
import { LucideIcon } from 'lucide-react';

export interface OnboardingAction {
  id: string;
  label: string;
  description?: string;
  href?: string;
  onClick?: () => void;
  icon?: LucideIcon;
  variant?: 'primary' | 'secondary';
  disabled?: boolean;
  buttonLabel?: string;
}

interface OnboardingCTAListProps {
  actions: OnboardingAction[];
  className?: string;
}

export function OnboardingCTAList({ actions, className }: OnboardingCTAListProps) {
  if (!actions.length) {
    return null;
  }

  return (
    <div className={cn('grid gap-4 md:grid-cols-2', className)}>
      {actions.map(({ id, label, description, href, onClick, icon: Icon, variant = 'primary', disabled, buttonLabel }) => (
        <div
          key={id}
          className="flex flex-col gap-3 rounded-2xl border border-brand-rose-soft bg-brand-card p-5 shadow-brand-primary backdrop-blur"
        >
          <div className="flex items-center gap-3">
            {Icon && (
              <span className="flex size-10 items-center justify-center rounded-full bg-brand-rose-soft text-brand-rose shadow-inner">
                <Icon className="size-5" />
              </span>
            )}
            <span className="text-base font-semibold text-brand-slate">{label}</span>
          </div>
          {description && (
            <p className="text-sm text-brand-navy/80">{description}</p>
          )}
          <div>
            <Button
              variant="default"
              size="lg"
              className={cn(
                'w-full rounded-full transition-all',
                variant === 'secondary'
                  ? 'bg-brand-gold text-brand-slate shadow-md shadow-amber-200/40 hover:bg-[var(--brand-gold-soft)]'
                  : 'bg-brand-rose text-white shadow-md shadow-rose-400/30 hover:bg-[var(--brand-rose-strong)]'
              )}
              disabled={disabled}
              onClick={onClick}
              {...(href ? { asChild: true } : {})}
            >
              {href ? <a href={href}>{buttonLabel ?? label}</a> : buttonLabel ?? label}
            </Button>
          </div>
        </div>
      ))}
    </div>
  );
}

OnboardingCTAList.displayName = 'OnboardingCTAList';
