"use client";
import React from "react";
import { cn } from "../shared/utils";

// Custom SVG icons to replace Radix UI dependencies
const BellIcon = ({ className }: { className?: string }) => (
  <svg
    className={cn("h-4 w-4", className)}
    fill="none"
    height="15"
    viewBox="0 0 15 15"
    width="15"
    xmlns="http://www.w3.org/2000/svg"
  >
    <path
      d="M7.5 0C7.77614 0 8 0.223858 8 0.5V1.5C10.3638 1.5 12.5 3.63622 12.5 6V9.5C12.5 10.0523 12.9477 10.5 13.5 10.5C14.0523 10.5 14.5 10.0523 14.5 9.5V6C14.5 2.68629 11.8137 0 8.5 0H7.5ZM0 6V9.5C0 10.0523 0.447715 10.5 1 10.5C1.55228 10.5 2 10.0523 2 9.5V6C2 3.63622 4.13622 1.5 6.5 1.5H7.5C7.77614 1.5 8 1.27614 8 1C8 0.723858 7.77614 0.5 7.5 0.5H6.5C3.18629 0.5 0.5 3.18629 0.5 6.5V6H0ZM7.5 12C8.60457 12 9.5 11.1046 9.5 10H5.5C5.5 11.1046 6.39543 12 7.5 12Z"
      fill="currentColor"
      fillRule="evenodd"
      clipRule="evenodd"
    />
  </svg>
);

const CalendarIcon = ({ className }: { className?: string }) => (
  <svg
    className={cn("h-4 w-4", className)}
    fill="none"
    height="15"
    viewBox="0 0 15 15"
    width="15"
    xmlns="http://www.w3.org/2000/svg"
  >
    <path
      d="M3.5 0C3.77614 0 4 0.223858 4 0.5V1H11V0.5C11 0.223858 11.2239 0 11.5 0C11.7761 0 12 0.223858 12 0.5V1H13C14.1046 1 15 1.89543 15 3V13C15 14.1046 14.1046 15 13 15H2C0.895431 15 0 14.1046 0 13V3C0 1.89543 0.895431 1 2 1H3V0.5C3 0.223858 3.22386 0 3.5 0ZM4 2H2C1.44772 2 1 2.44772 1 3V4H14V3C14 2.44772 13.5523 2 13 2H11V2.5C11 2.77614 10.7761 3 10.5 3C10.2239 3 10 2.77614 10 2.5V2H5V2.5C5 2.77614 4.77614 3 4.5 3C4.22386 3 4 2.77614 4 2.5V2ZM14 5H1V13C1 13.5523 1.44772 14 2 14H13C13.5523 14 14 13.5523 14 13V5Z"
      fill="currentColor"
      fillRule="evenodd"
      clipRule="evenodd"
    />
  </svg>
);

const FileTextIcon = ({ className }: { className?: string }) => (
  <svg
    className={cn("h-4 w-4", className)}
    fill="none"
    height="15"
    viewBox="0 0 15 15"
    width="15"
    xmlns="http://www.w3.org/2000/svg"
  >
    <path
      d="M3.5 2C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V6H8.5C8.22386 6 8 5.77614 8 5.5V2H3.5ZM9 2.70711L11.2929 5H9V2.70711ZM2 2.5C2 1.67157 2.67157 1 3.5 1H8.5C8.77614 1 9 1.22386 9 1.5V5.5C9 5.77614 9.22386 6 9.5 6H12.5C12.7761 6 13 6.22386 13 6.5V12.5C13 13.3284 12.3284 14 11.5 14H3.5C2.67157 14 2 13.3284 2 12.5V2.5ZM4.5 7C4.22386 7 4 7.22386 4 7.5C4 7.77614 4.22386 8 4.5 8H10.5C10.7761 8 11 7.77614 11 7.5C11 7.22386 10.7761 7 10.5 7H4.5ZM4 9.5C4 9.22386 4.22386 9 4.5 9H7.5C7.77614 9 8 9.22386 8 9.5C8 9.77614 7.77614 10 7.5 10H4.5C4.22386 10 4 9.77614 4 9.5Z"
      fill="currentColor"
      fillRule="evenodd"
      clipRule="evenodd"
    />
  </svg>
);

const GlobeIcon = ({ className }: { className?: string }) => (
  <svg
    className={cn("h-4 w-4", className)}
    fill="none"
    height="15"
    viewBox="0 0 15 15"
    width="15"
    xmlns="http://www.w3.org/2000/svg"
  >
    <path
      d="M7.5 0.875C5.51823 0.875 3.875 2.51823 3.875 4.5C3.875 6.15288 4.98124 7.54738 6.49373 7.98351C5.2997 8.12901 4.27557 8.55134 3.50407 9.31167C2.52216 10.2794 2.02502 11.72 2.02502 13.5999C2.02502 13.8623 2.23769 14.0749 2.50002 14.0749C2.76236 14.0749 2.97502 13.8623 2.97502 13.5999C2.97502 11.8799 3.42786 10.7206 4.17049 9.90498C4.91544 9.08626 5.98196 8.64851 7.49995 8.64851C9.01797 8.64851 10.0845 9.08626 10.8294 9.90498C11.572 10.7206 12.0249 11.8799 12.0249 13.5999C12.0249 13.8623 12.2376 14.0749 12.5 14.0749C12.7623 14.0749 12.975 13.8623 12.975 13.5999C12.975 11.72 12.4778 10.2794 11.4959 9.31167C10.7244 8.55135 9.70025 8.12903 8.50625 7.98352C10.0187 7.5474 11.125 6.15289 11.125 4.5C11.125 2.51823 9.48177 0.875 7.5 0.875ZM4.825 4.5C4.825 3.02264 6.02264 1.825 7.5 1.825C8.97736 1.825 10.175 3.02264 10.175 4.5C10.175 5.97736 8.97736 7.175 7.5 7.175C6.02264 7.175 4.825 5.97736 4.825 4.5Z"
      fill="currentColor"
      fillRule="evenodd"
      clipRule="evenodd"
    />
  </svg>
);

const InputIcon = ({ className }: { className?: string }) => (
  <svg
    className={cn("h-4 w-4", className)}
    fill="none"
    height="15"
    viewBox="0 0 15 15"
    width="15"
    xmlns="http://www.w3.org/2000/svg"
  >
    <path
      d="M1.5 0C0.671573 0 0 0.671573 0 1.5V13.5C0 14.3284 0.671573 15 1.5 15H13.5C14.3284 15 15 14.3284 15 13.5V1.5C15 0.671573 14.3284 0 13.5 0H1.5ZM1 1.5C1 1.22386 1.22386 1 1.5 1H13.5C13.7761 1 14 1.22386 14 1.5V13.5C14 13.7761 13.7761 14 13.5 14H1.5C1.22386 14 1 13.7761 1 13.5V1.5ZM3 3C3 2.44772 3.44772 2 4 2H11C11.5523 2 12 2.44772 12 3C12 3.55228 11.5523 4 11 4H4C3.44772 4 3 3.55228 3 3ZM3 6C3 5.44772 3.44772 5 4 5H11C11.5523 5 12 5.44772 12 6C12 6.55228 11.5523 7 11 7H4C3.44772 7 3 6.55228 3 6ZM3 9C3 8.44772 3.44772 8 4 8H7C7.55228 8 8 8.44772 8 9C8 9.55228 7.55228 10 7 10H4C3.44772 10 3 9.55228 3 9Z"
      fill="currentColor"
      fillRule="evenodd"
      clipRule="evenodd"
    />
  </svg>
);

// Icon mapping for easy access
const iconMap = {
  BellIcon,
  CalendarIcon,
  FileTextIcon,
  GlobeIcon,
  InputIcon,
};

export interface BentoCardProps {
  Icon: keyof typeof iconMap;
  name: string;
  description: string;
  href: string;
  cta: string;
  background?: React.ReactNode;
  className?: string;
}

export function BentoCard({ 
  Icon, 
  name, 
  description, 
  href, 
  cta, 
  background, 
  className 
}: BentoCardProps) {
  const IconComponent = iconMap[Icon];
  
  return (
    <div
      className={cn(
        "group relative overflow-hidden rounded-xl border border-white/[0.1] bg-black p-8",
        className
      )}
    >
      {background}
      <div className="relative z-10">
        <IconComponent className="mb-4 h-8 w-8 text-white" />
        <h3 className="mb-2 text-lg font-semibold text-white">{name}</h3>
        <p className="mb-4 text-sm text-neutral-300">{description}</p>
        <a
          href={href}
          className="inline-flex items-center gap-2 text-sm text-neutral-300 transition-colors hover:text-white"
        >
          {cta}
          <svg
            className="h-4 w-4 transition-transform group-hover:translate-x-1"
            fill="none"
            viewBox="0 0 24 24"
            stroke="currentColor"
          >
            <path
              strokeLinecap="round"
              strokeLinejoin="round"
              strokeWidth={2}
              d="M9 5l7 7-7 7"
            />
          </svg>
        </a>
      </div>
    </div>
  );
}
