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

$prices = $pdo->query("SELECT * FROM price_list WHERE is_active=1 ORDER BY category ASC, sort_order ASC")->fetchAll();
$grouped = [];
foreach ($prices as $p) $grouped[$p['category']][] = $p;

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" data-en="Price" data-id="Harga">Price</li></ol></nav>
        <h1 class="fw-bold mb-1 fs-2" data-en="Price List" data-id="Daftar Harga">Price List</h1>
        <p class="mb-0" style="color:rgba(255,255,255,.6);" data-en="Transparent pricing for all our products" data-id="Harga transparan untuk semua produk kami">Harga transparan untuk semua produk 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="Pricing" data-id="Harga">Pricing</div>
            <h2 class="section-title" data-en="Affordable Premium Quality" data-id="Kualitas Premium Harga Terjangkau">Kualitas Premium Harga Terjangkau</h2>
            <p class="section-subtitle" data-en="All prices listed are indicative. Contact us for bulk pricing and special offers." data-id="Semua harga yang tercantum bersifat indikatif. Hubungi kami untuk harga grosir dan penawaran khusus.">Semua harga bersifat indikatif. Hubungi kami untuk harga grosir dan penawaran khusus.</p>
            <div class="section-divider mx-auto"></div>
        </div>
        <div class="row g-4">
            <?php foreach ($grouped as $catName => $items): ?>
            <div class="col-md-6 col-lg-4 fade-up">
                <div class="price-card h-100">
                    <div class="price-header d-flex align-items-center gap-2">
                        <?php
                        $icons = ['Automotive'=>'bi-car-front','Interior'=>'bi-house','Marine'=>'bi-water'];
                        $icon = $icons[$catName] ?? 'bi-tag';
                        ?>
                        <i class="bi <?= $icon ?> fs-5"></i>
                        <h5 class="fw-bold mb-0"><?= htmlspecialchars($catName) ?></h5>
                    </div>
                    <div>
                        <?php foreach ($items as $item): ?>
                        <div class="price-item">
                            <div>
                                <div class="price-name"><?= htmlspecialchars($item['product_name']) ?></div>
                                <?php if ($item['description']): ?>
                                    <div class="price-desc"><?= htmlspecialchars($item['description']) ?></div>
                                <?php endif; ?>
                                <div class="price-desc text-muted"><i class="bi bi-box me-1"></i><?= htmlspecialchars($item['unit']) ?></div>
                            </div>
                            <div class="price-val ms-3"><?= htmlspecialchars($item['price_display']??'-') ?></div>
                        </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>

        <div class="card border-0 bg-dark text-white p-4 mt-5 fade-up" style="border-radius:12px;">
            <div class="row align-items-center g-3">
                <div class="col-md-8">
                    <h5 class="fw-bold mb-1" data-en="Need Custom Pricing?" data-id="Butuh Harga Custom?">Butuh Harga Custom?</h5>
                    <p class="text-secondary mb-0 small">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Hubungi kami untuk penawaran terbaik sesuai kebutuhan Anda.</p>
                </div>
                <div class="col-md-4 text-md-end">
                    <a href="contact.php" class="btn px-4" style="background:var(--accent);color:#fff;border-radius:7px;font-weight:600;" data-en="Get a Quote" data-id="Minta Penawaran">Minta Penawaran</a>
                </div>
            </div>
        </div>
    </div>
</section>

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