<?php
require_once __DIR__.'/includes/functions.php';
$user = require_user();
mj_require_user_feature('buying_center', (int)$user['id']);
$pageTitle = 'Buying Center';

include __DIR__.'/includes/header.php';
?>
<section class="mj-section">
  <div class="container">
    <div class="mj-center-shell">
      <?php include __DIR__.'/includes/account-sidebar.php'; ?>
      <div class="mj-center-main">
        <div class="mj-section-title mb-4">
          <div><span class="mj-badge mb-2"><i class="bi bi-bag-heart"></i> Buyer tools</span><h1 class="h2 fw-bold mb-1">Buying Center</h1><p class="text-muted mb-0">Saved items, messages, offers, quotes, appointments and reports in one place.</p></div>
        </div>
        
<div class="row g-3 mb-4">
  <div class="col-md-3"><div class="mj-stat-tile"><small class="text-muted">Saved</small><b class="d-block"><?=e(mj_v288_count('mj_saved_items','user_id=?',[(int)$user['id']]))?></b></div></div>
  <div class="col-md-3"><div class="mj-stat-tile"><small class="text-muted">Offers</small><b class="d-block"><?=e(mj_v288_count('mj_offers','buyer_id=? OR seller_id=?',[(int)$user['id'],(int)$user['id']]))?></b></div></div>
  <div class="col-md-3"><div class="mj-stat-tile"><small class="text-muted">Quotes</small><b class="d-block"><?=e(mj_v288_count('mj_quote_requests','user_id=?',[(int)$user['id']]))?></b></div></div>
  <div class="col-md-3"><div class="mj-stat-tile"><small class="text-muted">Appointments</small><b class="d-block"><?=e(mj_v288_count('mj_appointments','user_id=?',[(int)$user['id']]))?></b></div></div>
</div>
<div class="mj-module-grid mb-4">
  <a class="mj-module-tile" href="<?=base_url('messages.php')?>"><i class="bi bi-chat-dots"></i><b>Messages</b><small>All buyer/seller conversations.</small></a>
  <a class="mj-module-tile" href="<?=base_url('my-offers.php')?>"><i class="bi bi-cash-coin"></i><b>Offers</b><small>Track offers sent and received.</small></a>
  <a class="mj-module-tile" href="<?=base_url('my-quotes.php')?>"><i class="bi bi-receipt"></i><b>Quotes</b><small>RFQ and service quotation history.</small></a>
  <a class="mj-module-tile" href="<?=base_url('my-orders.php')?>"><i class="bi bi-bag-check"></i><b>Enquiries</b><small>Offers, quotes, chats and contact history. No customer payment.</small></a>
  <a class="mj-module-tile" href="<?=base_url('saved.php')?>"><i class="bi bi-heart"></i><b>Saved & Alerts</b><small>Saved listings, saved searches and price alerts.</small></a>
  <a class="mj-module-tile" href="<?=base_url('appointments.php')?>"><i class="bi bi-calendar-check"></i><b>Appointments</b><small>Booking requests and confirmed visits.</small></a>
  <a class="mj-module-tile" href="<?=base_url('report.php')?>"><i class="bi bi-flag"></i><b>Report Center</b><small>Track safety reports submitted to admin.</small></a>
  <a class="mj-module-tile" href="<?=base_url('compare-companies.php')?>"><i class="bi bi-columns-gap"></i><b>Compare</b><small>Compare companies and listings.</small></a>
</div>
<div class="mj-center-card"><div class="card-body"><h5 class="fw-bold">Recent buying timeline</h5><?php mj_v288_render_timeline(mj_v288_user_timeline((int)$user['id'], 35)); ?></div></div>

      </div>
    </div>
  </div>
</section>
<?php include __DIR__.'/includes/footer.php'; ?>
