The problem is that you assume the system is in equilibrium in your first line. Apparently the pendulum is not in equilibrium if the dot product of gravity and motion is not zero.
But actually d'alembert principle states the following for general cases,
$$\sideset{}{}\sum_{i}(F_i-\dot{p})\cdot \delta x_i=0 $$
So we have
$$\sideset{}{}\sum_{i}(F_{applied,i}+F_{constraint,i}-\dot{p})\cdot \delta x_i=0 $$
And we only consider the cases in which the contranint forces do not do work.
So $$\sideset{}{}\sum_{i}F_{constraint,i}\cdot \delta x_i=0$$
And thus we have $$\sideset{}{}\sum_{i}(F_{applied,i}-\dot{p})\cdot \delta x_i=0$$
And this is the d'alembert principle.
The principle of Least (Stationary) Action (aka Hamilton's Principle) is derived from Newton's axioms plus D'Alembert's principle of virtual displacements.
Because D'Alembert's principle allows to account for the (reactions of the) bonds between the components of a system in a transparent way, the Lagrangian and Hamiltonian formulations are possible.
Note1: Newton's axioms, as given, cannot derive neither the Lagrangian form nor the Hamiltonian as they would need the reactions of the bonds to be added literally inside the formalism, thus resulting in different dimensionality and equations for the same problem where the (reactions of the) constraints would appear as extra unknowns.
Note2: D'Alembert's principle is more general than the Lagrangian or Hamiltonian formalisms, as it can account also for non-holonomic bonds (in a slight generalisation).
UPDATE1:
When the forces are conservative, meaning derived from a potential $V(q_i)$ i.e $Q_i = -\frac{\partial V}{\partial q_i}$, and the potential is not depending on velocities $\dot{q_j}$ i.e $\partial V / \partial \dot{q_j} = 0$ (or the potential $V(q_i, \dot{q_i})$ can depend on velocities in a specific way i.e $Q_i = \frac{d}{dt} \left( \frac{\partial V}{\partial \dot{q_i}} \right) - \frac{\partial V}{\partial q_i}$, refered to as generalised potetial, like in the case of Electromagnetism), then the equations of motion become:
$$\frac{d}{dt} \left( \frac{\partial T}{\partial \dot{q_i}} \right) - \frac{\partial T}{\partial q_i}-Q_i = \frac{d}{dt} \left( \frac{\partial L}{\partial \dot{q_i}} \right) - \frac{\partial L}{\partial q_i}$$
where $L=T-V$ is the Lagrangian.
(ref: Theoretical Mechanics, Vol II, J. Hatzidimitriou, in Greek)
UPDATE2:
One can infact formulate D'Alembert's principle as an "action principle" but this "action" is in general very different from the known Hamiltonian/Lagrangian action.
Variational principles of classical mechanics
Variational Principles Cheat Sheet
THE GENERALIZED D' ALEMBERT-LAGRANGE EQUATION
1.2 Prehistory of the Lagrangian Approach
GENERALIZED LAGRANGE–D’ALEMBERT PRINCIPLE
For a further generalisation of d'Alembert-Lagrange-Gauss principle to non-linear (non-ideal) constraints see the work of Udwadia Firdaus (for example New General Principle of Mechanics and Its Application
to General Nonideal Nonholonomic Systems)
Best Answer
Let us consider a non-relativistic Newtonian problem of $N$ point particles with positions
$$ {\bf r}_i(q,t), \qquad i\in\{1, \ldots, N\},\tag{1}$$
with generalized coordinates $q^1, \ldots, q^n$, and $m=3N-n$ holonomic constraints.
Let us for simplicity assume that the applied force of the system has generalized (possibly velocity-dependent) potential $U$. (This e.g. rules out friction forces proportional to the velocity.)
It is then possible to derive the following key identity
$$\begin{align}\sum_{i=1}^N \left({\bf F}_i-\dot{\bf p}_i\right)\cdot \left(\delta {\bf r}_i - \frac{\partial {\bf r}_i}{\partial t}\delta t\right) ~=~& \sum_{i=1}^N \left({\bf F}_i-\dot{\bf p}_i\right)\cdot \sum_{j=1}^n\frac{\partial {\bf r}_i}{\partial q^j}\delta q^j\cr ~=~& \sum_{j=1}^n \left(\frac{\partial L}{\partial q^j}-\frac{\mathrm d}{\mathrm dt} \frac{\partial L}{\partial \dot{q}^j} \right) \delta q^j,\end{align} \tag{2} $$
where
$$ {\bf p}_i~=~m{\bf v}_i, \qquad {\bf v}_i~=~\dot{\bf r}_i, \qquad L~=~T-U,\qquad T~=~\frac{1}{2}\sum_{i=1}^Nm_i {\bf v}_i^2. \tag{3} $$
Here $\delta$ denotes an arbitrary infinitesimal$^1$ displacement in $q$s and $t$, which is consistent with the constraints. There are infinitely many such displacements $\delta$.
The actual displacement (i.e the one which is actually being realized) is just one of those with $\delta t >0$.
In contrast, a virtual displacement $\delta$ has by definition
$$\delta t~=~0. \tag{4} $$
It is customary to refer to the time axis as horizontal, and the $q^j$ directions as vertical. Then we may say that a virtual displacement is vertical (4), while an actual displacement never is.
Note that both the lhs. and the rhs. of eq. (2) do effectively not depend on $\delta t$.
We can chose between the following first principles:
$$ \text{D'Alembert's principle } \Leftrightarrow \text{ Lagrange equations }\Leftrightarrow\text{ Stationary action principle}. \tag{5} $$
I) On one hand, d'Alembert's principle says that
$$ \sum_{i=1}^N \left({\bf F}_i-\dot{\bf p}_i\right)\cdot \delta {\bf r}_i~=~0 \tag{6} $$
for all virtual displacements $\delta$ satisfying eq. (4). This is equivalent to saying that the lhs. of eq. (2) vanishes for arbitrary (not necessarily vertical) displacements. Then Lagrange equations
$$ \frac{\partial L}{\partial q^j}-\frac{\mathrm d}{\mathrm dt} \frac{\partial L}{\partial \dot{q}^j}~=~0\tag{7} $$
follows via eq. (2) from the fact that the virtual displacements $\delta q^j$ in the generalized coordinates are un-constrained and arbitrary.
Conversely, when the Lagrange eqs. (7) are satisfied, then the lhs. of eq. (2) vanishes. This leads to d'Alembert's principle (6) for vertical displacements. It does not lead to d'Alembert's principle (6) for non-vertical displacements.
II) On the other hand, if we integrate the rhs. of eq. (2) over time $t$, we get (after discarding boundary terms) the infinitesimal virtual/vertical variation
$$ \delta S ~=~ \int \! \mathrm dt \sum_{j=1}^n \left(\frac{\partial L}{\partial q^j}-\frac{\mathrm d}{\mathrm dt} \frac{\partial L}{\partial \dot{q}^j} \right) \delta q^j\tag{8}$$
of the action $S= \int \!\mathrm dt~L$. The principle of stationary action then yields Euler-Lagrange equations (7).
III) Finally let us stress the following points:
Note in both case (I) and (II) that the freedom to perform arbitrary virtual displacements or virtual variations is what allows us to deduce the Lagrange eqs. (7).
Note in both case (I) and (II) that the displacements are vertical (4), i.e. no horizontal variation $\delta t$.
References:
--
$^1$ All displacements and variations in this answer are implicitly assumed to be infinitesimal.