import React from 'react'

interface SpinnerProps {
  size?: 'sm' | 'md' | 'lg'
  color?: 'primary' | 'secondary' | 'white'
  className?: string
  label?: string
}

const Spinner: React.FC<SpinnerProps> = ({
  size = 'md',
  color = 'primary',
  className = '',
  label = 'Loading...',
}) => {
  const sizeClasses = {
    sm: 'w-4 h-4',
    md: 'w-8 h-8',
    lg: 'w-12 h-12',
  }

  const colorClasses = {
    primary: 'text-blue-600',
    secondary: 'text-gray-600',
    white: 'text-white',
  }

  return (
    <div className="inline-flex items-center justify-center">
      <div
        className={`
          animate-spin
          rounded-full
          border-2
          border-current
          border-t-transparent
          ${sizeClasses[size]}
          ${colorClasses[color]}
          ${className}
        `}
        role="status"
        aria-label="loading"
      >
        <span className="sr-only">{label}</span>
      </div>
    </div>
  )
}

export default Spinner
