namespace Backend.Contracts;

public sealed record AdminSeasonListItemDto(
    int Id,
    int Year,
    string Name,
    string CurrentPhase,
    bool IsCurrent,
    bool IsDemo,
    int CategoryCount,
    DateTimeOffset? WinnersPublishedAt,
    string? WinnersPublishedByTwitchId);

public sealed record AdminCategoryItemDto(
    int Id,
    string GroupName,
    string Name,
    string Slug,
    string Description,
    int SortOrder,
    int MaxNomineesPerUser,
    int? ViewerRangeMin,
    int? ViewerRangeMax,
    int CandidateCount);

public sealed record AdminSubcategoryTemplateDto(
    string Name,
    string Slug,
    int SortOrder,
    int? ViewerRangeMin,
    int? ViewerRangeMax);

public sealed record AdminCandidateItemDto(
    int Id,
    int CategoryId,
    int? StreamerIdentityId,
    string DisplayName,
    string ChannelSlug,
    string Platform,
    int? AvgViewers,
    int Votes,
    int NominationTally,
    string AcceptanceStatus,
    string? AcceptanceNote,
    string? ClipCompilationUrl,
    string? ClipCompilationTitle,
    string? ClipCompilationPlatform,
    string ClipEmbedStatus);

public sealed record AdminAwardResultItemDto(
    int Id,
    int CategoryId,
    string CategoryName,
    int CandidateId,
    int? StreamerIdentityId,
    string CandidateDisplayName,
    string CandidateChannelSlug,
    string CandidatePlatform);

public sealed record AdminVotingWorkspaceSummaryDto(
    int TotalVotes,
    int TotalBallots,
    int TotalSubcategories,
    int VotedSubcategories,
    int ReadySubcategories,
    int ProblemSubcategories,
    int WinnerSetSubcategories);

public sealed record AdminVotingCandidateRankDto(
    int CandidateId,
    string DisplayName,
    string ChannelSlug,
    string Platform,
    int Votes,
    int VoteSharePercent,
    int NominationTally,
    bool HasClip,
    string ClipEmbedStatus,
    bool HasWinnerConflict,
    bool IsCurrentWinner,
    bool IsAccepted,
    bool IsTopTie);

public sealed record AdminVotingCategoryWorkspaceItemDto(
    int CategoryId,
    string GroupName,
    string CategoryName,
    int SortOrder,
    int? ViewerRangeMin,
    int? ViewerRangeMax,
    int VoteCount,
    int BallotCount,
    int CandidateCount,
    int ReadyCandidateCount,
    int NominationCount,
    int OpenReviewCount,
    bool HasWinner,
    bool WinnerReady,
    bool HasTopVoteTie,
    bool HasMissingClip,
    bool HasRuleConflict,
    bool HasOpenReviews,
    bool HasSoftNominatorWarning,
    IEnumerable<AdminVotingCandidateRankDto> Leaderboard);

public sealed record AdminVotingWorkspaceDto(
    AdminVotingWorkspaceSummaryDto Summary,
    IEnumerable<AdminVotingCategoryWorkspaceItemDto> Categories);

public sealed record AdminSeasonDetailResponse(
    int Id,
    int Year,
    string Name,
    bool IsDemo,
    string CurrentPhase,
    bool IsCurrent,
    bool IsCommunityOnly,
    DateOnly NominationStartsAt,
    DateOnly NominationEndsAt,
    DateOnly VotingStartsAt,
    DateOnly VotingEndsAt,
    DateOnly ReviewStartsAt,
    DateOnly ReviewEndsAt,
    DateOnly ShowDate,
    TimeOnly ShowStartsAt,
    DateTimeOffset? WinnersPublishedAt,
    string? WinnersPublishedByTwitchId,
    IEnumerable<AdminSubcategoryTemplateDto> SubcategoryTemplates,
    IEnumerable<AdminCategoryItemDto> Categories,
    IEnumerable<AdminCandidateItemDto> Candidates,
    IEnumerable<AdminNominationReviewItemDto> PendingNominations,
    IEnumerable<AdminNominationReviewGroupDto> PendingNominationGroups,
    IEnumerable<AdminNominationReviewItemDto> ReviewedNominations,
    string TrackingReviewNotes,
    bool ShowTrackingReviewNotes,
    IEnumerable<AdminAwardResultItemDto> Results,
    AdminVotingWorkspaceDto VotingWorkspace,
    IEnumerable<AdminClipSubmissionItemDto> ClipSubmissions);

public sealed record CreateSeasonRequest(
    int Year,
    string Name,
    string CurrentPhase,
    bool IsCurrent,
    bool IsCommunityOnly,
    DateOnly NominationStartsAt,
    DateOnly NominationEndsAt,
    DateOnly VotingStartsAt,
    DateOnly VotingEndsAt,
    DateOnly ReviewStartsAt,
    DateOnly ReviewEndsAt,
    DateOnly ShowDate,
    TimeOnly ShowStartsAt,
    int? CopyStructureFromSeasonId = null);

public sealed record UpdateSeasonRequest(
    int Year,
    string Name,
    string CurrentPhase,
    bool IsCurrent,
    bool IsCommunityOnly,
    DateOnly NominationStartsAt,
    DateOnly NominationEndsAt,
    DateOnly VotingStartsAt,
    DateOnly VotingEndsAt,
    DateOnly ReviewStartsAt,
    DateOnly ReviewEndsAt,
    DateOnly ShowDate,
    TimeOnly ShowStartsAt);

public sealed record UpsertCategoryRequest(
    string GroupName,
    string Name,
    string Slug,
    string Description,
    int SortOrder,
    int MaxNomineesPerUser,
    int? ViewerRangeMin,
    int? ViewerRangeMax);

public sealed record UpdateSeasonSubcategoryTemplatesRequest(
    AdminSubcategoryTemplateDto[] Templates);

public sealed record UpsertCategoryGroupRequest(
    string GroupName,
    string Description,
    int SortOrder,
    int MaxNomineesPerUser);

public sealed record UpsertCandidateRequest(
    int CategoryId,
    string DisplayName,
    string ChannelSlug,
    string Platform,
    string? AcceptanceStatus = null,
    string? AcceptanceNote = null,
    string? ClipCompilationUrl = null,
    string? ClipCompilationTitle = null,
    string? ClipCompilationPlatform = null,
    string? ClipEmbedStatus = null);

public sealed record SetAwardResultRequest(
    int CategoryId,
    int CandidateId);
