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


class ProductCreate(BaseModel):
    name: str
    slug: Optional[str] = None
    description: str
    price: Optional[float] = None  # Optional - inherits from model if not set
    discount_price: Optional[float] = None
    category_id: int
    model_id: Optional[int] = None
    gender: str  # men, women
    brand: str
    sizes: Optional[List[str]] = []
    colors: Optional[List[str]] = []
    stock: Optional[int] = None
    images: Optional[List[str]] = []
    is_featured: bool = False
    is_on_sale: bool = False
    override_price: Optional[Decimal] = None
    override_sizes: Optional[List[str]] = None


class ProductUpdate(BaseModel):
    name: Optional[str] = None
    slug: Optional[str] = None
    description: Optional[str] = None
    price: Optional[float] = None
    discount_price: Optional[float] = None
    category_id: Optional[int] = None
    model_id: Optional[int] = None
    gender: Optional[str] = None
    brand: Optional[str] = None
    sizes: Optional[List[str]] = None
    colors: Optional[List[str]] = None
    stock: Optional[int] = None
    images: Optional[List[str]] = None
    is_featured: Optional[bool] = None
    is_on_sale: Optional[bool] = None
    override_price: Optional[Decimal] = None
    override_sizes: Optional[List[str]] = None


class ProductResponse(BaseModel):
    id: int
    name: str
    slug: Optional[str]
    description: str
    price: Optional[float]  # May be None if inherited from model
    discount_price: Optional[float]
    category_id: int
    model_id: Optional[int]
    gender: str
    brand: str
    sizes: Optional[List[str]]
    colors: Optional[List[str]]
    stock: Optional[int]
    images: Optional[List[str]]
    is_featured: bool
    is_on_sale: bool
    override_price: Optional[Decimal]
    override_sizes: Optional[List[str]]
    created_at: datetime

    class Config:
        from_attributes = True


class ProductDetailResponse(ProductResponse):
    pass
