<?php
/**
 * Admin sidebar navigation.
 *
 * Variable available: $current_page.
 *
 * @package PrivexPasswordProtect
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Helper: allowed SVG tags for wp_kses output.
 *
 * @return array
 */
if ( ! function_exists( 'ppmstr_allowed_svg_tags' ) ) {
	function ppmstr_allowed_svg_tags() {
		return array(
			'svg'      => array( 'width' => true, 'height' => true, 'viewBox' => true, 'viewbox' => true, 'fill' => true, 'xmlns' => true, 'stroke' => true, 'stroke-width' => true ),
			'path'     => array( 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true ),
			'rect'     => array( 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'fill' => true, 'stroke' => true ),
			'circle'   => array( 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, 'stroke' => true ),
			'line'     => array( 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, 'stroke' => true ),
			'polyline' => array( 'points' => true, 'fill' => true, 'stroke' => true ),
		);
	}
}

$ppmstr_nav_items = array(
	'dashboard'    => array(
		'label' => __( 'Dashboard', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>',
	),
	'settings'     => array(
		'label' => __( 'Settings', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>',
	),
	'passwords'    => array(
		'label' => __( 'Passwords', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.78 7.78 5.5 5.5 0 0 1 7.78-7.78zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/></svg>',
	),
	'templates'    => array(
		'label' => __( 'Templates', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/></svg>',
	),
	'analytics'    => array(
		'label' => __( 'Analytics', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>',
	),
	'security'     => array(
		'label' => __( 'Security', 'privex-password-protect' ),
		'icon'  => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>',
	),
);
?>
<nav class="ppmstr-admin-sidebar" role="navigation" aria-label="<?php esc_attr_e( 'Plugin navigation', 'privex-password-protect' ); ?>">
	<ul class="ppmstr-nav-list">
		<?php foreach ( $ppmstr_nav_items as $ppmstr_slug => $ppmstr_item ) : ?>
			<li class="ppmstr-nav-item<?php echo ( $current_page === $ppmstr_slug ) ? ' ppmstr-nav-active' : ''; ?>">
				<a href="<?php echo esc_url( admin_url( 'admin.php?page=ppmstr-' . $ppmstr_slug ) ); ?>">
					<span class="ppmstr-nav-icon"><?php echo wp_kses( $ppmstr_item['icon'], ppmstr_allowed_svg_tags() ); ?></span>
					<span class="ppmstr-nav-label"><?php echo esc_html( $ppmstr_item['label'] ); ?></span>
				</a>
			</li>
		<?php endforeach; ?>
	</ul>
</nav>
