<?php

/**
 * Provide a admin area view for the plugin settings
 *
 * This file is used to markup the admin-facing aspects of the plugin settings.
 *
 * @link       http://example.com
 * @since      1.0.0
 *
 * @package    Subscription_System
 * @subpackage Subscription_System/admin/partials
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<div class="wrap subscription-system-settings">
	<div class="settings-header">
		<div class="settings-header-content">
			<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
			<p class="settings-description"><?php esc_html_e( 'Configure your subscription system settings below.', 'subscription-system' ); ?></p>
		</div>
		<div class="settings-icon">
			<span class="dashicons dashicons-admin-settings"></span>
		</div>
	</div>

	<?php settings_errors( 'subs_sys_messages' ); ?>

	<div class="settings-container">
		<form method="post" action="options.php">
			<?php
			// WordPress handles nonce verification for settings automatically
			settings_fields( 'subs_sys_settings' );
			do_settings_sections( 'subs_sys_settings' );
			?>
			
			<div class="settings-section">
				<div class="section-header">
					<h2><?php esc_html_e( 'General Settings', 'subscription-system' ); ?></h2>
					<p><?php esc_html_e( 'Configure general subscription system settings.', 'subscription-system' ); ?></p>
				</div>
				
				<div class="settings-fields">
					<div class="field-group">
						<div class="field-header">
							<label for="subs_sys_enable_registration" class="field-label">
								<?php esc_html_e( 'Enable User Registration', 'subscription-system' ); ?>
							</label>
							<div class="field-description">
								<?php esc_html_e( 'Allow users to register through the subscription forms', 'subscription-system' ); ?>
							</div>
						</div>
						<div class="field-control">
							<?php $value = get_option( 'subs_sys_enable_registration', false ); ?>
							<div class="toggle-switch <?php echo $value ? 'active' : ''; ?>">
								<input type="checkbox" 
										id="subs_sys_enable_registration" 
										name="subs_sys_enable_registration" 
										value="1" 
										<?php checked( 1, $value ); ?>
										class="toggle-input" />
								<label for="subs_sys_enable_registration" class="toggle-label"></label>
							</div>
							<span class="toggle-text" 
									data-enabled-text="<?php esc_attr_e( 'Enabled', 'subscription-system' ); ?>"
									data-disabled-text="<?php esc_attr_e( 'Disabled', 'subscription-system' ); ?>">
								<?php echo $value ? esc_html__( 'Enabled', 'subscription-system' ) : esc_html__( 'Disabled', 'subscription-system' ); ?>
							</span>
						</div>
					</div>
				</div>
			</div>

			<div class="settings-actions">
				<?php submit_button( esc_html__( 'Save Settings', 'subscription-system' ), 'primary', 'submit', false, array( 'class' => 'button-save' ) ); ?>
			</div>
		</form>
	</div>

	<!-- Settings Info Sidebar -->
	<div class="settings-sidebar">
		<div class="sidebar-section">
			<h3><?php esc_html_e( 'Quick Help', 'subscription-system' ); ?></h3>
			<div class="help-items">
				<div class="help-item">
					<span class="dashicons dashicons-info"></span>
					<div>
						<strong><?php esc_html_e( 'User Registration', 'subscription-system' ); ?></strong>
						<p><?php esc_html_e( 'When enabled, users can create accounts through your subscription forms.', 'subscription-system' ); ?></p>
					</div>
				</div>
			</div>
		</div>

		<div class="sidebar-section">
			<h3><?php esc_html_e( 'Need Help?', 'subscription-system' ); ?></h3>
			<div class="help-links">
				<a href="<?php echo esc_url( admin_url( 'admin.php?page=subs-sys-mh-help' ) ); ?>" class="help-link">
					<span class="dashicons dashicons-book"></span>
					<?php esc_html_e( 'View Documentation', 'subscription-system' ); ?>
				</a>
				<a href="<?php echo esc_url( admin_url( 'admin.php?page=subs-sys' ) ); ?>" class="help-link">
					<span class="dashicons dashicons-dashboard"></span>
					<?php esc_html_e( 'Back to Dashboard', 'subscription-system' ); ?>
				</a>
			</div>
		</div>
	</div>
</div> 