<?php

if ( ! defined( 'ABSPATH' ) ) exit;



/**

 * システムプロンプトタブ のレンダリング

 *

 * 元 admin/class-aiap-admin-view.php から分離。

 * 共通基盤 (resolve_dynamic_key, log_message 等) は親クラス AIAP_Admin_View にあるため直接参照する。

 */

class AIAP_Admin_View_Prompt {



    public static function render_system_prompt( $s ) {

        ?>

        <header class="aiap-provider-hero">

            <span class="aiap-provider-hero-eyebrow"><?php echo esc_html( __( 'System Prompt', 'ai-auto-poster' ) ); ?></span>

            <h2 class="aiap-provider-hero-title"><?php echo esc_html( __( 'Your overall tone, format, and rules', 'ai-auto-poster' ) ); ?></h2>

            <p class="aiap-provider-hero-sub"><?php echo esc_html( __( 'Instructions applied to every post (tone, format, audience, etc.). Each individual task adds its own prompt on top of this.', 'ai-auto-poster' ) ); ?></p>

        </header>



        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="aiap-prompts-form">

            <input type="hidden" name="action" value="aiap_save_system_prompt"><?php wp_nonce_field( AIAP_Admin::NONCE ); ?>

            <div class="aiap-section">

                <?php /* Phase 12: section-header (title + sub) was redundant with the hero above

                       (both said "System prompt" + "Instructions applied to every post..."), so

                       removed entirely. The hero alone introduces the screen. */ ?>

                <div class="aiap-section-body">

                    <textarea name="system_prompt" rows="14" class="aiap-editor-textarea aiap-editor-textarea-mono"><?php echo esc_textarea( $s['system_prompt'] ); ?></textarea>

                    <input type="hidden" name="content_language" value="<?php echo esc_attr( $s['content_language'] ); ?>">

                    <input type="hidden" name="content_length" value="<?php echo esc_attr( $s['content_length'] ?? 0 ); ?>">

                </div>

            </div>

            <p class="submit"><button type="submit" class="button button-primary aiap-btn-primary"><span class="dashicons dashicons-saved" aria-hidden="true"></span> <?php echo esc_html( __( 'Save System Prompt', 'ai-auto-poster' ) ); ?></button></p>

        </form>

        <?php

    }



}

