<?php
require_once 'config/db.php';
$settings = getAllSettings($pdo);
$activePage = 'brand';
$pageTitle = 'Brand - '.($settings['site_name']??'');

$brands = $pdo->query("SELECT * FROM brands WHERE is_active=1 ORDER BY sort_order ASC")->fetchAll();
include 'partials/header.php';
?>

<div class="page-hero">
    <div class="container">
        <nav aria-label="breadcrumb"><ol class="breadcrumb mb-2"><li class="breadcrumb-item"><a href="index.php">Home</a></li><li class="breadcrumb-item active">Brand</li></ol></nav>
        <h1 class="fw-bold mb-1 fs-2">Brand</h1>
        <p class="mb-0" style="color:rgba(255,255,255,.6);" data-en="Explore our premium leather upholstery brands" data-id="Jelajahi brand kulit jok premium kami">Jelajahi brand kulit jok premium kami</p>
    </div>
</div>

<section class="py-5 py-lg-6">
    <div class="container">
        <div class="section-header text-center fade-up mb-5">
            <div class="section-label" data-en="Our Brands" data-id="Brand Kami">Our Brands</div>
            <h2 class="section-title" data-en="Premium Leather Upholstery Brands" data-id="Brand Kulit Jok Premium">Brand Kulit Jok Premium</h2>
            <p class="section-subtitle">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Kami bermitra dengan brand-brand terkemuka.</p>
            <div class="section-divider mx-auto"></div>
        </div>

        <div class="row g-4">
            <?php foreach ($brands as $brand): ?>
            <div class="col-md-6 col-lg-4 fade-up">
                <div class="brand-card">
                    <div class="mb-3">
                        <img src="<?= htmlspecialchars($brand['image']??'') ?>" class="brand-logo" alt="<?= htmlspecialchars($brand['name']) ?>"
                             onerror="this.src='https://placehold.co/200x80/f5f5f5/aaa?text=<?= urlencode($brand['name']) ?>'">
                    </div>
                    <h5 class="fw-bold mb-1"><?= htmlspecialchars($brand['name']) ?></h5>
                    <?php if ($brand['category']): ?>
                        <span class="badge bg-light text-muted border mb-2"><?= htmlspecialchars($brand['category']) ?></span>
                    <?php endif; ?>
                    <p class="small text-muted mb-3"><?= htmlspecialchars($brand['description']??'') ?></p>
                    
                    <?php if ($brand['sample_image']): ?>
                    <div class="mb-3">
                        <img src="<?= htmlspecialchars($brand['sample_image']) ?>" class="brand-sample" alt="<?= htmlspecialchars($brand['name']) ?> Sample"
                             onerror="this.style.display='none'">
                    </div>
                    <?php endif; ?>
                    
                    <?php if ($brand['color_variants']): ?>
                    <div>
                        <p class="small fw-semibold mb-2" data-en="Available Colors:" data-id="Pilihan Warna:">Pilihan Warna:</p>
                        <div class="color-tags">
                            <?php foreach (explode(',', $brand['color_variants']) as $color): ?>
                                <span class="color-tag"><?= htmlspecialchars(trim($color)) ?></span>
                            <?php endforeach; ?>
                        </div>
                    </div>
                    <?php endif; ?>
                    
                    <div class="mt-3">
                        <a href="contact.php" class="btn btn-outline-dark btn-sm w-100" data-en="Request Sample" data-id="Minta Sampel">Minta Sampel</a>
                    </div>
                </div>
            </div>
            <?php endforeach; ?>
            <?php if (empty($brands)): ?>
                <div class="col-12 text-center py-5 text-muted"><i class="bi bi-award display-4 mb-3 d-block"></i>Belum ada brand tersedia.</div>
            <?php endif; ?>
        </div>
    </div>
</section>

<!-- Brand Benefits -->
<section class="py-5 bg-section">
    <div class="container">
        <div class="section-header text-center fade-up">
            <div class="section-label" data-en="Why Choose Us" data-id="Mengapa Kami">Why Choose Us</div>
            <h2 class="section-title" data-en="Authorized Distributor" data-id="Distributor Resmi">Distributor Resmi</h2>
            <div class="section-divider mx-auto"></div>
        </div>
        <div class="row g-4 mt-2">
            <?php
            $benefits = [
                ['icon'=>'bi-patch-check-fill','title'=>'Produk Original','desc'=>'Semua produk kami 100% original dan bersumber langsung dari produsen resmi'],
                ['icon'=>'bi-tags-fill','title'=>'Harga Kompetitif','desc'=>'Harga terbaik dengan kualitas premium, tersedia berbagai pilihan paket'],
                ['icon'=>'bi-headset','title'=>'Dukungan Teknis','desc'=>'Tim teknis berpengalaman siap membantu konsultasi pemilihan material'],
                ['icon'=>'bi-truck','title'=>'Stok Tersedia','desc'=>'Stok lengkap selalu tersedia, pengiriman cepat ke seluruh Indonesia'],
            ];
            foreach ($benefits as $b):
            ?>
            <div class="col-sm-6 col-lg-3 fade-up">
                <div class="about-feature text-center h-100">
                    <div class="feature-icon mx-auto"><i class="bi <?= $b['icon'] ?>"></i></div>
                    <h6 class="fw-bold"><?= $b['title'] ?></h6>
                    <p class="small text-muted mb-0"><?= $b['desc'] ?></p>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<?php include 'partials/footer.php'; ?>
