import type { LucideIcon } from "lucide-react";
import { Workflow } from "lucide-react";
import { cn } from "@/utils/cn";

export type FlowCardItem = {
  title: string;
  description: string;
  background: string;
  iconBackground: string;
  iconColor: string;
  icon?: LucideIcon;
};

type FlowCardProps = {
  items: FlowCardItem[];
  className?: string;
};

const FlowCard = ({ items, className }: FlowCardProps) => {
  return (
    <ul
      className={cn(
        "mt-10 grid grid-cols-1 gap-4 sm:mt-14 sm:gap-5 md:mt-18 md:grid-cols-3 md:gap-6",
        className,
      )}
    >
      {items.map((item) => {
        const Icon = item.icon ?? Workflow;

        return (
          <li
            key={item.title}
            className="flex w-full flex-col items-center justify-center rounded-2xl p-6 text-center sm:rounded-[20px] sm:p-8 md:p-10"
            style={{ backgroundColor: item.background }}
          >
            <Icon
              size={40}
              className="mb-3 rounded-xl p-2 sm:mb-4"
              style={{
                backgroundColor: item.iconBackground,
                color: item.iconColor,
              }}
            />
            <h3 className="text-lg font-medium sm:text-xl md:text-[25px]">
              {item.title}
            </h3>
            <p className="mt-1.5 text-sm text-[#4D4D4D] sm:mt-2 sm:text-base">
              {item.description}
            </p>
          </li>
        );
      })}
    </ul>
  );
};

export default FlowCard;
