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

import { FrostedSurface } from '../../components/tenant';

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 }) => (
        <FrostedSurface
          key={id}
          className="flex flex-col gap-3 border border-white/20 p-5 text-slate-900 shadow-md shadow-rose-200/20 dark:border-slate-800/70 dark:bg-slate-950/80"
        >
          <div className="flex items-center gap-3">
            {Icon ? (
              <span className="flex size-10 items-center justify-center rounded-full bg-rose-100/80 text-rose-500 shadow-inner shadow-rose-200/60 dark:bg-rose-500/20 dark:text-rose-200">
                <Icon className="size-5" />
              </span>
            ) : null}
            <span className="text-base font-semibold text-slate-900 dark:text-slate-100">{label}</span>
          </div>
          {description ? (
            <p className="text-sm text-slate-600 dark:text-slate-400">{description}</p>
          ) : null}
          <div>
            <Button
              variant="default"
              size="lg"
              className={cn(
                'w-full rounded-full transition-colors',
                variant === 'secondary'
                  ? 'bg-slate-900/80 text-white shadow-md shadow-slate-900/30 hover:bg-slate-900 dark:bg-slate-800'
                  : 'bg-gradient-to-r from-[#ff5f87] via-[#ec4899] to-[#6366f1] text-white shadow-lg shadow-rose-300/30 hover:from-[#ff4470] hover:via-[#ec4899] hover:to-[#4f46e5]'
              )}
              disabled={disabled}
              onClick={onClick}
              {...(href ? { asChild: true } : {})}
            >
              {href ? <a href={href}>{buttonLabel ?? label}</a> : buttonLabel ?? label}
            </Button>
          </div>
        </FrostedSurface>
      ))}
    </div>
  );
}

OnboardingCTAList.displayName = 'OnboardingCTAList';
