import SwiftUI

/// Shown after a successful `POST /api/auth/signup` — the account exists but
/// is inert until the emailed confirmation link is opened (deliberate
/// anti-abuse design, mirrored from the web signup flow — see
/// `AppState.signup(name:email:password:)`). This screen never signs the
/// user in itself; it just points back to `LoginView` once they've verified
/// (on this device or any other) and come back.
struct VerificationPendingView: View {
    let email: String
    var onGoToLogin: () -> Void

    var body: some View {
        VStack(spacing: ZenithSpacing.md) {
            Spacer()

            Image(systemName: "envelope.badge")
                .font(.system(size: 48))
                .foregroundStyle(Color.zenithBlack)

            Text("Bitte bestätige deine E-Mail")
                .zenithHeadlineLgStyle()
                .multilineTextAlignment(.center)

            (
                Text("Wir haben einen Bestätigungslink an ")
                    + Text(email).fontWeight(.semibold)
                    + Text(" gesendet. Öffne den Link auf diesem oder einem anderen Gerät, um dein Konto zu aktivieren, und melde dich anschließend hier an.")
            )
            .zenithBodyStyle(color: .zenithMuted)
            .multilineTextAlignment(.center)
            .padding(.horizontal, ZenithSpacing.xs)

            Spacer()

            Button {
                onGoToLogin()
            } label: {
                Text("Zum Login")
                    .frame(maxWidth: .infinity)
            }
            .buttonStyle(.zenithPrimary)
        }
        .padding(.horizontal, ZenithSpacing.md)
        .padding(.vertical, ZenithSpacing.lg)
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .background(Color.zenithBg)
    }
}
