package dto

import "time"

// UserResponse is the canonical user profile response returned by auth endpoints.
type UserResponse struct {
	ID             string    `json:"id"`
	Email          string    `json:"email"`
	Mobile         string    `json:"mobile,omitempty"`
	Name           string    `json:"name"`
	DisplayName    string    `json:"displayName,omitempty"`
	AvatarURL      string    `json:"avatarUrl,omitempty"`
	IsAdmin        bool      `json:"isAdmin"`
	EmailVerified  bool      `json:"emailVerified"`
	MobileVerified bool      `json:"mobileVerified"`
	CreatedAt      time.Time `json:"createdAt"`
}

// AuthTokensResponse is the canonical session token response returned on login/registration.
type AuthTokensResponse struct {
	AccessToken  string       `json:"accessToken"`
	RefreshToken string       `json:"refreshToken"`
	User         UserResponse `json:"user"`
}

// MobileVerificationAttemptView represents a mobile verification attempt in API responses.
type MobileVerificationAttemptView struct {
	ID             string     `json:"id"`
	MobileHint     string     `json:"mobileHint"`
	Provider       string     `json:"provider"`
	Status         string     `json:"status"`
	CodeActive     bool       `json:"codeActive"`
	StatusDetail   string     `json:"statusDetail,omitempty"`
	ProviderStatus string     `json:"providerStatus,omitempty"`
	ExpiresAt      time.Time  `json:"expiresAt"`
	RequestedAt    time.Time  `json:"requestedAt"`
	CompletedAt    *time.Time `json:"completedAt,omitempty"`
}

// OIDCCallbackRequest is the request body for POST /api/v1/auth/oidc/callback.
type OIDCCallbackRequest struct {
	Code                                string `json:"code"`
	State                               string `json:"state"`
	Nonce                               string `json:"nonce"`
	CodeVerifier                        string `json:"code_verifier"`
	RedirectURI                         string `json:"redirect_uri"`
	DesktopOnboardingEnabled            bool   `json:"desktopOnboardingEnabled"`
	DesktopOnboardingRegistrationCutoff string `json:"desktopOnboardingRegistrationCutoff"`
}

// LoginRequest is the request body for POST /api/v1/auth/login.
type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

// RegisterRequest is the request body for POST /api/v1/auth/register.
type RegisterRequest struct {
	Email                               string `json:"email"`
	Password                            string `json:"password"`
	Name                                string `json:"name"`
	DesktopOnboardingEnabled            bool   `json:"desktopOnboardingEnabled"`
	DesktopOnboardingRegistrationCutoff string `json:"desktopOnboardingRegistrationCutoff"`
}

// ForgotPasswordRequest is the request body for POST /api/v1/auth/forgot-password.
type ForgotPasswordRequest struct {
	Email string `json:"email"`
}

// ResetPasswordRequest is the request body for POST /api/v1/auth/reset-password.
type ResetPasswordRequest struct {
	Token    string `json:"token"`
	Password string `json:"password"`
}

// UpdateProfileRequest is the request body for PATCH /api/v1/me.
type UpdateProfileRequest struct {
	DisplayName     *string `json:"displayName"`
	AvatarURL       *string `json:"avatarUrl"`
	CurrentPassword *string `json:"currentPassword"`
	NewPassword     *string `json:"newPassword"`
}

// FeishuLoginURLRequest is the request body for POST /api/v1/auth/feishu/login-url.
type FeishuLoginURLRequest struct {
	OrganizationSlug string `json:"organizationSlug"`
	RedirectURI      string `json:"redirectUri"`
}

// FeishuLoginRequest is the request body for POST /api/v1/auth/feishu/login.
type FeishuLoginRequest struct {
	Code        string `json:"code"`
	State       string `json:"state"`
	RedirectURI string `json:"redirectUri"`
}

// TokenRefreshResponse is the response for POST /api/v1/auth/refresh.
type TokenRefreshResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

// MobileSessionResponse is one active mobile login that the account owner can revoke.
type MobileSessionResponse struct {
	ID             string    `json:"id"`
	DeviceName     string    `json:"deviceName"`
	DevicePlatform string    `json:"devicePlatform"`
	ExpiresAt      time.Time `json:"expiresAt"`
	CreatedAt      time.Time `json:"createdAt"`
}

// MobileSessionListResponse contains every active mobile login for the caller.
type MobileSessionListResponse struct {
	Items []MobileSessionResponse `json:"items"`
}

// OIDCAuthorizationURLResponse is the response for POST /api/v1/auth/oidc/authorize-url.
type OIDCAuthorizationURLResponse struct {
	AuthorizationURL string `json:"authorization_url"`
	State            string `json:"state"`
	Nonce            string `json:"nonce"`
	CodeVerifier     string `json:"code_verifier"`
}
