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


# ==================== Hero Banner Settings ====================

class HeroBannerSettingsBase(BaseModel):
    slide_interval: int = 3000
    animation_type: str = "film-strip"
    image_width: int = 500
    image_height: int = 300
    auto_play: bool = True


class HeroBannerSettingsUpdate(BaseModel):
    slide_interval: Optional[int] = None
    animation_type: Optional[str] = None
    image_width: Optional[int] = None
    image_height: Optional[int] = None
    auto_play: Optional[bool] = None


class HeroBannerSettingsResponse(HeroBannerSettingsBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


# ==================== Hero Banner ====================

class HeroBannerBase(BaseModel):
    title_ko: Optional[str] = None
    title_en: Optional[str] = None
    title_mn: Optional[str] = None
    subtitle_ko: Optional[str] = None
    subtitle_en: Optional[str] = None
    subtitle_mn: Optional[str] = None
    image_url: str
    link_url: Optional[str] = None
    car_id: Optional[int] = None
    is_active: bool = True
    display_order: int = 0


class HeroBannerCreate(HeroBannerBase):
    pass


class HeroBannerUpdate(BaseModel):
    title_ko: Optional[str] = None
    title_en: Optional[str] = None
    title_mn: Optional[str] = None
    subtitle_ko: Optional[str] = None
    subtitle_en: Optional[str] = None
    subtitle_mn: Optional[str] = None
    image_url: Optional[str] = None
    link_url: Optional[str] = None
    car_id: Optional[int] = None
    is_active: Optional[bool] = None
    display_order: Optional[int] = None


class HeroBannerResponse(HeroBannerBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class HeroBannerListResponse(BaseModel):
    id: int
    title_ko: Optional[str] = None
    title_en: Optional[str] = None
    image_url: str
    link_url: Optional[str] = None
    car_id: Optional[int] = None
    is_active: bool
    display_order: int
    created_at: datetime

    class Config:
        from_attributes = True


# 다국어 지원 응답 (Public API용)
class HeroBannerLocalizedResponse(BaseModel):
    id: int
    title: Optional[str] = None
    subtitle: Optional[str] = None
    image_url: str
    link_url: Optional[str] = None
    car_id: Optional[int] = None

    class Config:
        from_attributes = True
