<!-- Add Single Food Modal -->
<div class="modal fade" id="addSingleFoodModal" tabindex="-1" aria-labelledby="addSingleFoodModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addSingleFoodModalLabel">Add Single Food</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="addSingleFoodForm">
                    <input type="hidden" name="person" value="{{ person }}">
                    <input type="hidden" name="date" value="{{ current_date.isoformat() }}">
                    <div class="mb-3">
                        <label class="form-label">Select Food</label>
                        <select class="form-control" name="food_id" required onchange="updateServingSizeNote(this)">
                            <option value="">Choose food...</option>
                            {% for food in foods %}
                            <option value="{{ food.id }}" data-serving-size="{{ food.serving_size }}">{{ food.name }}</option>
                            {% endfor %}
                        </select>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Quantity (g)</label>
                        <span id="servingSizeNote" class="text-muted small ms-2"></span>
                        <input type="number" step="0.1" class="form-control" name="quantity" value="1.0" min="0.1" required>
                    </div>
                    <input type="hidden" name="meal_time" id="addSingleFoodMealTime">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                <button type="button" class="btn btn-primary" onclick="submitAddSingleFood()">Add Food</button>
            </div>
<script>
    function updateServingSizeNote(selectElement) {
        const selectedOption = selectElement.options[selectElement.selectedIndex];
        const servingSize = selectedOption.getAttribute('data-serving-size');
        const servingSizeNote = document.getElementById('servingSizeNote');
        
        if (servingSize) {
            servingSizeNote.textContent = `(Serving size: ${servingSize}g)`;
        } else {
            servingSizeNote.textContent = '';
        }
    }
</script>
        </div>
    </div>
</div>