import React from 'react';

interface ScoreItem { label: string; value: number; max?: number; }
interface Props { title?: string; items: ScoreItem[]; color?: string; }

const ScoreBarList: React.FC<Props> = ({ title, items, color = '#6366f1' }) => {
    return (
        <div className="space-y-3">
            {title && <h4 className="text-sm font-medium text-[--text-secondary]">{title}</h4>}
            <ul className="space-y-2">
                {items.map(it => {
                    const pct = Math.min(100, Math.round((it.value / (it.max ?? 100)) * 100));
                    return (
                        <li key={it.label} className="space-y-1">
                            <div className="flex justify-between text-xs text-[--text-secondary]">
                                <span>{it.label}</span>
                                <span>{it.value}{it.max ? `/${it.max}` : ''}</span>
                            </div>
                            <div className="h-2 bg-[--background-secondary] rounded overflow-hidden">
                                <div className="h-full transition-all" style={{ width: pct + '%', background: color }} />
                            </div>
                        </li>
                    );
                })}
            </ul>
        </div>
    );
};

export default ScoreBarList;
