// js/components/widgets/users/UsersLogTable.jsx
// [Wave v223.27 2026-05-19] Tabela histórico login/logout extraída de UsersPanel.
(function(){
  'use strict';
  function UsersLogTable({logs}){
    return (
      <div className="card" style={{padding:0}}>
        <div style={{padding:'12px 16px',borderBottom:'1px solid #E5E7EB',fontSize:13,fontWeight:700,color:'#1B2A4A'}}>📋 Histórico de login/logout (últimos 200)</div>
        <div style={{overflowX:'auto'}}>
          <table style={{width:'100%'}}>
            <thead><tr><th>Usuário</th><th>Ação</th><th>Data/Hora</th></tr></thead>
            <tbody>
              {(logs||[]).map(e=>(
                <tr key={e.id}>
                  <td style={{fontWeight:500}}>{e.name||e.username}</td>
                  <td><span className={e.action==='login'?"badge badge-green":"badge badge-red"}>{e.action==='login'?'Login':'Logout'}</span></td>
                  <td className="dim">{new Date(e.timestamp).toLocaleDateString('pt-BR')} {new Date(e.timestamp).toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit',second:'2-digit'})}</td>
                </tr>
              ))}
              {(!logs||logs.length===0)&&<tr><td colSpan={3} style={{textAlign:'center',padding:24,color:'#9CA3AF'}}>Nenhum registro de atividade ainda</td></tr>}
            </tbody>
          </table>
        </div>
      </div>
    );
  }
  window.ZNX = window.ZNX || {};
  window.ZNX.widgets = window.ZNX.widgets || {};
  window.ZNX.widgets.users = window.ZNX.widgets.users || {};
  window.ZNX.widgets.users.UsersLogTable = UsersLogTable;
})();
