interface SeasonStatistics {
  racesCompleted: number;
  totalRaces: number;
  averagePoints: number;
  highestScore: number;
  totalPoints: number;
}

interface SeasonStatsCardProps {
  stats: SeasonStatistics;
}

export function SeasonStatsCard({ stats }: SeasonStatsCardProps) {
  const completionPercentage = stats.totalRaces > 0 
    ? Math.round((stats.racesCompleted / stats.totalRaces) * 100) 
    : 0;

  if (stats.racesCompleted === 0) {
    return null;
  }

  return (
    <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
      <div className="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
        <h3 className="text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2">
          📈 Season Statistics
        </h3>
        <p className="text-sm text-gray-600 dark:text-gray-400 mt-1">
          Your performance this season
        </p>
      </div>
      <div className="p-6">
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
          <div className="bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-950/20 dark:to-cyan-950/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800">
            <p className="text-xs text-blue-600 dark:text-blue-400 uppercase tracking-wider mb-1 font-medium">
              Races Completed
            </p>
            <p className="text-3xl font-bold text-gray-900 dark:text-white">
              {stats.racesCompleted}
              <span className="text-lg text-gray-500 dark:text-gray-400">/{stats.totalRaces}</span>
            </p>
          </div>
          
          <div className="bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-950/20 dark:to-emerald-950/20 rounded-lg p-4 border border-green-200 dark:border-green-800">
            <p className="text-xs text-green-600 dark:text-green-400 uppercase tracking-wider mb-1 font-medium">
              Average Points
            </p>
            <p className="text-3xl font-bold text-gray-900 dark:text-white">
              {stats.averagePoints.toFixed(1)}
            </p>
          </div>
          
          <div className="bg-gradient-to-br from-purple-50 to-pink-50 dark:from-purple-950/20 dark:to-pink-950/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800">
            <p className="text-xs text-purple-600 dark:text-purple-400 uppercase tracking-wider mb-1 font-medium">
              Highest Score
            </p>
            <p className="text-3xl font-bold text-gray-900 dark:text-white">
              {stats.highestScore}
            </p>
          </div>
          
          <div className="bg-gradient-to-br from-orange-50 to-red-50 dark:from-orange-950/20 dark:to-red-950/20 rounded-lg p-4 border border-orange-200 dark:border-orange-800">
            <p className="text-xs text-orange-600 dark:text-orange-400 uppercase tracking-wider mb-1 font-medium">
              Total Points
            </p>
            <p className="text-3xl font-bold text-gray-900 dark:text-white">
              {stats.totalPoints}
            </p>
          </div>
        </div>

        <div className="space-y-2">
          <div className="flex justify-between items-center text-sm">
            <span className="text-gray-600 dark:text-gray-400">Season Progress</span>
            <span className="font-semibold text-gray-900 dark:text-white">{completionPercentage}%</span>
          </div>
          <div className="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-3 overflow-hidden">
            <div 
              className="bg-gradient-to-r from-blue-500 to-purple-500 h-3 rounded-full transition-all duration-500 ease-out"
              style={{ width: `${completionPercentage}%` }}
            />
          </div>
        </div>
      </div>
    </div>
  );
}