

-- 2. Default Pipeline Stages
INSERT INTO `pipeline_stages` (`id`, `name`, `color`, `order_index`) VALUES
(1, 'New Lead', '#3b82f6', 1),
(2, 'Contacted', '#8b5cf6', 2),
(3, 'Qualified', '#f59e0b', 3),
(4, 'Proposal Sent', '#06b6d4', 4),
(5, 'Closed Won', '#10b981', 5),
(6, 'Closed Lost', '#ef4444', 6);

-- 3. Default Tags
INSERT INTO `tags` (`id`, `name`, `color`) VALUES
(1, 'Hot Lead', '#ef4444'),
(2, 'VIP Customer', '#8b5cf6'),
(3, 'Demo Scheduled', '#3b82f6'),
(4, 'Support Needed', '#f59e0b'),
(5, 'Cold Lead', '#64748b');

-- 4. Sample Contacts
INSERT INTO `contacts` (`id`, `whatsapp_id`, `phone_number`, `name`, `email`, `company`, `stage_id`, `assigned_to`, `notes`) VALUES
(1, '15550192834', '+15550192834', 'Alex Reynolds', 'alex@techcorp.com', 'TechCorp Solutions', 1, 1, 'Interested in Enterprise WhatsApp CRM licensing.'),
(2, '15550293845', '+15550293845', 'Elena Rostova', 'elena@luxgoods.io', 'LuxGoods Retail', 2, 2, 'Requested a pricing breakdown for 10 agent seats.'),
(3, '15550394856', '+15550394856', 'David Kim', 'david@growthex.co', 'GrowthEx Agency', 4, 1, 'Proposal sent on Monday. Follow up by Thursday.');

-- 5. Contact Tags
INSERT INTO `contact_tags` (`contact_id`, `tag_id`) VALUES
(1, 1),
(1, 3),
(2, 2),
(3, 1);

-- 6. Sample Deals
INSERT INTO `deals` (`id`, `contact_id`, `stage_id`, `title`, `value`, `currency`, `closing_date`, `assigned_to`, `notes`, `status`) VALUES
(1, 1, 1, 'TechCorp Enterprise Plan', 4500.00, 'USD', DATE_ADD(CURRENT_DATE, INTERVAL 14 DAY), 1, '50 seats with automated broadcasts.', 'open'),
(2, 2, 2, 'LuxGoods 10-Seat CRM Setup', 1800.00, 'USD', DATE_ADD(CURRENT_DATE, INTERVAL 7 DAY), 2, 'Needs catalog integration.', 'open'),
(3, 3, 4, 'GrowthEx Annual License', 6200.00, 'USD', DATE_ADD(CURRENT_DATE, INTERVAL 3 DAY), 1, 'Awaiting approval from procurement.', 'open');

-- 7. Sample Conversations & Messages
INSERT INTO `conversations` (`id`, `contact_id`, `assigned_user_id`, `status`, `unread_count`, `last_message`, `last_message_at`) VALUES
(1, 1, 1, 'open', 1, 'Hi, does your WhatsApp CRM support multiple agent logins?', NOW()),
(2, 2, 2, 'open', 0, 'We have received your proposal, thank you!', DATE_SUB(NOW(), INTERVAL 2 HOUR)),
(3, 3, 1, 'open', 0, 'Can we schedule a quick demo on Zoom?', DATE_SUB(NOW(), INTERVAL 1 DAY));

INSERT INTO `messages` (`id`, `conversation_id`, `contact_id`, `user_id`, `direction`, `message_type`, `content`, `status`, `created_at`) VALUES
(1, 1, 1, NULL, 'inbound', 'text', 'Hello there! I found your website online.', 'read', DATE_SUB(NOW(), INTERVAL 30 MINUTE)),
(2, 1, 1, 1, 'outbound', 'text', 'Hi Alex! Welcome to our WhatsApp CRM. How can we help you today?', 'read', DATE_SUB(NOW(), INTERVAL 25 MINUTE)),
(3, 1, 1, NULL, 'inbound', 'text', 'Hi, does your WhatsApp CRM support multiple agent logins?', 'delivered', NOW()),

(4, 2, 2, NULL, 'inbound', 'text', 'Good afternoon! Could you please share the pricing sheet?', 'read', DATE_SUB(NOW(), INTERVAL 3 HOUR)),
(5, 2, 2, 2, 'outbound', 'text', 'Hello Elena! Absolutely, here is our complete feature matrix and pricing details.', 'read', DATE_SUB(NOW(), INTERVAL 2 HOUR)),
(6, 2, 2, NULL, 'inbound', 'text', 'We have received your proposal, thank you!', 'read', DATE_SUB(NOW(), INTERVAL 2 HOUR));

-- 8. Quick Replies
INSERT INTO `quick_replies` (`id`, `shortcut`, `title`, `message`) VALUES
(1, '/welcome', 'Welcome Greeting', 'Hello {{name}}! Welcome to our customer support. How can our team assist you today?'),
(2, '/pricing', 'Pricing & Plans', 'Thank you for your interest! You can review all our subscription tiers and features here: https://example.com/pricing'),
(3, '/demo', 'Book Demo Call', 'We would love to give you a live tour! Please pick a convenient time on our calendar: https://calendly.com/crm-demo'),
(4, '/support', 'Support Ticket', 'Your request has been logged with ticket ID #{{ticket_id}}. An agent will attend to you shortly.'),
(5, '/thanks', 'Thank You Closing', 'Thank you for chatting with us today! If you have any further questions, feel free to reply anytime. Have a great day!');

-- 9. WhatsApp Templates
INSERT INTO `whatsapp_templates` (`id`, `name`, `category`, `language`, `header_type`, `body_text`, `footer_text`, `status`) VALUES
(1, 'crm_welcome_greeting', 'MARKETING', 'en_US', 'NONE', 'Hi {{1}}, thanks for reaching out to us! Our team has received your message and will get back to you shortly.', 'WhatsApp CRM Bot', 'APPROVED'),
(2, 'lead_followup_reminder', 'UTILITY', 'en_US', 'TEXT', 'Hello {{1}}, just following up on our previous conversation regarding {{2}}. Let us know if you need any additional info!', 'Sales Team', 'APPROVED'),
(3, 'payment_invoice_alert', 'UTILITY', 'en_US', 'DOCUMENT', 'Dear {{1}}, your invoice #{{2}} of {{3}} is ready for review. Please find the attached document.', 'Finance Department', 'APPROVED');

-- 10. Automation Rules
INSERT INTO `automation_rules` (`id`, `name`, `trigger_event`, `trigger_keyword`, `reply_type`, `reply_content`, `action_type`, `action_value`, `is_active`) VALUES
(1, 'Auto Welcome for New Leads', 'welcome_new_contact', NULL, 'text', '👋 Welcome to our CRM! How can we assist you with our products today?', 'add_tag', '1', 1),
(2, 'Keyword Pricing Response', 'message_contains', 'price,pricing,cost,quote', 'text', '💰 You can find our complete price list and plans at https://example.com/pricing or type "demo" to speak with a representative.', 'move_stage', '2', 1),
(3, 'Keyword Demo Booking', 'message_contains', 'demo,schedule,meeting,call', 'text', '📅 Great! You can instantly book a 15-minute live demo here: https://calendly.com/crm-demo', 'add_tag', '3', 1);
