<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } if (empty($faqs)): ?> <div style="text-align:center;padding:40px;color:rgba(200,204,212,.3)"> <p style="font-size:12px;font-weight:700">No FAQs found</p> <p style="font-size:10px;margin-top:4px">Create your first FAQ entry above.</p> </div><?php else: ?> <?php foreach ($faqs as $fq): $scopeClass = $fq['store_id'] === null ? 'faq-scope-universal' : 'faq-scope-store'; $scopeLabel = $fq['store_id'] === null ? 'UNIVERSAL' : ($storeNameMap[(string)$fq['store_id']] ?? 'Store #' . $fq['store_id']); $storeColor = '#60a5fa'; if ($fq['store_id'] !== null) { foreach ($faqStores as $s) { if ((int)$s['id'] === (int)$fq['store_id']) { $storeColor = $s['color']; break; } } } ?> <div class="faq-card<?= !$fq['is_active'] ? ' faq-card-inactive' : '' ?>"> <div class="faq-card-top"> <span class="faq-card-order">#<?= $fq['display_order'] ?></span> <span class="faq-card-q"><?= htmlspecialchars($fq['question']) ?></span> <div class="faq-card-meta"><?php if ($fq['tab_group']): ?> <span class="faq-tab-group"><?= htmlspecialchars($fq['tab_group']) ?></span><?php endif; ?> <span class="faq-scope <?= $scopeClass ?>"<?= $fq['store_id'] !== null ? 'style="background:rgba(' . implode(',', array_map('hexdec', str_split(ltrim($storeColor, '#'), 2))) . ',.08);color:' . $storeColor . ';border-color:' . $storeColor . '33"' : '' ?>><?= htmlspecialchars($scopeLabel) ?></span> </div> </div> <div class="faq-card-a"><?= htmlspecialchars(mb_substr($fq['answer'], 0, 200)) ?><?= mb_strlen($fq['answer']) > 200 ? '...' : '' ?></div> <div class="faq-card-footer"> <span class="faq-card-id">fq_<?= htmlspecialchars($fq['public_id']) ?></span> <div class="faq-card-actions"> <form method="POST" style="display:inline"><?= CSRF::field() ?><input type="hidden" name="faq_action" value="toggle"><input type="hidden" name="faq_id" value="<?= $fq['id'] ?>"><button type="submit" class="btn btn-sm btn-ghost" title="Toggle visibility"></button></form> <a href="?view=faq&edit=<?= $fq['id'] ?>&faq_filter=<?= urlencode($faqFilter) ?>" class="btn btn-sm btn-ghost" title="Edit"></a> <form method="POST" style="display:inline" data-confirm="Delete this FAQ?"><?= CSRF::field() ?><input type="hidden" name="faq_action" value="delete"><input type="hidden" name="faq_id" value="<?= $fq['id'] ?>"><button type="submit" class="btn btn-sm btn-danger" title="Delete"></button></form> </div> </div> </div><?php endforeach; ?> <?php endif; ?>