{% extends "base.html" %}

{% block title %}Consultant Dashboard{% endblock %}

{% block content %}
<div class="container mt-4">
    <h1 class="mb-4">Consultant Dashboard</h1>
    <p class="lead mb-5">Welcome, {{ current_user.username }}. Manage your clients, assessments, and reports.</p>

    <div class="row">
        <!-- Clients Card -->
        <div class="col-md-4 mb-4">
            <div class="card h-100 shadow-sm">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title"><i class="fas fa-users mr-2"></i>My Clients</h5>
                    <p class="card-text">View your clients and assign new assessments.</p>
                    <a href="{{ url_for('consultant.my_clients') }}" class="btn btn-primary mt-auto">Manage Clients</a>
                </div>
            </div>
        </div>

        <!-- Generated Links Card -->
        <div class="col-md-4 mb-4">
            <div class="card h-100 shadow-sm">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title"><i class="fas fa-link mr-2"></i>Generated Links</h5>
                    <p class="card-text">View and copy the one-time use assessment links you have generated.</p>
                    <a href="{{ url_for('consultant.view_generated_links') }}" class="btn btn-secondary mt-auto">View Links</a>
                </div>
            </div>
        </div>

        <!-- Reports Card -->
        <div class="col-md-4 mb-4">
            <div class="card h-100 shadow-sm">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title"><i class="fas fa-chart-pie mr-2"></i>Client Reports</h5>
                    <p class="card-text">Access and review completed assessment reports for your clients.</p>
                    <a href="{{ url_for('consultant.reports') }}" class="btn btn-success mt-auto">View Reports</a>
                </div>
            </div>
        </div>

        <!-- Assessment Requests Card -->
        <div class="col-md-4 mb-4">
            <div class="card h-100 shadow-sm">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title"><i class="fas fa-file-invoice-dollar mr-2"></i>My Assessment Requests</h5>
                    <p class="card-text">Track the status of your requests for paid assessments.</p>
                    <a href="{{ url_for('consultant.manage_requests') }}" class="btn btn-warning mt-auto">Manage Requests</a>
                </div>
            </div>
        </div>

        <!-- Profile Management Card -->
        <div class="col-md-4 mb-4">
            <div class="card h-100 shadow-sm">
                <div class="card-body d-flex flex-column">
                    <h5 class="card-title"><i class="fas fa-user-cog mr-2"></i>My Profile</h5>
                    <p class="card-text">Update your registration number, contact details, and logo for reports.</p>
                    <a href="{{ url_for('consultant.profile') }}" class="btn btn-info mt-auto">Manage Profile</a>
                </div>
            </div>
        </div>
    </div>

    <div class="row mt-4">
        <div class="col-12">
            <div class="card shadow-sm">
                <div class="card-body">
                    <h5 class="card-title"><i class="fas fa-clipboard-check mr-2"></i>Available Assessments</h5>
                    <p class="text-muted">Free assessments are unlimited. Paid assessments show remaining credits.</p>
                    <table class="table table-sm table-striped mb-0">
                        <thead>
                            <tr>
                                <th>Assessment</th>
                                <th>Type</th>
                                <th class="text-right">Approved</th>
                                <th class="text-right">Assigned</th>
                                <th class="text-right">Remaining</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for row in credit_summary %}
                            <tr>
                                <td>{{ row.assessment.name }}</td>
                                <td>{{ 'Free' if row.is_free else 'Paid' }}</td>
                                <td class="text-right">{{ row.approved if row.approved is not none else '-' }}</td>
                                <td class="text-right">{{ row.assigned if row.assigned is not none else '-' }}</td>
                                <td class="text-right">{{ row.remaining if row.remaining is not none else 'Unlimited' }}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}