<?php
/**
 * Admin View: Settings Extensions
 * @package    CodexShaper_Framework
 * @author     CodexShaper <info@codexshaper.com>
 * @license    https://www.gnu.org/licenses/gpl-2.0.html
 * @link       https://codexshaper.com
 * @since      1.0.0
 */

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

$modules = get_option( 'csmf_module_settings' ) ?? array();

if ( ! is_array( $modules)) {
	$modules = array();
}

$module_option_name = csmf_config( 'options.module.option_name' ) ?? 'csmf_modules_settings';
?>
<form action="POST" class="csmf--settings" name="<?php echo esc_attr($module_option_name); ?>">
	<div class="settings-wrapper">
		<div class="settings-header">
			<h3 class="settings-title"><?php echo esc_html__( 'Module Settings', 'codexshaper-framework' ); ?></h3>
			<div class="header-right">
				<div class="switcher-wrapper"></div>
				<div class="actions-wrapper">
					<button type="button" class="csmf--f-btn csmf--f-btn-primary csmf--module-settings-save">
						<?php esc_html_e( 'Save', 'codexshaper-framework' ); ?>
					</button>
					<button type="button" class="csmf--f-btn csmf--f-btn-primary csmf--module-settings-refresh">
						<?php esc_html_e( 'Refresh', 'codexshaper-framework' ); ?>
					</button>
					<button type="button" class="csmf--f-btn csmf--f-btn-primary csmf--module-settings-reset">
						<?php esc_html_e( 'Reset', 'codexshaper-framework' ); ?>
					</button>
				</div>
			</div>
		</div>
		<div class="settings-group">
			<!-- <h3 class="csmf-page-title">Widget <?php // echo esc_html( get_admin_page_title() ); ?></h3> -->
			<div class="csmf--grid csmf--gap-28">
				<?php
				foreach ( $modules as $key => $module ) :
					?>
					<div class="csmf--col-span-12 sm:csmf--col-span-6 xl:csmf--col-span-4 xxl:csmf--col-span-3">
						<div class="csmf-card csmf-widget-card csmf-d-flex csmf-justify-between csmf-items-center">
							<h2 class="csmf-card-title text-left"><?php echo esc_html( $module['title'] ?? '' ); ?></h2>
							<label class="csmf--switcher switcher-border">
								<input type="checkbox" class="switcher-input" name="<?php echo esc_attr( $key ); ?>" value="1" <?php checked( true, $module['is_active'] ); ?> >
								<span class="switcher-label" data-on="Yes" data-off="No"></span>
								<span class="switcher-indicator"></span>
							</label>
						</div>
					</div>
				<?php endforeach; ?>
			</div>

			<!-- Footer -->
			<div class="csmf-footer-bottom">
				<p class="csmf-copyright">Copyright © <?php echo esc_html( getdate()['year'] ); ?>. CodexShaper All Rights Reserved</p>
			</div>
		</div>
	</div>
</form>


