<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4 max-h-[80vh] overflow-y-auto">
    <div class="sm:flex sm:items-start">
        <div class="w-full">
            <!-- Header -->
            <div class="flex items-center justify-between mb-4">
                <h3 class="text-lg leading-6 font-medium text-gray-900">Agent Details: {{ agent.name or agent.slug or "Unknown Agent" }}</h3>
                <button
                    @click="open = false"
                    class="bg-white rounded-md text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
                >
                    <span class="sr-only">Close</span>
                    <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>

            <!-- Debug Info (remove in production) -->
            <div class="mb-4 p-4 bg-yellow-50 border border-yellow-200 rounded-md">
                <h4 class="text-sm font-medium text-yellow-800">Debug Info:</h4>
                <pre class="text-xs text-yellow-700 mt-2">{{ agent | tojson(indent=2) }}</pre>
            </div>

            <!-- Agent Information -->
            <div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
                <div>
                    <h4 class="text-sm font-medium text-gray-900 mb-3">Basic Information</h4>
                    <dl class="space-y-2">
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Name</dt>
                            <dd class="text-sm text-gray-900">{{ agent.name or "Unnamed Agent" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Type</dt>
                            <dd class="text-sm text-gray-900 capitalize">{{ agent.type or "conversational" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Version</dt>
                            <dd class="text-sm text-gray-900">{{ agent.version or "1.0.0" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Status</dt>
                            <dd>
                                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
                                    {{ agent.status or "Active" }}
                                </span>
                            </dd>
                        </div>
                    </dl>
                </div>

                <div>
                    <h4 class="text-sm font-medium text-gray-900 mb-3">Configuration</h4>
                    <dl class="space-y-2">
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Model</dt>
                            <dd class="text-sm text-gray-900">{{ agent.model or "-" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Provider</dt>
                            <dd class="text-sm text-gray-900">{{ agent.provider or "-" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Max Tokens</dt>
                            <dd class="text-sm text-gray-900">{{ agent.max_tokens or "-" }}</dd>
                        </div>
                        <div>
                            <dt class="text-xs font-medium text-gray-500 uppercase tracking-wider">Temperature</dt>
                            <dd class="text-sm text-gray-900">{{ agent.temperature or "-" }}</dd>
                        </div>
                    </dl>
                </div>
            </div>

            <!-- Description -->
            {% if agent.description %}
            <div class="mt-6">
                <h4 class="text-sm font-medium text-gray-900 mb-3">Description</h4>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <p class="text-sm text-gray-700">{{ agent.description }}</p>
                </div>
            </div>
            {% endif %}

            <!-- System Prompt -->
            {% if agent.system_prompt %}
            <div class="mt-6">
                <h4 class="text-sm font-medium text-gray-900 mb-3">System Prompt</h4>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <pre class="text-sm text-gray-700 whitespace-pre-wrap">{{ agent.system_prompt }}</pre>
                </div>
            </div>
            {% endif %}

            <!-- Tools -->
            {% if agent.tools %}
            <div class="mt-6">
                <h4 class="text-sm font-medium text-gray-900 mb-3">Available Tools ({{ agent.tools | length }})</h4>
                <div class="bg-white overflow-hidden shadow rounded-lg">
                    <ul role="list" class="divide-y divide-gray-200">
                        {% for tool in agent.tools %}
                        <li class="px-4 py-3">
                            <div class="flex items-center justify-between">
                                <div>
                                    <p class="text-sm font-medium text-gray-900">{{ tool.name if tool is mapping else tool }}</p>
                                    {% if tool is mapping and tool.description %}
                                    <p class="text-sm text-gray-500">{{ tool.description }}</p>
                                    {% endif %}
                                </div>
                                {% if tool is mapping and tool.enabled is defined %}
                                <span class="text-xs px-2 py-1 rounded-full {{ 'bg-green-100 text-green-800' if tool.enabled else 'bg-gray-100 text-gray-800' }}">
                                    {{ "Enabled" if tool.enabled else "Disabled" }}
                                </span>
                                {% endif %}
                            </div>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
            {% endif %}

            <!-- Additional Configuration -->
            {% if agent.config %}
            <div class="mt-6">
                <h4 class="text-sm font-medium text-gray-900 mb-3">Additional Configuration</h4>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <pre class="text-sm text-gray-700 whitespace-pre-wrap">{{ agent.config | tojson(indent=2) }}</pre>
                </div>
            </div>
            {% endif %}
        </div>
    </div>
</div>

<!-- Modal Footer -->
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
    <button
        @click="open = false"
        type="button"
        class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
    >
        Close
    </button>
</div>
