import{c as w,r as a,e as S,a as L,u as k,j as e,L as A,m as h,I as f,B as E}from"./index-BOOC9B8a.js";import{C as I,L as b}from"./label-DoZz00xR.js";import{A as C}from"./arrow-left-RVwEGMvW.js";import{S as F}from"./shield-B6_HSr1V.js";import{M as P}from"./mail-CNwzbeXK.js";const g=w("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),D=()=>{const[l,j]=a.useState(""),[n,N]=a.useState(""),[m,r]=a.useState(""),[i,t]=a.useState(!1),{signIn:v,user:u,isAdmin:x,isLoading:o}=S(),d=L(),p=k();a.useEffect(()=>{const s=p.state;s?.error&&r(s.error)},[p.state]),a.useEffect(()=>{!o&&u&&x&&d("/admin/dashboard",{replace:!0})},[u,x,o,d]);const y=async s=>{if(s.preventDefault(),r(""),t(!0),!l.trim()||!n.trim()){r("Please enter both email and password"),t(!1);return}try{const{error:c}=await v(l.trim(),n);if(c){r(c.message||"Invalid credentials"),t(!1);return}d("/admin/dashboard",{replace:!0}),t(!1)}catch{r("An unexpected error occurred. Please try again."),t(!1)}};return o?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary border-t-transparent rounded-full"})}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx("header",{className:"p-4",children:e.jsxs(A,{to:"/",className:"inline-flex items-center text-muted-foreground hover:text-primary transition-colors",children:[e.jsx(C,{className:"w-4 h-4 mr-2"}),"Back to Website"]})}),e.jsx("main",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(h.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"w-full max-w-md",children:e.jsxs("div",{className:"glass-intense p-8 rounded-2xl border border-border/50",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/logo-final.png",alt:"VSYNC Studio",className:"w-[230px] h-auto object-contain mx-auto mb-6"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(F,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-display font-bold text-2xl",children:"Admin Login"})]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Secure access to admin dashboard"})]}),m&&e.jsxs(h.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"mb-6 p-4 bg-destructive/10 border border-destructive/30 rounded-lg flex items-start gap-3",children:[e.jsx(I,{className:"w-5 h-5 text-destructive shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-destructive",children:m})]}),e.jsxs("form",{onSubmit:y,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"email",className:"sr-only",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx(f,{id:"email",type:"email",placeholder:"Email",value:l,onChange:s=>j(s.target.value),className:"pl-10 bg-surface border-border/50 focus:border-primary",disabled:i,autoComplete:"email",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",className:"text-foreground",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(g,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx(f,{id:"password",type:"password",placeholder:"••••••••••",value:n,onChange:s=>N(s.target.value),className:"pl-10 bg-surface border-border/50 focus:border-primary",disabled:i,autoComplete:"current-password",required:!0})]})]}),e.jsx(E,{type:"submit",className:"w-full btn-studio",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-white border-t-transparent rounded-full mr-2"}),"Signing In..."]}):e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),"Sign In"]})})]}),e.jsx("div",{className:"mt-6 pt-6 border-t border-border/30",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"🔒 This is a secure admin area. All login attempts are logged."})})]})})})]})};export{D as default};
