namespace Nexus.Api.Models;

public sealed record DashboardAgentInfo(
    string Id,
    string Name,
    string Role,
    string Model,
    bool IsActive,
    string? CurrentTask,
    string? Description,
    string[] Tags,
    int Progress = 0,
    int Workload = 0,
    string? Goal = null,
    string RoleBadge = "badge-slate",
    string StatusLabel = "Bereit",
    string? Elapsed = null,
    string? Think = null,
    string? Next = null
);

public sealed record MessageEntry(
    string Role,
    string Content,
    string Timestamp
);

public sealed record ChatRequest(
    string Message,
    string? AgentId
);

public sealed record ChatResponse(
    bool Ok,
    string? Reply,
    string? Error
);

public sealed record FeedEntry(
    string Agent,
    string Action,
    string Timestamp,
    string Time,
    string? AgentId = null,
    string? Type = null
);

public sealed record DashboardStatus(
    bool GatewayOk,
    string IrisStatus,
    int ActiveAgents,
    int PendingTasks
);

public sealed record QueueItem(
    string Id,
    string Name,
    string Status,
    string Priority,
    string Source,
    string WaitTime
);

public sealed record AgentModelInfo(
    string Model,
    string Provider
);

public sealed record SetModelRequest(
    string Model
);

public sealed record ModelOption(
    string Id,
    string Name,
    string Provider
);

// ── Dashboard Task DTOs ──

public sealed record DashboardTaskDto(
    Guid Id,
    string Title,
    string? Detail,
    string Source,
    string State,
    string Priority,
    string? AssignedTo,
    Guid? ParentTaskId,
    DateTimeOffset? DueDate,
    DateTimeOffset CreatedAt,
    DateTimeOffset UpdatedAt,
    bool IsAgentTask = false,
    string? ExpectedFrom = null
);

public sealed record CreateDashboardTaskRequest(
    string Title,
    string? Detail,
    string? Source,
    string? Priority,
    string? AssignedTo,
    Guid? ParentTaskId = null
);

public sealed record CreateAgentTaskRequest(
    string Title,
    string? Detail,
    string? Source,
    string? Priority,
    string? AssignedTo,
    string? ExpectedFrom,
    Guid? ParentTaskId = null
);

public sealed record UpdateDashboardTaskRequest(
    string? Title,
    string? Detail,
    string? Source,
    string? Priority,
    string? AssignedTo,
    DateTimeOffset? DueDate = null
);

public sealed record UpdateDashboardTaskStatusRequest(
    string Status
);

public sealed record AgentActivityEntry(
    string Time,
    string Text
);

// ── Task Board DTOs ──

public sealed record BoardResponse(
    List<DashboardTaskDto> Offen,
    List<DashboardTaskDto> InProgress,
    List<DashboardTaskDto> Delegated,
    List<DashboardTaskDto> Review,
    List<DashboardTaskDto> Blocked,
    List<DashboardTaskDto> Done
);

public sealed record MoveTaskRequest(
    string State
);

public sealed record ResetStaleRequest(
    int StaleHours = 2
);

public sealed record ResetStaleResponse(
    int ResetCount
);

public sealed record PostActivityRequest(
    string Message,
    string? Type = null
);

// ── Agent Workflow DTOs ──

/// <summary>
/// Overview of the agent workflow state, grouping tasks by expected respondent
/// and highlighting stale tasks. Used by Iris to see who she is waiting for.
/// </summary>
public sealed record AgentWorkflowOverview(
    List<DashboardTaskDto> WaitingForBao,
    List<DashboardTaskDto> WaitingForIris,
    List<DashboardTaskDto> WaitingForOthers,
    List<DashboardTaskDto> StaleTasks,
    TimeSpan StaleThreshold
);

// ── Notification DTOs ──

public sealed record NotificationDto(
    Guid Id, string Type, string Title, string? Message,
    string ForUser, Guid? TaskId, bool IsRead, DateTimeOffset CreatedAt
);

public sealed record UnreadCountDto(int Count);
