import React from 'react';
import { View, StyleSheet, ViewStyle } from 'react-native';
import { colors, spacing, radii, shadows } from '../../theme/tokens';

type CardVariant = 'default' | 'elevated' | 'outlined';

interface CardProps {
  children: React.ReactNode;
  variant?: CardVariant;
  padding?: keyof typeof spacing;
  style?: ViewStyle;
}

export function Card({
  children,
  variant = 'default',
  padding = 'xl',
  style,
}: CardProps) {
  return (
    <View
      style={[
        styles.base,
        VARIANT_STYLES[variant],
        { padding: spacing[padding] },
        style,
      ]}
    >
      {children}
    </View>
  );
}

const VARIANT_STYLES: Record<CardVariant, ViewStyle> = {
  default: {
    backgroundColor: colors.surface,
    ...shadows.md,
  },
  elevated: {
    backgroundColor: colors.surface,
    ...shadows.lg,
  },
  outlined: {
    backgroundColor: colors.surface,
    borderWidth: 1,
    borderColor: colors.neutral[200],
  },
};

const styles = StyleSheet.create({
  base: {
    borderRadius: radii['2xl'],
    overflow: 'hidden',
  },
});
