{% extends "base.html" %}
{% load static %}

{% block title %}AI Chat Component Demo - AgomTradePro{% endblock %}

{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/components/chat-widget.css' %}">
<link rel="stylesheet" href="{% static 'css/shared/shared-chat-renderer.css' %}">
<style>
.example-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.example-header {
    margin-bottom: 24px;
}

.example-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.example-header p {
    color: #6b7280;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.example-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.example-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.example-card p {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.example-card .chat-container {
    margin-top: 12px;
}

.code-block {
    background: #1f2937;
    color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.code-block code {
    color: #e5e7eb;
}

.scenario-section {
    margin-top: 32px;
}

.scenario-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.regime-chat {
    --chat-theme: #10b981;
}

.signal-chat {
    --chat-theme: #f59e0b;
}

.macro-chat {
    --chat-theme: #3b82f6;
}

.feature-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.feature-badge.new {
    background: #dcfce7;
    color: #16a34a;
}

.example-card .features {
    margin-bottom: 12px;
}
</style>
{% endblock %}

{% block content %}
<div class="example-page">
    <div class="example-header">
        <h1>AI Chat Component Demo</h1>
        <p>AgomChatWidget integration examples with shared API and rich rendering capabilities</p>
    </div>

    <div class="scenario-section">
        <h2 class="scenario-title">Standard Chat Window</h2>
        <div class="example-grid">
            <div class="example-card">
                <h3>Basic Usage <span class="feature-badge">default</span></h3>
                <p>Simple chat widget with default settings</p>
                <div class="chat-container" id="chat-standard"></div>
            </div>

            <div class="example-card">
                <h3>Compact Mode</h3>
                <p>Smaller widget with model selector only</p>
                <div class="chat-container" id="chat-compact"></div>
            </div>
        </div>
    </div>

    <div class="scenario-section">
        <h2 class="scenario-title">Rich Rendering <span class="feature-badge new">NEW</span></h2>
        <div class="example-grid">
            <div class="example-card">
                <h3>Markdown & Mermaid Support</h3>
                <p>Supports rich text rendering including Mermaid diagrams</p>
                <div class="chat-container" id="chat-rich"></div>
            </div>

            <div class="example-card">
                <h3>Answer Chain & Suggestion Cards <span class="feature-badge new">NEW</span></h3>
                <p>Displays answer chain and action suggestion cards</p>
                <div class="chat-container" id="chat-suggestion"></div>
            </div>
        </div>
    </div>

    <div class="scenario-section">
        <h2 class="scenario-title">Scenario-specific Helpers</h2>
        <div class="example-grid">
            <div class="example-card regime-chat">
                <h3>Regime Analysis Assistant</h3>
                <p>Helper for macro regime questions</p>
                <div class="chat-container" id="chat-regime"></div>
            </div>

            <div class="example-card signal-chat">
                <h3>Investment Signal Assistant</h3>
                <p>Helper for investment signal questions</p>
                <div class="chat-container" id="chat-signal"></div>
            </div>

            <div class="example-card macro-chat">
                <h3>Macro Data Assistant</h3>
                <p>Helper for macro data queries</p>
                <div class="chat-container" id="chat-macro"></div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script src="{% static 'js/marked.min.js' %}"></script>
<script src="{% static 'js/mermaid.min.js' %}"></script>
<script src="{% static 'js/shared/shared-chat-renderer.js' %}"></script>
<script src="{% static 'js/components/chat-widget.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
    // 1. Standard chat widget with shared API
    new AgomChatWidget({
        containerId: 'chat-standard',
        title: 'AI Assistant',
        height: '450px',
        useSharedApi: true
    });

    // 2. Compact mode
    new AgomChatWidget({
        containerId: 'chat-compact',
        title: 'Compact',
        height: '200px',
        showHeader: true,
        showModelSelector: true,
        showProviderSelector: false,
        useSharedApi: true
    });

    // 3. Rich rendering demo
    new AgomChatWidget({
        containerId: 'chat-rich',
        title: 'Rich Text Demo',
        height: '400px',
        useSharedApi: true,
        showAnswerChain: true,
        showSuggestionCard: true
    });

    // 4. Suggestion cards demo
    new AgomChatWidget({
        containerId: 'chat-suggestion',
        title: 'Action Suggestions',
        height: '400px',
        useSharedApi: true,
        showAnswerChain: true,
        showSuggestionCard: true,
        onSuggestionExecute: function(action) {
            console.log('Custom suggestion handler:', action);
        }
    });

    // 5. Regime assistant
    new AgomChatWidget({
        containerId: 'chat-regime',
        title: 'Regime Assistant',
        placeholder: 'Ask about macro regime analysis...',
        height: '400px',
        useSharedApi: true,
        showAnswerChain: true,
        onMessageReceived: function(data) {
            console.log('[Regime Assistant]', data);
        }
    });

    // 6. Signal assistant
    new AgomChatWidget({
        containerId: 'chat-signal',
        title: 'Signal Assistant',
        placeholder: 'Ask about investment signals...',
        height: '400px',
        useSharedApi: true
    });

    // 7. Macro data assistant
    new AgomChatWidget({
        containerId: 'chat-macro',
        title: 'Macro Data Assistant',
        placeholder: 'Query macro economic data...',
        height: '400px',
        useSharedApi: true
    });
});
</script>
{% endblock %}
