import { Employee, EmployeeReport, Submission, FaqItem, CompanyReport } from './types';

// URL Configuration - reads from environment variables with fallbacks
export const SITE_URL = import.meta.env.VITE_SITE_URL || 'http://localhost:5173';

// API Base URL - auto-detect development vs production
const isLocalhost = typeof window !== 'undefined' &&
  (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');

// Check if we should force production API (useful for testing invite links locally)
// const forceProductionAPI = typeof window !== 'undefined' &&
//   window.location.search.includes('use-production-api=true');

// Use Firebase Functions emulator in development, production functions in production
// export const API_URL = (isLocalhost && !forceProductionAPI)
//   ? 'http://127.0.0.1:5002/auditly-consulting/us-central1'  // Firebase Functions Emulator
//   : 'https://us-central1-auditly-consulting.cloudfunctions.net';       // Production Firebase Functions

export const API_URL = 'https://us-central1-auditly-c0027.cloudfunctions.net';
// export const API_URL = 'https://us-central1-auditly-consulting.cloudfunctions.net';
// export const API_URL = 'http://127.0.0.1:5002/auditly-consulting/us-central1';

// Log URL configuration in development
if (import.meta.env.DEV) {
  console.log('🌐 Frontend URL Configuration:');
  console.log(`   SITE_URL: ${SITE_URL}`);
  console.log(`   API_URL: ${API_URL}`);
}

// DEPRECATED: These are legacy sample data that should not be used in production
// Real data should be generated via AI backend calls or user input
export const EMPLOYEES: Employee[] = [];

// DEPRECATED: Sample report data - real reports should be generated via /generateEmployeeReport API
export const REPORT_DATA: EmployeeReport = {
  employeeId: 'sample',
  department: 'Sample Department',
  role: 'Sample Role',
  roleAndOutput: {
    responsibilities: 'This is sample data. Real reports are generated via AI.',
    clarityOnRole: 'Sample data',
    selfRatedOutput: 'Sample data',
    recurringTasks: 'Sample data',
  },
  insights: {
    personalityTraits: 'Sample data - use AI-generated reports',
    psychologicalIndicators: ['Sample data'],
    selfAwareness: 'Sample data',
    emotionalResponses: 'Sample data',
    growthDesire: 'Sample data',
  },
  strengths: ['Sample data - use AI-generated reports'],
  weaknesses: [
    'Sample data - use AI-generated reports'
  ],
  opportunities: [
    {
      title: 'Sample data',
      description: 'Sample data',
    }
  ],
  risks: ['Sample data - use AI-generated reports'],
  recommendations: ['Sample recommendation - use AI-generated reports'],
  gradingOverview: {
    employeeName: 'Sample Employee',
    scalability: 3,
    reliability: 4,
    roleFit: 3,
    output: 3,
    grade: "A",
    initiative: 10
  }
};

// DEPRECATED: Sample submission data - real submissions come from employee questionnaires
export const SUBMISSIONS_DATA: Submission = {
  employeeId: 'sample',
  answers: [
    {
      question: 'Sample question',
      answer: 'Sample answer - real data comes from employee questionnaires',
    }
  ],
};

export const FAQ_DATA: FaqItem[] = [
  {
    question: "What is the process for submitting a support ticket?",
    answer: "Team members will undergo evaluations every three months, focusing on their performance, teamwork, and communication skills. Role advancements will be considered at these intervals."
  },
  {
    question: "How can I reset my password?",
    answer: "You can reset your password by clicking the 'Forgot Password' link on the login page. An email will be sent to you with instructions."
  },
  {
    question: "What are the criteria for performance reviews?",
    answer: "Performance reviews are based on a combination of self-assessment, peer feedback, and manager evaluation. Key criteria include goal achievement, collaboration, and contribution to company values."
  },
  {
    question: "How can I access the company's training resources?",
    answer: "All training resources are available in the 'Company Wiki' section of the platform. You can find documents, videos, and links to external courses."
  },
  {
    question: "What should I do if I encounter a technical issue?",
    answer: "For any technical issues, please submit a ticket through the 'Help & Support' page. Our IT team will get back to you within 24 hours."
  },
  {
    question: "How do I provide feedback on team projects?",
    answer: "Feedback can be provided directly within the project management tool or during scheduled team retrospectives. We encourage open and constructive communication."
  }
];

export const CHAT_STARTERS = [
  "Summarize the latest employee reports.",
  "What are the company's organizational strengths?",
  "Identify any risks in our current workforce.",
  "Which employees should be considered for promotion?",
  "What are our immediate hiring needs?",
  "How can we improve team performance?"
];

// DEPRECATED: This should not be used in production - real company reports are AI-generated
export const SAMPLE_COMPANY_REPORT: CompanyReport = {
  id: 'placeholder-report',
  createdAt: Date.now(),
  overview: {
    totalEmployees: 8,
    departmentBreakdown: [
      { department: 'Campaigns', count: 3 },
      { department: 'Social Media', count: 2 },
      { department: 'Creative', count: 2 },
      { department: 'Tech', count: 1 }
    ],
    submissionRate: 87.5,
    lastUpdated: Date.now(),
    averagePerformanceScore: 8.2,
    riskLevel: 'Low'
  },
  weaknesses: [
    { title: 'Lack of Structure', description: 'People are confused about their roles. No one knows who\'s responsible.' },
    { title: 'Communication Gaps', description: 'Information doesn\'t flow effectively between departments.' }
  ],
  gradingBreakdown: [
    {
      departmentNameShort: 'Campaigns',
      departmentName: 'Campaigns Department',
      lead: 'Sarah Johnson',
      support: 'Mike Chen',
      departmentGrade: 'A',
      executiveSummary: 'Campaigns team shows exceptional performance with strong collaboration and innovative approaches to client work.',
      teamScores: [
        {
          employeeName: 'Sarah Johnson',
          grade: 'A+',
          reliability: 9,
          roleFit: 10,
          scalability: 8,
          output: 9,
          initiative: 9
        },
        {
          employeeName: 'Mike Chen',
          grade: 'A',
          reliability: 8,
          roleFit: 9,
          scalability: 7,
          output: 8,
          initiative: 8
        },
        {
          employeeName: 'Lisa Wong',
          grade: 'B+',
          reliability: 7,
          roleFit: 8,
          scalability: 6,
          output: 7,
          initiative: 7
        },
        {
          employeeName: 'Alex Rivera',
          grade: 'A',
          reliability: 8,
          roleFit: 9,
          scalability: 7,
          output: 8,
          initiative: 8
        },
        {
          employeeName: 'Jamie Park',
          grade: 'B',
          reliability: 10,
          roleFit: 1,
          scalability: 6,
          output: 2,
          initiative: 7
        },
        {
          employeeName: 'Taylor Smith',
          grade: 'A',
          reliability: 9,
          roleFit: 7,
          scalability: 3,
          output: 1,
          initiative: 9
        },
        {
          employeeName: 'Jordan Lee',
          grade: 'B+',
          reliability: 7,
          roleFit: 8,
          scalability: 7,
          output: 8,
          initiative: 7
        },
        {
          employeeName: 'Casey Johnson',
          grade: 'A+',
          reliability: 10,
          roleFit: 9,
          scalability: 9,
          output: 10,
          initiative: 9
        }
      ]
    },
    {
      departmentNameShort: 'Social Media',
      departmentName: 'Social Media Department',
      lead: 'Alex Rivera',
      support: 'Taylor Smith',
      departmentGrade: 'A-',
      executiveSummary: 'Social Media team excels in engagement and content creation, driving significant brand awareness.',
      teamScores: [
        {
          employeeName: 'Alex Rivera',
          grade: 'A',
          reliability: 9,
          roleFit: 9,
          scalability: 8,
          output: 9,
          initiative: 8
        },
        {
          employeeName: 'Taylor Smith',
          grade: 'A-',
          reliability: 8,
          roleFit: 8,
          scalability: 7,
          output: 8,
          initiative: 7
        }
      ]
    }
  ],
  personnelChanges: {
    newHires: [
      { name: 'Emma Wilson', department: 'Creative', role: 'Graphic Designer', impact: 'Will strengthen visual design capabilities' }
    ],
    promotions: [
      { name: 'Sarah Johnson', fromRole: 'Campaign Manager', toRole: 'Senior Campaign Manager', impact: 'Will lead larger client accounts' }
    ],
    departures: []
  },
  immediateHiringNeeds: [
    { department: 'Tech', role: 'Frontend Developer', priority: 'High', reasoning: 'Need to expand web development capacity for growing client demands' },
    { department: 'Social Media', role: 'Content Creator', priority: 'Medium', reasoning: 'Additional support needed for video content production' }
  ],
  forwardOperatingPlan: [
    {
      title: 'Q1 Client Growth Initiative',
      details: ['Expand campaign team by 2 members', 'Implement new project management system', 'Launch client referral program']
    },
    {
      title: 'Technology Infrastructure',
      details: ['Upgrade development tools', 'Implement automated testing', 'Enhance security protocols']
    }
  ],
  strengths: [
    'Strong creative vision and execution across all projects',
    'Excellent client satisfaction ratings (4.8/5)',
    'Highly collaborative team culture',
    'Innovative approach to campaign development',
    'Reliable project delivery within deadlines'
  ],
  organizationalImpactSummary: [
    {
      category: 'Mission Critical',
      employees: [
        {
          employeeName: 'Sarah Johnson',
          impact: 'Lead Campaign Manager',
          description: 'Manages top-tier client relationships and drives 40% of company revenue',
          suggestedPay: '$120,000'
        },
        {
          employeeName: 'Casey Johnson',
          impact: 'Tech Infrastructure',
          description: 'Maintains all technical systems and client delivery platforms',
          suggestedPay: '$110,000'
        }
      ]
    },
    {
      category: 'Highly Valuable',
      employees: [
        {
          employeeName: 'Alex Rivera',
          impact: 'Social Media Strategy',
          description: 'Develops social strategies that increase client engagement by 150%',
          suggestedPay: '$95,000'
        },
        {
          employeeName: 'Taylor Smith',
          impact: 'Creative Director',
          description: 'Ensures brand consistency and award-winning creative output',
          suggestedPay: '$92,000'
        }
      ]
    },
    {
      category: 'Core Support',
      employees: [
        {
          employeeName: 'Mike Chen',
          impact: 'Campaign Support',
          description: 'Reliable execution of campaign tasks and client communication',
          suggestedPay: '$70,000'
        },
        {
          employeeName: 'Jordan Lee',
          impact: 'Design Support',
          description: 'Produces high-quality visual assets and maintains design standards',
          suggestedPay: '$68,000'
        }
      ]
    },
    {
      category: 'Low Criticality',
      employees: [

      ]
    }
  ],
  executiveSummary: `Welcome to Auditly! Generate your first AI-powered company report by inviting employees and completing the onboarding process.`
};