function LoginPage({ onLogin }) {
  const [username, setUsername] = React.useState('');
  const [password, setPassword] = React.useState('');
  const [error, setError] = React.useState('');
  const [loading, setLoading] = React.useState(false);

  const handleSubmit = async (e) => {
    e.preventDefault();
    if (!username || !password) return;
    setLoading(true);
    setError('');
    try {
      const data = await API.post('/api/auth/login', { username, password });
      API.setTokens(data.access_token, data.refresh_token);
      API.setUser(data.user);
      onLogin(data.user);
    } catch (err) {
      setError(err.message || 'Identifiants incorrects');
    } finally {
      setLoading(false);
    }
  };

  return React.createElement('div', { className: 'login-page' },
    React.createElement('div', { className: 'login-bg-orbs' },
      React.createElement('div', { className: 'orb' }),
      React.createElement('div', { className: 'orb' }),
      React.createElement('div', { className: 'orb' })
    ),
    React.createElement('div', { className: 'login-card' },
      React.createElement('div', { className: 'login-logo' },
        React.createElement('h1', null, 'APROGSYS'),
        React.createElement('p', null, 'Gestion de Projets Industriels')
      ),
      React.createElement('form', { className: 'login-form', onSubmit: handleSubmit },
        error && React.createElement('div', { className: 'login-error' }, error),
        React.createElement('div', { className: 'form-group' },
          React.createElement('label', null, 'Identifiant'),
          React.createElement('input', {
            type: 'text', value: username, placeholder: 'Nom d\'utilisateur',
            onChange: e => setUsername(e.target.value), autoFocus: true
          })
        ),
        React.createElement('div', { className: 'form-group' },
          React.createElement('label', null, 'Mot de passe'),
          React.createElement('input', {
            type: 'password', value: password, placeholder: '••••••••',
            onChange: e => setPassword(e.target.value)
          })
        ),
        React.createElement('button', {
          type: 'submit', className: 'btn btn-primary btn-lg btn-full',
          disabled: loading || !username || !password
        },
          loading ? React.createElement('span', { className: 'loading-spinner' }) : null,
          loading ? 'Connexion...' : 'Se connecter'
        )
      )
    )
  );
}
