"""
Pydantic schemas for card import feature.

Provides request/response models for importing card collections
and using them for deckbuilding.
"""
from pydantic import BaseModel, Field
from typing import List, Optional, Dict, Any
from datetime import datetime


class CardImportRequest(BaseModel):
    """Request body for importing card collection."""
    card_names: List[str] = Field(
        ...,
        min_length=1,
        max_length=10000,
        description="List of card names to import",
        examples=[["Lightning Bolt", "Shock", "Thoughtseize"]]
    )


class CardImportResponse(BaseModel):
    """Response after successful card import."""
    message: str
    card_count: int
    card_names: List[str]
    imported_at: datetime


class CardImportStatusResponse(BaseModel):
    """Response showing current import status."""
    has_import: bool
    card_count: Optional[int] = None
    card_names: Optional[List[str]] = None
    last_imported: Optional[datetime] = None


class CardMatchResult(BaseModel):
    """Result of matching imported card name to database card."""
    card_id: Optional[int] = None
    card_name: str
    matched_name: str
    match_type: str  # 'exact', 'fuzzy', 'partial'
    confidence: float  # 0.0 to 1.0


class CardImportSummary(BaseModel):
    """Summary of card import with match results."""
    total_cards: int
    matched_cards: List[CardMatchResult]
    unmatched_cards: List[str]
    import_id: Optional[int] = None


# Generic response models
class MessageResponse(BaseModel):
    """Generic message response."""
    message: str


class CountResponse(BaseModel):
    """Generic count response."""
    count: int


class ErrorResponse(BaseModel):
    """Error response with details."""
    detail: str
    error_code: Optional[str] = None
