import React from 'react';
import clsx from 'clsx';

export interface CardProps {
  title?: string;
  description?: string;
  children: React.ReactNode;
  footer?: React.ReactNode;
  className?: string;
  actions?: React.ReactNode;
  'data-testid'?: string;
}

export function Card({ title, description, children, footer, className, actions, ...rest }: CardProps) {
  return (
    <div
      className={clsx(
        'bg-white rounded-lg shadow-sm border border-secondary-200 overflow-hidden',
        className
      )}
      {...rest}
    >
      {(title || actions) && (
        <div className="px-6 py-4 border-b border-secondary-200 flex items-center justify-between">
          <div>
            {title && <h3 className="text-lg font-semibold text-secondary-900">{title}</h3>}
            {description && <p className="text-sm text-secondary-500 mt-1">{description}</p>}
          </div>
          {actions && <div className="flex items-center gap-2">{actions}</div>}
        </div>
      )}
      <div className="px-6 py-4">{children}</div>
      {footer && (
        <div className="px-6 py-3 bg-secondary-50 border-t border-secondary-200">{footer}</div>
      )}
    </div>
  );
}
