from typing import List, Optional
from datetime import datetime
from pydantic import BaseModel

# Base schema with common attributes
class CardBase(BaseModel):
    name: str
    rarity: Optional[str] = None
    set_name: Optional[str] = None
    price: Optional[float] = None
    quantity: Optional[int] = 0
    
    # TCGPlayer specific fields
    tcgplayer_sku: Optional[str] = None
    product_line: Optional[str] = None
    product_name: Optional[str] = None
    title: Optional[str] = None
    number: Optional[str] = None
    condition: Optional[str] = None
    tcg_market_price: Optional[float] = None
    tcg_direct_low: Optional[float] = None
    tcg_low_price_with_shipping: Optional[float] = None
    tcg_low_price: Optional[float] = None
    total_quantity: Optional[int] = None
    add_to_quantity: Optional[int] = None
    tcg_marketplace_price: Optional[float] = None
    photo_url: Optional[str] = None

# Schema for creating a new card
class CardCreate(CardBase):
    pass

# Schema for updating a card
class CardUpdate(CardBase):
    pass

# Schema for reading a card (includes id and relationships)
class CardInDB(CardBase):
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

# Schema for listing cards
class CardList(BaseModel):
    cards: List[CardInDB]
    total: int
    page: int
    limit: int

# Schema for deleting a card
class CardDelete(BaseModel):
    message: str 