{% extends "base.html" %}

{% block title %}Consumption Sheets - Admin - ScanLook{% endblock %}

{% block content %}
<div class="dashboard-container">
    <!-- Back to Admin Dashboard -->
    <div class="mode-selector">
        <a href="{{ url_for('admin_dashboard') }}" class="btn btn-secondary btn-sm">
            <i class="fa-solid fa-arrow-left"></i> Back to Admin
        </a>
    </div>

    <div class="dashboard-header">
        <div class="header-left">
            <h1 class="page-title">Consumption Sheets</h1>
            <p class="page-subtitle">Manage process types and templates</p>
        </div>
        <a href="{{ url_for('cons_sheets.create_process') }}" class="btn btn-primary">
            <span class="btn-icon">+</span> New Process
        </a>
    </div>

    {% if processes %}
        <div class="sessions-grid">
            {% for process in processes %}
            <div class="session-card">
                <div class="session-card-header">
                    <h3 class="session-name">{{ process.process_name }}</h3>
                    <span class="session-type-badge">
                        {{ process.field_count or 0 }} fields
                    </span>
                </div>

                <div class="session-meta">
                    <div class="meta-item">
                        <span class="meta-label">Key:</span>
                        <span class="meta-value" style="font-family: var(--font-mono);">{{ process.process_key }}</span>
                    </div>
                    <div class="meta-item">
                        <span class="meta-label">Created:</span>
                        <span class="meta-value">{{ process.created_at[:16] if process.created_at else 'N/A' }}</span>
                    </div>
                    <div class="meta-item">
                        <span class="meta-label">By:</span>
                        <span class="meta-value">{{ process.created_by_name or 'Unknown' }}</span>
                    </div>
                    <div class="meta-item">
                        <span class="meta-label">Template:</span>
                        <span class="meta-value">{{ '✅ Uploaded' if process.template_file else '❌ None' }}</span>
                    </div>
                </div>

                <div class="session-actions">
                    <a href="{{ url_for('cons_sheets.process_detail', process_id=process.id) }}" class="btn btn-secondary btn-block">
                        Configure
                    </a>
                </div>
            </div>
            {% endfor %}
        </div>
    {% else %}
        <div class="empty-state">
            <div class="empty-icon">📝</div>
            <h2 class="empty-title">No Processes Defined</h2>
            <p class="empty-text">Create a process type to get started (e.g., "AD WIP")</p>
            <a href="{{ url_for('cons_sheets.create_process') }}" class="btn btn-primary">
                Create First Process
            </a>
        </div>
    {% endif %}
</div>
{% endblock %}
