-- ============================================================
-- CRM Platform - Seed Data
-- ============================================================
USE crm_db;

-- ============================================================
-- PIPELINES & STAGES
-- ============================================================
INSERT INTO pipelines (name, is_default, created_by) VALUES
('Sales Pipeline', 1, 1),
('Enterprise Pipeline', 0, 1),
('Partnership Pipeline', 0, 1);

INSERT INTO pipeline_stages (pipeline_id, name, order_index, win_probability, color) VALUES
-- Sales Pipeline (id=1)
(1, 'Prospecting',        1,  10, '#94a3b8'),
(1, 'Qualification',      2,  20, '#f59e0b'),
(1, 'Needs Analysis',     3,  40, '#f97316'),
(1, 'Value Proposition',  4,  60, '#8b5cf6'),
(1, 'Proposal Sent',      5,  75, '#3b82f6'),
(1, 'Negotiation',        6,  85, '#06b6d4'),
(1, 'Closed Won',         7, 100, '#10b981'),
(1, 'Closed Lost',        8,   0, '#ef4444'),
-- Enterprise Pipeline (id=2)
(2, 'Initial Contact',    1,  5,  '#94a3b8'),
(2, 'Discovery',          2,  15, '#f59e0b'),
(2, 'Technical Review',   3,  35, '#f97316'),
(2, 'Executive Sponsor',  4,  55, '#8b5cf6'),
(2, 'Procurement',        5,  70, '#3b82f6'),
(2, 'Contract Review',    6,  90, '#06b6d4'),
(2, 'Closed Won',         7, 100, '#10b981'),
(2, 'Closed Lost',        8,   0, '#ef4444'),
-- Partnership Pipeline (id=3)
(3, 'Outreach',           1,  10, '#94a3b8'),
(3, 'Alignment Call',     2,  25, '#f59e0b'),
(3, 'Due Diligence',      3,  50, '#8b5cf6'),
(3, 'Agreement Draft',    4,  75, '#3b82f6'),
(3, 'Signed',             5, 100, '#10b981');

-- ============================================================
-- COMPANIES
-- ============================================================
INSERT INTO companies (name, domain, industry, company_size, annual_revenue, phone, email, website, city, state, country, description, owner_id, status, type) VALUES
('Acme Corporation',         'acme.com',          'Technology',        '501-1000',  12000000.00, '+1-415-555-0100', 'info@acme.com',          'https://acme.com',          'San Francisco', 'CA', 'USA', 'Leading tech company specializing in cloud solutions.',     2, 'customer', 'customer'),
('TechStart Inc',            'techstart.io',      'Software',          '51-200',     3500000.00, '+1-512-555-0200', 'hello@techstart.io',     'https://techstart.io',      'Austin',        'TX', 'USA', 'Startup focused on developer tools and APIs.',              3, 'customer', 'customer'),
('Global Retail Group',      'globalretail.com',  'Retail',            '5000+',     85000000.00, '+1-212-555-0300', 'partnerships@gr.com',    'https://globalretail.com',  'New York',      'NY', 'USA', 'Major retail chain with 500+ locations nationwide.',        2, 'prospect', 'prospect'),
('HealthCare Plus',          'hcplus.org',        'Healthcare',        '1001-5000', 25000000.00, '+1-312-555-0400', 'it@hcplus.org',          'https://hcplus.org',        'Chicago',       'IL', 'USA', 'Regional healthcare network serving 2M+ patients.',         4, 'customer', 'customer'),
('EduLearn Foundation',      'edulearn.edu',      'Education',         '201-500',    1200000.00, '+1-617-555-0500', 'admin@edulearn.edu',     'https://edulearn.edu',      'Boston',        'MA', 'USA', 'Non-profit education technology organization.',              3, 'partner',  'partner'),
('FinancePro LLC',           'financepro.com',    'Financial Services','51-200',     4800000.00, '+1-212-555-0600', 'ops@financepro.com',     'https://financepro.com',    'New York',      'NY', 'USA', 'B2B financial analytics and compliance software.',          4, 'prospect', 'prospect'),
('Manufacture First Co',     'mfirst.com',        'Manufacturing',     '1001-5000', 45000000.00, '+1-313-555-0700', 'procurement@mfirst.com', 'https://mfirst.com',        'Detroit',       'MI', 'USA', 'Automotive parts supplier for OEMs.',                       2, 'customer', 'customer'),
('Digital Agency Pro',       'dagency.com',       'Marketing',         '11-50',      800000.00,  '+1-323-555-0800', 'hello@dagency.com',      'https://dagency.com',       'Los Angeles',   'CA', 'USA', 'Full-service digital marketing agency.',                    3, 'prospect', 'prospect'),
('CloudBase Systems',        'cloudbase.io',      'Technology',        '201-500',    9500000.00, '+1-206-555-0900', 'sales@cloudbase.io',     'https://cloudbase.io',      'Seattle',       'WA', 'USA', 'Cloud infrastructure and DevOps tooling.',                  4, 'customer', 'customer'),
('NovaBiotech Research',     'novabiotech.com',   'Biotechnology',     '51-200',     6200000.00, '+1-858-555-1000', 'info@novabiotech.com',   'https://novabiotech.com',   'San Diego',     'CA', 'USA', 'Genomics and precision medicine research firm.',            2, 'prospect', 'prospect'),
('RetailEdge Solutions',     'retailedge.com',    'Technology',        '51-200',     2100000.00, '+1-404-555-1100', 'sales@retailedge.com',   'https://retailedge.com',    'Atlanta',       'GA', 'USA', 'POS and inventory management systems for retail.',          3, 'customer', 'customer'),
('PrimeLogistics Co',        'primelogistics.com','Logistics',         '501-1000',  18000000.00, '+1-469-555-1200', 'ops@primelogistics.com', 'https://primelogistics.com','Dallas',        'TX', 'USA', 'Last-mile delivery and supply chain optimization.',         4, 'prospect', 'prospect');

-- ============================================================
-- CONTACTS
-- ============================================================
INSERT INTO contacts (first_name, last_name, email, phone, mobile, job_title, department, company_id, owner_id, lifecycle_stage, lead_source, city, state, country, description) VALUES
('Robert',   'Chang',    'rchang@acme.com',         '+1-415-555-1001', '+1-415-555-1002', 'VP of Engineering',      'Engineering',  1, 2, 'customer',           'referral',        'San Francisco', 'CA', 'USA', 'Main technical contact at Acme.'),
('Jennifer', 'Lee',      'jlee@acme.com',            '+1-415-555-1003', NULL,              'Procurement Manager',    'Operations',   1, 2, 'customer',           'referral',        'San Francisco', 'CA', 'USA', 'Handles all vendor contracts.'),
('Marcus',   'Webb',     'mwebb@techstart.io',       '+1-512-555-2001', '+1-512-555-2002', 'CEO',                    'Executive',    2, 3, 'customer',           'website',         'Austin',        'TX', 'USA', 'Co-founder and CEO of TechStart.'),
('Priya',    'Sharma',   'pshsarma@techstart.io',    '+1-512-555-2003', NULL,              'Head of Product',        'Product',      2, 3, 'customer',           'website',         'Austin',        'TX', 'USA', 'Drives product roadmap decisions.'),
('David',    'Nguyen',   'dnguyen@globalretail.com', '+1-212-555-3001', '+1-212-555-3002', 'CTO',                    'Technology',   3, 2, 'prospect',           'cold_call',       'New York',      'NY', 'USA', 'Decision maker for tech investments.'),
('Karen',    'Thompson', 'kthompson@hcplus.org',     '+1-312-555-4001', NULL,              'Director of IT',         'IT',           4, 4, 'customer',           'event',           'Chicago',       'IL', 'USA', 'Oversees all healthcare IT systems.'),
('Brian',    'Foster',   'bfoster@hcplus.org',       '+1-312-555-4002', '+1-312-555-4003', 'CISO',                   'IT Security',  4, 4, 'customer',           'event',           'Chicago',       'IL', 'USA', 'Security compliance focus.'),
('Amy',      'Rodriguez','arodriguez@edulearn.edu',  '+1-617-555-5001', NULL,              'Technology Director',    'Technology',   5, 3, 'customer',           'referral',        'Boston',        'MA', 'USA', 'Manages all EdTech partnerships.'),
('Tom',      'Williams', 'twilliams@financepro.com', '+1-212-555-6001', '+1-212-555-6002', 'COO',                    'Operations',   6, 4, 'prospect',           'paid_ad',         'New York',      'NY', 'USA', 'Evaluating CRM solutions.'),
('Sandra',   'Brown',    'sbrown@mfirst.com',        '+1-313-555-7001', NULL,              'IT Director',            'IT',           7, 2, 'customer',           'referral',        'Detroit',       'MI', 'USA', 'Led digital transformation initiative.'),
('Kevin',    'Martinez', 'kmartinez@dagency.com',    '+1-323-555-8001', '+1-323-555-8002', 'Founder',                'Executive',    8, 3, 'prospect',           'social_media',    'Los Angeles',   'CA', 'USA', 'Agency founder exploring automation.'),
('Rachel',   'Kim',      'rkim@cloudbase.io',        '+1-206-555-9001', NULL,              'VP of Sales',            'Sales',        9, 4, 'customer',           'website',         'Seattle',       'WA', 'USA', 'Partnership opportunity for reselling.'),
('Daniel',   'Patel',    'dpatel@novabiotech.com',   '+1-858-555-1001', '+1-858-555-1002', 'Chief Scientific Officer','Research',   10, 2, 'prospect',           'event',           'San Diego',     'CA', 'USA', 'Interested in data management tools.'),
('Michelle', 'Garcia',   'mgarcia@retailedge.com',   '+1-404-555-1101', NULL,              'Sales Director',         'Sales',       11, 3, 'customer',           'referral',        'Atlanta',       'GA', 'USA', 'Key contact for upsell opportunities.'),
('Christopher','Anderson','canderson@primelogistics.com','+1-469-555-1201','+1-469-555-1202','VP of Operations',    'Operations',   12, 4, 'prospect',           'cold_call',       'Dallas',        'TX', 'USA', 'Looking for route optimization software.'),
('Stephanie','Taylor',   'staylor@acme.com',         '+1-415-555-1004', NULL,              'Director of Marketing',  'Marketing',    1, 2, 'customer',           'referral',        'San Francisco', 'CA', 'USA', 'Drives demand gen initiatives.'),
('Tyler',    'Jackson',  'tjackson@techstart.io',    '+1-512-555-2004', '+1-512-555-2005', 'Lead Developer',         'Engineering',  2, 3, 'customer',           'website',         'Austin',        'TX', 'USA', 'Technical evaluator for integrations.'),
('Monica',   'White',    'mwhite@hcplus.org',        '+1-312-555-4004', NULL,              'CFO',                    'Finance',      4, 4, 'customer',           'event',           'Chicago',       'IL', 'USA', 'Budget approval authority.'),
('Eric',     'Harris',   'eharris@cloudbase.io',     '+1-206-555-9002', '+1-206-555-9003', 'Solutions Architect',    'Engineering',  9, 4, 'customer',           'website',         'Seattle',       'WA', 'USA', 'Technical integration contact.'),
('Nicole',   'Clark',    'nclark@globalretail.com',  '+1-212-555-3002', NULL,              'VP of Digital',          'Digital',      3, 2, 'prospect',           'cold_call',       'New York',      'NY', 'USA', 'Championing digital transformation.');

-- ============================================================
-- LEADS
-- ============================================================
INSERT INTO leads (first_name, last_name, email, phone, company_name, job_title, lead_source, status, rating, owner_id, description) VALUES
('Alex',    'Pemberton', 'apemberton@startupco.com', '+1-650-555-2001', 'StartupCo',          'CTO',               'website',         'new',       'hot',  3, 'Downloaded whitepaper on sales automation.'),
('Jessica', 'Holloway',  'jholloway@bigcorp.com',    '+1-800-555-2002', 'BigCorp Inc',        'VP of Sales',       'paid_ad',         'contacted', 'warm', 4, 'Responded to LinkedIn ad campaign.'),
('Nathan',  'Brooks',    'nbrooks@mediahouse.com',   '+1-212-555-2003', 'Media House LLC',    'CEO',               'referral',        'qualified', 'hot',  3, 'Referred by Robert Chang at Acme.'),
('Olivia',  'Stone',     'ostone@fintech99.com',     '+1-415-555-2004', 'FinTech99',          'Head of Ops',       'social_media',    'new',       'warm', 4, 'Engaged with social media posts.'),
('Derek',   'Hunt',      'dhunt@legalpartners.com',  '+1-312-555-2005', 'Legal Partners LLP', 'Managing Partner',  'event',           'working',   'warm', 3, 'Met at LegalTech conference.'),
('Sophie',  'Warren',    'swarren@constructco.com',  '+1-714-555-2006', 'Construct Co',       'Director of IT',    'cold_call',       'contacted', 'cold', 4, 'Initial cold outreach.'),
('Ryan',    'Cooper',    'rcooper@ecommercex.com',   '+1-206-555-2007', 'eCommerceX',         'VP of Technology',  'organic_search',  'qualified', 'hot',  3, 'Found via Google, booked demo.'),
('Lauren',  'Mitchell',  'lmitchell@pharmaplus.com', '+1-617-555-2008', 'PharmaPlusInc',      'IT Manager',        'email_campaign',  'new',       'cold', 4, 'Opened 3 emails but no response yet.');

-- ============================================================
-- DEALS
-- ============================================================
INSERT INTO deals (name, contact_id, company_id, owner_id, pipeline_id, stage_id, value, close_date, probability, status, description, lead_source) VALUES
('Acme - Enterprise License Renewal',    1,  1, 2, 1, 5,  48000.00, '2026-05-31', 75,  'open', 'Annual enterprise license renewal for 200 seats.',          'referral'),
('TechStart - API Platform Deal',        3,  2, 3, 1, 3,  12500.00, '2026-04-30', 40,  'open', 'API platform subscription with custom integrations.',        'website'),
('Global Retail - POS Integration',      5,  3, 2, 1, 2,  95000.00, '2026-06-30', 20,  'open', 'Massive POS system rollout across 500 locations.',           'cold_call'),
('HealthCare Plus - Compliance Suite',   6,  4, 4, 1, 6,  32000.00, '2026-04-15', 85,  'open', 'HIPAA compliance monitoring and reporting suite.',           'event'),
('FinancePro - Analytics Platform',      9,  6, 4, 1, 4,  18000.00, '2026-05-15', 60,  'open', 'Real-time financial analytics dashboard.',                   'paid_ad'),
('CloudBase - Reseller Agreement',       12, 9, 4, 1, 1,  24000.00, '2026-07-31', 10,  'open', 'Potential reseller partnership deal.',                        'website'),
('Manufacture First - ERP Integration',  10, 7, 2, 1, 5,  67000.00, '2026-05-01', 75,  'open', 'Full ERP integration project for production floor.',         'referral'),
('NovaBiotech - Data Platform',          13,10, 2, 1, 3,  21000.00, '2026-06-15', 40,  'open', 'Research data management and analytics platform.',           'event'),
('EduLearn - LMS Integration',           8,  5, 3, 1, 7,  8500.00,  '2026-03-31',100,  'won',  'Learning management system integration project.',            'referral'),
('PrimeLogistics - Route Optimizer',     15,12, 4, 1, 2,  41000.00, '2026-06-30', 20,  'open', 'AI-powered route optimization and fleet management.',        'cold_call'),
('Digital Agency - Marketing Suite',     11, 8, 3, 1, 8,  5500.00,  '2026-02-28',  0,  'lost', 'Marketing automation suite - lost to competitor.',           'social_media'),
('RetailEdge - Support Contract',        14,11, 3, 1, 6,  15000.00, '2026-04-20', 85,  'open', 'Annual support and maintenance contract.',                   'referral'),
('Acme - Security Module Add-on',        2,  1, 2, 1, 4,  16000.00, '2026-05-15', 60,  'open', 'Security and compliance module add-on for existing license.','referral'),
('TechStart - Premium Support',          4,  2, 3, 1, 7, 6000.00,  '2026-01-31', 100, 'won',  'Premium support tier upgrade - closed successfully.',        'website');

-- ============================================================
-- ACTIVITIES
-- ============================================================
INSERT INTO activities (type, subject, description, contact_id, company_id, deal_id, owner_id, due_date, duration_minutes, outcome, completed, completed_at) VALUES
('call',    'Discovery call - Acme renewal',              'Discussed renewal terms and new requirements.',    1, 1, 1,  2, '2026-04-10 10:00:00', 45,  'connected',     1, '2026-04-10 10:45:00'),
('email',   'Follow-up: Enterprise License Proposal',     'Sent detailed pricing and feature comparison.',    1, 1, 1,  2, '2026-04-12 09:00:00', NULL,'sent',          1, '2026-04-12 09:05:00'),
('meeting', 'TechStart API Demo',                         'Live demo of API platform capabilities.',          3, 2, 2,  3, '2026-04-15 14:00:00', 60,  'completed',     1, '2026-04-15 15:00:00'),
('call',    'Global Retail - Intro Call',                 'Initial discovery with David Nguyen.',             5, 3, 3,  2, '2026-04-16 11:00:00', 30,  'connected',     1, '2026-04-16 11:30:00'),
('email',   'HC Plus Compliance Demo Prep',               'Sent compliance checklist ahead of demo.',         6, 4, 4,  4, '2026-04-08 08:00:00', NULL,'sent',          1, '2026-04-08 08:05:00'),
('meeting', 'HealthCare Plus - Contract Review',          'Reviewed contract terms with legal team.',         6, 4, 4,  4, '2026-04-18 13:00:00', 90,  'completed',     1, '2026-04-18 14:30:00'),
('call',    'FinancePro Analytics Pitch',                 'Presented analytics ROI case study.',              9, 6, 5,  4, '2026-04-14 15:00:00', 45,  'connected',     1, '2026-04-14 15:45:00'),
('call',    'Manufacture First - Scope Review',           'Reviewed project scope and timeline.',             10,7, 7,  2, '2026-04-19 09:00:00', 60,  'connected',     1, '2026-04-19 10:00:00'),
('meeting', 'Acme Security Add-on Presentation',          'Presented security module roadmap.',               2, 1, 13, 2, '2026-04-22 10:00:00', 45,  NULL,            0, NULL),
('call',    'NovaBiotech Follow-up',                      'Check in on data platform evaluation.',            13,10, 8, 2, '2026-04-23 11:00:00', 30,  NULL,            0, NULL),
('email',   'PrimeLogistics Proposal',                    'Sent route optimizer proposal and ROI analysis.',  15,12,10,  4, '2026-04-20 08:00:00', NULL,'sent',          1, '2026-04-20 08:10:00'),
('meeting', 'RetailEdge Contract Close',                  'Final contract review and signature.',             14,11,12, 3, '2026-04-21 14:00:00', 60,  NULL,            0, NULL);

-- ============================================================
-- TASKS
-- ============================================================
INSERT INTO tasks (title, description, contact_id, company_id, deal_id, assigned_to, created_by, due_date, priority, status) VALUES
('Send Acme renewal proposal',            'Include volume discounts and new features.',        1, 1, 1,  2, 1, '2026-04-22 17:00:00', 'high',   'todo'),
('Schedule Global Retail demo',           'Demo POS integration capabilities.',                5, 3, 3,  2, 1, '2026-04-23 12:00:00', 'high',   'todo'),
('Prepare HC Plus contract',              'Include HIPAA addendum and BAA.',                   6, 4, 4,  4, 1, '2026-04-19 17:00:00', 'urgent', 'completed'),
('Follow up with FinancePro',             'Check on internal budget approval status.',         9, 6, 5,  4, 1, '2026-04-24 10:00:00', 'medium', 'todo'),
('CloudBase partnership call',            'Discuss reseller terms and commission structure.',  12,9, 6,  4, 1, '2026-04-25 14:00:00', 'medium', 'todo'),
('Manufacture First SOW review',          'Get legal to review statement of work.',            10,7, 7,  2, 1, '2026-04-21 17:00:00', 'high',   'in_progress'),
('Research NovaBiotech compliance needs', 'Review HIPAA/GDPR requirements for biotech.',      13,10,8,  2, 1, '2026-04-26 12:00:00', 'low',    'todo'),
('Send RetailEdge support contract',      'Final version with SLA terms.',                     14,11,12, 3, 1, '2026-04-21 16:00:00', 'urgent', 'todo'),
('Update PrimeLogistics CRM record',      'Add new decision-maker contact info.',              15,12,10, 4, 1, '2026-04-22 09:00:00', 'low',    'todo'),
('TechStart API scope document',          'Detail API endpoints needed for integration.',      3, 2, 2,  3, 1, '2026-04-23 17:00:00', 'medium', 'in_progress'),
('Quarterly business review prep - Acme', 'Prepare QBR deck for Q2 review.',                  1, 1, NULL,2, 1, '2026-04-30 17:00:00', 'medium', 'todo'),
('Onboard HealthCare Plus',               'Setup customer portal and initial training.',       6, 4, 4,  5, 1, '2026-04-28 09:00:00', 'high',   'todo');

-- ============================================================
-- NOTES
-- ============================================================
INSERT INTO notes (content, contact_id, company_id, deal_id, created_by, is_pinned) VALUES
('Robert is the main technical champion for the renewal. He mentioned they want to add 50 more seats and need SSO integration.', 1, 1, 1, 2, 1),
('Jennifer controls the procurement process. She needs at least 2 weeks notice before any contract change.', 2, 1, NULL, 2, 0),
('Marcus is very excited about the API platform but needs to get CTO approval. Follow up after April 15.', 3, 2, 2, 3, 1),
('David Nguyen is a champion but says the board needs to approve any spend over $50K. Involves 6-week approval cycle.', 5, 3, 3, 2, 1),
('Karen confirmed budget is approved. Legal review is the last step before signing.', 6, 4, 4, 4, 1),
('Tom is evaluating 3 vendors. Our main differentiator is real-time data sync. Demo went very well.', 9, 6, 5, 4, 0),
('Sandra mentioned they are moving to SAP next year - this deal must close before Q3 or budget disappears.', 10, 7, 7, 2, 1),
('IMPORTANT: NovaBiotech has strict data residency requirements (US only). Make sure solution architect confirms before proposing.', 13, 10, 8, 2, 1),
('Rachel is very interested in becoming a reseller. She wants to see our margin structure and training program.', 12, 9, 6, 4, 0),
('Michelle at RetailEdge is pushing to close by end of April to get their Q2 support covered.', 14, 11, 12, 3, 0);

-- ============================================================
-- SUPPORT TICKETS
-- ============================================================
INSERT INTO tickets (ticket_number, subject, description, contact_id, company_id, assigned_to, created_by, priority, status, type) VALUES
('TKT-001', 'API rate limiting issue causing timeouts',         'Our integration hits 429 errors during peak hours.',                                        3,  2, 5, 3, 'high',   'open',       'bug'),
('TKT-002', 'SSO login not working for new users',             'New users added to AD group cannot log in via SSO.',                                        1,  1, 5, 2, 'urgent', 'in_progress','bug'),
('TKT-003', 'Feature request: Bulk email export',             'We need to export all email logs to CSV for compliance.',                                    6,  4, 6, 4, 'medium', 'pending',    'feature_request'),
('TKT-004', 'Question about HIPAA data residency',            'Can you confirm all data is stored in US-based data centers?',                              6,  4, 6, 4, 'medium', 'resolved',   'question'),
('TKT-005', 'Mobile app crashes on iOS 17.4',                 'App crashes immediately on launch for iOS 17.4 users.',                                     14,11, 5, 3, 'high',   'open',       'bug'),
('TKT-006', 'Billing discrepancy on March invoice',           'Invoice shows 250 seats but contract is for 200.',                                          2,  1, 6, 2, 'high',   'in_progress','billing'),
('TKT-007', 'Request for dedicated support manager',          'Given our contract size, we would like a dedicated CSM.',                                   10, 7, 6, 4, 'low',    'open',       'feature_request'),
('TKT-008', 'Data import failing for contacts over 10k rows', 'CSV imports with more than 10,000 rows fail without error message.',                        8,  5, 5, 3, 'medium', 'resolved',   'bug'),
('TKT-009', 'Dashboard not loading in Firefox',               'Dashboard shows blank page in Firefox 124. Works in Chrome.',                               12, 9, 5, 4, 'medium', 'open',       'bug'),
('TKT-010', 'Need training for new team members',             'We have 5 new hires who need product training sessions.',                                   18, 4, 6, 4, 'low',    'pending',    'question');

-- ============================================================
-- TAGS
-- ============================================================
INSERT INTO tags (name, color, entity_type, created_by) VALUES
('VIP',              '#f59e0b', 'all',     1),
('Decision Maker',   '#8b5cf6', 'contact', 1),
('Champion',         '#10b981', 'contact', 1),
('Renewal',          '#3b82f6', 'deal',    1),
('At Risk',          '#ef4444', 'all',     1),
('High Value',       '#f97316', 'company', 1),
('Partner',          '#06b6d4', 'company', 1),
('Hot Lead',         '#ef4444', 'lead',    1),
('Cold Lead',        '#94a3b8', 'lead',    1),
('Upsell',           '#10b981', 'deal',    1),
('New Business',     '#3b82f6', 'deal',    1),
('Enterprise',       '#8b5cf6', 'all',     1),
('SMB',              '#06b6d4', 'all',     1),
('Follow-up Needed', '#f59e0b', 'all',     1);

-- Tag some entities
INSERT INTO entity_tags (tag_id, entity_type, entity_id) VALUES
(1, 'contact', 1), (1, 'contact', 3), (1, 'contact', 6),
(2, 'contact', 1), (2, 'contact', 5), (2, 'contact', 9), (2, 'contact', 10),
(3, 'contact', 6), (3, 'contact', 12),
(4, 'deal', 1), (4, 'deal', 9),
(5, 'deal', 3), (5, 'deal', 11),
(6, 'company', 1), (6, 'company', 3), (6, 'company', 7),
(7, 'company', 5), (7, 'company', 9),
(8, 'lead', 1), (8, 'lead', 3), (8, 'lead', 7),
(9, 'lead', 6), (9, 'lead', 8),
(10, 'deal', 13), (10, 'deal', 12),
(11, 'deal', 3), (11, 'deal', 8), (11, 'deal', 10),
(12, 'company', 1), (12, 'company', 4), (12, 'company', 7),
(13, 'company', 2), (13, 'company', 5), (13, 'company', 8),
(14, 'contact', 13), (14, 'deal', 6), (14, 'deal', 10);

-- ============================================================
-- AUDIT LOG (sample entries)
-- ============================================================
INSERT INTO audit_logs (user_id, action, entity_type, entity_id, entity_name, ip_address) VALUES
(2, 'login',  NULL, NULL, NULL,                             '192.168.1.10'),
(3, 'create', 'deal', 2, 'TechStart - API Platform Deal',  '192.168.1.11'),
(4, 'update', 'deal', 4, 'HealthCare Plus - Compliance',   '192.168.1.12'),
(2, 'create', 'contact', 16, 'Stephanie Taylor',           '192.168.1.10'),
(3, 'update', 'lead', 3, 'Nathan Brooks',                  '192.168.1.11'),
(4, 'create', 'ticket', 1, 'TKT-001',                      '192.168.1.12'),
(5, 'update', 'ticket', 2, 'TKT-002',                      '192.168.1.13'),
(2, 'export', 'contact', NULL, 'Contacts export',          '192.168.1.10');

-- ============================================================
-- NOTIFICATIONS
-- ============================================================
INSERT INTO notifications (user_id, type, title, message, entity_type, entity_id) VALUES
(2, 'task_due',      'Task Due Today',         'Send Acme renewal proposal is due today.',         'task',   1),
(2, 'deal_updated',  'Deal Stage Changed',     'HealthCare Plus moved to Negotiation stage.',      'deal',   4),
(3, 'task_due',      'Task Overdue',           'TechStart API scope document is overdue.',         'task',   10),
(4, 'ticket_opened', 'New Ticket Assigned',    'TKT-001 API rate limiting assigned to you.',       'ticket', 1),
(5, 'ticket_opened', 'New Support Ticket',     'TKT-002 SSO login issue needs attention.',         'ticket', 2),
(4, 'lead_assigned', 'New Lead Assigned',      'Olivia Stone (FinTech99) assigned to you.',        'lead',   4),
(2, 'deal_won',      'Deal Closed Won!',       'TechStart Premium Support closed successfully!',   'deal',   14),
(1, 'user_created',  'New User Registered',    'readonly@example.com joined the platform.',           'user',   7);
