func (h *PostHandler) CreateComment(c *gin.Context) {
	userIDStr, _ := c.Get("user_id")
	userID, _ := uuid.Parse(userIDStr.(string))
	postID := c.Param("id")

	var req struct {
		Body string `json:"body" binding:"required,max=500"`
	}

	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	parentUUID, err := uuid.Parse(postID)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid post ID"})
		return
	}

	tags := utils.ExtractHashtags(req.Body)
	tone := "neutral"
	cis := 0.8

	post := &models.Post{
		AuthorID:       userID,
		Body:           req.Body,
		Status:         "active",
		ToneLabel:      &tone,
		CISScore:       &cis,
		BodyFormat:     "plain",
		Tags:           tags,
		IsBeacon:       false,
		IsActiveBeacon: false,
		AllowChain:     true,
		Visibility:     "public",
		ChainParentID:  &parentUUID,
	}

	if err := h.postRepo.CreatePost(c.Request.Context(), post); err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create comment", "details": err.Error()})
		return
	}

	comment := &models.Comment{
		ID:        post.ID,
		PostID:    postID,
		AuthorID:  post.AuthorID,
		Body:      post.Body,
		Status:    "active",
		CreatedAt: post.CreatedAt,
	}

	c.JSON(http.StatusCreated, gin.H{"comment": comment})
}

