<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div id="kirilkirkov" class="wrap">
    <form method="post" action="options.php" enctype="multipart/form-data">
        <div class="header p-4 flex items-center space-between">
            <div class="flex items-center">
                <img class="logo" src="<?php echo esc_url(plugins_url('/Assets/Img/logo.svg', __FILE__ )); ?>" alt="<?php echo esc_attr( 'WP Invoices' ) ?>" />
             </div>
            
            <button type="submit" class="button-primary"><?php esc_html_e( 'Save', 'kirilkirkov-pdf-invoice-manager' ) ?></button>
        </div>
    
        <div class="flex flex-wrap">
            
            <div class="w-full md:w-3/4">
                <div class="section-header p-4">
                    <strong><?php esc_html_e( 'WordPress Invoices by Kiril Kirkov', 'kirilkirkov-pdf-invoice-manager' ) ?></strong>
                    <p>
                        <?php esc_html_e('Electronic invoicing and warehouse management system, pdf downloads, etc.', 'kirilkirkov-pdf-invoice-manager' ) ?>
                    </p>
                </div>

                <div class="section-body bg-gray">
                
                    <div class="nav-tab-wrapper">
                        <?php 
                            // No nonce verification needed here – only reading a safe GET param for tab.
			                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
                            $kirilkirkovwipdf_active_tab = isset( $_GET[ "tab"] ) ? sanitize_text_field(wp_unslash($_GET["tab"])) : "invoices";
                            $kirilkirkovwipdf_active_invoices = ($kirilkirkovwipdf_active_tab == 'invoices' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_clients_page = ($kirilkirkovwipdf_active_tab == 'clients_page' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_company = ($kirilkirkovwipdf_active_tab == 'company' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_templates = ($kirilkirkovwipdf_active_tab == 'templates' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_woocommerce = ($kirilkirkovwipdf_active_tab == 'woocommerce' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_payments = ($kirilkirkovwipdf_active_tab == 'payments' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_currency_exhange = ($kirilkirkovwipdf_active_tab == 'currency_exhange' ? 'nav-tab-active':'');
                            $kirilkirkovwipdf_active_api_integration = ($kirilkirkovwipdf_active_tab == 'api-integration' ? 'nav-tab-active':'');
                        ?>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=invoices" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_invoices)); ?>">
                            <?php esc_html_e( 'Invoices', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=clients_page" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_clients_page)); ?>">
                            <?php esc_html_e( 'Clients Page', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=company" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_company)); ?>">
                            <?php esc_html_e( 'Company', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=templates" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_templates)); ?>">
                            <?php esc_html_e( 'Templates', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=woocommerce" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_woocommerce)); ?>">
                            <?php esc_html_e( 'WooCommerce', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=payments" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_payments)); ?>">
                            <?php esc_html_e( 'Payments', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=currency_exhange" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_currency_exhange)); ?>">
                            <?php esc_html_e( 'Currency Exchange', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                        <a href="?page=<?php echo esc_attr(sanitize_text_field($Config::SETTINGS_GET_PARAM)); ?>&tab=api-integration" class="nav-tab <?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_active_api_integration)); ?>">
                            <?php esc_html_e( 'Api Integration', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                    </div>
                    
                    <div class="p-4">

                        <?php 
                            if($kirilkirkovwipdf_active_tab === "invoices") {
                                do_settings_sections('invoices'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "clients_page") {
                                do_settings_sections('clients_page'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "company") {
                                do_settings_sections('company'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "templates") {
                                do_settings_sections('templates'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "woocommerce") {
                                do_settings_sections('woocommerce'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "payments") {
                                do_settings_sections('payments'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "api-integration") {
                                do_settings_sections('api-integration'); 
                            }
                            elseif($kirilkirkovwipdf_active_tab === "currency_exhange") {
                                do_settings_sections('currency_exhange'); 
                            }
                            else {
                                esc_html_e( 'Page not found', 'kirilkirkov-pdf-invoice-manager' );
                            }
                        ?>

                        <input type="hidden" name="action" value="update" />
                        
                        <div class="flex justify-end">
                            <button type="submit" class="button-primary"><?php esc_html_e( 'Save', 'kirilkirkov-pdf-invoice-manager' ) ?></button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="w-full md:w-1/4 ad-col">
                <div class="p-4">
                    <div class="ad-box p-4 flex flex-wrap items-center justify-between mb-4">
                        <a href="https://codecanyon.net/user/kirilkirkov/portfolio" class="accent-button w-full" target="_blank">
                            <?php esc_html_e( 'Explore More Plugins', 'kirilkirkov-pdf-invoice-manager' ); ?>
                        </a>
                    </div>

                    <div class="ad-box p-4 flex flex-wrap items-center justify-between">
                        <p class="m-0 mb-4 text-center"><?php esc_html_e( 'Increase Shopify AOV across Product, Cart, Checkout & Post-Purchase with intelligent upsells, Bought Together, Spin to Win, Free Shipping Bar or Delivery Estimator. Just $9/month - 14 days free.', 'kirilkirkov-wp-invoices' ); ?></p>
                        <a href="https://apps.shopify.com/smartsellio" class="w-full" target="_blank">
                            <img class="w-full rounded-sm" src="<?php echo plugins_url('/Assets/Img/smartsellio-banner.png', __FILE__ ); ?>" alt="<?php echo esc_attr( 'SmartSellio - Shopify Upsell & Cross-Sell' ) ?>" />
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </form>

    <?php
        require 'Views/InfoModal.php'
    ?>

</div>