function tradesmate_premium_handle_chat() { $message = sanitize_text_field($_POST['message'] ?? 'hello'); $message_lower = strtolower($message); if (strpos($message_lower, 'radiator') !== false) { $response = "For your radiator installation, I'll help with:\n\n• Building regulations Part L (conservation of fuel and power)\n• Central heating system requirements\n• Installation costs: £150-£400 per radiator including labor\n• BTU calculations for room heating\n\nWhat type of radiator and room size are you working with?"; } elseif (strpos($message_lower, 'bathroom') !== false) { $response = "For your bathroom renovation, I can help with:\n\n• Building regulations - Part G (sanitation)\n• Waterproofing requirements\n• Cost estimates: £3,000-£8,000\n• Electrical safety zones\n\nWhat specific aspect would you like to discuss?"; } elseif (strpos($message_lower, 'kitchen') !== false) { $response = "For your kitchen renovation, I'll help with:\n\n• Building regulations Parts F & P (ventilation & electrical)\n• Gas safety requirements for hobs\n• Worktop height regulations (900mm standard)\n• Cost planning: £8,000-£25,000 typical range\n• Appliance installation requirements\n\nWhat's your main kitchen concern?"; } elseif (strpos($message_lower, 'toilet') !== false) { $response = "For your toilet installation/replacement:\n\n• Building regulations Part G (sanitation)\n• Soil pipe connections and fall requirements\n• Water efficiency standards (6/4 litre dual flush)\n• Accessibility requirements Part M\n• Installation costs: £200-£800 including labor\n• Ventilation requirements\n\nWhat type of toilet work are you planning?"; } else { $response = "Hello! I'm TradesMate Premium with specialized UK trade knowledge. I can provide expert advice on:\n\n• Building regulations and compliance\n• Material specifications and costs\n• Project planning with regulatory requirements\n• Health & safety standards\n• Trade-specific calculations\n\nWhat specific trade project can I help you with today?"; } wp_send_json_success(array('response' => $response)); } ?>