export type PerformanceBadgeTone = 'auto' | 'positive' | 'negative' | 'neutral' | 'primary';
export type PerformanceBadgeResolvedTone = Exclude<PerformanceBadgeTone, 'auto'>;
export type PerformanceBadgeShape = 'badge' | 'inline';
export type PerformanceBadgeValue = string | number | null;

export interface KviewPerformanceBadgeProps {
    value?: PerformanceBadgeValue;
    label?: string | null;
    tone?: PerformanceBadgeTone;
    icon?: string | null;
    shape?: PerformanceBadgeShape;
    dot?: boolean;
}

export type MetricTrendDirection = 'up' | 'down' | 'neutral';
export type MetricTrendTone = 'positive' | 'negative' | 'neutral';
export type MetricTrendValue = string | number | null;

export interface KviewMetricTrendProps {
    direction?: MetricTrendDirection;
    value?: MetricTrendValue;
    label?: string | null;
    tone?: MetricTrendTone | null;
    icon?: string | null;
    compact?: boolean;
}

export type InfoCardVariant = 'default' | 'metric';
export type InfoCardValue = string | number | null;
export type InfoCardMeta = string | number | null;

export interface KviewInfoCardProps {
    label: string;
    value?: InfoCardValue;
    icon?: string | null;
    variant?: InfoCardVariant;
    meta?: InfoCardMeta;
    trendValue?: MetricTrendValue;
    trendLabel?: string | null;
    trendDirection?: MetricTrendDirection;
}

export type KviewChartKind = 'line' | 'bar';
export type KviewChartAxis = 'primary' | 'secondary';
export type KviewChartLineStyle = 'solid' | 'dashed';
export type KviewChartValueFormat = 'amount' | 'ratio' | 'percent' | 'number';
export type KviewChartVariant = 'panel' | 'compact' | 'bare';

/**
 * One plotted series. `kind` lets a single chart mix bar and line series
 * (a "combo" chart); `axis` sends a series to the secondary (right) axis,
 * for a series on a different scale than the rest (for example a ratio
 * plotted alongside amounts). `color` accepts any canvas-valid CSS color,
 * including a resolvable `var(--token)` reference so callers can lean on
 * existing design tokens (`var(--fpc-nav-color)`) instead of literal hex.
 */
export interface KviewChartDataset {
    id: string;
    label: string;
    values: Array<number | null>;
    kind?: KviewChartKind;
    axis?: KviewChartAxis;
    color?: string;
    style?: KviewChartLineStyle;
    valueFormat?: KviewChartValueFormat;
    /** Bar/point emphasis; defaults to false. Points render slightly larger, bars keep full opacity. */
    emphasize?: boolean;
}

/** A small highlighted figure in the chart header, matching KviewMetricTrend's up/down/neutral language. */
export interface KviewChartSummaryItem {
    id: string;
    label: string;
    value: string;
    direction?: MetricTrendDirection;
}

export interface KviewChartProps {
    id?: string | null;
    kind?: KviewChartKind;
    labels: string[];
    datasets: KviewChartDataset[];
    title?: string | null;
    subtitle?: string | null;
    summary?: KviewChartSummaryItem[];
    variant?: KviewChartVariant;
    height?: number;
    primaryAxisLabel?: string | null;
    secondaryAxisLabel?: string | null;
    ariaLabel: string;
    loading?: boolean;
    emptyTitle?: string;
    emptyText?: string;
}

export type KviewPerformanceChartVariant = 'panel' | 'bare' | 'compact';
export type KviewPerformanceChartTrendDirection = 'up' | 'down' | 'neutral';

/** One plotted period. `nav`/`benchmark` are already-converted numeric values, or `null` for a gap. */
export interface KviewPerformanceChartPoint {
    label: string;
    nav: number | null;
    benchmark: number | null;
}

/**
 * Dependency-free SVG performance chart (NAV vs. a benchmark line over time).
 * No external charting library — this is the Overview-tab primitive; charts
 * that need Chart.js use `KviewChart` instead. `navColor`/`benchmarkColor`
 * accept any CSS color value, including a `var(--token)` reference, since
 * they are set as inline custom properties and resolved natively by CSS
 * (there is no canvas here, so no runtime JS resolution is needed).
 */
export interface KviewPerformanceChartProps {
    id?: string | null;
    points: KviewPerformanceChartPoint[];
    title?: string | null;
    subtitle?: string | null;
    navLabel?: string;
    benchmarkLabel?: string;
    value?: string | null;
    valueLabel?: string | null;
    trendValue?: string | null;
    trendLabel?: string | null;
    trendDirection?: KviewPerformanceChartTrendDirection | null;
    autoTrend?: boolean;
    unit?: string | null;
    prefix?: string | null;
    suffix?: string | null;
    decimals?: number;
    width?: number | null;
    height?: number;
    min?: number | null;
    max?: number | null;
    variant?: KviewPerformanceChartVariant;
    showHeader?: boolean;
    showLegend?: boolean;
    showPoints?: boolean;
    showGrid?: boolean;
    emptyText?: string;
    navColor?: string;
    benchmarkColor?: string;
}
