import { ReactNode } from 'react';
import { Box } from './Box';

export interface SectionProps {
  children: ReactNode;
  variant?: 'default' | 'dark' | 'muted';
  padding?: 'none' | 'sm' | 'md' | 'lg';
  id?: string;
  minHeight?: string;
  py?: number;
  fullWidth?: boolean;
  maxWidth?: string;
  /** @deprecated DO NOT USE. Use semantic props instead. */
  className?: string;
}

export const Section = ({ 
  children, 
  variant = 'default',
  padding = 'md',
  id,
  minHeight,
  py,
  className,
  fullWidth = false,
  maxWidth = '80rem'
}: SectionProps) => {
  const variantClasses = {
    default: 'bg-[var(--ui-color-bg-base)]',
    dark: 'bg-black',
    muted: 'bg-[var(--ui-color-bg-surface)]',
  };

  const paddingClasses = {
    none: 'py-0',
    sm: 'py-8',
    md: 'py-16',
    lg: 'py-24',
  };

  const classes = [
    variantClasses[variant],
    py !== undefined ? '' : paddingClasses[padding],
    className,
  ].join(' ');

  return (
    <section id={id} className={classes} style={{ 
      ...(minHeight ? { minHeight } : {}),
      ...(py !== undefined ? { paddingTop: `${py * 0.25}rem`, paddingBottom: `${py * 0.25}rem` } : {})
    }}>
      {fullWidth ? (
        children
      ) : (
        <Box marginX="auto" maxWidth={maxWidth} paddingX={4}>
          {children}
        </Box>
      )}
    </section>
  );
};
