from pydantic import BaseModel
from typing import Optional


# ===== System Health =====
class SystemHealth(BaseModel):
    uptime_seconds: int
    cpu_percent: float
    memory_used_mb: float
    memory_total_mb: float
    memory_percent: float
    disk_used_gb: float
    disk_total_gb: float
    disk_percent: float
    active_users_24h: int


# ===== Daily Stats Base =====
class DailyStatItem(BaseModel):
    date: str
    count: int


class DailyTokenStatItem(BaseModel):
    date: str
    input_tokens: int
    output_tokens: int


# ===== Conversation Stats =====
class ConversationStats(BaseModel):
    daily_conversations: list[DailyStatItem]
    daily_messages: list[DailyStatItem]
    daily_input_tokens: list[DailyTokenStatItem]
    daily_output_tokens: list[DailyTokenStatItem]
    totals: dict


# ===== Knowledge Stats =====
class KnowledgeStats(BaseModel):
    daily_new_tags: list[DailyStatItem]
    daily_documents: list[DailyStatItem]
    daily_knowledge_queries: list[DailyStatItem]
    daily_tag_relations: list[DailyStatItem]
    totals: dict


# ===== Kanban Stats =====
class KanbanStats(BaseModel):
    daily_new_tasks: list[DailyStatItem]
    daily_completed_tasks: list[DailyStatItem]
    daily_completion_rate: list[DailyStatItem]
    current_pending_tasks: int
    totals: dict


# ===== Community Stats =====
class CommunityStats(BaseModel):
    daily_posts: list[DailyStatItem]
    daily_replies: list[DailyStatItem]
    daily_ai_executions: list[DailyStatItem]
    daily_agent_calls: list[DailyStatItem]
    totals: dict


# ===== Personal Insights =====
class HourlyActivity(BaseModel):
    hour: int
    count: int


class TagUsage(BaseModel):
    tag_path: str
    usage_count: int


class PersonalInsights(BaseModel):
    hourly_activity: list[HourlyActivity]
    top_tags: list[TagUsage]
    token_trend_percent: float
    this_month_tokens: int
    last_month_tokens: int
