import { Box, Card, CardContent, Skeleton } from '@mui/material'

interface CardSkeletonProps {
  lines?: number
  hasHeader?: boolean
  hasActions?: boolean
}

export function CardSkeleton({ lines = 3, hasHeader = true, hasActions = false }: CardSkeletonProps) {
  return (
    <Card>
      <CardContent>
        {hasHeader && (
          <Box sx={{ mb: 1.5 }}>
            <Skeleton variant="text" width="55%" height={22} />
            <Skeleton variant="text" width="35%" height={16} />
          </Box>
        )}
        <Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.75 }}>
          {Array.from({ length: lines }).map((_, i) => (
            <Skeleton key={i} variant="text" width={i % 2 === 0 ? '100%' : '80%'} height={16} />
          ))}
        </Box>
        {hasActions && (
          <Box sx={{ display: 'flex', gap: 1, mt: 2 }}>
            <Skeleton variant="rectangular" width={80} height={32} sx={{ borderRadius: 1 }} />
            <Skeleton variant="rectangular" width={80} height={32} sx={{ borderRadius: 1 }} />
          </Box>
        )}
      </CardContent>
    </Card>
  )
}
