export default function TokenBar({ token, onRefresh, onClear }) {
  const handleCopy = () => {
    if (!token) { alert('No token to copy.'); return; }
    navigator.clipboard
      .writeText(token)
      .then(() => alert('Token copied!'))
      .catch(() => alert(token.substring(0, 80) + '…'));
  };

  return (
    <div className="token-bar">
      <span className="token-label">JWT Token</span>
      <span className="token-val">
        {token ? token.substring(0, 64) + '…' : 'No token — log in first'}
      </span>
      <button className="btn btn-ghost btn-sm" onClick={handleCopy}>Copy</button>
      <button className="btn btn-danger btn-sm" onClick={onClear}>Clear</button>
    </div>
  );
}
