<?php
/**
 * Chatbot Full Page Template
 *
 * Displays chatbot in a full page view for direct URL access.
 * URL format: /?ai-chatbot={id}
 *
 * @package    Kitsune_AI_Platform
 * @subpackage Kitsune_AI_Platform/public/partials
 */

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

// Extract appearance settings
$appearance = $config['appearance'] ?? array();
$primary_color = sanitize_hex_color($appearance['primaryColor'] ?? '#3B82F6');
$primary_color = $primary_color ? $primary_color : '#3B82F6';
$theme_mode = $appearance['mode'] ?? 'light';
$is_dark = $theme_mode === 'dark';

wp_enqueue_style(
    'ai-platform-chatbot-preview-fullpage',
    KITSUNE_AI_PLATFORM_PLUGIN_URL . 'admin/assets/css/chatbot-preview.css',
    array(),
    KITSUNE_AI_PLATFORM_VERSION
);

$fullpage_bg = $is_dark ? '#111827' : 'linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%)';
$branding_color = $is_dark ? '#9ca3af' : '#6b7280';
$branding_bg = $is_dark ? '#1f2937' : '#ffffff';

$fullpage_inline_css = "
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    background: {$fullpage_bg};
    display: flex;
    flex-direction: column;
}

.chatbot-fullpage-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chatbot-fullpage-wrapper .ai-platform-chatbot-container,
.chatbot-fullpage-wrapper .ai-platform-chatbot-container--inline {
    width: 100% !important;
    max-width: none !important;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.chatbot-fullpage-wrapper .chatbot-preview {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 0;
    box-shadow: none;
}

.chatbot-branding {
    text-align: center;
    padding: 10px;
    font-size: 12px;
    color: {$branding_color};
    background: {$branding_bg};
}

.chatbot-branding a {
    color: {$primary_color};
    text-decoration: none;
}

.chatbot-branding a:hover {
    text-decoration: underline;
}
";

wp_add_inline_style('ai-platform-chatbot-preview-fullpage', $fullpage_inline_css);
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?php echo esc_html($chatbot->name); ?> - <?php bloginfo('name'); ?></title>
    
    <?php wp_head(); ?>
</head>
<body>
    <div class="chatbot-fullpage-wrapper">
        <?php
        $mode = 'inline'; // Full page uses inline mode (no toggle button)
        include KITSUNE_AI_PLATFORM_PLUGIN_DIR . 'public/partials/chatbot-embed.php';
        ?>
        
        <div class="chatbot-branding">
            <?php echo wp_kses_post(sprintf(
                /* translators: %s: site name link */
                esc_html__('Chat with %s', 'kitsune-ai-platform'),
                '<a href="' . esc_url(home_url('/')) . '">' . esc_html(get_bloginfo('name')) . '</a>'
            )); ?>
        </div>
    </div>
    
    <?php wp_footer(); ?>
</body>
</html>
