### Elasticsearch Version

8.6.0, 8.7.0, 8.8.0, 8.9.0

### Installed Plugins

ESS default

### Java Version

ESS default

### OS Version

ESS default

### Problem Description

Our clusters hit continuously the following error on ESS

It is related to the number of shards per cluster `max_shards_in_cluster` that is calculated based on `max_shards_per_node` but is not correctly calculated, our value for `max_shards_per_node` is 10000. We have 10 data nodes, so we have configured more than 7000 shards per cluster for sure. No matter the value you put on `max_shards_per_node`, we cannot have more than 7000 shards in our clusters.

![image](https://github.com/elastic/elasticsearch/assets/5400788/b32b3025-6c49-4ea8-a793-3a3d8ff0d300)

```
      "shards_capacity" : {
        "status" : "Red",
        "symptom" : "Cluster is close to reaching the configured maximum number of shards for data nodes.",
        "details" : {
          "data" : {
            "max_shards_in_cluster" : 7000,
            "current_used_shards" : 9023
```

```
{
  "status": "green",
  "number_of_nodes": 10,
  "unassigned_shards": 0,
  "number_of_pending_tasks": 2,
  "number_of_in_flight_fetch": 0,
  "timed_out": false,
  "active_primary_shards": 5185,
  "task_max_waiting_in_queue_millis": 600,
  "cluster_name": "0000000000000000000000000",
  "relocating_shards": 0,
  "active_shards_percent_as_number": 100,
  "active_shards": 9753,
  "initializing_shards": 0,
  "number_of_data_nodes": 7,
  "delayed_unassigned_shards": 0
}
```

Probably related to https://github.com/elastic/elasticsearch/issues/91119

### Steps to Reproduce

* Deploy a cluster with Elastic Stack 8.7.0
* Create more than 7000 shards
* Change the value of `max_shards_per_node` to 5000
* Wait until the error appears again

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/node/Node.java
final Metadata onDiskMetadata = gatewayMetaState.getPersistedState().getLastAcceptedState().metadata();
        assert onDiskMetadata != null : "metadata is null but shouldn't"; 
        validateNodeBeforeAcceptingRequests(
            new BootstrapContext(environment, onDiskMetadata),
            transportService.boundAddress(),
            pluginsService.flatMap(Plugin::getBootstrapChecks).toList()
        );
        final FileSettingsService fileSettingsService = injector.getInstance(FileSettingsService.class);
        fileSettingsService.start();
        
        if (ReadinessService.enabled(environment)) {
            fileSettingsService.addFileChangedListener(injector.getInstance(ReadinessService.class));
        }
        clusterService.addStateApplier(transportService.getTaskManager());
        
        coordinator.start(); 
        clusterService.start();
        assert clusterService.localNode().equals(localNodeFactory.getNode())
            : "clusterService has a different local node than the factory provided";
        transportService.acceptIncomingRequests();
        /*
         * CoordinationDiagnosticsService expects to be able to send transport requests and use the cluster state, so it is important to
         * start it here after the clusterService and transportService have been started.
         */
        injector.getInstance(CoordinationDiagnosticsService.class).start();
        coordinator.startInitialJoin();
        final TimeValue initialStateTimeout = INITIAL_STATE_TIMEOUT_SETTING.get(settings());
        configureNodeAndClusterIdStateListener(clusterService);
        if (initialStateTimeout.millis() > 0) {
            final ThreadPool thread = injector.getInstance(ThreadPool.class);