<link rel="stylesheet" href="/public/assets/css/cda-family-messages-972.css?v=9.7.3">
<section class="card message-page-head"><div><span class="cda-eyebrow">Échange</span><h2><?= htmlspecialchars((string)$thread['subject']) ?></h2>
<p><?= htmlspecialchars((string)$thread['nom'].' '.(string)$thread['prenom']) ?> · Statut : <?= htmlspecialchars(str_replace('_',' ',(string)$thread['status'])) ?></p></div></section>
<section class="card"><div class="conversation"><?php foreach($posts as $post):?>
<article class="<?= $post['author_side']==='direction'?'from-direction':'from-family' ?>">
<strong><?= $post['author_side']==='direction'?'Direction':'Adhérent' ?></strong>
<p><?= nl2br(htmlspecialchars((string)$post['body'])) ?></p><time><?= date('d/m/Y H:i',strtotime((string)$post['created_at'])) ?></time>
</article><?php endforeach?></div></section>
<?php if((string)$thread['status']!=='fermee'):?><section class="card message-form">
<form method="post" action="/public/mon-espace/demandes/repondre"><?= \App\Core\Csrf::field() ?><input type="hidden" name="id" value="<?= (int)$thread['id'] ?>">
<label><?= $direction?'Réponse de la Direction':'Ajouter le complément demandé' ?><textarea name="body" rows="6" required></textarea></label>
<?php if($direction):?><label>Suite donnée<select name="status"><option value="en_cours">En cours</option><option value="complement_requis">Complément requis (envoi d’un mail)</option><option value="fermee">Demande traitée et fermée</option></select></label><?php endif?>
<div class="form-actions"><a class="button button-secondary" href="/public/mon-espace/demandes">← Retour</a><button class="button button-primary">Envoyer le message</button></div>
</form></section><?php else:?><a class="button button-secondary" href="/public/mon-espace/demandes">← Retour</a><?php endif?>
