<div class="col-xl-6">
    <div class="card border-0 shadow-sm h-100">
        <div class="card-header bg-white border-0 pb-0">
            <div class="d-flex align-items-start justify-content-between gap-2">
                <div>
                    <div class="fw-bold">{{ $definition['lookup_name'] }}</div>
                    <div class="small text-muted">{{ $definition['use_case'] }}</div>
                </div>
                <span class="badge {{ ($definition['group'] ?? '') === 'lookup' ? 'text-bg-primary' : 'text-bg-success' }}">
                    {{ ($definition['group'] ?? '') === 'lookup' ? 'Lookup' : 'Knowledge' }}
                </span>
            </div>
        </div>
        <div class="card-body">
            <div class="row g-2 small mb-3">
                <div class="col-md-6">
                    <div class="border rounded p-2 h-100">
                        <div class="text-muted">Operation</div>
                        <div class="fw-semibold">{{ $operation }}</div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="border rounded p-2 h-100">
                        <div class="text-muted">Result Path</div>
                        <div class="fw-semibold">{{ $definition['result_path'] }}</div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="border rounded p-2 h-100">
                        <div class="text-muted">Variable Name</div>
                        <div class="fw-semibold">{{ $definition['variable_name'] ?: 'N/A' }}</div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="border rounded p-2 h-100">
                        <div class="text-muted">Sample Test Value</div>
                        <div class="fw-semibold">{{ $definition['sample_value'] ?: 'N/A' }}</div>
                    </div>
                </div>
            </div>

            <div class="small mb-2">
                <span class="fw-bold">Trigger Keywords:</span>
                <span class="text-muted">{{ $definition['trigger_keywords'] }}</span>
            </div>
            @if(!empty($definition['customer_prompt']))
                <div class="small mb-2">
                    <span class="fw-bold">Customer Prompt:</span>
                    <span class="text-muted">{{ $definition['customer_prompt'] }}</span>
                </div>
            @endif
            <div class="small mb-3">
                <span class="fw-bold">AI-safe Fields:</span>
                <span class="text-muted">{{ $definition['safe_fields'] }}</span>
            </div>

            <div class="d-flex justify-content-between align-items-center gap-2 mb-2">
                <div class="fw-bold small">Read-Only Query</div>
                <button type="button" class="btn btn-sm btn-outline-dark" data-copy="{{ $definition['query'] }}">Copy Query</button>
            </div>
            <pre class="rounded bg-light border p-3 small mb-3" style="white-space:pre-wrap;"><code>{{ $definition['query'] }}</code></pre>

            <div class="d-flex justify-content-between align-items-center gap-2 mb-2">
                <div class="fw-bold small">POST Payload</div>
                <button type="button" class="btn btn-sm btn-outline-dark" data-copy='@json([
                    "query" => $definition["query"],
                    "variables" => $definition["variable_name"] ? [$definition["variable_name"] => $definition["sample_value"]] : new stdClass(),
                ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)'>Copy Payload</button>
            </div>
            <pre class="rounded bg-dark text-white p-3 small mb-0" style="white-space:pre-wrap;"><code>@json([
    "query" => $definition["query"],
    "variables" => $definition["variable_name"] ? [$definition["variable_name"] => $definition["sample_value"]] : new stdClass(),
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)</code></pre>
        </div>
    </div>
</div>
