<?php
$label = function ($key, $fallback) {
	$value = __($key, true);
	return !empty($value) && $value !== $key ? $value : $fallback;
};
$sections = array(
	array(
		'id' => 'dashboard',
		'icon' => 'fa-th-large',
		'title' => $label('help_section_dashboard', 'Dashboard'),
		'path' => $label('help_path_dashboard', 'Dashboard'),
		'body' => $label('help_section_dashboard_body', 'The Dashboard is the first admin overview. Use it to quickly check store activity, recent orders, system shortcuts, and the main areas that need attention after login.'),
		'items' => array(
			$label('help_dashboard_item_1', 'Start here after login to confirm the store is running normally.'),
			$label('help_dashboard_item_2', 'Use dashboard shortcuts to move into orders, products, reports, or settings.'),
			$label('help_dashboard_item_3', 'If demo data is enabled, use Remove demo data only when you are ready to clean the sample records.'),
		),
	),
	array(
		'id' => 'orders',
		'icon' => 'fa-list',
		'title' => $label('help_section_orders', 'Orders'),
		'path' => $label('help_path_orders', 'Orders > All orders'),
		'body' => $label('help_section_orders_body', 'Use Orders to review purchases, update status, confirm payments, manage order notes, and open order details. The order total follows the current shopping cart structure: product subtotal, discount, shipping or insurance, tax when configured, and final total.'),
		'items' => array(
			$label('help_orders_item_1', 'Click an order number to open the full order record.'),
			$label('help_orders_item_2', 'Use bulk actions only for records you intentionally want to export or delete.'),
			$label('help_orders_item_3', 'Order status changes should match the customer-facing order history and invoice flow.'),
			$label('help_orders_item_4', 'Use the frontend order history to verify what customers see after placing an order.'),
		),
	),
	array(
		'id' => 'invoices',
		'icon' => 'fa-file-text-o',
		'title' => $label('help_section_invoices', 'Invoices'),
		'path' => $label('help_path_invoices', 'Orders > Invoices'),
		'body' => $label('help_section_invoices_body', 'Invoices are generated from orders and use the same order data structure. The invoice module supports invoice listing, PDF download, email sending, and a configurable invoice template.'),
		'items' => array(
			$label('help_invoices_item_1', 'Use Orders > Invoices to download, email, delete, or review invoices.'),
			$label('help_invoices_item_2', 'Click the order number from an invoice row to open the connected order when available.'),
			$label('help_invoices_item_3', 'Use Settings > Invoice template to choose visible invoice sections and preview the PDF layout.'),
			$label('help_invoices_item_4', 'Company tokens come from Company profile and can be used in invoice and notification templates.'),
		),
	),
	array(
		'id' => 'clients',
		'icon' => 'fa-user',
		'title' => $label('help_section_clients', 'Clients'),
		'path' => $label('help_path_clients', 'Clients'),
		'body' => $label('help_section_clients_body', 'Clients are customer accounts used for login, checkout, saved addresses, order history, and repeat purchases. Keep email addresses correct because they are used for notifications and invoices.'),
		'items' => array(
			$label('help_clients_item_1', 'Open a client to review contact details and order activity.'),
			$label('help_clients_item_2', 'Billing and shipping details shown in order history come from the order record, not only the latest client profile.'),
			$label('help_clients_item_3', 'Use this area to support customers who need account or address corrections.'),
		),
	),
	array(
		'id' => 'products',
		'icon' => 'fa-cube',
		'title' => $label('help_section_products', 'Products list'),
		'path' => $label('help_path_products', 'Products > Products list'),
		'body' => $label('help_section_products_body', 'Products contain the catalog data shown in the storefront. Keep names, descriptions, prices, stock, attributes, extras, images, and active status up to date so checkout and reorder can restore the same configuration later.'),
		'items' => array(
			$label('help_products_item_1', 'Use attributes for customer selections such as size, color, or model options.'),
			$label('help_products_item_2', 'Use stock management when product variations need separate inventory.'),
			$label('help_products_item_3', 'Regenerate images after changing image sizes in Display > Images.'),
			$label('help_products_item_4', 'Keep product status and stock accurate so unavailable items cannot be purchased unintentionally.'),
		),
	),
	array(
		'id' => 'stock',
		'icon' => 'fa-archive',
		'title' => $label('help_section_stock', 'Product stock'),
		'path' => $label('help_path_stock', 'Products > Product stock'),
		'body' => $label('help_section_stock_body', 'Product stock manages quantity and stock images for sellable product variations. It is important when size, color, or other attributes create separate inventory records.'),
		'items' => array(
			$label('help_stock_item_1', 'Assign images to stock records when a variation needs its own picture.'),
			$label('help_stock_item_2', 'Update quantities before accepting live orders.'),
			$label('help_stock_item_3', 'Cart and reorder use stock IDs, so stock records must stay connected to product attributes.'),
		),
	),
	array(
		'id' => 'categories',
		'icon' => 'fa-folder-o',
		'title' => $label('help_section_categories', 'Categories'),
		'path' => $label('help_path_categories', 'Products > Categories'),
		'body' => $label('help_section_categories_body', 'Categories organize the storefront catalog and help customers browse product groups. Category structure also affects product URLs when SEO URLs are enabled.'),
		'items' => array(
			$label('help_categories_item_1', 'Create clear category names so customers can find products quickly.'),
			$label('help_categories_item_2', 'Assign products to the correct categories from the product editor.'),
			$label('help_categories_item_3', 'Review category order after importing or creating many records.'),
		),
	),
	array(
		'id' => 'vouchers',
		'icon' => 'fa-gift',
		'title' => $label('help_section_vouchers', 'Vouchers'),
		'path' => $label('help_path_vouchers', 'Vouchers'),
		'body' => $label('help_section_vouchers_body', 'Vouchers create discount codes that customers can apply in the cart. Voucher rules affect order totals, so test them before publishing promotions.'),
		'items' => array(
			$label('help_vouchers_item_1', 'Set discount type, amount, validity dates, and usage rules carefully.'),
			$label('help_vouchers_item_2', 'Use a test cart to confirm the discount is calculated correctly.'),
			$label('help_vouchers_item_3', 'Disable expired or promotional vouchers when campaigns end.'),
		),
	),
	array(
		'id' => 'reports',
		'icon' => 'fa-files-o',
		'title' => $label('help_section_reports', 'Reports'),
		'path' => $label('help_path_reports', 'Reports'),
		'body' => $label('help_section_reports_body', 'Reports summarize store activity and help review sales, order volume, product performance, and customer activity. Use the filters to focus on the period you need.'),
		'items' => array(
			$label('help_reports_item_1', 'Compare report totals with the Orders list when checking a specific date range.'),
			$label('help_reports_item_2', 'Export data from the relevant list view when you need detailed row-level records.'),
			$label('help_reports_item_3', 'Use reports after test orders are removed to avoid mixing demo data with live results.'),
		),
	),
	array(
		'id' => 'appearance',
		'icon' => 'fa-paint-brush',
		'title' => $label('help_section_appearance', 'Display'),
		'path' => $label('help_path_appearance', 'Display > Product Display, Images, Preview, Visual & Branding'),
		'body' => $label('help_section_appearance_body', 'Display controls how products, images, storefront colors, preview behavior, admin theme colors, and sidebar branding appear. These settings should stay aligned with the default Shopping Cart theme.'),
		'items' => array(
			$label('help_appearance_item_1', 'Product Display controls grid columns, listing counts, product recommendations, and pagination behavior.'),
			$label('help_appearance_item_2', 'Images controls product image sizes. After changing sizes, regenerate images so existing files are rebuilt.'),
			$label('help_appearance_item_3', 'Preview controls storefront colors and fonts. These settings affect frontend buttons, links, prices, panels, forms, cart, checkout, and order history.'),
			$label('help_appearance_item_4', 'Visual & Branding controls admin colors, table density, sidebar logo, sidebar title, and sidebar subtitle.'),
		),
	),
	array(
		'id' => 'settings',
		'icon' => 'fa-cog',
		'title' => $label('help_section_settings', 'Settings'),
		'path' => $label('help_path_settings', 'Settings > Company profile, Order settings, Payments, Checkout Form, Shipping & Tax, Terms, Notifications, Invoice template'),
		'body' => $label('help_section_settings_body', 'Settings define company profile, checkout, payment, shipping, terms, notifications, and invoice template behavior. Review settings after installation and before enabling live orders.'),
		'items' => array(
			$label('help_settings_item_1', 'Company profile controls business details used by invoices, emails, and sidebar branding.'),
			$label('help_settings_item_2', 'Order settings control order behavior, demo purchase behavior, and checkout flow rules.'),
			$label('help_settings_item_3', 'Payments controls enabled payment methods and payment configuration.'),
			$label('help_settings_item_4', 'Checkout Form controls the fields customers complete during checkout.'),
			$label('help_settings_item_5', 'Shipping & Tax controls order charges that affect totals.'),
			$label('help_settings_item_6', 'Terms stores customer-facing terms shown during checkout.'),
			$label('help_settings_item_7', 'Notifications controls customer and admin email/SMS templates and token usage.'),
			$label('help_settings_item_8', 'Invoice template controls invoice layout, visible sections, PDF preview, and default invoice content.'),
		),
	),
	array(
		'id' => 'system-options',
		'icon' => 'fa-wrench',
		'title' => $label('help_section_system_options', 'System Options'),
		'path' => $label('help_path_system_options', 'System Options > General, API Keys, Email Settings, SMS Settings, Languages, Login Protection, Captcha & Spam, Countries, Cron Jobs, Backup'),
		'body' => $label('help_section_system_options_body', 'System Options contains the base script settings that support the whole admin area. These settings affect language labels, email delivery, security, country lists, scheduled jobs, backups, and other system-level behavior.'),
		'items' => array(
			$label('help_system_options_item_1', 'General stores global script settings that should be reviewed after installation.'),
			$label('help_system_options_item_2', 'Email Settings and SMS Settings control how notifications are delivered.'),
			$label('help_system_options_item_3', 'Languages is where labels and translations are managed for multilingual-ready screens.'),
			$label('help_system_options_item_4', 'Login Protection and Captcha & Spam help protect public and admin forms.'),
			$label('help_system_options_item_5', 'Countries, Cron Jobs, and Backup support checkout data, scheduled tasks, and maintenance.'),
		),
	),
	array(
		'id' => 'users',
		'icon' => 'fa-users',
		'title' => $label('help_section_users', 'Users'),
		'path' => $label('help_path_users', 'Users'),
		'body' => $label('help_section_users_body', 'Users manages admin accounts and access permissions. Use it to control who can view, create, edit, delete, export, or configure each admin module.'),
		'items' => array(
			$label('help_users_item_1', 'Create a separate admin user for each team member instead of sharing one login.'),
			$label('help_users_item_2', 'Open user permissions to enable only the modules that user needs.'),
			$label('help_users_item_3', 'Review permissions after adding new modules such as invoices, display settings, or reports.'),
		),
	),
	array(
		'id' => 'install',
		'icon' => 'fa-code',
		'title' => $label('help_section_install', 'Install'),
		'path' => $label('help_path_install', 'Install'),
		'body' => $label('help_section_install_body', 'Install provides the integration code and preview links needed to embed the storefront into a website. Use it after configuration is complete.'),
		'items' => array(
			$label('help_install_item_1', 'Use Preview to test the store before copying installation code.'),
			$label('help_install_item_2', 'Copy the generated code into the target page where the store should appear.'),
			$label('help_install_item_3', 'Retest product browsing, cart, checkout, notifications, invoices, and order history after installation.'),
		),
	),
	array(
		'id' => 'support',
		'icon' => 'fa-wrench',
		'title' => $label('help_section_support', 'Request customization'),
		'path' => $label('help_path_support', 'Request customization'),
		'body' => $label('help_section_support_body', 'Use Request customization when the client needs changes outside normal script settings, such as custom workflows, additional fields, special invoice rules, or design changes.'),
		'items' => array(
			$label('help_support_item_1', 'Prepare a clear list of requested changes before contacting support.'),
			$label('help_support_item_2', 'Include the page URL, expected behavior, and screenshots when reporting an issue.'),
			$label('help_support_item_3', 'For code changes, confirm whether the change should affect admin, frontend, emails, invoices, or installation SQL.'),
		),
	),
);
?>
<style>
.sc-help-page .page-heading h2 { color: var(--pj-primary, #f97316); font-weight: 700; }
.sc-help-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.sc-help-nav { position: sticky; top: 20px; border: 1px solid #e7eaec; border-radius: 8px; background: #fff; overflow: hidden; }
.sc-help-nav a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid #f0f0f0; color: #333; }
.sc-help-nav a:last-child { border-bottom: 0; }
.sc-help-nav a:hover { color: var(--pj-primary, #f97316); background: #f8faf8; }
.sc-help-card { margin-bottom: 18px; border: 1px solid #e7eaec; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.sc-help-card__head { padding: 18px 20px; border-bottom: 1px solid #edf0f2; }
.sc-help-card__head h3 { margin: 0; font-size: 20px; font-weight: 700; color: #1f2933; }
.sc-help-card__body { padding: 18px 20px 20px; color: #555; font-size: 14px; line-height: 1.65; }
.sc-help-card__body ul { margin: 12px 0 0; padding-left: 20px; }
.sc-help-card__body li { margin-bottom: 6px; }
.sc-help-kicker { margin: 0 0 8px; color: var(--pj-primary, #f97316); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.sc-help-path { margin: 8px 0 0; color: #6b7280; font-size: 13px; }
.sc-help-path i { margin-right: 5px; color: var(--pj-primary, #f97316); }
@media (max-width: 991px) { .sc-help-layout { grid-template-columns: 1fr; } .sc-help-nav { position: static; } }
</style>

<div class="sc-help-page">
	<div class="row wrapper border-bottom white-bg page-heading">
		<div class="col-sm-12">
			<h2><?php echo pjSanitize::html($label('help_page_title', 'Help manual')); ?></h2>
			<p class="m-b-none"><i class="fa fa-info-circle"></i> <?php echo pjSanitize::html($label('help_page_intro', 'Use this guide to understand the main Shopping Cart admin sections and how they work together.')); ?></p>
		</div>
	</div>

	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="sc-help-layout">
			<nav class="sc-help-nav">
				<?php foreach ($sections as $section): ?>
					<a href="#<?php echo pjSanitize::html($section['id']); ?>"><i class="fa <?php echo pjSanitize::html($section['icon']); ?>"></i> <span><?php echo pjSanitize::html($section['title']); ?></span></a>
				<?php endforeach; ?>
			</nav>

			<div>
				<div class="sc-help-card" id="overview">
					<div class="sc-help-card__head">
						<p class="sc-help-kicker"><?php echo pjSanitize::html($label('help_overview_kicker', 'Overview')); ?></p>
						<h3><?php echo pjSanitize::html($label('help_overview_title', 'How the admin flow fits together')); ?></h3>
					</div>
					<div class="sc-help-card__body">
						<p><?php echo pjSanitize::html($label('help_overview_body', 'Set up products and display settings first, confirm checkout and shipping settings, then test orders, notifications, invoices, reorder, and frontend order history before going live.')); ?></p>
					</div>
				</div>

				<?php foreach ($sections as $section): ?>
					<section class="sc-help-card" id="<?php echo pjSanitize::html($section['id']); ?>">
						<div class="sc-help-card__head">
							<p class="sc-help-kicker"><i class="fa <?php echo pjSanitize::html($section['icon']); ?>"></i> <?php echo pjSanitize::html($label('help_section_kicker', 'Admin section')); ?></p>
							<h3><?php echo pjSanitize::html($section['title']); ?></h3>
							<?php if (!empty($section['path'])): ?>
								<p class="sc-help-path"><i class="fa fa-location-arrow"></i><?php echo pjSanitize::html($section['path']); ?></p>
							<?php endif; ?>
						</div>
						<div class="sc-help-card__body">
							<p><?php echo pjSanitize::html($section['body']); ?></p>
							<ul>
								<?php foreach ($section['items'] as $item): ?>
									<li><?php echo pjSanitize::html($item); ?></li>
								<?php endforeach; ?>
							</ul>
						</div>
					</section>
				<?php endforeach; ?>
			</div>
		</div>
	</div>
</div>
