
<ul class="list-group">
	<li class="list-group-item">
		<ul class="nav nav-pills alt-pills float-right mini-labels">
			<form method="get" action="" class="filtro">
				<li class="nav-item float-left mr-3">
					<label>Tipo:</label>
					<select class="form-control" name="tipo" onchange="this.form.submit()">
						<option value="">Todos los tipos</option>
						<?php foreach ($tipos as $row): ?>
							<option value="<?= $row['tipo']; ?>" 
								<?= (isset($filtros['tipo']) && $filtros['tipo'] == $row['tipo']) ? 'selected' : '' ?>>
								<?= ucfirst($row['tipo']); ?>
							</option>
						<?php endforeach; ?>
					</select>
				</li>
				<li class="nav-item float-left mr-3">
					<label>Estado:</label>
					<select class="form-control" name="leido" onchange="this.form.submit()">
						<option value="">Todos</option>
						<option value="1" <?= ($filtros['leido'] == 1) ? 'selected' : '' ?>>Leídas</option>
						<option value="0" <?= ($filtros['leido'] == 0) ? 'selected' : '' ?>>No leídas</option>
					</select>
				</li>
			</form>
		</ul>
	</li>
	<li class="list-group-item">

		<h3>Notificaciones</h3>

		<?php if (empty($notificaciones)): ?>
			<div class="alert alert-secondary text-center">
				No tienes notificaciones
			</div>
		<?php else: ?>
			<div class="list-group">
				<?php foreach ($notificaciones as $notif): ?>
					<?php
						$fecha = !empty($notif['created']) ? date('d/m/Y H:i', strtotime($notif['created'])) : '';
						$titulo = !empty($notif['mensaje']) ? htmlspecialchars($notif['mensaje']) : 'Notificación';
						$link = !empty($notif['link']) ? $notif['link'] : '#';
						$clase_leida = !empty($notif['leido']) ? 'text-muted' : 'font-weight-bold';
					?>
					<a href="<?= $link ?>" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
						<div class="<?= $clase_leida ?>">
							<?= $titulo ?>
							<?php if (empty($notif['leido'])): ?>
								<span class="badge badge-primary rounded-pill ms-2">Nueva</span>
							<?php endif; ?>
						</div>
						<div class="text-secondary small"><?= $fecha ?></div>
					</a>
				<?php endforeach; ?>
			</div>
		<?php endif; ?>
		<div class="row paginacion">
			<div class="info col-12 col-md-6">
				<?php echo $paginacion['info']; ?>
			</div>
			<div class="col-12 col-md-6">
				<?php echo $paginacion['links']; ?>
			</div>
		</div>
	</li>
</ul>