/**
 * 服务端 API 通用响应类型
 */

/** 服务端标准响应封装 */
export interface ApiEnvelope<T> {
    success: boolean;
    data: T | null;
    message: string | null;
    timestamp: string;
}

/** 体力值信息 */
export interface StaminaInfo {
    /** 当前体力值（已计算恢复） */
    current: number;
    /** 体力上限，固定为 50 */
    max: number;
    /** 下一点体力恢复的时间（ISO 8601），满体力时为 null */
    nextRecoverAt: string | null;
}

/** 登录响应数据 */
export interface WxLoginData {
    token: string;
    user: {
        id: string;
        nickname: string | null;
        stamina: number;
    };
}

/** 用户资料响应数据 */
export interface UserProfileData {
    id: string;
    nickname: string | null;
    stamina: StaminaInfo;
}

/** 游戏数据响应（Loading 页面） */
export interface GameData {
    user: {
        id: string;
        stamina: StaminaInfo;
    };
    completedLevelIds: string[];
    completedLevelCount?: number;
}

/** 关卡列表项 */
export interface LevelListItem {
    id: string;
    level: number;
    image1Url: string;
    image1Description: string | null;
    image2Url: string;
    image2Description: string | null;
    answer: string | null;
    punchline: string | null;
    hint1: string | null;
    hint2: string | null;
    hint3: string | null;
    completed: boolean;
    timeSpent: number | null;
}

/** 关卡列表响应 */
export interface LevelListData {
    levels: LevelListItem[];
    total: number;
}

/** 进入关卡响应 */
export interface EnterLevelData {
    id: string;
    level: number;
    image1Url: string;
    image1Description: string | null;
    image2Url: string;
    image2Description: string | null;
    answer: string;
    punchline: string | null;
    hint1: string | null;
    hint2: string | null;
    hint3: string | null;
    stamina: StaminaInfo;
}

/** 通关上报响应 */
export interface CompleteLevelData {
    firstClear: boolean;
    levelId: string;
    timeSpent: number;
}

/** 创建分享响应 */
export interface CreateShareData {
    shareCode: string;
    title: string;
    levelCount: number;
}

/** 分享关卡数据 */
export interface ShareLevelData {
    id: string;
    level: number;
    image1Url: string;
    image1Description: string | null;
    image2Url: string;
    image2Description: string | null;
    answer: string;
    punchline: string | null;
    hint1: string | null;
    hint2: string | null;
    hint3: string | null;
    sortOrder: number;
}

/** 加入分享响应 */
export interface JoinShareData {
    shareCode: string;
    title: string;
    levels: ShareLevelData[];
}

/** 上报关卡进度响应 */
export interface ReportProgressData {
    passed: boolean;
    timeLimit: number | null;
    withinTimeLimit: boolean;
}

/** 我创建的分享挑战条目 */
export interface CreatedShareItem {
    id: string;
    shareCode: string;
    title: string;
    levelCount: number;
    participantCount: number;
    userRank: number | null;
    createdAt: string;
}

/** 我创建的分享挑战列表响应 */
export interface CreatedShareListData {
    items: CreatedShareItem[];
}
