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


class ManifestDriverBaseDTO(BaseModel):
    manifest_number: str = Field(..., max_length=15, description="Manifest number")
    driver_name: str = Field(..., max_length=80, description="Driver name")
    driver_type: Optional[str] = Field(None, max_length=1, description="Driver type")
    address_1: Optional[str] = Field(None, max_length=100, description="Address line 1")
    address_2: Optional[str] = Field(None, max_length=100, description="Address line 2")
    city: Optional[str] = Field(None, max_length=30, description="City")
    state: Optional[str] = Field(None, max_length=30, description="State")
    postal_code: Optional[str] = Field(None, max_length=15, description="Postal code")
    country: Optional[str] = Field(None, max_length=3, description="Country")


class ManifestDriverCreateDTO(ManifestDriverBaseDTO):
    pass


class ManifestDriverUpdateDTO(ManifestDriverBaseDTO):
    # Overriding to make PKs optional for update if needed, but usually PKs are in URL
    manifest_number: Optional[str] = Field(None, max_length=15)
    driver_name: Optional[str] = Field(None, max_length=80)


class ManifestDriverResponseDTO(ManifestDriverBaseDTO):
    tenant_id: int
    company_id: int

    class Config:
        from_attributes = True


class ManifestDriverListDTO(BaseModel):
    items: List[ManifestDriverResponseDTO]
    total: int
    page: int
    page_size: int

    class Config:
        from_attributes = True
