'use client'

import React from 'react'

export type CardVariant = 'elevated' | 'outlined' | 'flat'

export interface CardProps {
  variant?: CardVariant
  className?: string
  padding?: boolean
  children: React.ReactNode
}

export interface CardHeaderProps {
  className?: string
  children: React.ReactNode
}

export interface CardBodyProps {
  className?: string
  children: React.ReactNode
}

export interface CardFooterProps {
  className?: string
  children: React.ReactNode
}

const variantStyles: Record<CardVariant, string> = {
  elevated: 'bg-white dark:bg-gray-800 shadow-md',
  outlined: 'bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700',
  flat: 'bg-gray-50 dark:bg-gray-900',
}

export const Card = ({
  variant = 'elevated',
  className = '',
  padding = true,
  children,
}: CardProps) => {
  const baseStyles = 'rounded-lg'
  const paddingStyles = padding ? 'p-6' : ''

  const combinedClassName = `${baseStyles} ${variantStyles[variant]} ${paddingStyles} ${className}`.trim()

  return (
    <div className={combinedClassName}>
      {children}
    </div>
  )
}

export const CardHeader = ({ className = '', children }: CardHeaderProps) => {
  return (
    <div className={`mb-4 ${className}`.trim()}>
      {children}
    </div>
  )
}

export const CardBody = ({ className = '', children }: CardBodyProps) => {
  return (
    <div className={className}>
      {children}
    </div>
  )
}

export const CardFooter = ({ className = '', children }: CardFooterProps) => {
  return (
    <div className={`mt-4 ${className}`.trim()}>
      {children}
    </div>
  )
}
