<?php
/**
 * Security Logs Admin Page
 * Combined Activity Log + Firewall Blocks
 *
 * @package Bearmor_Security
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Check if Pro feature is available
$is_pro = Bearmor_License::is_pro();

// === ACTIVITY LOG ===
// Get filter parameters
$action_filter = isset( $_GET['action_filter'] ) ? sanitize_text_field( $_GET['action_filter'] ) : '';
$user_filter = isset( $_GET['user_filter'] ) ? intval( $_GET['user_filter'] ) : 0;
$search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';

// Pagination
$per_page = 25; // Reduced to fit side-by-side
$current_page = isset( $_GET['paged'] ) ? max( 1, intval( $_GET['paged'] ) ) : 1;
$offset = ( $current_page - 1 ) * $per_page;

// Build query args
$args = array(
	'limit'  => $per_page,
	'offset' => $offset,
);

if ( $action_filter ) {
	$args['action'] = $action_filter;
}

if ( $user_filter ) {
	$args['user_id'] = $user_filter;
}

if ( $search ) {
	$args['search'] = $search;
}

// Get logs
$logs = Bearmor_Activity_Log::get_logs( $args );
$total_items = Bearmor_Activity_Log::get_count( $args );
$total_pages = ceil( $total_items / $per_page );

// Get unique actions for filter
global $wpdb;
$actions = $wpdb->get_col( "SELECT DISTINCT action FROM {$wpdb->prefix}bearmor_activity_log ORDER BY action" );

// Get users for filter
$users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );

// === FIREWALL BLOCKS ===
$firewall_per_page = 25;
$firewall_page = isset( $_GET['firewall_paged'] ) ? max( 1, intval( $_GET['firewall_paged'] ) ) : 1;
$firewall_offset = ( $firewall_page - 1 ) * $firewall_per_page;

$firewall_blocks = $wpdb->get_results(
	$wpdb->prepare(
		"SELECT * FROM {$wpdb->prefix}bearmor_firewall_blocks 
		ORDER BY blocked_at DESC 
		LIMIT %d OFFSET %d",
		$firewall_per_page,
		$firewall_offset
	)
);

$firewall_total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_firewall_blocks" );
$firewall_total_pages = ceil( $firewall_total / $firewall_per_page );

// Enqueue CSS and dashicons
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'bearmor-dashboard', plugins_url( 'assets/css/dashboard.css', dirname( __FILE__ ) ), array(), '1.0.0' );
?>

<div class="wrap">
	<h1>Security Logs</h1>

	<!-- Tabs Navigation -->
	<nav class="nav-tab-wrapper">
		<a href="?page=bearmor-security-logs&tab=activity" class="nav-tab <?php echo (!isset($_GET['tab']) || $_GET['tab'] === 'activity') ? 'nav-tab-active' : ''; ?>">
			<span class="dashicons dashicons-clock" style="color: #7267EF;"></span> Activity Log
		</a>
		<a href="?page=bearmor-security-logs&tab=firewall" class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] === 'firewall') ? 'nav-tab-active' : ''; ?>">
			<span class="dashicons dashicons-shield" style="color: #7267EF;"></span> Firewall Blocks
		</a>
	</nav>

	<div class="tab-content">
		<?php
		$tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'activity';
		
		if ($tab === 'activity') {
			// Activity Log Tab
			?>
			<!-- Filters -->
			<div class="bearmor-widget" style="padding: 16px; margin-bottom: 15px;">
				<form method="get" style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
					<input type="hidden" name="page" value="bearmor-security-logs">
					<input type="hidden" name="tab" value="activity">
					
					<select name="action_filter" class="bearmor-select">
						<option value="">All Actions</option>
						<?php foreach ( $actions as $action ) : ?>
					<option value="<?php echo esc_attr( $action ); ?>" <?php selected( $action_filter, $action ); ?>>
						<?php echo esc_html( wp_strip_all_tags( Bearmor_Activity_Log::get_action_label( $action ) ) ); ?>
					</option>
						<?php endforeach; ?>
					</select>
					
					<select name="user_filter" class="bearmor-select">
						<option value="0">All Users</option>
						<?php foreach ( $users as $user ) : ?>
						<option value="<?php echo esc_attr( $user->ID ); ?>" <?php selected( $user_filter, $user->ID ); ?>>
							<?php echo esc_html( $user->user_login ); ?>
						</option>
						<?php endforeach; ?>
					</select>
					
					<input type="text" name="s" value="<?php echo esc_attr( $search ); ?>" placeholder="Search..." class="bearmor-input">
					
					<button type="submit" class="bearmor-button bearmor-button-primary">Filter</button>
					<a href="?page=bearmor-security-logs&tab=activity" class="bearmor-button bearmor-button-secondary">Clear</a>
				</form>
			</div>
			
			<div style="margin-left: auto; color: #666; font-size: 13px;">
				Total: <?php echo esc_html( number_format( $total_items ) ); ?> records
				<?php
				$total_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_activity_log" );
				if ( $total_count >= Bearmor_Activity_Log::MAX_RECORDS ) {
					echo ' <span style="color: #d63638;">(Limit: ' . esc_html( Bearmor_Activity_Log::MAX_RECORDS ) . ')</span>';
				}
				?>
			</div>
		</div>

	<!-- Activity Log Table -->
	<table class="wp-list-table widefat fixed striped">
			<thead>
				<tr>
					<th style="width: 110px;">User</th>
					<th>Action</th>
					<th>Details</th>
					<th style="width: 90px;">IP</th>
				</tr>
			</thead>
			<tbody>
				<?php if ( empty( $logs ) ) : ?>
					<tr>
						<td colspan="4" style="text-align: center; padding: 40px; color: #666;">
							No activity logs found
							<?php if ( $action_filter || $user_filter || $search ) : ?>
								<br><small>Try adjusting your filters</small>
							<?php endif; ?>
						</td>
					</tr>
				<?php else : ?>
					<?php foreach ( $logs as $log ) : ?>
						<?php $is_critical = ( $log->action === 'plugin_auto_disabled' ); ?>
						<tr<?php echo $is_critical ? ' style="background: #fff5f5; border-left: 3px solid #d63638;"' : ''; ?>>
							<td>
								<?php if ( $log->user_id ) : ?>
									<strong><?php echo esc_html( $log->user_login ); ?></strong><br>
									<small style="color: #666;">ID: <?php echo esc_html( $log->user_id ); ?></small>
								<?php else : ?>
									<em style="color: #666;">System</em>
								<?php endif; ?>
							</td>
							<td>
								<span style="background: #e7f3ff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600; color: #0073aa;">
									<?php echo esc_html( wp_strip_all_tags( Bearmor_Activity_Log::get_action_label( $log->action ) ) ); ?>
								</span>
							</td>
							<td>
								<?php echo esc_html( wp_strip_all_tags( $log->details ) ); ?>
								<?php if ( $log->ip_address ) : ?>
									<br><code style="background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: 11px;"><?php echo esc_html( $log->ip_address ); ?></code>
								<?php endif; ?>
							</td>
							<td>
								<?php if ( $log->ip_address ) : ?>
									<code><?php echo esc_html( $log->ip_address ); ?></code>
								<?php else : ?>
									<em style="color: #666;">—</em>
								<?php endif; ?>
							</td>
						</tr>
					<?php endforeach; ?>
				<?php endif; ?>
			</tbody>
		</table>
	</div>

	<!-- Pagination -->
	<?php if ( $total_pages > 1 ) : ?>
		<div class="bearmor-pagination">
			<?php
			for ( $i = 1; $i <= $total_pages; $i++ ) {
				$class = $i === $current_page ? 'current' : '';
				$url = add_query_arg( array(
					'page'          => 'bearmor-security-logs',
					'tab'           => 'activity',
					'paged'         => $i,
					'action_filter' => $action_filter,
					'user_filter'   => $user_filter,
					's'             => $search,
				), admin_url( 'admin.php' ) );
				?>
				<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $class ); ?>">
					<?php echo esc_html( $i ); ?>
				</a>
				<?php
			}
			?>
		</div>
	<?php endif; ?>
		<?php
		} elseif ($tab === 'firewall') {
			// Firewall Blocks Tab
			?>
			
			<?php if ( ! $is_pro ) : ?>
				<!-- Pro Feature Overlay -->
				<div style="
					background: #f5f5f5;
					border: 2px solid #ddd;
					border-radius: 8px;
					padding: 30px;
					text-align: center;
					margin: 20px 0;
				">
					<h3 style="margin: 0 0 10px 0;">🔒 Pro Feature</h3>
					<p style="margin: 0 0 15px 0;">Firewall logging is available in Pro version only.</p>
					<a href="?page=bearmor-license" class="button button-primary">Upgrade to Pro</a>
				</div>
			<?php else : ?>
				<!-- Firewall Stats -->
				<div class="bearmor-widget" style="padding: 16px; margin-bottom: 15px;">
					<div style="display: flex; justify-content: space-between; font-size: 12px;">
						<span><strong>Total Blocks:</strong> <?php echo number_format( $firewall_total ); ?></span>
						<span><strong>Last 24h:</strong> <?php
							$last_24h = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_firewall_blocks WHERE blocked_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)" );
							echo number_format( $last_24h );
						?></span>
					</div>
				</div>
				
				<!-- Firewall Table -->
				<table class="wp-list-table widefat fixed striped">
						<thead>
							<tr>
								<th style="width: 100px;">Time</th>
								<th style="width: 100px;">IP Address</th>
								<th>Rule Matched</th>
								<th>Request URI</th>
							</tr>
						</thead>
							<tbody>
								<?php if ( empty( $firewall_blocks ) ) : ?>
									<tr>
										<td colspan="4" style="text-align: center; padding: 40px; color: #666;">
											No firewall blocks yet
										</td>
									</tr>
								<?php else : ?>
									<?php foreach ( $firewall_blocks as $block ) : ?>
										<tr>
											<td>
												<strong><?php echo esc_html( date( 'M d', strtotime( $block->blocked_at ) ) ); ?></strong><br>
												<small style="color: #666;"><?php echo esc_html( date( 'H:i', strtotime( $block->blocked_at ) ) ); ?></small>
											</td>
											<td>
												<code><?php echo esc_html( $block->ip_address ); ?></code>
											</td>
											<td>
												<span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">
													<?php echo esc_html( $block->rule_matched ); ?>
												</span>
											</td>
											<td>
												<code style="font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;">
													<?php echo esc_html( $block->request_uri ); ?>
												</code>
											</td>
										</tr>
									<?php endforeach; ?>
								<?php endif; ?>
							</tbody>
						</table>
				
				<!-- Firewall Pagination -->
				<?php if ( $firewall_total_pages > 1 ) : ?>
					<div class="bearmor-pagination">
						<?php
						for ( $i = 1; $i <= $firewall_total_pages; $i++ ) {
							$class = $i === $firewall_page ? 'current' : '';
							$url = add_query_arg( array(
								'page' => 'bearmor-security-logs',
								'tab' => 'firewall',
								'firewall_paged' => $i,
							), admin_url( 'admin.php' ) );
							?>
							<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $class ); ?>">
								<?php echo esc_html( $i ); ?>
							</a>
							<?php
						}
						?>
					</div>
				<?php endif; ?>
			<?php
			} elseif ($tab === 'firewall') {
				// Firewall Blocks Tab
				?>
				
				<?php if ( ! $is_pro ) : ?>
					<!-- Pro Feature Overlay -->
					<div style="
						background: #f5f5f5;
						border: 2px solid #ddd;
						border-radius: 8px;
						padding: 30px;
						text-align: center;
						margin: 20px 0;
					">
						<h3 style="margin: 0 0 10px 0;">🔒 Pro Feature</h3>
						<p style="margin: 0 0 15px 0;">Firewall logging is available in Pro version only.</p>
						<a href="?page=bearmor-license" class="button button-primary">Upgrade to Pro</a>
					</div>
				<?php else : ?>
					<!-- Firewall Stats -->
					<div class="bearmor-widget" style="padding: 16px; margin-bottom: 15px;">
						<div style="display: flex; justify-content: space-between; font-size: 12px;">
							<span><strong>Total Blocks:</strong> <?php echo number_format( $firewall_total ); ?></span>
							<span><strong>Last 24h:</strong> <?php
								$last_24h = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_firewall_blocks WHERE blocked_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)" );
								echo number_format( $last_24h );
							?></span>
						</div>
					</div>
					
					<!-- Firewall Table -->
					<table class="wp-list-table widefat fixed striped">
							<thead>
								<tr>
									<th style="width: 100px;">Time</th>
									<th style="width: 100px;">IP Address</th>
									<th>Rule Matched</th>
									<th>Request URI</th>
								</tr>
							</thead>
								<tbody>
									<?php if ( empty( $firewall_blocks ) ) : ?>
										<tr>
											<td colspan="4" style="text-align: center; padding: 40px; color: #666;">
												No firewall blocks yet
											</td>
										</tr>
									<?php else : ?>
										<?php foreach ( $firewall_blocks as $block ) : ?>
											<tr>
												<td>
													<strong><?php echo esc_html( date( 'M d', strtotime( $block->blocked_at ) ) ); ?></strong><br>
													<small style="color: #666;"><?php echo esc_html( date( 'H:i', strtotime( $block->blocked_at ) ) ); ?></small>
												</td>
												<td>
													<code><?php echo esc_html( $block->ip_address ); ?></code>
												</td>
												<td>
													<span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">
														<?php echo esc_html( $block->rule_matched ); ?>
													</span>
												</td>
												<td>
													<code style="font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;">
														<?php echo esc_html( $block->request_uri ); ?>
													</code>
												</td>
											</tr>
										<?php endforeach; ?>
									<?php endif; ?>
								</tbody>
							</table>
					
					<!-- Firewall Pagination -->
					<?php if ( $firewall_total_pages > 1 ) : ?>
						<div class="bearmor-pagination">
							<?php
							for ( $i = 1; $i <= $firewall_total_pages; $i++ ) {
								$class = $i === $firewall_page ? 'current' : '';
								$url = add_query_arg( array(
									'page' => 'bearmor-security-logs',
									'tab' => 'firewall',
									'firewall_paged' => $i,
								), admin_url( 'admin.php' ) );
								?>
								<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $class ); ?>">
									<?php echo esc_html( $i ); ?>
								</a>
								<?php
							}
							?>
						</div>
					<?php endif; ?>
				<?php
				}
				?>
			</div><!-- End Activity Log Column -->
	
	<!-- RIGHT: Firewall Blocks -->
	<div>
		<h2 style="margin: 0 0 15px 0;"><span class="dashicons dashicons-shield" style="color: #7267EF;"></span> Firewall Blocks</h2>
		
		<?php if ( ! $is_pro ) : ?>
			<!-- Pro Feature Overlay -->
			<div style="
				background: #f5f5f5;
				border: 2px solid #ddd;
				border-radius: 8px;
				padding: 30px;
				text-align: center;
				margin: 20px 0;
			">
				<h3 style="color: #666; margin-top: 0;">🔒 Pro Feature</h3>
				<p style="color: #999; font-size: 14px; margin: 10px 0;">
					Advanced Firewall is available for Pro members only.
				</p>
				<p style="color: #999; margin: 20px 0;">
					Block malicious requests (SQL injection, XSS, path traversal) with advanced request filtering.
				</p>
				<a href="<?php echo esc_url( admin_url( 'admin.php?page=bearmor-settings' ) ); ?>" class="button button-primary" style="background: #8269FF; border-color: #8269FF;">
					Upgrade to Pro
				</a>
			</div>
		<?php endif; ?>
<?php if ( ! $is_pro ) : ?>
<!-- Example Preview (grayed out) -->
<div style="opacity: 0.5; filter: grayscale(100%); margin-top: 20px;">
<h3 style="color: #999;">Example Firewall Blocks:</h3>
<div style="background: #fff; border: 1px solid #ccc; padding: 10px; margin-bottom: 15px; border-radius: 5px;">
<div style="display: flex; justify-content: space-between; font-size: 12px;">
<span><strong>Total Blocks:</strong> 1,247</span>
<span><strong>Last 24h:</strong> 89</span>
</div>
</div>
<table class="wp-list-table widefat fixed striped" style="font-size: 12px;"><thead><tr><th style="width: 100px;">Time</th><th style="width: 100px;">IP Address</th><th>Rule Matched</th><th>Request URI</th></tr></thead><tbody><tr><td><strong>Oct 18</strong><br><small style="color: #666;">14:32</small></td><td><code style="font-size: 10px;">203.0.113.45</code></td><td><span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">SQL Injection</span></td><td><small style="color: #666; font-size: 10px;">/ajax-endpoint?id=1 OR 1=1</small></td></tr><tr><td><strong>Oct 18</strong><br><small style="color: #666;">12:15</small></td><td><code style="font-size: 10px;">198.51.100.89</code></td><td><span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">XSS Attack</span></td><td><small style="color: #666; font-size: 10px;">/search?q=&lt;script&gt;alert()</small></td></tr></tbody></table>
<p style="text-align: center; color: #999; font-size: 11px; margin-top: 10px;"><em>Demo data - This is what you'll see with Pro</em></p>
</div>
<?php endif; ?>
		
		<?php if ( $is_pro ) : ?>
		<!-- Firewall Stats -->
		<div style="background: #fff; border: 1px solid #ccc; padding: 10px; margin-bottom: 15px; border-radius: 5px;">
			<div style="display: flex; justify-content: space-between; font-size: 12px;">
				<span><strong>Total Blocks:</strong> <?php echo number_format( $firewall_total ); ?></span>
				<span><strong>Last 24h:</strong> <?php
					$last_24h = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_firewall_blocks WHERE blocked_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)" );
					echo number_format( $last_24h );
				?></span>
			</div>
		</div>
		
		<!-- Firewall Table -->
		<table class="wp-list-table widefat fixed striped">
				<thead>
					<tr>
						<th style="width: 100px;">Time</th>
						<th style="width: 100px;">IP Address</th>
						<th>Rule Matched</th>
						<th>Request URI</th>
					</tr>
				</thead>
					<tbody>
						<?php if ( empty( $firewall_blocks ) ) : ?>
							<tr>
								<td colspan="4" style="text-align: center; padding: 40px; color: #666;">
									No firewall blocks yet
								</td>
							</tr>
						<?php else : ?>
							<?php foreach ( $firewall_blocks as $block ) : ?>
								<tr>
									<td>
										<strong><?php echo esc_html( date( 'M d', strtotime( $block->blocked_at ) ) ); ?></strong><br>
										<small style="color: #666;"><?php echo esc_html( date( 'H:i', strtotime( $block->blocked_at ) ) ); ?></small>
									</td>
									<td>
										<code style="font-size: 10px;"><?php echo esc_html( $block->ip_address ); ?></code>
									</td>
									<td>
										<span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">
											<?php echo esc_html( $block->rule_matched ); ?>
										</span>
									</td>
									<td>
										<small style="color: #666; font-size: 10px;" title="<?php echo esc_attr( $block->request_uri ); ?>">
											<?php echo esc_html( substr( $block->request_uri, 0, 40 ) ); ?><?php echo strlen( $block->request_uri ) > 40 ? '...' : ''; ?>
										</small>
									</td>
								</tr>
							<?php endforeach; ?>
						<?php endif; ?>
					</tbody>
				</table>
			</div>
			
			<!-- Firewall Pagination -->
			<?php if ( $firewall_total_pages > 1 ) : ?>
				<div class="bearmor-pagination">
					<?php
					for ( $i = 1; $i <= $firewall_total_pages; $i++ ) {
						$class = $i === $firewall_page ? 'current' : '';
						$url = add_query_arg( array(
							'page' => 'bearmor-security-logs',
							'firewall_paged' => $i,
						), admin_url( 'admin.php' ) );
						?>
						<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $class ); ?>">
							<?php echo esc_html( $i ); ?>
						</a>
						<?php
					}
					?>
				</div>
			<?php endif; ?>
		<?php
		} elseif ($tab === 'firewall') {
			// Firewall Blocks Tab
			?>
			
			<?php if ( ! $is_pro ) : ?>
				<!-- Pro Feature Overlay -->
				<div style="
					background: #f5f5f5;
					border: 2px solid #ddd;
					border-radius: 8px;
					padding: 30px;
					text-align: center;
					margin: 20px 0;
				">
					<h3 style="margin: 0 0 10px 0;">🔒 Pro Feature</h3>
					<p style="margin: 0 0 15px 0;">Firewall logging is available in Pro version only.</p>
					<a href="?page=bearmor-license" class="button button-primary">Upgrade to Pro</a>
				</div>
			<?php else : ?>
				<!-- Firewall Stats -->
				<div class="bearmor-widget" style="padding: 16px; margin-bottom: 15px;">
					<div style="display: flex; justify-content: space-between; font-size: 12px;">
						<span><strong>Total Blocks:</strong> <?php echo number_format( $firewall_total ); ?></span>
						<span><strong>Last 24h:</strong> <?php
							$last_24h = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}bearmor_firewall_blocks WHERE blocked_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)" );
							echo number_format( $last_24h );
						?></span>
					</div>
				</div>
				
				<!-- Firewall Table -->
				<table class="wp-list-table widefat fixed striped">
						<thead>
							<tr>
								<th style="width: 100px;">Time</th>
								<th style="width: 100px;">IP Address</th>
								<th>Rule Matched</th>
								<th>Request URI</th>
							</tr>
						</thead>
							<tbody>
								<?php if ( empty( $firewall_blocks ) ) : ?>
									<tr>
										<td colspan="4" style="text-align: center; padding: 40px; color: #666;">
											No firewall blocks yet
										</td>
									</tr>
								<?php else : ?>
									<?php foreach ( $firewall_blocks as $block ) : ?>
										<tr>
											<td>
												<strong><?php echo esc_html( date( 'M d', strtotime( $block->blocked_at ) ) ); ?></strong><br>
												<small style="color: #666;"><?php echo esc_html( date( 'H:i', strtotime( $block->blocked_at ) ) ); ?></small>
											</td>
											<td>
												<code><?php echo esc_html( $block->ip_address ); ?></code>
											</td>
											<td>
												<span style="background: #d63638; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;">
													<?php echo esc_html( $block->rule_matched ); ?>
												</span>
											</td>
											<td>
												<code style="font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;">
													<?php echo esc_html( $block->request_uri ); ?>
												</code>
											</td>
										</tr>
									<?php endforeach; ?>
								<?php endif; ?>
							</tbody>
						</table>
				
				<!-- Firewall Pagination -->
				<?php if ( $firewall_total_pages > 1 ) : ?>
					<div class="bearmor-pagination">
						<?php
						for ( $i = 1; $i <= $firewall_total_pages; $i++ ) {
							$class = $i === $firewall_page ? 'current' : '';
							$url = add_query_arg( array(
								'page' => 'bearmor-security-logs',
								'tab' => 'firewall',
								'firewall_paged' => $i,
							), admin_url( 'admin.php' ) );
							?>
							<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $class ); ?>">
								<?php echo esc_html( $i ); ?>
							</a>
							<?php
						}
						?>
					</div>
				<?php endif; ?>
			<?php endif; ?>
			<?php
		}
		?>
	</div><!-- End Tab Content -->
</div><!-- End Wrap -->
