{% extends "layouts/app.html" %}
{% from "components/card.html" import stat_card %}

{% block title %}Files - Claude Monitor{% endblock %}

{% block main_content %}
<div class="space-y-8" x-data="{ selectedPeriod: 'all' }">
    <!-- Page Title and Time Filter -->
    <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
        <div>
            <h1 class="text-3xl font-bold text-gray-900">Files</h1>
            <p class="mt-2 text-gray-600">File-level usage statistics and analytics</p>
        </div>

        <!-- Time Filter -->
        <div class="flex gap-2" role="group">
            <button
                hx-get="/api/files?period=today"
                hx-target="#files-content"
                hx-swap="innerHTML"
                @click="selectedPeriod = 'today'"
                :class="selectedPeriod === 'today' ? 'bg-[#0770E3] text-white border-[#0770E3]' : 'bg-white text-gray-700 border-gray-300'"
                class="px-4 py-2 text-sm font-medium rounded-lg border transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-[#0770E3] focus:ring-offset-2"
            >
                Today
            </button>
            <button
                hx-get="/api/files?period=week"
                hx-target="#files-content"
                hx-swap="innerHTML"
                @click="selectedPeriod = 'week'"
                :class="selectedPeriod === 'week' ? 'bg-[#0770E3] text-white border-[#0770E3]' : 'bg-white text-gray-700 border-gray-300'"
                class="px-4 py-2 text-sm font-medium rounded-lg border transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-[#0770E3] focus:ring-offset-2"
            >
                Week
            </button>
            <button
                hx-get="/api/files?period=month"
                hx-target="#files-content"
                hx-swap="innerHTML"
                @click="selectedPeriod = 'month'"
                :class="selectedPeriod === 'month' ? 'bg-[#0770E3] text-white border-[#0770E3]' : 'bg-white text-gray-700 border-gray-300'"
                class="px-4 py-2 text-sm font-medium rounded-lg border transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-[#0770E3] focus:ring-offset-2"
            >
                Month
            </button>
            <button
                hx-get="/api/files?period=all"
                hx-target="#files-content"
                hx-swap="innerHTML"
                @click="selectedPeriod = 'all'"
                :class="selectedPeriod === 'all' ? 'bg-[#0770E3] text-white border-[#0770E3]' : 'bg-white text-gray-700 border-gray-300'"
                class="px-4 py-2 text-sm font-medium rounded-lg border transition-colors hover:bg-[#0660c3] focus:outline-none focus:ring-2 focus:ring-[#0770E3] focus:ring-offset-2"
            >
                All Time
            </button>
        </div>
    </div>

    <!-- Files Content (HTMX Target) -->
    <div id="files-content" hx-get="/api/files?period=all" hx-trigger="load" hx-target="this" hx-swap="innerHTML"></div>
{% endblock %}
