/**
 * Маппинг slug'ов lead_statuses → стилевые токены пилюли.
 * Slugs синхронизированы с db/schema.sql:2076 (источник истины).
 *
 * Spec §8. Используется компонентом StatusPill.vue.
 */
export interface PillStyle {
    bg: string;
    color: string;
    fontWeight?: number;
    textDecoration?: 'line-through' | 'none';
}

export const STATUS_PILL_SLUGS = [
    'new',
    'in_progress',
    'callback',
    'quality',
    'meeting_set',
    'won',
    'refund',
    'duplicate',
    'junk',
    'no_answer',
    'cancelled',
    'closed',
    'postponed',
    'archived',
] as const;

type StatusPillSlug = (typeof STATUS_PILL_SLUGS)[number];

const STYLES: Record<StatusPillSlug, PillStyle> = {
    new: { bg: 'rgba(15,110,86,0.12)', color: '#0F6E56' },
    in_progress: { bg: 'rgba(63,124,149,0.12)', color: '#2A5A6E' },
    callback: { bg: 'rgba(217,164,65,0.18)', color: '#A07820' },
    quality: { bg: 'rgba(46,139,87,0.15)', color: '#2E8B57' },
    meeting_set: { bg: 'rgba(122,91,163,0.15)', color: '#7A5BA3' },
    won: { bg: 'rgba(46,139,87,0.22)', color: '#1F6940', fontWeight: 600 },
    refund: { bg: 'rgba(204,110,80,0.15)', color: '#B0563D' },
    duplicate: { bg: 'rgba(1,32,25,0.08)', color: '#3A3A3A' },
    junk: { bg: 'rgba(184,58,58,0.10)', color: '#B83A3A' },
    no_answer: { bg: 'rgba(107,99,86,0.15)', color: '#6B6356' },
    cancelled: { bg: 'rgba(107,99,86,0.18)', color: '#6B6356', textDecoration: 'line-through' },
    closed: { bg: 'rgba(1,32,25,0.10)', color: '#3A3A3A' },
    postponed: { bg: 'rgba(15,110,86,0.06)', color: '#6B6356' },
    archived: { bg: '#012019', color: '#E8E2D4' },
};

const FALLBACK: PillStyle = { bg: 'rgba(1,32,25,0.08)', color: '#3A3A3A' };

export function useStatusPill(slug: string): PillStyle {
    return STYLES[slug as StatusPillSlug] ?? FALLBACK;
}
