"""
Report schemas for the sim-search API.

This module defines the Pydantic models for report-related operations.
"""

from typing import Dict, List, Optional, Any
from datetime import datetime

from pydantic import BaseModel, Field


class ReportBase(BaseModel):
    """Base report schema."""
    
    title: Optional[str] = None
    detail_level: Optional[str] = "standard"
    query_type: Optional[str] = None
    model: Optional[str] = None


class ReportCreate(ReportBase):
    """Report creation schema."""
    
    search_id: Optional[str] = None
    search_results: Optional[List[Dict[str, Any]]] = None
    query: str
    token_budget: Optional[int] = None
    chunk_size: Optional[int] = None
    overlap_size: Optional[int] = None


class ReportUpdate(ReportBase):
    """Report update schema."""
    
    content: Optional[str] = None


class ReportInDBBase(ReportBase):
    """Base report in DB schema."""
    
    id: str
    user_id: str
    search_id: Optional[str] = None
    content: str
    model_used: Optional[str] = None
    created_at: datetime
    updated_at: datetime
    
    class Config:
        """Pydantic config."""
        
        from_attributes = True


class Report(ReportInDBBase):
    """Report schema."""
    
    pass


class ReportList(BaseModel):
    """Report list schema."""
    
    reports: List[Report]
    total: int


class ReportProgress(BaseModel):
    """Report generation progress schema."""
    
    report_id: str
    progress: float
    status: str
    current_chunk: Optional[int] = None
    total_chunks: Optional[int] = None
    current_report: Optional[str] = None


class ReportDownload(BaseModel):
    """Report download schema."""
    
    report_id: str
    format: str = "markdown"  # markdown, html, pdf
