import{p as L,n as k,k as t,s as _,j as e,L as B}from"./index-D0iJORaS.js";import{C as P,I as g,B as F,L as I}from"./input-CcQzS21A.js";import{L as j}from"./label-gVuAupIv.js";import{a as q,E as D,C as M}from"./checkbox-Cl0VgUkO.js";import{M as A}from"./mail-u7iluGro.js";import{L as R}from"./lock-DL7_GkL6.js";import"./index-BDB3jGHw.js";import"./index-BMUrwkl5.js";function Q(){const a=L(),{login:b,isAuthenticated:r,loading:o}=k(),[l,N]=t.useState(""),[i,v]=t.useState(""),[n,y]=t.useState(!0),[c,w]=t.useState(!1),[m,d]=t.useState(null),[u,x]=t.useState(!1),[h,E]=t.useState(null),[p,S]=t.useState("365-BI");t.useEffect(()=>{!o&&r&&a({to:"/"})},[o,r,a]),t.useEffect(()=>{_.from("system_config").select("titulo_sistema, logo_url").limit(1).maybeSingle().then(({data:s})=>{s?.logo_url&&E(s.logo_url),s?.titulo_sistema&&S(s.titulo_sistema)})},[]);const C=async s=>{s.preventDefault(),d(null),x(!0);try{await b(l,i,n),a({to:"/"})}catch(f){d(f instanceof Error?f.message:"Erro ao entrar.")}finally{x(!1)}};return e.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-gradient-to-br from-muted/40 via-background to-accent/30 px-4 py-10",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"mb-6 flex flex-col items-center",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl bg-gradient-to-br from-primary to-primary-glow shadow-lg shadow-primary/20 overflow-hidden",children:h?e.jsx("img",{src:h,alt:p,className:"h-full w-full object-contain"}):e.jsx(P,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx("h1",{className:"mt-3 text-xl font-bold tracking-tight",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Business Intelligence Platform"})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow-xl shadow-black/[0.04] sm:p-8",children:[e.jsxs("div",{className:"mb-6 space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Bem-vindo de volta"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Entre com seu e-mail e senha para acessar"})]}),e.jsxs("form",{onSubmit:C,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{htmlFor:"email",children:"E-mail"}),e.jsxs("div",{className:"relative",children:[e.jsx(A,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(g,{id:"email",type:"email",required:!0,autoComplete:"email",placeholder:"voce@empresa.com",value:l,onChange:s=>N(s.target.value),className:"h-11 pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(j,{htmlFor:"password",children:"Senha"}),e.jsx(B,{to:"/recuperar-senha",className:"text-xs font-medium text-primary hover:underline",children:"Esqueci minha senha"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(R,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(g,{id:"password",type:c?"text":"password",required:!0,autoComplete:"current-password",placeholder:"••••••••",value:i,onChange:s=>v(s.target.value),className:"h-11 pl-9 pr-10"}),e.jsx("button",{type:"button",onClick:()=>w(s=>!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Mostrar senha",children:c?e.jsx(q,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer select-none",children:[e.jsx(M,{checked:n,onCheckedChange:s=>y(!!s)}),"Lembrar acesso neste dispositivo"]}),m&&e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:m}),e.jsx(F,{type:"submit",className:"w-full h-11",disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4 animate-spin"})," Entrando..."]}):"Entrar"})]})]}),e.jsxs("p",{className:"mt-6 text-center text-xs text-muted-foreground",children:["© ",new Date().getFullYear()," Diário de bordo · Todos os direitos reservados"]})]})})}export{Q as component};
