{% extends "admin/index.html" %}

{% block admin_content %}
<div class="card">
    <div class="card-header">
        <h5 class="mb-0">System Configuration Status</h5>
    </div>
    <div class="card-body">
        <p class="text-muted">Current system environment and database connection details.</p>

        <table class="table table-striped table-bordered">
            <thead class="table-light">
                <tr>
                    <th style="width: 30%">Setting</th>
                    <th>Value</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><strong>Database Type</strong></td>
                    <td>
                        {% if 'sqlite' in config.database_url %}
                        <span class="badge bg-secondary">SQLite</span>
                        {% elif 'postgresql' in config.database_url %}
                        <span class="badge bg-primary">PostgreSQL</span>
                        {% else %}
                        <span class="badge bg-warning text-dark">{{ config.database_type }}</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td><strong>Connection URL</strong></td>
                    <td><code>{{ config.database_url_masked }}</code></td>
                </tr>
                <tr>
                    <td><strong>Database Host/Path</strong></td>
                    <td>{{ config.database_host }}</td>
                </tr>
                <tr>
                    <td><strong>Environment</strong></td>
                    <td>
                        {% if config.debug %}
                        <span class="badge bg-warning text-dark">Debug Mode</span>
                        {% else %}
                        <span class="badge bg-success">Production</span>
                        {% endif %}
                    </td>
                </tr>
            </tbody>
        </table>

        <div class="alert alert-info mt-3">
            <i class="bi bi-info-circle"></i>
            {% if 'sqlite' in config.database_url %}
            Running in portable SQLite mode. To switch to PostgreSQL, please refer to the migration guide.
            {% else %}
            Running in PostgreSQL mode. Database is hosted at <strong>{{ config.database_host }}</strong>.
            {% endif %}
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function () {
        // Activate the correct tab
        const tabLink = document.getElementById('config-status-tab');
        if (tabLink) {
            tabLink.classList.add('active');
            tabLink.setAttribute('aria-selected', 'true');
        }
    });
</script>
{% endblock %}