<?php
require_once 'includes/db.php';
require_once 'includes/functions.php';

$kok_dizin = "/magaza/";
$page_title = "Tüm Yayıncılar ve Markalar | SINAVKOCU Mağaza";

require_once 'header.php';

// Aktif Markaları Çek (Rastgele Sıralı)
$markalar = $db->query("SELECT * FROM brands WHERE status = 1 ORDER BY RAND()")->fetchAll(PDO::FETCH_ASSOC);
?>

<main class="container py-4 text-dark">
    <nav aria-label="breadcrumb" class="mb-4">
        <ol class="breadcrumb mb-0">
            <li class="breadcrumb-item"><a href="<?= $kok_dizin ?>index.php" class="text-decoration-none"><i class="bi bi-house-door"></i> Ana Sayfa</a></li>
            <li class="breadcrumb-item active" aria-current="page">Markalar</li>
        </ol>
    </nav>

    <div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-4">
        <h1 class="h3 fw-bold mb-0 text-primary"><i class="bi bi-bookmark-star me-2"></i>Tüm Yayıncılar ve Markalar</h1>
    </div>

    <?php if(count($markalar) > 0): ?>
        <div class="row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5 g-4 mb-5">
            <?php foreach($markalar as $marka): 
                $logo = !empty($marka['logo']) ? $marka['logo'] : 'assets/img/no-image.jpg';
            ?>
            <div class="col">
                <a href="<?= $kok_dizin ?>marka/<?= htmlspecialchars($marka['slug']) ?>" class="text-decoration-none">
                    <div class="card h-100 border-0 shadow-sm brand-card transition rounded-4 p-3 text-center align-items-center justify-content-center">
                        <img src="<?= $kok_dizin ?><?= htmlspecialchars($logo) ?>" class="img-fluid mb-2" alt="<?= htmlspecialchars($marka['name']) ?>" style="max-height: 80px; object-fit: contain;">
                        <h6 class="fw-bold text-dark mb-0 w-100 text-truncate mt-2"><?= htmlspecialchars($marka['name']) ?></h6>
                    </div>
                </a>
            </div>
            <?php endforeach; ?>
        </div>
    <?php else: ?>
        <div class="alert alert-secondary text-center py-5 shadow-sm border-0 rounded-4">
            <i class="bi bi-tags fs-1 text-muted d-block mb-3"></i>
            <h5 class="fw-bold">Henüz marka eklenmemiş.</h5>
        </div>
    <?php endif; ?>
</main>

<style>
.brand-card { transition: all 0.3s ease; border: 1px solid #f8f9fa !important; }
.brand-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important; border-color: #dee2e6 !important; }
</style>

<?php require_once 'footer.php'; ?>