<?php
  defined('ABSPATH') || die('No direct access.');
?>

<div class="swpanel-full-body">
    <div class="swpanel-header-full">
        <img class="image_full" src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/logo.svg');?>" alt="SWPanel Logo">
        <img class="image_mobile" src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/logo_symbol.svg');?>" alt="SWPanel Logo">
        <h1><?php esc_html_e("Let SWPanel's AI build your perfect website.", 'swpanel-ai'); ?></h1>
        <div id="right-header">
            <div id="steps">
                <div id="current">
                    <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/concept.svg');?>" alt="Concept Logo">
                </div>
                <div>
                    <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/structure_grey.svg');?>" alt="Structure Logo">
                </div>
                <div>
                    <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/brush_grey.svg');?>" alt="Style Logo">
                </div>
                <div>
                    <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/template_grey.svg');?>" alt="Template Logo">
                </div>
            </div>
            <?php if ( get_option('swpanel_ai_redirect', 0 ) >= 1 ) : ?>
                <a href="<?php echo esc_url(admin_url()); ?>">
                    <div id="exit">
                        <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/x.svg');?>" alt="Exit Logo">
                    </div>
                </a>
            <?php endif; ?>
        </div>
    </div>

    <div id="concept-form"> 
        <?php
        $swpanel_ai_active_theme = get_option('stylesheet');
        if ($swpanel_ai_active_theme === 'twentytwentyfive'): ?>

            <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
                <div id="concept-block"> 
                    <div class="description"><?php esc_html_e("Describe your website, project, or business in detail, and SWPanel's artificial intelligence will automatically create a professional, personalized website for you. Simply share what you have in mind and choose the tone you prefer for the content.", 'swpanel-ai'); ?></div>
                    <?php wp_nonce_field('swpanel_ai_concept'); ?>
                    <input type="hidden" name="action" value="swpanel_ai_concept_form">

                    <div class="form-field">
                        <label><?php esc_html_e("What do you want to call your website or business? Enter the name you'd like your website or project to have. This name will be used as the main reference to generate your site's content, logo, and text.", 'swpanel-ai'); ?></label>
                        <input type="text" id="site_title" name="site_title" value="<?php echo esc_attr($data['title']); ?>" class="regular-text">
                    </div>

                    <div class="form-field">
                        <label><?php esc_html_e('Briefly describe what your website is about. Tell the AI about your business, service, or project. The more details you provide, the more personalized and accurate the generated website will be.', 'swpanel-ai'); ?></label>
                        <textarea id="site_description" name="site_description" class="regular-text"><?php echo esc_textarea($data['description']); ?></textarea>
                    </div>

                    <div class="form-field">
                        <label><?php esc_html_e('Choose the writing style you want the AI to use when creating the text for your website. The tone you select will shape how your content sounds to visitors, whether professional, friendly, casual, or creative.', 'swpanel-ai'); ?></label>
                        <div class="tone-options">
                            <?php
                                $swpanel_ai_first = true;
                                foreach ($data['all_tones'] as $swpanel_ai_tone): 
                                    $swpanel_ai_is_checked = false;

                                    if (!empty($data['tone'])) {
                                        $swpanel_ai_is_checked = ($swpanel_ai_tone['title'] === $data['tone']);
                                    } elseif ($swpanel_ai_first) {
                                        $swpanel_ai_is_checked = true;
                                    }
                            ?>
                                <label class="tone-row">
                                    <input type="radio" class="tone-checkbox" 
                                        name="site_tone" 
                                        value="<?php echo esc_attr($swpanel_ai_tone['title'] ); ?>" 
                                        <?php checked($swpanel_ai_is_checked); ?>>
                                    <div class="tone-text">
                                        <span><?php echo esc_html($swpanel_ai_tone['title'] ); ?></span>
                                        <span class="tone-description"><?php echo esc_html($swpanel_ai_tone['description'] ); ?></span>
                                    </div>
                                </label>
                            <?php 
                                $swpanel_ai_first = false; 
                            endforeach; 
                            ?>
                        </div>
                    </div>
                </div>

                <div class="form-buttons">
                    <div class="left">
                        <?php if ( get_option('swpanel_ai_redirect', 0 ) >= 1 ) : ?>
                            <button type="button" id="exit-button" class="blue-button" onclick="window.location.href='<?php echo esc_url(admin_url()); ?>'">
                                <?php esc_html_e('Exit', 'swpanel-ai'); ?>
                            </button>
                        <?php endif; ?>
                    </div>
                    <div class="right">
                        <button type="submit" id="continue-button" class="green-button">
                            <?php esc_html_e('Continue', 'swpanel-ai'); ?>
                        </button>
                    </div>
                </div>
            </form>

        <?php else: ?>
            <div class='theme-form'>
                <p style="text-decoration: none;"><?php esc_html_e('The Twenty Twenty-Five theme is not active.', 'swpanel-ai'); ?></p>
                <button type="button" id="theme-button" class="green-button" onclick="window.location.href='<?php echo esc_url(admin_url('theme-install.php?theme=twentytwentyfive')); ?>'">
                    <?php esc_html_e('Install and Activate Twenty Twenty-Five', 'swpanel-ai'); ?>
                </button>
            </div>
        <?php endif; ?>
    </div>

    
    <?php
    $swpanel_ai_active_theme = get_option('stylesheet');
    if ($swpanel_ai_active_theme === 'twentytwentyfive'): ?>
        <?php if ( get_option('swpanel_ai_redirect', 0 ) < 1 ) : ?>
            <div class="info-message" style="margin-top: -120px !important; margin-bottom: 140px !important; display: flex !important;">
                <div class="icon-message">
                <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/box_info.svg');?>">
                </div>
                <div class="content-message">
                    <h1><?php esc_html_e('Important', 'swpanel-ai'); ?></h1>
                    <p><?php esc_html_e("You won't be able to access the WordPress admin until the website setup is complete.", 'swpanel-ai'); ?></p>
                </div>
            </div>
        <?php else : ?>
            <div class="alert-message" style="margin-top: -120px !important; margin-bottom: 140px !important;">
                <div class="icon-message">
                    <img src="<?php echo esc_url(plugin_dir_url(__FILE__) . '../assets/img/box_alerta.svg'); ?>">
                </div>
                <div class="content-message">
                    <h1><?php esc_html_e('Created pages will be deleted !!', 'swpanel-ai'); ?></h1>
                    <p>
                        <?php esc_html_e('Keep in mind that if you continue, all existing pages on your current website will be deleted and replaced with the new ones generated by the AI.', 'swpanel-ai'); ?>
                        <br>
                        <?php esc_html_e('This process cannot be undone, so make sure you really want to start from scratch before proceeding.', 'swpanel-ai'); ?>
                    </p>
                </div>
            </div>
        <?php endif; ?>
    <?php endif; ?>
</div>
