{% extends "base.html" %}

{% block title %}Email Organizer - Prototype{% endblock %}

{% block header %}
{% include "partials/header.html" %}
{% endblock %}

{% block content %}
<div class="flex">
    {% include "partials/sidebar.html" %}

    <!-- Main Content -->
    <div class="flex-1 ml-64 mt-16 flex flex-col">
        <!-- Top Bar -->

        <!-- Main Content Area -->
        <main class="flex-1 p-6 overflow-auto bg-base-100">
            <div class="flex justify-between items-center mb-6">
                <div>
                    <h2 class="text-2xl font-bold">Email Folders</h2>
                    <p class="text-base-content/70">Create and manage your email organization rules</p>
                </div>
                <div class="flex space-x-2">
                    {% if current_user.imap_config %}
                    <div data-loading-states>
                        <button class="btn btn-outline" hx-get="/api/imap/config" hx-target="#modal-holder" data-loading-disable>
                            <i class="fas fa-sync mr-2" data-loading-class="!hidden"></i>
                            <span data-loading-class="!hidden">Sync Folders</span>
                            <span class="loading loading-spinner loading-xs hidden" data-loading-class-remove="hidden"></span>
                        </button>
                    </div>
                    <div data-loading-states>
                        <button class="btn btn-outline" hx-get="/api/imap/config" hx-target="#modal-holder" hx-swap="innerHTML"
                            data-loading-disable>
                            <i class="fas fa-cog" data-loading-class="!hidden"></i>
                            <span class="loading loading-spinner loading-xs hidden" data-loading-class-remove="hidden"></span>
                        </button>
                    </div>
                    {% else %}
                    <div data-loading-states>
                        <button class="btn btn-outline" hx-get="/api/imap/config" hx-target="#modal-holder" hx-swap="innerHTML"
                            data-loading-disable>
                            <i class="fas fa-cog mr-2" data-loading-class="!hidden"></i>
                            <span data-loading-class="!hidden">Configure IMAP</span>
                            <span class="loading loading-spinner loading-xs hidden" data-loading-class-remove="hidden"></span>
                        </button>
                    </div>
                    {% endif %}
                
                </div>
            </div>
            
            <!-- Welcome Section - Only shown when IMAP is not configured -->
            {% if not current_user.imap_config %}
                {% include "partials/welcome_section.html" %}
                {% include "partials/folders_list.html" %}
            {% else %}

                {% include 'partials/folders_list.html' %}
                {% endif %}
            
    </div>
</div>
{% endblock %}

{% block modal %}
{% include "partials/modal_holder.html" %}
{% endblock %}
