<?php
if ( ! defined( 'ABSPATH' ) ) exit;
/**
 * 🔹 Admin Page: Reusable Templates (Section Builder)
 */
class Sifency_Section_Builder_Admin {
	
	public function render_admin_page() {

		$tabs = [
			'all'   => [ 'label' => __( 'All Sections', 'sifency-addons' ), 'icon' => 'dashicons-layout' ],
			'trash' => [ 'label' => __( 'Trash', 'sifency-addons' ), 'icon' => 'dashicons-trash' ],
		];

		$active_tab = 'all';
		if ( isset( $_GET['tab'] ) ) {
			$active_tab = sanitize_key( wp_unslash( $_GET['tab'] ) );
			$allowed_tabs = [ 'all', 'trash' ];

			if ( ! in_array( $active_tab, $allowed_tabs, true ) ) {
				$active_tab = 'all';
			}
		}

		?>
		<div class="sifency-admin-page">
			<div class="sifency-dashboard-layout">
				<nav class="sifency-dashboard-nav">
					<?php foreach ( $tabs as $tab_slug => $tab_data ) : ?>
						<a href="<?php echo esc_url( admin_url( 'admin.php?page=sifency-templates-shortcode&tab=' . $tab_slug ) ); ?>" 
						class="sifency-nav-item sifency-admin-btn <?php echo $active_tab === $tab_slug ? 'is-active' : ''; ?>">
							
							<?php if ( ! empty( $tab_data['icon'] ) ) : ?>
								<span class="sifency-nav-item-icon dashicons <?php echo esc_attr( $tab_data['icon'] ); ?>"></span>
							<?php endif; ?>

							<span class="sifency-nav-item-label"><?php echo esc_html( $tab_data['label'] ); ?></span>
						</a>
					<?php endforeach; ?>
				</nav>

				<div class="sifency-dashboard-content">
					<?php sifency_addons_render_section_tab_content( $active_tab ); ?>
				</div>
			</div>

            <?php 
            sifency_addons_render_new_section_modal(); 
            ?>
		</div>
		<?php
	}
}