// screens_auth.jsx — Login, Register, Forgot Password, Welcome
// Clean Apple-native auth flow for TeamCaddy

// ─────────────────────────────────────────────────────────────
// Shared visual: logo mark
// ─────────────────────────────────────────────────────────────
function TTLogo({ size = 72, accent = '#FF3B30' }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: size * 0.26,
      background: `linear-gradient(145deg, ${accent}, ${accent}dd 60%, #000 180%)`,
      display:'flex', alignItems:'center', justifyContent:'center',
      boxShadow: `0 8px 24px ${accent}40, inset 0 -2px 4px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,255,255,0.3)`,
      position:'relative', overflow:'hidden',
    }}>
      <svg width={size * 0.58} height={size * 0.58} viewBox="0 0 40 40" fill="none">
        {/* Stylized TT with ball */}
        <path d="M6 10h12v4h-4v16h-4V14H6z" fill="#fff"/>
        <path d="M22 10h12v4h-4v16h-4V14h-4z" fill="#fff"/>
        <circle cx="32" cy="30" r="5" fill="#fff" opacity="0.9"/>
        <path d="M32 25v10M27 30h10" stroke={accent} strokeWidth="1.2"/>
      </svg>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Field: iOS-style grouped input
// ─────────────────────────────────────────────────────────────
function AuthField({ T, icon, type = 'text', placeholder, value, onChange, trailing, autoFocus, error }) {
  return (
    <div style={{
      display:'flex', alignItems:'center', gap: 10,
      background: T.card,
      border: `0.5px solid ${error ? T.red : T.sep}`,
      borderRadius: 14, padding: '0 14px', height: 52,
    }}>
      {icon && <Icon name={icon} size={18} color={T.label2} weight={2} />}
      <input
        type={type}
        value={value}
        onChange={e => onChange(e.target.value)}
        placeholder={placeholder}
        autoFocus={autoFocus}
        style={{
          flex: 1, border:'none', outline:'none', background:'transparent',
          fontFamily: T.font, fontSize: 16, color: T.label, letterSpacing: -0.2,
          padding: '14px 0', minWidth: 0,
        }}
      />
      {trailing}
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Primary button
// ─────────────────────────────────────────────────────────────
function AuthButton({ T, children, onClick, disabled, variant = 'primary', icon, loading }) {
  const isPrimary = variant === 'primary';
  const isSocial = variant === 'social';
  const isApple = variant === 'apple';
  const isGhost = variant === 'ghost';

  let style = {};
  if (isPrimary) style = { background: T.accent, color: '#fff', border: 'none' };
  if (isApple)   style = { background: T.dark ? '#fff' : '#000', color: T.dark ? '#000' : '#fff', border: 'none' };
  if (isSocial)  style = { background: T.card, color: T.label, border: `0.5px solid ${T.sep}` };
  if (isGhost)   style = { background: 'transparent', color: T.accent, border: 'none' };

  return (
    <button
      onClick={onClick}
      disabled={disabled || loading}
      style={{
        width:'100%', height: 52, borderRadius: 14,
        fontFamily: T.font, fontSize: 16, fontWeight: 600, letterSpacing: -0.2,
        cursor: disabled ? 'default' : 'pointer',
        opacity: disabled ? 0.5 : 1,
        display:'flex', alignItems:'center', justifyContent:'center', gap: 8,
        ...style,
      }}
    >
      {loading ? (
        <div style={{
          width: 18, height: 18, borderRadius: 9,
          border: `2px solid ${isPrimary || isApple ? 'rgba(255,255,255,0.35)' : T.sep}`,
          borderTopColor: isPrimary || isApple ? '#fff' : T.label,
          animation: 'spin 0.7s linear infinite',
        }}/>
      ) : (
        <>
          {icon && <Icon name={icon} size={18} color={isPrimary || isApple ? (isApple ? (T.dark ? '#000' : '#fff') : '#fff') : T.label} />}
          {children}
        </>
      )}
    </button>
  );
}

// ─────────────────────────────────────────────────────────────
// Divider with label
// ─────────────────────────────────────────────────────────────
function OrDivider({ T }) {
  return (
    <div style={{ display:'flex', alignItems:'center', gap: 10, margin:'6px 0' }}>
      <div style={{ flex: 1, height: 0.5, background: T.sep }}/>
      <span style={{ color: T.label2, fontSize: 12, fontWeight: 500, letterSpacing: 0.3 }}>OR</span>
      <div style={{ flex: 1, height: 0.5, background: T.sep }}/>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// WELCOME / LAUNCH SCREEN
// ─────────────────────────────────────────────────────────────
function WelcomeScreen({ T, onNav }) {
  return (
    <div style={{
      height:'100%', display:'flex', flexDirection:'column',
      padding: '0 28px 40px', background: T.bg,
      position:'relative', overflow:'hidden',
    }}>
      {/* Ambient backdrop */}
      <div style={{
        position:'absolute', top: -120, left: '50%', transform:'translateX(-50%)',
        width: 520, height: 520, borderRadius:'50%',
        background: `radial-gradient(circle, ${T.accent}26 0%, transparent 60%)`,
        pointerEvents:'none',
      }}/>
      <div style={{
        position:'absolute', bottom: -80, right: -60,
        width: 340, height: 340, borderRadius:'50%',
        background: `radial-gradient(circle, ${T.accent}18 0%, transparent 60%)`,
        pointerEvents:'none',
      }}/>

      {/* Hero */}
      <div style={{
        flex: 1, display:'flex', flexDirection:'column',
        alignItems:'center', justifyContent:'center', gap: 24,
        position:'relative', zIndex: 1,
      }}>
        <TTLogo size={92} accent={T.accent} />
        <div style={{ textAlign:'center' }}>
          <div style={{
            fontFamily: T.displayFont, fontSize: 44, fontWeight: 700,
            color: T.label, letterSpacing: -1.4, lineHeight: 1, marginBottom: 10,
          }}>TeamCaddy</div>
          <div style={{
            fontSize: 17, color: T.label2, lineHeight: 1.4,
            maxWidth: 280, margin:'0 auto',
          }}>Your team's schedule, chat, and memories — in one clean app.</div>
        </div>

        {/* Floating sample chips */}
        <div style={{ display:'flex', flexDirection:'column', gap: 10, marginTop: 16 }}>
          <FloatingChip T={T} icon="check" bg={T.green} text="RSVP'd for Saturday" delay={0}/>
          <FloatingChip T={T} icon="message" bg={T.accent} text="3 new from Coach" delay={0.4}/>
          <FloatingChip T={T} icon="camera" bg={T.blue} text="12 new photos" delay={0.8}/>
        </div>
      </div>

      {/* CTAs */}
      <div style={{ display:'flex', flexDirection:'column', gap: 10, position:'relative', zIndex: 1 }}>
        <AuthButton T={T} onClick={() => onNav('register')} variant="primary">Create account</AuthButton>
        <AuthButton T={T} onClick={() => onNav('login')} variant="ghost">I already have an account</AuthButton>
      </div>

      <style>{`
        @keyframes spin { to { transform: rotate(360deg); } }
        @keyframes floatchip { 0%{transform:translateY(6px);opacity:0} 100%{transform:translateY(0);opacity:1} }
      `}</style>
    </div>
  );
}

function FloatingChip({ T, icon, bg, text, delay = 0 }) {
  return (
    <div style={{
      display:'inline-flex', alignItems:'center', gap: 8,
      padding:'8px 14px 8px 10px', borderRadius: 18,
      background: T.card,
      border: `0.5px solid ${T.sep}`,
      boxShadow:'0 2px 8px rgba(0,0,0,0.05)',
      animation: `floatchip 0.6s ease ${delay}s both`,
    }}>
      <div style={{
        width: 22, height: 22, borderRadius: 11,
        background: bg, display:'flex', alignItems:'center', justifyContent:'center',
      }}>
        <Icon name={icon} size={13} color="#fff" weight={2.8}/>
      </div>
      <span style={{ color: T.label, fontSize: 14, fontWeight: 500 }}>{text}</span>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// LOGIN
// ─────────────────────────────────────────────────────────────
function LoginScreen({ T, onNav, onAuth }) {
  const [email, setEmail] = React.useState('jess@patel.co');
  const [password, setPassword] = React.useState('');
  const [show, setShow] = React.useState(false);
  const [loading, setLoading] = React.useState(false);
  const [error, setError] = React.useState(null);

  const submit = () => {
    setError(null);
    if (!email || !password) { setError('Please fill in both fields.'); return; }
    setLoading(true);
    setTimeout(() => { setLoading(false); onAuth(); }, 900);
  };

  return (
    <div style={{ padding:'16px 24px 40px', background: T.bg, minHeight:'100%', display:'flex', flexDirection:'column' }}>
      <button onClick={() => onNav('welcome')} style={{
        display:'flex', alignItems:'center', gap: 2, background:'none', border:'none', padding: 0,
        color: T.accent, fontSize: 17, cursor:'pointer', marginBottom: 20, fontFamily: T.font,
      }}>
        <Icon name="chevron-left" size={22} color={T.accent} weight={2.4}/>
      </button>

      <div style={{ display:'flex', flexDirection:'column', alignItems:'flex-start', marginBottom: 28 }}>
        <TTLogo size={56} accent={T.accent}/>
        <div style={{
          fontFamily: T.displayFont, fontSize: 32, fontWeight: 700, color: T.label,
          letterSpacing: -1, lineHeight: 1.05, marginTop: 20,
        }}>Welcome back</div>
        <div style={{ fontSize: 15, color: T.label2, marginTop: 4 }}>Sign in to your TeamCaddy account.</div>
      </div>

      <div style={{ display:'flex', flexDirection:'column', gap: 10 }}>
        <AuthField T={T} icon="mail" type="email" placeholder="Email" value={email} onChange={setEmail} autoFocus error={error} />
        <AuthField T={T} icon="lock" type={show ? 'text' : 'password'} placeholder="Password" value={password} onChange={setPassword} error={error}
          trailing={
            <button onClick={() => setShow(!show)} style={{
              background:'none', border:'none', padding: 4, cursor:'pointer', display:'flex',
            }}><Icon name={show ? 'eye-off' : 'eye'} size={18} color={T.label2} weight={2}/></button>
          }/>
        {error && <div style={{ color: T.red, fontSize: 13, marginTop: 2, marginLeft: 4 }}>{error}</div>}

        <button onClick={() => onNav('forgot')} style={{
          alignSelf:'flex-end', background:'none', border:'none', padding:'4px 2px',
          color: T.accent, fontSize: 14, fontWeight: 500, cursor:'pointer', fontFamily: T.font,
          marginTop: 2,
        }}>Forgot password?</button>
      </div>

      <div style={{ marginTop: 20, display:'flex', flexDirection:'column', gap: 10 }}>
        <AuthButton T={T} variant="primary" onClick={submit} loading={loading}>Sign in</AuthButton>

        <OrDivider T={T}/>

        <AuthButton T={T} variant="apple" icon="apple" onClick={() => onAuth()}>Continue with Apple</AuthButton>
        <AuthButton T={T} variant="social" icon="google" onClick={() => onAuth()}>Continue with Google</AuthButton>
      </div>

      <div style={{ flex: 1 }}/>

      <div style={{ textAlign:'center', color: T.label2, fontSize: 14, marginTop: 24 }}>
        New to TeamCaddy?{' '}
        <button onClick={() => onNav('register')} style={{
          background:'none', border:'none', padding: 0, color: T.accent, fontSize: 14, fontWeight: 600, cursor:'pointer', fontFamily: T.font,
        }}>Create account</button>
      </div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// REGISTER
// ─────────────────────────────────────────────────────────────
function RegisterScreen({ T, onNav, onAuth }) {
  const [step, setStep] = React.useState(1); // 1: account, 2: join team
  const [name, setName] = React.useState('');
  const [email, setEmail] = React.useState('');
  const [password, setPassword] = React.useState('');
  const [show, setShow] = React.useState(false);
  const [role, setRole] = React.useState('parent');
  const [teamCode, setTeamCode] = React.useState('');
  const [loading, setLoading] = React.useState(false);

  const pwStrength = password.length === 0 ? 0
    : password.length < 6 ? 1
    : password.length < 10 ? 2
    : /[0-9]/.test(password) && /[A-Z]/.test(password) ? 4 : 3;
  const pwLabel = ['', 'Weak', 'Fair', 'Good', 'Strong'][pwStrength];
  const pwColor = [T.sep, T.red, T.yellow, T.blue, T.green][pwStrength];

  const canContinue = name && email && password.length >= 6;
  const submit = () => {
    setLoading(true);
    setTimeout(() => { setLoading(false); onAuth(); }, 900);
  };

  return (
    <div style={{ padding:'16px 24px 40px', background: T.bg, minHeight:'100%', display:'flex', flexDirection:'column' }}>
      <div style={{ display:'flex', alignItems:'center', justifyContent:'space-between', marginBottom: 14 }}>
        <button onClick={() => step === 1 ? onNav('welcome') : setStep(1)} style={{
          display:'flex', alignItems:'center', background:'none', border:'none', padding: 0,
          color: T.accent, fontSize: 17, cursor:'pointer', fontFamily: T.font,
        }}>
          <Icon name="chevron-left" size={22} color={T.accent} weight={2.4}/>
        </button>
        <div style={{ display:'flex', gap: 6 }}>
          <StepDot active={step >= 1} T={T}/>
          <StepDot active={step >= 2} T={T}/>
        </div>
        <div style={{ width: 22 }}/>
      </div>

      {step === 1 ? (
        <>
          <div style={{ marginBottom: 24 }}>
            <div style={{
              fontFamily: T.displayFont, fontSize: 32, fontWeight: 700, color: T.label,
              letterSpacing: -1, lineHeight: 1.05,
            }}>Create your account</div>
            <div style={{ fontSize: 15, color: T.label2, marginTop: 4 }}>Takes about 30 seconds.</div>
          </div>

          <div style={{ display:'flex', flexDirection:'column', gap: 10 }}>
            <AuthField T={T} icon="user" placeholder="Your name" value={name} onChange={setName} autoFocus/>
            <AuthField T={T} icon="mail" type="email" placeholder="Email" value={email} onChange={setEmail}/>
            <AuthField T={T} icon="lock" type={show ? 'text' : 'password'} placeholder="Create password" value={password} onChange={setPassword}
              trailing={
                <button onClick={() => setShow(!show)} style={{
                  background:'none', border:'none', padding: 4, cursor:'pointer', display:'flex',
                }}><Icon name={show ? 'eye-off' : 'eye'} size={18} color={T.label2} weight={2}/></button>
              }/>
            {password && (
              <div style={{ display:'flex', alignItems:'center', gap: 8, padding:'2px 4px' }}>
                <div style={{ flex: 1, height: 4, borderRadius: 2, background: T.fill, overflow:'hidden' }}>
                  <div style={{ width: `${(pwStrength/4)*100}%`, height:'100%', background: pwColor, transition: 'all 0.2s' }}/>
                </div>
                <span style={{ fontSize: 12, color: pwColor, fontWeight: 600, minWidth: 44, textAlign:'right' }}>{pwLabel}</span>
              </div>
            )}
          </div>

          <div style={{ marginTop: 20 }}>
            <div style={{ fontSize: 13, fontWeight: 600, color: T.label2, marginBottom: 8, letterSpacing: 0.3, textTransform:'uppercase' }}>I'm joining as</div>
            <div style={{ display:'flex', gap: 10 }}>
              <RoleCard T={T} icon="user"  label="Parent / Player" active={role === 'parent'} onClick={() => setRole('parent')}/>
              <RoleCard T={T} icon="coach" label="Coach / Admin"   active={role === 'admin'}  onClick={() => setRole('admin')}/>
            </div>
          </div>

          <div style={{ flex: 1 }}/>

          <div style={{ fontSize: 12, color: T.label2, textAlign:'center', lineHeight: 1.45, marginTop: 20, marginBottom: 12 }}>
            By continuing, you agree to our{' '}
            <span style={{ color: T.accent, fontWeight: 500 }}>Terms</span> and{' '}
            <span style={{ color: T.accent, fontWeight: 500 }}>Privacy Policy</span>.
          </div>

          <AuthButton T={T} variant="primary" onClick={() => setStep(2)} disabled={!canContinue} icon="arrow-right">Continue</AuthButton>

          <div style={{ textAlign:'center', color: T.label2, fontSize: 14, marginTop: 18 }}>
            Already a member?{' '}
            <button onClick={() => onNav('login')} style={{
              background:'none', border:'none', padding: 0, color: T.accent, fontSize: 14, fontWeight: 600, cursor:'pointer', fontFamily: T.font,
            }}>Sign in</button>
          </div>
        </>
      ) : (
        <>
          <div style={{ marginBottom: 24 }}>
            <div style={{
              fontFamily: T.displayFont, fontSize: 32, fontWeight: 700, color: T.label,
              letterSpacing: -1, lineHeight: 1.05,
            }}>{role === 'admin' ? 'Set up your team' : 'Join your team'}</div>
            <div style={{ fontSize: 15, color: T.label2, marginTop: 4 }}>
              {role === 'admin'
                ? "Create a new team or join as a coach."
                : "Enter the invite code from your coach."}
            </div>
          </div>

          {role === 'parent' ? (
            <>
              <div style={{ fontSize: 13, fontWeight: 600, color: T.label2, marginBottom: 8, letterSpacing: 0.3, textTransform:'uppercase' }}>Team invite code</div>
              <AuthField T={T} icon="shield" placeholder="e.g. STRIKERS-2026" value={teamCode} onChange={v => setTeamCode(v.toUpperCase())} autoFocus/>

              <div style={{ marginTop: 20, padding: 14, background: T.card, border:`0.5px solid ${T.sep}`, borderRadius: 14, display:'flex', gap: 12, alignItems:'flex-start' }}>
                <div style={{ width: 32, height: 32, borderRadius: 10, background: `${T.accent}22`, display:'flex', alignItems:'center', justifyContent:'center', flexShrink: 0 }}>
                  <Icon name="mail" size={18} color={T.accent} weight={2}/>
                </div>
                <div style={{ fontSize: 13, color: T.label2, lineHeight: 1.45 }}>
                  <span style={{ color: T.label, fontWeight: 600 }}>No code?</span> Your coach can send an invite link to your email.
                </div>
              </div>

              <div style={{ marginTop: 16, textAlign:'center' }}>
                <button onClick={submit} style={{
                  background:'none', border:'none', padding: 8, color: T.accent, fontSize: 15, fontWeight: 500, cursor:'pointer', fontFamily: T.font,
                }}>Skip for now</button>
              </div>
            </>
          ) : (
            <>
              <div style={{ display:'flex', flexDirection:'column', gap: 10 }}>
                <button onClick={submit} style={{
                  display:'flex', alignItems:'center', gap: 14, padding: 16, borderRadius: 14,
                  background: T.card, border:`0.5px solid ${T.sep}`, cursor:'pointer',
                  textAlign:'left', fontFamily: T.font,
                }}>
                  <div style={{ width: 40, height: 40, borderRadius: 12, background: T.accent, display:'flex', alignItems:'center', justifyContent:'center', flexShrink: 0 }}>
                    <Icon name="plus" size={22} color="#fff" weight={2.6}/>
                  </div>
                  <div style={{ flex: 1 }}>
                    <div style={{ fontSize: 16, fontWeight: 600, color: T.label }}>Create a new team</div>
                    <div style={{ fontSize: 13, color: T.label2, marginTop: 1 }}>Set up roster, schedule, and invite parents</div>
                  </div>
                  <Icon name="chevron-right" size={18} color={T.label2} weight={2.2}/>
                </button>

                <button onClick={submit} style={{
                  display:'flex', alignItems:'center', gap: 14, padding: 16, borderRadius: 14,
                  background: T.card, border:`0.5px solid ${T.sep}`, cursor:'pointer',
                  textAlign:'left', fontFamily: T.font,
                }}>
                  <div style={{ width: 40, height: 40, borderRadius: 12, background: T.blue, display:'flex', alignItems:'center', justifyContent:'center', flexShrink: 0 }}>
                    <Icon name="shield" size={20} color="#fff" weight={2.2}/>
                  </div>
                  <div style={{ flex: 1 }}>
                    <div style={{ fontSize: 16, fontWeight: 600, color: T.label }}>Join as assistant coach</div>
                    <div style={{ fontSize: 13, color: T.label2, marginTop: 1 }}>Use a code from the head coach</div>
                  </div>
                  <Icon name="chevron-right" size={18} color={T.label2} weight={2.2}/>
                </button>
              </div>
            </>
          )}

          <div style={{ flex: 1 }}/>

          {role === 'parent' && (
            <AuthButton T={T} variant="primary" onClick={submit} disabled={!teamCode || loading} loading={loading}>Join team</AuthButton>
          )}
        </>
      )}
    </div>
  );
}

function StepDot({ active, T }) {
  return (
    <div style={{
      width: active ? 20 : 6, height: 6, borderRadius: 3,
      background: active ? T.accent : T.fill, transition: 'all 0.2s',
    }}/>
  );
}

function RoleCard({ T, icon, label, active, onClick }) {
  return (
    <button onClick={onClick} style={{
      flex: 1, padding: '16px 12px', borderRadius: 14,
      background: active ? `${T.accent}14` : T.card,
      border: `1.5px solid ${active ? T.accent : T.sep}`,
      cursor:'pointer', display:'flex', flexDirection:'column', alignItems:'center', gap: 8,
      fontFamily: T.font,
    }}>
      <div style={{
        width: 36, height: 36, borderRadius: 12,
        background: active ? T.accent : T.fill2,
        display:'flex', alignItems:'center', justifyContent:'center',
      }}>
        <Icon name={icon} size={20} color={active ? '#fff' : T.label2} weight={2.2}/>
      </div>
      <span style={{ fontSize: 14, fontWeight: 600, color: active ? T.accent : T.label }}>{label}</span>
    </button>
  );
}

// ─────────────────────────────────────────────────────────────
// FORGOT PASSWORD
// ─────────────────────────────────────────────────────────────
function ForgotScreen({ T, onNav }) {
  const [email, setEmail] = React.useState('');
  const [sent, setSent] = React.useState(false);
  const [loading, setLoading] = React.useState(false);

  const submit = () => {
    if (!email) return;
    setLoading(true);
    setTimeout(() => { setLoading(false); setSent(true); }, 700);
  };

  return (
    <div style={{ padding:'16px 24px 40px', background: T.bg, minHeight:'100%', display:'flex', flexDirection:'column' }}>
      <button onClick={() => onNav('login')} style={{
        display:'flex', alignItems:'center', background:'none', border:'none', padding: 0,
        color: T.accent, fontSize: 17, cursor:'pointer', marginBottom: 20, fontFamily: T.font,
      }}>
        <Icon name="chevron-left" size={22} color={T.accent} weight={2.4}/>
      </button>

      {!sent ? (
        <>
          <div style={{
            width: 64, height: 64, borderRadius: 20,
            background: `${T.accent}18`, display:'flex', alignItems:'center', justifyContent:'center',
            marginBottom: 20,
          }}>
            <Icon name="lock" size={30} color={T.accent} weight={2}/>
          </div>

          <div style={{
            fontFamily: T.displayFont, fontSize: 32, fontWeight: 700, color: T.label,
            letterSpacing: -1, lineHeight: 1.05,
          }}>Forgot password?</div>
          <div style={{ fontSize: 15, color: T.label2, marginTop: 6, marginBottom: 28, lineHeight: 1.45 }}>
            Enter the email you signed up with and we'll send a link to reset it.
          </div>

          <AuthField T={T} icon="mail" type="email" placeholder="Email" value={email} onChange={setEmail} autoFocus/>

          <div style={{ marginTop: 20 }}>
            <AuthButton T={T} variant="primary" onClick={submit} disabled={!email} loading={loading}>Send reset link</AuthButton>
          </div>

          <div style={{ flex: 1 }}/>

          <div style={{ textAlign:'center', color: T.label2, fontSize: 14, marginTop: 20 }}>
            Remembered it?{' '}
            <button onClick={() => onNav('login')} style={{
              background:'none', border:'none', padding: 0, color: T.accent, fontSize: 14, fontWeight: 600, cursor:'pointer', fontFamily: T.font,
            }}>Sign in</button>
          </div>
        </>
      ) : (
        <>
          <div style={{ flex: 1, display:'flex', flexDirection:'column', alignItems:'center', justifyContent:'center', textAlign:'center', padding:'0 8px' }}>
            <div style={{
              width: 80, height: 80, borderRadius: 24,
              background: T.green, display:'flex', alignItems:'center', justifyContent:'center',
              marginBottom: 24, boxShadow: `0 8px 24px ${T.green}40`,
            }}>
              <Icon name="check" size={40} color="#fff" weight={3}/>
            </div>
            <div style={{
              fontFamily: T.displayFont, fontSize: 28, fontWeight: 700, color: T.label,
              letterSpacing: -0.8, marginBottom: 10,
            }}>Check your email</div>
            <div style={{ fontSize: 15, color: T.label2, lineHeight: 1.5, maxWidth: 300 }}>
              We sent a password reset link to<br/>
              <span style={{ color: T.label, fontWeight: 500 }}>{email}</span>
            </div>
            <div style={{ fontSize: 13, color: T.label3, marginTop: 24 }}>
              Didn't receive it? Check spam or{' '}
              <button onClick={() => setSent(false)} style={{
                background:'none', border:'none', padding: 0, color: T.accent, fontSize: 13, fontWeight: 500, cursor:'pointer', fontFamily: T.font,
              }}>try again</button>.
            </div>
          </div>

          <AuthButton T={T} variant="primary" onClick={() => onNav('login')}>Back to sign in</AuthButton>
        </>
      )}
    </div>
  );
}

Object.assign(window, { WelcomeScreen, LoginScreen, RegisterScreen, ForgotScreen });
