<?php
/**
 * Composant témoignage
 * @param array $testimonial Données du témoignage
 * @param bool $showProjectLink Afficher le lien vers le projet (défaut: true)
 */

$quote = $testimonial['quote'] ?? '';
$authorName = $testimonial['author_name'] ?? 'Anonyme';
$authorRole = $testimonial['author_role'] ?? '';
$authorCompany = $testimonial['author_company'] ?? '';
$authorPhoto = $testimonial['author_photo'] ?? null;
$projectSlug = $testimonial['project_slug'] ?? null;
$showProjectLink = $showProjectLink ?? true;
?>

<blockquote class="card h-full flex flex-col">
    <div class="card-body flex flex-col h-full">
        <!-- Guillemets décoratifs -->
        <svg class="w-8 h-8 text-primary/30 mb-4 flex-shrink-0" fill="currentColor" viewBox="0 0 24 24">
            <path d="M14.017 21v-7.391c0-5.704 3.731-9.57 8.983-10.609l.995 2.151c-2.432.917-3.995 3.638-3.995 5.849h4v10h-9.983zm-14.017 0v-7.391c0-5.704 3.748-9.57 9-10.609l.996 2.151c-2.433.917-3.996 3.638-3.996 5.849h3.983v10h-9.983z"/>
        </svg>

        <!-- Citation -->
        <p class="text-text-primary leading-relaxed mb-6 italic flex-grow">
            "<?= htmlspecialchars($quote) ?>"
        </p>

        <!-- Auteur -->
        <footer class="flex items-center gap-4 mt-auto">
            <?php if ($authorPhoto): ?>
                <img
                    src="/assets/img/testimonials/<?= htmlspecialchars($authorPhoto) ?>"
                    alt="<?= htmlspecialchars($authorName) ?>"
                    class="w-12 h-12 rounded-full object-cover"
                    loading="lazy"
                >
            <?php else: ?>
                <div class="w-12 h-12 rounded-full bg-primary/20 flex items-center justify-center flex-shrink-0">
                    <span class="text-primary font-semibold text-lg">
                        <?= strtoupper(mb_substr($authorName, 0, 1)) ?>
                    </span>
                </div>
            <?php endif; ?>

            <div>
                <p class="font-semibold text-text-primary"><?= htmlspecialchars($authorName) ?></p>
                <p class="text-sm text-text-secondary">
                    <?= htmlspecialchars($authorRole) ?>
                    <?php if ($authorCompany): ?>
                        <span class="text-text-muted">—</span> <?= htmlspecialchars($authorCompany) ?>
                    <?php endif; ?>
                </p>
            </div>
        </footer>

        <!-- Lien vers le projet -->
        <?php if ($showProjectLink && $projectSlug): ?>
            <a href="/projet/<?= htmlspecialchars($projectSlug) ?>" class="inline-flex items-center gap-1 text-primary text-sm mt-4 hover:underline">
                Voir le projet
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
                </svg>
            </a>
        <?php endif; ?>
    </div>
</blockquote>
