<?php $companyName = $settings['company_name'] ?? 'FM ERP'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Track Request — <?= esc($companyName) ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<link href="<?= base_url('assets/css/custom.css') ?>" rel="stylesheet">
<style>body{padding-top:0!important}</style>
</head>
<body>
<div class="public-bg py-4">
<div class="public-card">
  <a href="<?= base_url('request') ?>" class="small text-primary"><i class="bi bi-arrow-left me-1"></i>New Request</a>
  <h4 class="fw-bold mt-3 mb-4" style="color:#0a3d6b"><i class="bi bi-search me-2"></i>Track Request: <?= esc($ticket) ?></h4>
  <?php if($req): ?>
  <div class="row g-3">
    <div class="col-md-6"><div class="small text-muted">Ticket Number</div><div class="fw-bold fs-5"><?= esc($req['ticket_number']) ?></div></div>
    <div class="col-md-6"><div class="small text-muted">Status</div><span class="fm-badge badge-status-<?= esc($req['status']) ?> fs-6"><?= ucfirst($req['status']) ?></span></div>
    <div class="col-md-6"><div class="small text-muted">Priority</div><span class="fm-badge badge-priority-<?= esc($req['priority']) ?>"><?= ucfirst($req['priority']) ?></span></div>
    <div class="col-md-6"><div class="small text-muted">Submitted</div><div><?= date('d M Y H:i',strtotime($req['created_at'])) ?></div></div>
    <div class="col-12"><div class="small text-muted">Description</div><div class="p-3 rounded" style="background:#f7f9fc"><?= nl2br(esc($req['description'])) ?></div></div>
    <?php if($req['status']==='converted'): ?>
    <div class="col-12"><div class="alert alert-success border-0 rounded-3"><i class="bi bi-check-circle-fill me-2"></i>Your request has been reviewed and converted to a work order. Our team is working on it.</div></div>
    <?php elseif($req['status']==='rejected'): ?>
    <div class="col-12"><div class="alert alert-warning border-0 rounded-3"><i class="bi bi-info-circle me-2"></i>Your request was reviewed but could not be processed at this time. Please contact us directly.</div></div>
    <?php elseif($req['status']==='reviewed'): ?>
    <div class="col-12"><div class="alert alert-info border-0 rounded-3"><i class="bi bi-eye me-2"></i>Your request has been reviewed and is pending assignment.</div></div>
    <?php else: ?>
    <div class="col-12"><div class="alert alert-secondary border-0 rounded-3"><i class="bi bi-clock me-2"></i>Your request is pending review. We will process it shortly.</div></div>
    <?php endif; ?>
  </div>
  <?php else: ?>
  <div class="alert alert-warning border-0 rounded-3"><i class="bi bi-search me-2"></i>No request found with ticket number <strong><?= esc($ticket) ?></strong>. Please check your ticket number and try again.</div>
  <?php endif; ?>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body></html>
