import uuid  # HOZZÁADVA
from pydantic import BaseModel, ConfigDict
from typing import Optional, List
from datetime import datetime
from app.models import ModerationStatus, SourceType

# --- Alap Sémák (Szolgáltatók) ---

class ServiceProviderBase(BaseModel):
    name: str
    address: Optional[str] = None
    category: Optional[str] = None
    source: SourceType = SourceType.manual

class ServiceProviderCreate(BaseModel):
    name: str
    address: str
    category: Optional[str] = None

class ServiceProviderResponse(ServiceProviderBase):
    id: int
    status: ModerationStatus
    validation_score: int
    evidence_image_path: Optional[str] = None
    added_by_user_id: Optional[int] = None
    created_at: datetime
    
    model_config = ConfigDict(from_attributes=True)

# --- Értékelések (Reviews) - HOZZÁADVA ---

class ServiceReviewBase(BaseModel):
    price_rating: int
    quality_rating: int
    time_rating: int
    communication_rating: int
    comment: Optional[str] = None

class ServiceReviewCreate(ServiceReviewBase):
    pass

class ServiceReviewResponse(ServiceReviewBase):
    id: int
    user_id: int
    service_id: int
    transaction_id: uuid.UUID
    is_verified: bool
    created_at: datetime
    
    model_config = ConfigDict(from_attributes=True)

# --- Gamifikáció és Szavazás (Voting & Gamification) ---

class VoteCreate(BaseModel):
    vote_value: int

class LeaderboardEntry(BaseModel):
    username: str
    points: int
    rank: int
    
    model_config = ConfigDict(from_attributes=True)

class BadgeSchema(BaseModel):
    id: int
    name: str
    description: str
    icon_url: Optional[str] = None
    
    model_config = ConfigDict(from_attributes=True)

class UserStatSchema(BaseModel):
    user_id: int
    total_xp: int
    current_level: int
    penalty_points: int
    rank_title: Optional[str] = None
    badges: List[BadgeSchema] = []
    
    model_config = ConfigDict(from_attributes=True)