package com.unicorn.hgzero.meeting.infra.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 회의록 상세 조회 응답 DTO (프로토타입 기반 - 대시보드/회의록 탭 구조)
 */
@Getter
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class MinutesDetailResponse {

    private String minutesId;
    private String title;
    private String memo;
    private String status; // DRAFT, FINALIZED
    private int version;
    private LocalDateTime createdAt;
    private LocalDateTime lastModifiedAt;
    private String createdBy;
    private String lastModifiedBy;
    
    // 회의 기본 정보
    private MeetingInfo meeting;
    
    // 대시보드 탭 정보
    private DashboardInfo dashboard;
    
    // 회의록 탭 정보 (안건별 상세)
    private List<AgendaInfo> agendas;

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class MeetingInfo {
        private String meetingId;
        private String title;
        private LocalDateTime scheduledAt;
        private LocalDateTime startedAt;
        private LocalDateTime endedAt;
        private String organizerId;
        private String organizerName;
        private String location;
        private int durationMinutes;
        private List<Participant> participants;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Participant {
        private String userId;
        private String name;
        private String role; // 작성자, 참여자
        private String avatarColor; // avatar-green, avatar-blue, etc.
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class DashboardInfo {
        private List<KeyPoint> keyPoints;      // 핵심내용
        private List<String> keywords;         // 키워드 태그
        private Statistics stats;              // 통계 정보
        private List<Decision> decisions;      // 결정사항
        private TodoProgress todoProgress;     // Todo 진행상황
        private List<RelatedMinutes> relatedMinutes; // 관련회의록
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class KeyPoint {
        private int index;
        private String content;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Statistics {
        private int participantCount;
        private int durationMinutes;
        private int agendaCount;
        private int todoCount;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Decision {
        private String content;
        private String decidedBy;
        private LocalDateTime decidedAt;
        private String background;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TodoProgress {
        private int totalCount;
        private int completedCount;
        private int progressPercentage;
        private List<SimpleTodo> todos; // 간단한 Todo 목록 (한줄 텍스트)
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SimpleTodo {
        private String todoId;
        private String title; // 간단한 한줄 텍스트
        private String assigneeName;
        private String status; // IN_PROGRESS, COMPLETED, OVERDUE
        private String priority; // HIGH, MEDIUM, LOW
        private LocalDateTime dueDate;
        private String dueDayStatus; // D-2, D+1, 완료 등
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RelatedMinutes {
        private String minutesId;
        private String title;
        private LocalDateTime meetingDate;
        private String author;
        private int relevancePercentage;
        private String relevanceLevel; // HIGH, MEDIUM, LOW
        private String summary;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AgendaInfo {
        private String agendaId;
        private String title;
        private int orderIndex;
        private boolean isVerified;
        private String verifiedBy;
        private LocalDateTime verifiedAt;
        
        // AI 요약
        private AiSummary aiSummary;
        
        // 안건 상세 내용
        private AgendaDetails details;
        
        // 관련회의록
        private List<RelatedMinutes> relatedMinutes;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AiSummary {
        private String content;
        private LocalDateTime generatedAt;
        private LocalDateTime modifiedAt;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AgendaDetails {
        private List<String> discussions; // 논의 사항
        private List<String> decisions;   // 결정 사항
    }
}