<section class="report-section">
    <h3 class="section-subtitle">Model Information</h3>

    <div class="info-grid">
        <div class="info-item">
            <span class="info-label">Model Type:</span>
            <span class="info-value">{{ model_info.model_type }}</span>
        </div>

        {% if model_info.formula %}
        <div class="info-item">
            <span class="info-label">Formula:</span>
            <code class="info-value">{{ model_info.formula }}</code>
        </div>
        {% endif %}

        <div class="info-item">
            <span class="info-label">Observations:</span>
            <span class="info-value">{{ model_info.nobs_formatted or model_info.nobs }}</span>
        </div>

        {% if model_info.n_entities %}
        <div class="info-item">
            <span class="info-label">Entities:</span>
            <span class="info-value">{{ model_info.n_entities_formatted or model_info.n_entities }}</span>
        </div>
        {% endif %}

        {% if model_info.n_periods %}
        <div class="info-item">
            <span class="info-label">Time Periods:</span>
            <span class="info-value">{{ model_info.n_periods_formatted or model_info.n_periods }}</span>
        </div>
        {% endif %}

        {% if model_info.balanced %}
        <div class="info-item">
            <span class="info-label">Panel Type:</span>
            <span class="info-value">
                {% if model_info.balanced %}Balanced{% else %}Unbalanced{% endif %}
            </span>
        </div>
        {% endif %}
    </div>
</section>

<section class="report-section mt-6">
    <h3 class="section-subtitle">Tests by Category</h3>

    <div class="grid grid-cols-2 gap-4">
        <!-- Specification Tests -->
        <div class="test-category-card">
            <h4 class="test-category-title">Specification Tests</h4>
            <div class="test-category-count">
                {{ summary.failed_by_category.specification }} /
                {{ tests|selectattr('category', 'equalto', 'Specification')|list|length }} failed
            </div>
            <div class="test-category-status">
                {% if summary.failed_by_category.specification == 0 %}
                <span class="badge badge-success">All Passed</span>
                {% else %}
                <span class="badge badge-danger">Issues Detected</span>
                {% endif %}
            </div>
        </div>

        <!-- Serial Correlation Tests -->
        <div class="test-category-card">
            <h4 class="test-category-title">Serial Correlation</h4>
            <div class="test-category-count">
                {{ summary.failed_by_category.serial }} /
                {{ tests|selectattr('category', 'equalto', 'Serial Correlation')|list|length }} failed
            </div>
            <div class="test-category-status">
                {% if summary.failed_by_category.serial == 0 %}
                <span class="badge badge-success">All Passed</span>
                {% else %}
                <span class="badge badge-danger">Issues Detected</span>
                {% endif %}
            </div>
        </div>

        <!-- Heteroskedasticity Tests -->
        <div class="test-category-card">
            <h4 class="test-category-title">Heteroskedasticity</h4>
            <div class="test-category-count">
                {{ summary.failed_by_category.heteroskedasticity }} /
                {{ tests|selectattr('category', 'equalto', 'Heteroskedasticity')|list|length }} failed
            </div>
            <div class="test-category-status">
                {% if summary.failed_by_category.heteroskedasticity == 0 %}
                <span class="badge badge-success">All Passed</span>
                {% else %}
                <span class="badge badge-danger">Issues Detected</span>
                {% endif %}
            </div>
        </div>

        <!-- Cross-Sectional Dependence Tests -->
        <div class="test-category-card">
            <h4 class="test-category-title">Cross-Sectional Dependence</h4>
            <div class="test-category-count">
                {{ summary.failed_by_category.cross_sectional }} /
                {{ tests|selectattr('category', 'equalto', 'Cross-Sectional Dependence')|list|length }} failed
            </div>
            <div class="test-category-status">
                {% if summary.failed_by_category.cross_sectional == 0 %}
                <span class="badge badge-success">All Passed</span>
                {% else %}
                <span class="badge badge-danger">Issues Detected</span>
                {% endif %}
            </div>
        </div>
    </div>
</section>

<section class="report-section mt-6">
    <h3 class="section-subtitle">Quick Summary</h3>

    {% if summary.has_issues %}
    <div class="summary-box summary-box-warning">
        <h4>Issues Detected</h4>
        <p>Your model has failed {{ summary.total_failed }} validation test(s). Review the detailed results and recommendations to address these issues.</p>

        <ul class="mt-3">
            {% if summary.failed_by_category.specification > 0 %}
            <li><strong>Specification:</strong> {{ summary.failed_by_category.specification }} test(s) failed</li>
            {% endif %}
            {% if summary.failed_by_category.serial > 0 %}
            <li><strong>Serial Correlation:</strong> {{ summary.failed_by_category.serial }} test(s) failed</li>
            {% endif %}
            {% if summary.failed_by_category.heteroskedasticity > 0 %}
            <li><strong>Heteroskedasticity:</strong> {{ summary.failed_by_category.heteroskedasticity }} test(s) failed</li>
            {% endif %}
            {% if summary.failed_by_category.cross_sectional > 0 %}
            <li><strong>Cross-Sectional Dependence:</strong> {{ summary.failed_by_category.cross_sectional }} test(s) failed</li>
            {% endif %}
        </ul>
    </div>
    {% else %}
    <div class="summary-box summary-box-success">
        <h4>All Tests Passed</h4>
        <p>Your panel data model has successfully passed all {{ summary.total_tests }} validation tests. The model specification appears appropriate and the data shows no major violations of panel data assumptions.</p>
    </div>
    {% endif %}
</section>
