import { cn } from '@/lib/cn';
import { cva, type VariantProps } from 'class-variance-authority';
import { forwardRef, type HTMLAttributes } from 'react';

const cardVariants = cva('rounded-xl border bg-card shadow-sm transition-shadow', {
    variants: {
        variant: {
            default: 'border-border',
            dashed: 'border-dashed border-border',
            interactive:
                'border-border hover:border-accent/40 hover:shadow-md cursor-pointer',
        },
        padding: {
            none: '',
            sm: 'p-4',
            md: 'p-5',
            lg: 'p-6',
        },
    },
    defaultVariants: {
        variant: 'default',
        padding: 'md',
    },
});

type CardProps = HTMLAttributes<HTMLDivElement> & VariantProps<typeof cardVariants>;

export const Card = forwardRef<HTMLDivElement, CardProps>(
    ({ className, variant, padding, ...props }, ref) => (
        <div
            ref={ref}
            className={cn(cardVariants({ variant, padding }), className)}
            {...props}
        />
    ),
);

Card.displayName = 'Card';
