{% extends "base.html" %}

{% block title %}Documents - FINA{% endblock %}

{% block body %}
<div class="flex h-screen w-full">
    <!-- Sidebar -->
    <aside id="sidebar" class="hidden lg:flex w-64 flex-col bg-sidebar-light dark:bg-background-dark border-r border-border-light dark:border-[#233648]">
        <div class="p-6 flex flex-col h-full justify-between">
            <div class="flex flex-col gap-8">
                <div class="flex gap-3 items-center">
                    <img src="{{ current_user.avatar | avatar_url }}" alt="{{ current_user.username }}" class="size-10 rounded-full border-2 border-primary/30 object-cover">
                    <div class="flex flex-col">
                        <h1 class="text-text-main dark:text-white text-base font-bold leading-none">{{ current_user.username }}</h1>
                        <p class="text-text-muted dark:text-[#92adc9] text-xs font-normal mt-1">
                            {% if current_user.is_admin %}<span data-translate="user.admin">Admin</span>{% else %}<span data-translate="user.user">User</span>{% endif %}
                        </p>
                    </div>
                </div>
                
                <nav class="flex flex-col gap-2">
                    <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('main.dashboard') }}">
                        <span class="material-symbols-outlined text-[20px]">dashboard</span>
                        <span class="text-sm font-medium" data-translate="nav.dashboard">Dashboard</span>
                    </a>
                    <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('main.transactions') }}">
                        <span class="material-symbols-outlined text-[20px]">receipt_long</span>
                        <span class="text-sm font-medium" data-translate="nav.transactions">Transactions</span>
                    </a>
                    <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('main.reports') }}">
                        <span class="material-symbols-outlined text-[20px]">pie_chart</span>
                        <span class="text-sm font-medium" data-translate="nav.reports">Reports</span>
                    </a>
                    <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg bg-primary/20 text-primary border border-primary/10" href="{{ url_for('main.documents') }}">
                        <span class="material-symbols-outlined text-[20px]">folder_open</span>
                        <span class="text-sm font-medium" data-translate="nav.documents">Documents</span>
                    </a>
                    {% if current_user.is_admin %}
                    <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('main.admin') }}">
                        <span class="material-symbols-outlined text-[20px]">admin_panel_settings</span>
                        <span class="text-sm font-medium" data-translate="nav.admin">Admin</span>
                    </a>
                    {% endif %}
                </nav>
            </div>
            
            <div class="flex flex-col gap-2">
                <button id="theme-toggle" class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors">
                    <span class="material-symbols-outlined text-[20px]" id="theme-icon">light_mode</span>
                    <span class="text-sm font-medium" id="theme-text" data-translate="dashboard.lightMode">Light Mode</span>
                </button>
                <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('main.settings') }}">
                    <span class="material-symbols-outlined text-[20px]">settings</span>
                    <span class="text-sm font-medium" data-translate="nav.settings">Settings</span>
                </a>
                <a class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-text-muted dark:text-[#92adc9] hover:bg-background-light dark:hover:bg-[#233648] hover:text-text-main dark:hover:text-white transition-colors" href="{{ url_for('auth.logout') }}">
                    <span class="material-symbols-outlined text-[20px]">logout</span>
                    <span class="text-sm font-medium" data-translate="nav.logout">Log out</span>
                </a>
            </div>
        </div>
    </aside>
    
    <main class="flex-1 flex flex-col h-full overflow-hidden relative bg-background-light dark:bg-background-dark">
        <header class="h-16 flex items-center justify-between px-6 lg:px-8 border-b border-border-light dark:border-[#233648] bg-card-light/95 dark:bg-background-dark/80 backdrop-blur z-10 shrink-0">
            <div class="flex items-center gap-4">
                <button id="menu-toggle" class="lg:hidden text-text-main dark:text-white">
                    <span class="material-symbols-outlined">menu</span>
                </button>
                <h2 class="text-text-main dark:text-white text-lg font-bold" data-translate="documents.title">Documents</h2>
            </div>
        </header>
        
        <div class="flex-1 overflow-y-auto p-6 lg:p-8 scroll-smooth">
            <div class="max-w-7xl mx-auto flex flex-col gap-8 pb-10">
                <!-- Upload Section -->
                <div class="flex flex-col gap-4">
                    <h3 class="text-base font-semibold text-text-main dark:text-white" data-translate="documents.uploadTitle">Upload Documents</h3>
                    <div id="upload-area" class="bg-card-light dark:bg-card-dark border-2 border-dashed border-border-light dark:border-[#233648] rounded-xl p-10 flex flex-col items-center justify-center text-center hover:border-primary/50 hover:bg-slate-50 dark:hover:bg-white/[0.02] transition-all cursor-pointer group relative overflow-hidden">
                        <input id="file-input" type="file" class="absolute inset-0 opacity-0 cursor-pointer z-10" accept=".pdf,.csv,.xlsx,.xls,.png,.jpg,.jpeg" multiple />
                        <div class="bg-primary/10 p-4 rounded-full text-primary mb-4 group-hover:scale-110 transition-transform duration-300">
                            <span class="material-symbols-outlined text-[32px]">cloud_upload</span>
                        </div>
                        <h3 class="text-lg font-semibold text-text-main dark:text-white mb-1" data-translate="documents.dragDrop">Drag & drop files here or click to browse</h3>
                        <p class="text-text-muted dark:text-[#92adc9] text-sm max-w-sm leading-relaxed">
                            <span data-translate="documents.uploadDesc">Upload bank statements, invoices, or receipts.</span><br/>
                            <span class="text-xs text-text-muted/70 dark:text-[#92adc9]/70" data-translate="documents.supportedFormats">Supported formats: CSV, PDF, XLS, XLSX, PNG, JPG (Max 10MB)</span>
                        </p>
                    </div>
                </div>
                
                <!-- Documents List -->
                <div class="flex flex-col gap-4">
                    <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
                        <h3 class="text-base font-semibold text-text-main dark:text-white" data-translate="documents.yourFiles">Your Files</h3>
                        <div class="flex flex-col sm:flex-row gap-3 w-full md:w-auto">
                            <div class="relative flex-1 min-w-[240px]">
                                <span class="material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted dark:text-[#92adc9] text-[20px]">search</span>
                                <input id="search-input" type="text" class="w-full bg-card-light dark:bg-card-dark border border-border-light dark:border-[#233648] rounded-lg py-2 pl-10 pr-4 text-sm text-text-main dark:text-white focus:ring-1 focus:ring-primary focus:border-primary outline-none transition-all placeholder:text-text-muted/50 dark:placeholder:text-[#92adc9]/50" placeholder="Search by name..." data-translate="documents.searchPlaceholder" />
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-card-light dark:bg-card-dark border border-border-light dark:border-[#233648] rounded-xl overflow-hidden shadow-sm">
                        <div class="overflow-x-auto">
                            <table class="w-full text-sm text-left">
                                <thead class="text-xs text-text-muted dark:text-[#92adc9] uppercase bg-slate-50 dark:bg-white/5 border-b border-border-light dark:border-[#233648]">
                                    <tr>
                                        <th class="px-6 py-4 font-medium" data-translate="documents.tableDocName">Document Name</th>
                                        <th class="px-6 py-4 font-medium" data-translate="documents.tableUploadDate">Upload Date</th>
                                        <th class="px-6 py-4 font-medium" data-translate="documents.tableType">Type</th>
                                        <th class="px-6 py-4 font-medium" data-translate="documents.tableStatus">Status</th>
                                        <th class="px-6 py-4 font-medium text-right" data-translate="documents.tableActions">Actions</th>
                                    </tr>
                                </thead>
                                <tbody id="documents-list" class="divide-y divide-border-light dark:divide-[#233648]">
                                    <!-- Documents will be loaded here -->
                                </tbody>
                            </table>
                        </div>
                        <div class="bg-slate-50 dark:bg-white/5 border-t border-border-light dark:border-[#233648] p-4 flex items-center justify-between">
                            <span class="text-sm text-text-muted dark:text-[#92adc9]">
                                <span data-translate="documents.showing">Showing</span> <span id="page-start" class="text-text-main dark:text-white font-medium">1</span>-<span id="page-end" class="text-text-main dark:text-white font-medium">5</span> <span data-translate="documents.of">of</span> <span id="total-count" class="text-text-main dark:text-white font-medium">0</span> <span data-translate="documents.documents">documents</span>
                            </span>
                            <div id="pagination" class="flex gap-2">
                                <!-- Pagination buttons will be added here -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
</div>

<script src="{{ url_for('static', filename='js/documents.js') }}"></script>
{% endblock %}
