{% extends 'base.html' %}
{% load static %}

{% block title %}Log Work | FoxFitt{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0" style="color: #0f172a; font-family: 'Poppins', sans-serif;">Log Daily Attendance</h1>
        <a href="{% url 'home' %}" class="btn btn-outline-secondary btn-sm shadow-sm">
            <i class="fas fa-arrow-left fa-sm me-1"></i> Back
        </a>
    </div>

    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card shadow-sm border-0" style="border-radius: 12px;">
                <div class="card-body p-5">
                    <form method="POST" id="attendanceForm">
                        {% csrf_token %}
                        <div class="mb-4">
                            <label class="form-label" style="font-weight: 600;">{{ form.date.label }}</label>
                            {{ form.date }}
                        </div>

                        <div class="row g-3 mb-4">
                            <div class="col-md-6">
                                <label class="form-label" style="font-weight: 600;">{{ form.project.label }}</label>
                                {{ form.project }}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label" style="font-weight: 600;">{{ form.supervisor.label }}</label>
                                {{ form.supervisor }}
                            </div>
                        </div>

                        <div class="mb-4">
                            <label class="form-label" style="font-weight: 600;">{{ form.team.label }} <span class="text-muted fw-normal">(Optional)</span></label>
                            {{ form.team }}
                        </div>

                        <div class="mb-4">
                            <label class="form-label d-block mb-3" style="font-weight: 600;">Workers Present</label>
                            <div class="worker-selection border rounded p-3" style="max-height: 300px; overflow-y: auto; background-color: #f8fafc; border-color: #e2e8f0 !important;">
                                <div class="row">
                                    {% for worker in form.workers %}
                                    <div class="col-md-6 mb-2">
                                        <div class="form-check">
                                            {{ worker.tag }}
                                            <label class="form-check-label ms-1" for="{{ worker.id_for_label }}">
                                                {{ worker.choice_label }}
                                            </label>
                                        </div>
                                    </div>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>

                        <div class="row g-3 mb-4">
                            <div class="col-md-6">
                                <label class="form-label" style="font-weight: 600;">{{ form.overtime_amount.label }}</label>
                                {{ form.overtime_amount }}
                            </div>
                        </div>

                        <div class="mb-4">
                            <label class="form-label" style="font-weight: 600;">{{ form.notes.label }}</label>
                            {{ form.notes }}
                        </div>

                        <div class="d-grid mt-5">
                            <button type="submit" class="btn btn-lg text-white shadow-sm" style="background-color: #10b981; border: none; font-weight: 600; border-radius: 8px;">Save Attendance Log</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}