<?php
$mobileTitle = 'More';
require_once __DIR__ . '/../includes/functions.php';
requireLogin();
$role = $_SESSION['role'] ?? 'cashier';
include __DIR__ . '/includes/m_header.php';
?>

<div class="m-section-title">Tools</div>

<div class="m-card mb-3">
  <div class="m-card-body" style="padding:.5rem 0">

    <a href="camera-help.php" class="m-menu-row">
      <div class="m-menu-icon bg-danger-subtle text-danger">
        <i class="bi bi-camera-video"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Camera Troubleshooting</div>
        <div class="text-muted small">Fix camera errors on Android</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <a href="register.php" class="m-menu-row">
      <div class="m-menu-icon bg-primary-subtle text-primary">
        <i class="bi bi-person-plus"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Register Member</div>
        <div class="text-muted small">Scan card &amp; add member info</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <a href="members.php" class="m-menu-row">
      <div class="m-menu-icon bg-info-subtle text-info">
        <i class="bi bi-people"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Members List</div>
        <div class="text-muted small">Search &amp; view all members</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <a href="card-generator.php" class="m-menu-row">
      <div class="m-menu-icon bg-warning-subtle text-warning">
        <i class="bi bi-credit-card-2-front"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Card Generator</div>
        <div class="text-muted small">Generate &amp; save new reward cards</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <a href="<?= BASE_URL ?>/reports.php" class="m-menu-row">
      <div class="m-menu-icon bg-secondary-subtle text-secondary">
        <i class="bi bi-bar-chart-line"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Reports</div>
        <div class="text-muted small">View &amp; export reports (desktop)</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <?php if ($role === 'admin'): ?>
    <a href="<?= BASE_URL ?>/settings.php" class="m-menu-row">
      <div class="m-menu-icon bg-danger-subtle text-danger">
        <i class="bi bi-gear"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Settings</div>
        <div class="text-muted small">Configure store &amp; points</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>
    <?php endif; ?>

  </div>
</div>

<div class="m-section-title">Account</div>

<div class="m-card mb-3">
  <div class="m-card-body" style="padding:.5rem 0">

    <div class="m-menu-row" style="cursor:default">
      <div class="m-menu-icon bg-light text-secondary">
        <i class="bi bi-person-circle"></i>
      </div>
      <div>
        <div class="fw-semibold"><?= e($_SESSION['full_name'] ?? $_SESSION['username']) ?></div>
        <div class="text-muted small"><?= ucfirst($role) ?></div>
      </div>
    </div>

    <a href="<?= BASE_URL ?>/dashboard.php?desktop=1" class="m-menu-row">
      <div class="m-menu-icon bg-light text-secondary">
        <i class="bi bi-display"></i>
      </div>
      <div class="flex-grow-1">
        <div class="fw-semibold">Desktop View</div>
        <div class="text-muted small">Switch to full desktop interface</div>
      </div>
      <i class="bi bi-chevron-right text-muted"></i>
    </a>

    <a href="<?= BASE_URL ?>/logout.php" class="m-menu-row text-danger">
      <div class="m-menu-icon bg-danger-subtle text-danger">
        <i class="bi bi-box-arrow-right"></i>
      </div>
      <div class="flex-grow-1 text-danger fw-semibold">Logout</div>
      <i class="bi bi-chevron-right text-danger"></i>
    </a>

  </div>
</div>

<div class="text-center text-muted mt-4" style="font-size:.7rem">
  Rewards System v<?= APP_VER ?> — Mobile
</div>

<?php include __DIR__ . '/includes/m_footer.php'; ?>
