<?php ob_start(); ?>

<div class="bg-white rounded-xl shadow-sm border border-gray-100">
    <div class="p-6 border-b border-gray-100 flex justify-between items-center">
        <h3 class="text-lg font-semibold text-gray-800">
            <i class="fas fa-bell mr-2 text-red-600"></i>Alertes Intelligentes
        </h3>
        <?php if (!empty($alertes)): ?>
        <span class="text-sm text-gray-500"><?= count($alertes) ?> alerte(s)</span>
        <?php endif; ?>
    </div>
    
    <div class="p-6">
        <?php if (empty($alertes)): ?>
            <div class="text-center py-12">
                <div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <i class="fas fa-check text-2xl text-green-600"></i>
                </div>
                <p class="text-gray-500">Aucune alerte pour le moment</p>
                <p class="text-sm text-gray-400 mt-2">Tout fonctionne normalement</p>
            </div>
        <?php else: ?>
            <div class="space-y-4">
                <?php foreach ($alertes as $alerte): ?>
                <div class="p-4 rounded-lg border <?= $alerte['severite'] === 'critical' ? 'border-red-200 bg-red-50' : 
                    ($alerte['severite'] === 'warning' ? 'border-yellow-200 bg-yellow-50' : 'border-blue-200 bg-blue-50') ?>">
                    <div class="flex items-start justify-between">
                        <div class="flex items-start">
                            <div class="mr-3 mt-1">
                                <i class="fas <?= $alerte['severite'] === 'critical' ? 'fa-exclamation-circle text-red-500' : 
                                    ($alerte['severite'] === 'warning' ? 'fa-exclamation-triangle text-yellow-500' : 'fa-info-circle text-blue-500') ?>"></i>
                            </div>
                            <div>
                                <h4 class="font-medium text-gray-800"><?= htmlspecialchars($alerte['titre']) ?></h4>
                                <p class="text-sm text-gray-600 mt-1"><?= htmlspecialchars($alerte['description'] ?? '') ?></p>
                                <div class="flex items-center mt-2 text-xs text-gray-500">
                                    <span><i class="fas fa-clock mr-1"></i><?= date('d/m/Y H:i', strtotime($alerte['created_at'])) ?></span>
                                    <span class="mx-2">•</span>
                                    <span class="px-2 py-0.5 rounded-full <?= $alerte['severite'] === 'critical' ? 'bg-red-200 text-red-700' : 
                                        ($alerte['severite'] === 'warning' ? 'bg-yellow-200 text-yellow-700' : 'bg-blue-200 text-blue-700') ?>">
                                        <?= ucfirst($alerte['severite']) ?>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="flex items-center space-x-2">
                            <?php if (!$alerte['is_read']): ?>
                                <span class="w-2 h-2 bg-red-500 rounded-full"></span>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</div>

<div class="mt-6 bg-blue-50 border border-blue-200 rounded-xl p-6">
    <h4 class="font-medium text-blue-800 mb-2"><i class="fas fa-info-circle mr-2"></i>Types d'alertes</h4>
    <ul class="text-sm text-blue-700 space-y-1">
        <li><strong>Volume plaintes</strong> - Hausse anormale du nombre de réclamations</li>
        <li><strong>Baisse satisfaction</strong> - Diminution significative de la satisfaction client</li>
        <li><strong>Sujet sensible</strong> - Thème récurrent nécessitant attention</li>
        <li><strong>Crise potentielle</strong> - Risque de crise détecté par l'analyse</li>
    </ul>
</div>

<?php 
$content = ob_get_clean();
$title = 'Alertes - ' . APP_NAME;
$pageTitle = 'Alertes Intelligentes';
include VIEWS_PATH . '/layouts/main.php';
?>
