<?php if ($nginxConfigMeta): ?>
<div class="log-meta">
    <span data-label="Fichier"><?= htmlspecialchars($nginxConfigMeta['path']) ?></span>
    <span data-label="Taille"><?= $nginxConfigMeta['size'] ?></span>
    <span data-label="Modifié"><?= $nginxConfigMeta['mtime'] ?></span>
    <?php if ($nginxConfigSource === 'live'): ?>
    <span class="nginx-source-badge nginx-source-badge--live">● Config déployée</span>
    <?php else: ?>
    <span class="nginx-source-badge nginx-source-badge--local">⚠ Référence locale (config live inaccessible)</span>
    <?php endif; ?>
</div>
<?php endif; ?>

<?php if ($nginxConfigError !== null): ?>
    <div class="log-unavailable">
        <strong>Configuration nginx non disponible</strong>
        <div class="log-unavail-path"><?= htmlspecialchars($nginxConfigError) ?></div>
        <?php if (php_sapi_name() === 'cli-server'): ?>
        <div class="log-unavail-dev">
            En développement, <code>/etc/nginx/sites-available/posterg</code> n'existe pas.
            La config de référence se trouve dans <code>nginx/posterg.conf</code>.
        </div>
        <?php endif; ?>
    </div>

<?php elseif (empty($nginxConfigLines)): ?>
    <div class="log-empty">Le fichier de configuration est vide.</div>

<?php else: ?>
    <div class="log-output" id="log-output" role="region" aria-label="Configuration nginx">
        <button class="log-copy-btn" id="log-copy-btn" type="button" title="Copier la configuration"
                onclick="copyLogContent(this);return false">
            Copier
        </button>
        <?php foreach ($nginxConfigLines as $i => $line): ?>
        <span class="log-line <?= SystemController::nginxLineClass($line) ?>"
              data-n="<?= $i + 1 ?>"><?= htmlspecialchars($line, ENT_QUOTES | ENT_SUBSTITUTE) ?></span>
        <?php endforeach; ?>
    </div>
<?php endif; ?>
