{% extends "base.html" %}

{% block title %}Summary Report - {{ app_name }}{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <div>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="{{ url_for('reports.reports') }}">Reports</a></li>
                            <li class="breadcrumb-item active">Summary</li>
                        </ol>
                    </nav>
                    <h1 class="h3 mb-0">
                        <i class="fas fa-chart-line text-primary"></i> Summary Report
                    </h1>
                </div>
            </div>
        </div>
    </div>

    <!-- Key Metrics -->
    <div class="row mb-4">
        <div class="col-md-4 col-sm-6 mb-3">
            <div class="card border-0 shadow-sm h-100 summary-card">
                <div class="card-body p-3">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="summary-icon bg-primary bg-opacity-10 text-primary">
                                <i class="fas fa-sun"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <div class="summary-label">Today</div>
                            <div class="summary-value">{{ "%.1f"|format(today_hours) }}h</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 col-sm-6 mb-3">
            <div class="card border-0 shadow-sm h-100 summary-card">
                <div class="card-body p-3">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="summary-icon bg-success bg-opacity-10 text-success">
                                <i class="fas fa-calendar-week"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <div class="summary-label">Last 7 Days</div>
                            <div class="summary-value">{{ "%.1f"|format(week_hours) }}h</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 col-sm-6 mb-3">
            <div class="card border-0 shadow-sm h-100 summary-card">
                <div class="card-body p-3">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="summary-icon bg-info bg-opacity-10 text-info">
                                <i class="fas fa-calendar-alt"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <div class="summary-label">Last 30 Days</div>
                            <div class="summary-value">{{ "%.1f"|format(month_hours) }}h</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Top Projects -->
    <div class="row">
        <div class="col-12">
            <div class="card shadow-sm border-0">
                <div class="card-header bg-white py-3">
                    <h5 class="mb-0">
                        <i class="fas fa-project-diagram"></i> Top Projects ({{ project_stats|length }})
                    </h5>
                </div>
                <div class="card-body p-0">
                    {% if project_stats %}
                    <div class="table-responsive">
                        <table class="table table-hover mb-0">
                            <thead class="table-light">
                                <tr>
                                    <th>Project</th>
                                    <th>Client</th>
                                    <th>Total Hours</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for item in project_stats %}
                                <tr>
                                    <td>
                                        <a href="{{ url_for('projects.view_project', project_id=item.project.id) }}">
                                            {{ item.project.name }}
                                        </a>
                                    </td>
                                    <td>{{ item.project.client }}</td>
                                    <td><strong>{{ "%.1f"|format(item.hours) }}h</strong></td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    {% else %}
                    <div class="text-center py-5">
                        <div class="empty-state">
                            <i class="fas fa-chart-bar fa-3x text-muted mb-3"></i>
                            <h5 class="text-muted">No Data Found</h5>
                            <p class="text-muted">No time entries available for the selected period.</p>
                        </div>
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}


