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

class DashboardStatsResponse(BaseModel):
    total_passengers: int
    total_drivers: int
    active_rides: int
    total_revenue: float
    
    model_config = ConfigDict(from_attributes=True)

class RevenueChartPoint(BaseModel):
    date: str  # Format: "Jan 01"
    revenue: float
    rides: int
    commission: float

    model_config = ConfigDict(from_attributes=True)

class UserGrowthPoint(BaseModel):
    date: str # Format: "Jan"
    count: int

    model_config = ConfigDict(from_attributes=True)

class ActiveRideLocation(BaseModel):
    ride_id: int
    driver_name: str
    lat: float
    lng: float
    status: str

    model_config = ConfigDict(from_attributes=True)

class DriverPerformance(BaseModel):
    id: int
    name: str # Full name
    profile_picture: Optional[str]
    completed_rides: int
    earnings: float
    rating: float
    status: str # Active, Suspended, etc.

    model_config = ConfigDict(from_attributes=True)

class PassengerListItem(BaseModel):
    id: int
    name: str
    pax_id: str  # Format: PAX-11234
    phone: str
    rides_count: int
    rating: float
    status: str  # Active, Suspended, Blocked
    wallet_balance: float
    profile_picture: Optional[str]

    model_config = ConfigDict(from_attributes=True)

class PassengerListResponse(BaseModel):
    items: List[PassengerListItem]
    total: int
    page: int
    limit: int
    pages: int
    has_next: bool
    has_prev: bool

class DriverVerificationItem(BaseModel):
    id: int
    name: str
    drv_id: str  # Format: DRV-11234
    phone: str
    vehicle_type: str
    document_status: str  # Pending, Approved, Rejected
    applied_on: str  # Format: "20 jan, 2026"
    profile_picture: Optional[str]

    model_config = ConfigDict(from_attributes=True)

class DriverVerificationResponse(BaseModel):
    items: List[DriverVerificationItem]
    total: int
    page: int
    limit: int
    pages: int
    has_next: bool
    has_prev: bool

class RideStatsResponse(BaseModel):
    all_rides: int
    ongoing_rides: int
    upcoming_rides: int
    completed_rides: int

class RideListItem(BaseModel):
    id: int
    trip_id: str # Format: #t123 (mapped to ride_code)
    driver_name: str
    driver_profile_picture: Optional[str]
    start_address: str
    destination_address: str
    date_time: str # Format: "20 july 25, 3:00 am"
    passengers: int
    status: str # Live (mapped from STARTED), Requested, Completed, etc.
    action: Optional[str] = None

    model_config = ConfigDict(from_attributes=True)

class RideListResponse(BaseModel):
    items: List[RideListItem]
    total: int
    page: int
    size: int

class TransactionListItem(BaseModel):
    id: int
    transaction_id: str # TXN-1234
    date_time: str
    ride_id: str # RIDE-1234
    passenger_name: str
    driver_name: str
    payment_method: str
    status: str
    driver_earning: str # Formatted with currency
    admin_commission: str # Formatted
    action: Optional[str] = None

    model_config = ConfigDict(from_attributes=True)

class TransactionListResponse(BaseModel):
    items: List[TransactionListItem]
    total: int
    page: int
    limit: int
    pages: int
    has_next: bool
    has_prev: bool
