<?php $PAGE_TITLE='Services'; require __DIR__.'/_layout.php';
// Only CUSTOM services show here (API services live under Auto Server Copy)
$rows = $pdo->query("SELECT * FROM services
                     WHERE kind='custom' AND status IN ('open','closed')
                     ORDER BY pinned DESC, position, id DESC")->fetchAll();
?>
<style>
.svc2-card{background:#fff;border:1px solid #e2e8f0;border-radius:14px;padding:14px;box-shadow:0 4px 12px rgba(15,23,42,.04);position:relative;display:flex;gap:12px;align-items:flex-start}
.svc2-card .svc2-thumb{flex:0 0 auto;width:70px;height:70px;border-radius:10px;overflow:hidden;border:1px solid #e2e8f0;background:#f8fafc;display:flex;align-items:center;justify-content:center}
.svc2-card .svc2-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.svc2-card .svc2-body{flex:1;min-width:0}
.svc2-card h3{font-size:15px;margin:0 0 4px;color:#0f172a;line-height:1.3}
.svc2-card p{color:#64748b;font-size:12px;margin:0 0 8px;line-height:1.4}
.svc2-card .svc2-price{font-size:18px;font-weight:700;color:#6366f1;margin-bottom:8px}
.svc2-card .svc2-pin{position:absolute;top:8px;right:10px;background:#fef3c7;color:#92400e;font-size:10px;font-weight:700;padding:2px 7px;border-radius:999px}
.svc2-card .btn{padding:7px 12px;font-size:13px}
</style>
<h2 style="margin-bottom:14px">🎯 সকল সার্ভিস</h2>
<?php if(!$rows): ?>
  <p style="color:#64748b">এখনো কোন সার্ভিস যোগ করা হয়নি।</p>
<?php else: ?>
<div class="grid g2">
<?php foreach($rows as $s):
  $closed = ($s['status']==='closed');
?>
<div class="svc2-card">
  <?php if(!empty($s['pinned'])): ?><span class="svc2-pin">📌 পিন</span><?php endif; ?>
  <?php if(!empty($s['image'])): ?>
    <div class="svc2-thumb"><img src="../uploads/services/<?=e($s['image'])?>" alt="<?=e($s['name'])?>"></div>
  <?php else: ?>
    <div class="svc2-thumb" style="font-size:26px;color:#94a3b8">🎯</div>
  <?php endif; ?>
  <div class="svc2-body">
    <h3><?=e($s['name'])?></h3>
    <?php if(!empty($s['description'])): ?><p><?=e($s['description'])?></p><?php endif; ?>
    <div class="svc2-price"><?=money($s['price'])?></div>
    <?php if($closed): ?>
      <button class="btn" disabled style="background:#94a3b8;cursor:not-allowed">🚫 বন্ধ</button>
    <?php else: ?>
      <a class="btn" href="service_order.php?id=<?=$s['id']?>">🛒 অর্ডার করুন</a>
    <?php endif; ?>
  </div>
</div>
<?php endforeach;?>
</div>
<?php endif; ?>
<?php require __DIR__.'/_footer.php';
