$user_id, 'total_conversations' => rand(10, 100), 'conversations_today' => rand(0, 15), 'conversations_this_week' => rand(5, 50), 'conversations_this_month' => rand(20, 80), 'first_message_date' => date('Y-m-d H:i:s', strtotime('-' . rand(1, 30) . ' days')), 'last_message_date' => date('Y-m-d H:i:s', strtotime('-' . rand(1, 24) . ' hours')), 'avg_response_time' => rand(5, 120) . ' minutos', 'most_active_hour' => rand(9, 18) . ':00', 'conversation_status' => 'active', 'tags' => ['cliente', 'activo'], 'notes' => 'Usuario activo con buena interacción' ]; if ($debug) { error_log("Estadísticas simuladas: " . json_encode($stats)); } // Respuesta exitosa $response = [ 'success' => true, 'data' => $stats, 'message' => 'Estadísticas obtenidas correctamente', 'debug' => $debug ? [ 'timestamp' => date('Y-m-d H:i:s'), 'user_id' => $user_id, 'simulated' => true ] : null ]; echo json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } catch (Exception $e) { $error_response = [ 'success' => false, 'error' => $e->getMessage(), 'debug' => $debug ? [ 'timestamp' => date('Y-m-d H:i:s'), 'file' => __FILE__, 'line' => $e->getLine(), 'trace' => $e->getTraceAsString() ] : null ]; http_response_code(500); echo json_encode($error_response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } ?>