<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } RBAC::enforce('view.support'); require_once __DIR__.'/../modules/support/thread_viewer.php'; require_once __DIR__.'/../modules/support/thread_intelligence.php'; require_once __DIR__.'/../modules/support/thread_replies.php'; require_once __DIR__.'/../modules/support/thread_state_manager.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message']) && isset($_GET['thread_id'])) { CSRF::enforce(); $threadId = (int)$_GET['thread_id']; sendReply($threadId, $_POST['message']); header('Location: ?view=support&thread_id=' . $threadId); exit; } $threadId = (int)($_GET['thread_id'] ?? 0); ?> <div class="workspace" id="ws-support"> <div class="workspace-header"> <h1>Support</h1><?php if ($threadId > 0): ?> <div class="workspace-actions"> <a href="?view=support" class="btn btn-sm" style="background:rgba(255,255,255,0.1); border-radius:4px; padding:6px 12px; text-decoration:none; color:#fff;">Back to Inbox</a> </div><?php endif; ?> </div><?php if ($threadId > 0): ?> <div id="support-thread" class="panel"> <div style="display: flex; gap: 20px;"> <div style="flex: 2;"><?php echo renderThread($threadId); ?> <div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1);"><?php echo renderReplyForm($threadId); ?> </div> </div> <div style="flex: 1; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 20px;"><?php  if (function_exists('renderCustomerIntelligence')) { echo renderCustomerIntelligence($threadId); } ?> </div> </div> </div><?php else: ?> <div id="support-inbox" class="panel"><?php require_once __DIR__.'/../modules/support/inbox_list.php'; ?> </div><?php endif; ?> </div> <script src="/assets/js/inbox_logic.js" nonce="<?= $cspNonce ?? '' ?>"></script>