from pydantic import BaseModel, Field
from typing import Optional, List

class StartDayRequest(BaseModel):
    session_id: str

class CheckInRequest(BaseModel):
    goal_id: int = Field(..., description="체크인할 세부 목표의 ID")
    increment_count: float = Field(..., description="지난 30분 동안 달성한 수치 (없으면 0)")
    user_mood: Optional[str] = Field(None, description="유저의 현재 감정이나 코멘트")
    session_type: str = Field("AM", description="'AM'(오전) 또는 'PM'(오후)")

class CheckInResponse(BaseModel):
    status: str
    is_success: bool
    ai_mode: str  
    message: str  
    
class AdjustedGoal(BaseModel):
    goal_id: int
    category: str
    original_target: float
    adjusted_target: float
    
class MorningAssessmentRequest(BaseModel):
    plan_id: int = Field(..., description="평가할 오늘의 계획(daily_plans) ID")
    
class GoalBreakdown(BaseModel):
    title: str
    current: float
    target: float
    rate: int
    
class MorningAssessmentResponse(BaseModel):
    motivation_level: str = Field(..., description="'HIGH' 또는 'LOW'")
    score: int = Field(..., description="전체 달성률 (%)")
    ai_summary: str = Field(..., description="AI 요약 코멘트")
    afternoon_action: str = Field(..., description="오후 행동 지침")
    adjusted_goals: List[AdjustedGoal] = Field(default=[], description="조정된 목표 리스트")
    
    # [신규 추가] 항목별 상세 내역 리스트
    breakdown: List[GoalBreakdown] = Field(default=[], description="항목별 상세 달성 현황")
    
class MorningReflectionRequest(BaseModel):
    plan_id: int = Field(..., description="오늘의 계획 ID")
    reflection_text: str = Field(..., description="유저의 고민 또는 회고 내용")

class MorningReflectionResponse(BaseModel):
    message: str
    ai_advice: str # 간단한 격려 메시지
    
class EndDayRequest(BaseModel):
    plan_id: int = Field(..., description="오늘의 계획 ID")

class EndDayResponse(BaseModel):
    final_score: int = Field(..., description="최종 달성률(%)")
    message: str = Field(..., description="마무리 인사 메시지")
    breakdown: List[GoalBreakdown] = Field(..., description="최종 항목별 상세 내역")
    goals: Optional[List[dict]] = None
    
class SalesReflectionItem(BaseModel):
    goal_id: int
    reflection_text: str

class SubmitSalesReportRequest(BaseModel):
    session_id: str 
    plan_id: int
    reflections: List[SalesReflectionItem]
    
class BossCommentRequest(BaseModel):
    session_id: str
    date: str
    boss_comment: str
    
# 상담 채팅 요청 스키마
class CounselingRequest(BaseModel):
    session_id: str
    plan_id: Optional[int] = None
    message: str
    sender: str = "user" # user or bot
    
# 최종 AI 분석 요청
class FinalReviewAnalysisRequest(BaseModel):
    plan_id: int
    session_id: str

# 최종 총평 제출
class SubmitFinalReviewRequest(BaseModel):
    plan_id: int
    final_user_comment: str
    final_ai_comment: str
    

class FinishCounselingRequest(BaseModel):
    session_id: str
    plan_id: int