<?php
/**
 * Template du widget chat universel SlideMind
 *
 * Page HTML autonome (zero dependance externe).
 * Variables attendues : $config_uid, $mode, $theme, $color, $border_radius, $show_header, $title, $slidemind_user, $rest_url, $max_turns, $closing_message
 * Assets (CSS/JS) are enqueued by ChatWidget::maybe_render() and printed via wp_print_styles/wp_print_scripts.
 *
 * @package SlideMind
 * @since 2.7.0
 */
if (!defined('ABSPATH')) { exit;
}
?><!DOCTYPE html>
<html lang="<?php echo esc_attr(get_bloginfo('language')); ?>" data-theme="<?php echo esc_attr($theme); ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><?php echo esc_html($title); ?></title>
<?php wp_print_styles(['slidemind-widget']); ?>
</head>
<body>

<?php if ($consent_enabled): ?>
<!-- Consent overlay -->
<div id="sm-consent-overlay" style="position:absolute;inset:0;z-index:100;background:var(--sm-bg);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:24px;text-align:center;">
    <span style="font-size:32px;">&#128274;</span>
    <p style="color:var(--sm-text);font-size:14px;max-width:300px;">
        <?php esc_html_e('Your messages will be processed by an AI assistant. By continuing, you agree that your messages may be transmitted to the AI provider configured by this site.', 'slidemind'); ?>
    </p>
    <button id="sm-consent-accept" style="background:var(--sm-primary);color:#fff;border:none;border-radius:8px;padding:10px 24px;font-size:14px;cursor:pointer;">
        <?php esc_html_e('I understand, continue', 'slidemind'); ?>
    </button>
</div>
<?php endif; ?>

<?php if ($show_header): ?>
<!-- Header -->
<div class="sm-w-header">
    <h1><?php echo esc_html($title); ?></h1>
    <?php if ($mode === 'chat'): ?>
    <button type="button" id="sm-w-reset" title="<?php esc_attr_e('New conversation', 'slidemind'); ?>">&#8635;</button>
    <?php endif; ?>
</div>
<?php elseif ($mode === 'chat'): ?>
<!-- Reset button only (no header) -->
<div style="position:absolute;top:8px;right:8px;z-index:10;">
    <button type="button" id="sm-w-reset" style="background:var(--sm-border);border:none;color:var(--sm-text-muted);width:28px;height:28px;border-radius:6px;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;" title="<?php esc_attr_e('New conversation', 'slidemind'); ?>">&#8635;</button>
</div>
<?php endif; ?>

<!-- Messages -->
<div class="sm-w-messages" id="sm-w-messages">
    <div class="sm-w-empty" id="sm-w-empty">
        <?php if ($mode === 'qa'): ?>
            <?php esc_html_e('Ask your question.', 'slidemind'); ?>
        <?php else: ?>
            <?php esc_html_e('Start the conversation.', 'slidemind'); ?>
        <?php endif; ?>
    </div>
    <div class="sm-w-typing" id="sm-w-typing">
        <span></span><span></span><span></span>
    </div>
</div>

<!-- Input -->
<div class="sm-w-input">
    <textarea id="sm-w-textarea"
              rows="1"
              placeholder="<?php esc_attr_e('Your message...', 'slidemind'); ?>"
              autocomplete="off"></textarea>
    <button type="button" id="sm-w-send" title="<?php esc_attr_e('Send', 'slidemind'); ?>">&#10148;</button>
</div>

<?php wp_print_scripts(['slidemind-widget']); ?>
</body>
</html>
