<?php
/**
 * Ancienne fenêtre flottante « AvisionDashboard » (layout-main démo).
 * Cockpit Premium / Agence : utiliser le thème `template-parts/components/avi-chat-widget.php` (id #avi-chat-widget-root).
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<div class="avi-chat-window" id="aviWindow" style="position: fixed; bottom: 100px; right: 30px; width: 350px; height: 500px; background: white; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); border: 1px solid #e2e8f0; display: none; flex-direction: column; z-index: 3000; overflow: hidden; font-family: 'Inter', sans-serif;">
    
    <div style="background: #0f172a; color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center;">
        <div style="display: flex; flex-direction: column; gap: 4px;">
            <div style="display: flex; align-items: center; gap: 10px;">
                <span style="width: 10px; height: 10px; background: #10b981; border-radius: 50%;"></span>
                <span style="font-weight: 700;">Avi - AI Coach</span>
            </div>
            <span id="aviLevelTitle" style="font-size: 0.75rem; opacity: 0.9;"></span>
        </div>
        <div style="cursor: pointer; opacity: 0.7;" onclick="AvisionDashboard.toggleChat()">✕</div>
    </div>

    <div id="chatBody" style="flex: 1; padding: 20px; overflow-y: auto; background: #f8fafc; display: flex; flex-direction: column; gap: 10px;">
    </div>

    <div style="padding: 15px; background: white; border-top: 1px solid #e2e8f0; display: flex; gap: 10px;">
        <input type="text" id="chatInput" placeholder="Ask a question..." onkeypress="AvisionDashboard.handleEnter(event)" style="flex: 1; border: 1px solid #e2e8f0; padding: 10px; border-radius: 8px; outline: none; font-size: 0.9rem;">
        <button onclick="AvisionDashboard.sendMessage()" style="background: #2563eb; color: white; border: none; padding: 10px 15px; border-radius: 8px; cursor: pointer;">➤</button>
    </div>
</div>

<div class="avi-widget-btn" onclick="AvisionDashboard.toggleChat()" style="position: fixed; bottom: 30px; right: 30px; width: 65px; height: 65px; background: #0f172a; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3000; box-shadow: 0 10px 25px rgba(0,0,0,0.3); border: 3px solid white; transition: transform 0.2s; overflow: hidden;">
    <div id="aviBadge" style="position: absolute; top: -5px; right: -5px; background: #ef4444; color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; border: 2px solid white; display: none;">1</div>
    <div class="avi-icon"><?php 
$avi_chat_icon_src = function_exists( 'avi_chat_icon_url' ) ? avi_chat_icon_url() : 'https://avision.org/wp-content/uploads/2026/03/avi-ss-fond-chat.png'; 
?><img src="<?php echo esc_url( $avi_chat_icon_src ); ?>" alt="Avi" class="avi-chat-icon-img" width="65" height="65" /></div>
</div>
