export interface ProductRoadmap {
  id: string;
  name: string;
  vision: string;
  timeHorizon: 'quarterly' | 'annual' | 'multi-year';
  status: 'draft' | 'active' | 'archived';
  themes: RoadmapTheme[];
  milestones: Milestone[];
  releases: Release[];
  createdAt: Date;
  updatedAt: Date;
  owner: string;
  stakeholders: string[];
  metrics: RoadmapMetrics;
}

export interface RoadmapTheme {
  id: string;
  name: string;
  description: string;
  objectives: string[];
  initiatives: Initiative[];
  priority: 'must-have' | 'should-have' | 'nice-to-have';
  timeframe: {
    startQuarter: string; // e.g., "Q1 2024"
    endQuarter: string;
  };
  status: 'planned' | 'in-progress' | 'completed' | 'deferred';
  metrics: ThemeMetrics;
}

export interface Initiative {
  id: string;
  themeId: string;
  title: string;
  description: string;
  features: Feature[];
  epicIds: string[]; // Links to agile management epics
  value: ValueMetrics;
  effort: EffortEstimate;
  risks: Risk[];
  dependencies: Dependency[];
  status: 'ideation' | 'validated' | 'scheduled' | 'in-development' | 'launched';
}

export interface Feature {
  id: string;
  initiativeId: string;
  name: string;
  description: string;
  userStories: string[]; // Links to agile stories
  priority: number; // 1-100 score
  businessValue: BusinessValue;
  technicalComplexity: 'low' | 'medium' | 'high' | 'very-high';
  targetRelease?: string;
  status: 'proposed' | 'approved' | 'in-progress' | 'completed' | 'cancelled';
}

export interface Milestone {
  id: string;
  name: string;
  date: Date;
  type: 'release' | 'business' | 'technical' | 'regulatory';
  description: string;
  deliverables: string[];
  status: 'upcoming' | 'at-risk' | 'completed' | 'missed';
  dependencies: string[];
}

export interface Release {
  id: string;
  version: string;
  name: string;
  date: Date;
  features: string[]; // Feature IDs
  themes: string[]; // Theme IDs
  goals: string[];
  status: 'planning' | 'development' | 'testing' | 'released';
  notes?: string;
}

export interface ValueMetrics {
  userImpact: 'low' | 'medium' | 'high' | 'critical';
  revenueImpact: number; // estimated revenue impact
  costSavings: number;
  strategicValue: number; // 1-10
  customerSatisfaction: number; // projected NPS impact
}

export interface BusinessValue {
  score: number; // 1-100
  rationale: string;
  metrics: string[];
}

export interface EffortEstimate {
  developmentWeeks: number;
  designWeeks: number;
  qaWeeks: number;
  totalStoryPoints?: number;
  confidence: 'low' | 'medium' | 'high';
}

export interface Risk {
  id: string;
  description: string;
  likelihood: 'low' | 'medium' | 'high';
  impact: 'low' | 'medium' | 'high';
  mitigation: string;
  owner?: string;
}

export interface Dependency {
  id: string;
  type: 'internal' | 'external' | 'technical' | 'business';
  description: string;
  targetId?: string; // ID of dependent item
  status: 'resolved' | 'pending' | 'blocked';
}

export interface RoadmapMetrics {
  featuresPlanned: number;
  featuresCompleted: number;
  initiativesActive: number;
  velocityTrend: 'increasing' | 'stable' | 'decreasing';
  onTimeDelivery: number; // percentage
  valueDelivered: number; // calculated score
}

export interface ThemeMetrics {
  initiativesTotal: number;
  initiativesCompleted: number;
  featuresTotal: number;
  featuresCompleted: number;
  progressPercentage: number;
  valueScore: number;
}

// Prioritization interfaces
export interface PrioritizationCriteria {
  method: 'rice' | 'value-effort' | 'moscow' | 'kano' | 'custom';
  weights?: {
    businessValue: number;
    userImpact: number;
    strategicAlignment: number;
    technicalFeasibility: number;
    risk: number;
  };
}

export interface RICEScore {
  reach: number;
  impact: number;
  confidence: number;
  effort: number;
  score: number; // (Reach * Impact * Confidence) / Effort
}

export interface PrioritizationResult {
  featureId: string;
  method: string;
  score: number;
  rank: number;
  rationale: string;
  breakdown?: any; // Method-specific breakdown
}

// Timeline interfaces
export interface TimelineView {
  type: 'quarterly' | 'monthly' | 'release' | 'now-next-later';
  startDate: Date;
  endDate: Date;
  items: TimelineItem[];
}

export interface TimelineItem {
  id: string;
  type: 'theme' | 'initiative' | 'feature' | 'milestone' | 'release';
  name: string;
  startDate: Date;
  endDate: Date;
  status: string;
  dependencies: string[];
  progress?: number;
}

// Review and approval interfaces
export interface RoadmapReview {
  id: string;
  roadmapId: string;
  reviewDate: Date;
  participants: string[];
  decisions: ReviewDecision[];
  feedback: ReviewFeedback[];
  nextReviewDate?: Date;
}

export interface ReviewDecision {
  itemId: string;
  itemType: 'theme' | 'initiative' | 'feature';
  decision: 'approved' | 'deferred' | 'cancelled' | 'needs-revision';
  rationale: string;
  approvedBy: string;
}

export interface ReviewFeedback {
  itemId: string;
  feedback: string;
  author: string;
  priority: 'low' | 'medium' | 'high';
  resolved: boolean;
}

// Input interfaces for tool handlers
export interface CreateRoadmapOptions {
  name: string;
  vision: string;
  timeHorizon: 'quarterly' | 'annual' | 'multi-year';
  owner: string;
  stakeholders?: string[];
}

export interface AddThemeOptions {
  roadmapId: string;
  name: string;
  description: string;
  objectives: string[];
  priority: 'must-have' | 'should-have' | 'nice-to-have';
  startQuarter: string;
  endQuarter: string;
}

export interface CreateInitiativeOptions {
  roadmapId: string;
  themeId: string;
  title: string;
  description: string;
  estimatedValue: ValueMetrics;
  estimatedEffort: EffortEstimate;
  risks?: Risk[];
}

export interface AddFeatureOptions {
  roadmapId: string;
  initiativeId: string;
  name: string;
  description: string;
  businessValue: BusinessValue;
  technicalComplexity: 'low' | 'medium' | 'high' | 'very-high';
  targetRelease?: string;
}

export interface PrioritizeOptions {
  roadmapId: string;
  method: PrioritizationCriteria;
  scope?: 'all' | 'theme' | 'initiative' | 'unscheduled';
  scopeId?: string;
}