<?php
$pageTitle = 'Project Assignment Response';
ob_start();
?>
<div class="max-w-2xl mx-auto py-8">
    <div class="bg-white p-8 rounded-lg shadow border-t-4 border-indigo-600">
        <h1 class="text-2xl font-bold mb-2">Project Assignment Response</h1>
        <p class="text-gray-600 mb-6">You have been assigned to the following project. Please accept or reject this assignment.</p>

        <div class="bg-gray-50 p-4 rounded mb-6 border">
            <h2 class="font-bold text-lg"><?= htmlspecialchars($project['name']) ?></h2>
            <p class="text-sm text-gray-500 mb-2">Code: <?= htmlspecialchars($project['project_code']) ?></p>
            <p class="text-sm"><strong>Client:</strong> <?= htmlspecialchars($project['client_name'] ?? 'N/A') ?></p>
            <p class="text-sm"><strong>Value:</strong> <?= formatCurrency((float)$project['project_value'], $project['currency'] ?? DEFAULT_CURRENCY) ?></p>
            <p class="text-sm"><strong>Start Date:</strong> <?= htmlspecialchars($project['start_date'] ?? 'TBD') ?></p>
            <?php if (!empty($project['location'])): ?>
            <p class="text-sm"><strong>Location:</strong> <?= htmlspecialchars($project['location']) ?></p>
            <?php endif; ?>
            <?php if (!empty($project['description'])): ?>
            <p class="text-sm mt-2"><?= nl2br(htmlspecialchars($project['description'])) ?></p>
            <?php endif; ?>
        </div>

        <form action="<?= APP_URL ?>/projects/<?= $project['id'] ?>/contractor-response" method="POST">
            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION[CSRF_TOKEN_NAME] ?? '') ?>">

            <div class="mb-6">
                <label class="block text-gray-700 font-bold mb-2">Comments (Required if rejecting)</label>
                <textarea name="comment" rows="4" class="w-full border rounded p-2" placeholder="State your reasons..."></textarea>
            </div>

            <div class="flex gap-4">
                <button type="submit" name="response_status" value="accepted" class="flex-1 bg-green-600 hover:bg-green-700 text-white font-bold py-3 rounded shadow">
                    Accept Assignment
                </button>
                <button type="submit" name="response_status" value="rejected" class="flex-1 bg-red-600 hover:bg-red-700 text-white font-bold py-3 rounded shadow">
                    Reject Assignment
                </button>
            </div>
        </form>
    </div>
</div>
<?php
$content = ob_get_clean();
require ROOT_PATH . '/modules/shared/views/layouts/main.php';
?>
