<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="darlink-title mb-1">
            <i class="bi bi-envelope-paper me-2"></i>
            Envoyer le devis <?= htmlspecialchars((string)$document['numero']) ?>
        </h1>
        <p class="text-muted mb-0">
            Le PDF sera généré automatiquement et joint à l’e-mail.
        </p>
    </div>

    <a href="index.php?page=<?= htmlspecialchars($returnRoute) ?>"
       class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-1"></i> Retour
    </a>
</div>

<form method="post" action="index.php?page=<?= htmlspecialchars($sendRoute) ?>">
    <input type="hidden" name="id" value="<?= (int)$document['id'] ?>">

    <div class="row g-4">
        <div class="col-xl-8">
            <div class="darlink-form-card">
                <div class="darlink-form-header">
                    <h2 class="darlink-form-title h5">
                        <i class="bi bi-send me-2"></i>Message
                    </h2>
                </div>

                <div class="darlink-form-body">
                    <div class="darlink-form-group">
                        <label class="darlink-label" for="recipient">Destinataire</label>
                        <input class="darlink-input" type="email" id="recipient"
                               name="recipient"
                               value="<?= htmlspecialchars((string)$defaults['recipient']) ?>"
                               placeholder="client@exemple.com" required>
                    </div>

                    <div class="darlink-form-group">
                        <label class="darlink-label" for="subject">Objet</label>
                        <input class="darlink-input" type="text" id="subject"
                               name="subject"
                               value="<?= htmlspecialchars((string)$defaults['subject']) ?>"
                               required>
                    </div>

                    <div class="darlink-form-group mb-0">
                        <label class="darlink-label" for="message">Message</label>
                        <textarea class="darlink-textarea" id="message" name="message"
                                  rows="12" required><?= htmlspecialchars((string)$defaults['message']) ?></textarea>
                    </div>
                </div>

                <div class="darlink-form-actions">
                    <a href="index.php?page=<?= htmlspecialchars($returnRoute) ?>"
                       class="btn btn-outline-secondary">Annuler</a>
                    <button type="submit" class="btn darlink-btn-primary">
                        <i class="bi bi-send me-1"></i> Envoyer le devis
                    </button>
                </div>
            </div>
        </div>

        <div class="col-xl-4">
            <div class="darlink-card p-4 mb-4">
                <div class="text-muted small text-uppercase fw-bold mb-3">
                    Pièce jointe
                </div>
                <div class="d-flex align-items-center gap-3">
                    <i class="bi bi-file-earmark-pdf fs-2 text-danger"></i>
                    <div>
                        <strong><?= htmlspecialchars((string)$defaults['attachment_name']) ?></strong>
                        <div class="small text-muted">Générée au moment de l’envoi</div>
                    </div>
                </div>
            </div>

            <div class="darlink-card p-4">
                <div class="text-muted small text-uppercase fw-bold mb-3">
                    Options
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="1"
                           id="copySender" name="copy_sender">
                    <label class="form-check-label" for="copySender">
                        M’envoyer une copie cachée
                    </label>
                </div>
                <div class="small text-muted mt-3">
                    Modèle utilisé :
                    <strong><?= htmlspecialchars((string)$defaults['template_name']) ?></strong>
                </div>
            </div>
        </div>
    </div>
</form>
