using System;
using System.Collections.Generic;

namespace Haoliang.Models.Common
{
    public class ApiResponse<T>
    {
        public bool Success { get; set; }
        public T Data { get; set; }
        public string Message { get; set; }
        public int ErrorCode { get; set; }
        public DateTime Timestamp { get; set; }
        public string RequestId { get; set; }
        public Dictionary<string, object> Meta { get; set; }
    }

    public class PaginatedResponse<T>
    {
        public List<T> Items { get; set; }
        public int TotalCount { get; set; }
        public int PageNumber { get; set; }
        public int PageSize { get; set; }
        public int TotalPages { get; set; }
        public bool HasPreviousPage { get; set; }
        public bool HasNextPage { get; set; }
        public ApiResponse<T> Response { get; set; }
    }

    public class ValidationResult
    {
        public bool IsValid { get; set; }
        public List<ValidationError> Errors { get; set; }
    }

    public class ValidationError
    {
        public string Field { get; set; }
        public string Message { get; set; }
        public string Code { get; set; }
    }

    public class SelectOption
    {
        public string Value { get; set; }
        public string Label { get; set; }
        public bool Disabled { get; set; }
        public string Group { get; set; }
    }

    public class TreeNode
    {
        public string Id { get; set; }
        public string Text { get; set; }
        public string Type { get; set; }
        public List<TreeNode> Children { get; set; }
        public Dictionary<string, object> Data { get; set; }
        public bool Expanded { get; set; }
        public bool Selected { get; set; }
        public bool HasChildren { get; set; }
    }

    public class ChartData
    {
        public string Type { get; set; } // line, bar, pie, doughnut, radar
        public string Title { get; set; }
        public List<string> Labels { get; set; }
        public List<Dataset> Datasets { get; set; }
        public Dictionary<string, object> Options { get; set; }
    }

    public class Dataset
    {
        public string Label { get; set; }
        public List<decimal> Data { get; set; }
        public string BackgroundColor { get; set; }
        public string BorderColor { get; set; }
        public decimal BorderWidth { get; set; }
        public string BorderDash { get; set; }
        public bool Fill { get; set; }
        public string Tension { get; set; }
    }

    public class DashboardWidget
    {
        public string Id { get; set; }
        public string Title { get; set; }
        public string Type { get; set; } // chart, statistic, table, list
        public string Size { get; set; } // small, medium, large
        public int Row { get; set; }
        public int Col { get; set; }
        public Dictionary<string, object> Config { get; set; }
        public bool Refreshable { get; set; }
        public int RefreshInterval { get; set; }
        public bool Visible { get; set; }
    }

    public class FilterCondition
    {
        public string Field { get; set; }
        public string Operator { get; set; } // eq, ne, gt, lt, gte, lte, in, like
        public object Value { get; set; }
        public string Logic { get; set; } // and, or
    }
}