First break the problem up using two free body diagrams.

Then figure out the kinematics at point A
$$ \vec{r}_A = \begin{pmatrix} x \\ 0 \\ 0 \end{pmatrix} $$
$$ \vec{v}_A = \begin{pmatrix}\dot x \\ 0 \\ 0 \end{pmatrix} $$
$$ \vec{a}_A = \begin{pmatrix}\ddot x \\ 0 \\ 0 \end{pmatrix} $$
and point B
$$ \vec{r}_B = \vec{r}_A + \begin{bmatrix} \cos\theta & \text{-}\sin\theta & 0
\\ \sin\theta & \cos\theta & 0
\\ 0 & 0 & 1 \end{bmatrix} \begin{pmatrix} 0 \\ l \\ 0 \end{pmatrix} = \begin{pmatrix} x - l \sin\theta \\ l \cos\theta \\ 0 \end{pmatrix} $$
$$ \vec{v}_B = \vec{v}_A + \begin{pmatrix} 0 \\ 0 \\ \dot\theta \end{pmatrix} \times
\left( \vec{r}_B - \vec{r}_A \right) = \begin{pmatrix} \dot{x}-l \dot{\theta}\cos\theta \\ \text{-}l \dot\theta \sin\theta \\ 0 \end{pmatrix} $$
$$ \vec{a}_B = \vec{a}_A + \begin{pmatrix} 0 \\ 0 \\ \ddot\theta \end{pmatrix} \times \left( \vec{r}_B - \vec{r}_A \right)+ \begin{pmatrix} 0 \\ 0 \\ \ddot\theta \end{pmatrix} \times \left( \vec{v}_B - \vec{v}_A \right) = \begin{pmatrix} \ddot{x}-l \ddot{\theta}\cos\theta+l \dot{\theta}^2 \sin\theta \\ \text{-}l \ddot\theta\sin\theta -l \dot{\theta}^2 \cos\theta \\ 0 \end{pmatrix} $$
Find the sum of the forces for the two bodies using trigonometry
$$ \sum \vec{F}_A = \begin{pmatrix} F +A_y \sin\theta
\\ N- A_y \cos\theta
\\ 0 \end{pmatrix} $$
$$ \sum \vec{F}_B = \begin{pmatrix} - A_y \sin\theta
\\ A_y \cos\theta - m g \\ 0 \end{pmatrix} $$
And finally apply Newtons laws to the centers of gravity
$$ \sum \vec{F}_A = M \vec{a}_A $$
$$ \sum \vec{F}_B = m \vec{a}_B $$
which is 4 equations (ignore z-components) with 4 unknowns $N$, $A_y$, $\ddot{x}$, $\ddot\theta$.
The final solution I get for the motion is
$$ \ddot{x} = \frac{F + m g \cos\theta \sin\theta -m l \dot{\theta}^2 \sin\theta } {M + m\sin^2\theta} $$
$$ \ddot{\theta} = \frac{g (M+m) \sin\theta - \cos\theta (l m \dot{\theta}^2 \sin\theta-F)}{l (m \sin^2\theta+M) } $$
The above ignores all the rotational components for rigid bodies expressed in Newton-Euler's equations of motion. The rotational equations of motion would be $\sum \vec{M}_A = I_A \dot{\vec{\omega}_A} + \vec{\omega}_A\times I_A \vec{\omega}_A $ and $\sum \vec{M}_B = I_B \dot{\vec{\omega}_B} + \vec{\omega}_B\times I_B \vec{\omega}_B $ but that is beyond the scope of this discussion.