namespace PlotLine.Models;

public sealed class WordCompanionProjectDto
{
    public int ProjectId { get; set; }
    public string Title { get; set; } = string.Empty;
}

public sealed class WordCompanionProjectsResponse
{
    public IReadOnlyList<WordCompanionProjectDto> Projects { get; init; } = [];
}

public sealed class WordCompanionBookDto
{
    public int BookId { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? Subtitle { get; set; }
    public int SortOrder { get; set; }
}

public sealed class WordCompanionBooksResponse
{
    public IReadOnlyList<WordCompanionBookDto> Books { get; init; } = [];
}

public sealed class WordCompanionSceneStructureDto
{
    public int SceneId { get; set; }
    public string Title { get; set; } = string.Empty;
    public int SortOrder { get; set; }
    public string RevisionStatus { get; set; } = string.Empty;
    public int? EstimatedWords { get; set; }
    public int? ActualWords { get; set; }
}

public sealed class WordCompanionChapterStructureDto
{
    public int ChapterId { get; set; }
    public string Title { get; set; } = string.Empty;
    public int SortOrder { get; set; }
    public IReadOnlyList<WordCompanionSceneStructureDto> Scenes { get; set; } = [];
}

public sealed class WordCompanionBookStructureResponse
{
    public int BookId { get; init; }
    public IReadOnlyList<WordCompanionChapterStructureDto> Chapters { get; init; } = [];
}

public sealed class WordCompanionChaptersResponse
{
    public IReadOnlyList<WordCompanionChapterDto> Chapters { get; init; } = [];
}

public sealed class WordCompanionChapterDto
{
    public int ChapterId { get; init; }
    public string Title { get; init; } = string.Empty;
    public int SortOrder { get; init; }
}

public sealed class WordCompanionResolveSceneRequest
{
    public string? ChapterTitle { get; set; }
    public string? SceneTitle { get; set; }
}

public sealed class WordCompanionResolveSceneResponse
{
    public bool Matched { get; init; }
    public bool ChapterMatched { get; init; }
    public int? ChapterId { get; init; }
    public int? SceneId { get; init; }
    public string? MatchType { get; init; }
    public int? BookId { get; init; }
    public string? ChapterTitleSearched { get; init; }
    public string? SceneTitleSearched { get; init; }
    public int? AvailableChapterCount { get; init; }
    public int? AvailableSceneCount { get; init; }
    public bool BookAccessible { get; init; } = true;
}

public sealed class WordCompanionLinkItemDto
{
    public int CharacterId { get; set; }
    public int AssetId { get; set; }
    public int LocationId { get; set; }
    public string Name { get; set; } = string.Empty;
    public bool Linked { get; set; }
}

public sealed class WordCompanionSceneCompanionResponse
{
    public int SceneId { get; init; }
    public int ChapterId { get; init; }
    public string ChapterTitle { get; init; } = string.Empty;
    public string SceneTitle { get; init; } = string.Empty;
    public int? ActualWords { get; init; }
    public int? EstimatedWords { get; init; }
    public string? WritingBrief { get; init; }
    public bool Blocked { get; init; }
    public string? BlockedReason { get; init; }
    public int? PrimaryLocationId { get; init; }
    public IReadOnlyList<WordCompanionLinkItemDto> Characters { get; init; } = [];
    public IReadOnlyList<WordCompanionLinkItemDto> Assets { get; init; } = [];
    public IReadOnlyList<WordCompanionLinkItemDto> Locations { get; init; } = [];
}

public sealed class WordCompanionSyncSceneRequest
{
    public string? ChapterTitle { get; set; }
    public int? ChapterSortOrder { get; set; }
    public string? SceneTitle { get; set; }
    public int? SceneSortOrder { get; set; }
    public int ActualWords { get; set; }
    public string? DocumentId { get; set; }
    public string? ContentHash { get; set; }
}

public sealed class WordCompanionSyncSceneResponse
{
    public int ChapterId { get; init; }
    public int SceneId { get; init; }
    public bool ChapterCreated { get; init; }
    public bool SceneCreated { get; init; }
    public bool ActualWordsUpdated { get; init; }
    public string Message { get; init; } = "Scene synced successfully.";
}

public sealed class WordCompanionCreateSceneRequest
{
    public string? SceneTitle { get; set; }
}

public sealed class WordCompanionCreateSceneResponse
{
    public int ChapterId { get; init; }
    public int SceneId { get; init; }
    public string Message { get; init; } = "Scene created.";
}

public sealed class WordCompanionCreateChapterRequest
{
    public string? Title { get; set; }
    public int? SortOrder { get; set; }
}

public sealed class WordCompanionCreateChapterResponse
{
    public int ChapterId { get; init; }
    public string Title { get; init; } = string.Empty;
    public int SortOrder { get; init; }
    public string Message { get; init; } = "Chapter created successfully.";
}

public sealed class WordCompanionSyncManuscriptRequest
{
    public string? DocumentId { get; set; }
    public IReadOnlyList<WordCompanionSyncChapterRequest> Chapters { get; set; } = [];
}

public sealed class WordCompanionSyncChapterRequest
{
    public string? Title { get; set; }
    public int? SortOrder { get; set; }
    public int WordCount { get; set; }
    public IReadOnlyList<WordCompanionSyncManuscriptSceneRequest> Scenes { get; set; } = [];
}

public sealed class WordCompanionSyncManuscriptSceneRequest
{
    public string? Title { get; set; }
    public int? SortOrder { get; set; }
    public int WordCount { get; set; }
    public string? ContentHash { get; set; }
}

public sealed class WordCompanionSyncManuscriptResponse
{
    public int ChaptersCreated { get; init; }
    public int ChaptersUpdated { get; init; }
    public int ScenesCreated { get; init; }
    public int ScenesUpdated { get; init; }
    public IReadOnlyList<string> ItemsNotMatched { get; init; } = [];
    public string Message { get; init; } = "Manuscript sync completed.";
}

public sealed class WordCompanionUpdateSceneLinksRequest
{
    public IReadOnlyList<int> CharacterIds { get; set; } = [];
    public IReadOnlyList<int> AssetIds { get; set; } = [];
    public IReadOnlyList<int> LocationIds { get; set; } = [];
    public int? PrimaryLocationId { get; set; }
}

public sealed class WordCompanionUpdateSceneLinksResponse
{
    public int SceneId { get; init; }
    public int CharactersUpdated { get; init; }
    public int AssetsUpdated { get; init; }
    public int LocationsUpdated { get; init; }
    public string Message { get; init; } = "Scene links updated.";
}

public sealed class WordCompanionUpdateWordCountRequest
{
    public int? ActualWords { get; set; }
    public int? ActualWordCount { get; set; }
    public DateTime? LastWorkedOn { get; set; }
}

public sealed class WordCompanionUpdateWordCountResponse
{
    public int SceneId { get; init; }
    public int ActualWords { get; init; }
    public DateTime? LastWorkedOn { get; init; }
    public string Message { get; init; } = "Word count updated.";
}
