{% extends "admin/base.html" %}
{% from 'shared/macros/headers.html' import detail_page_header, section_header, tab_header %}
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
{% from 'shared/macros/modals.html' import modal %}

{% block title %}Prospect Detail{% endblock %}

{% block alpine_data %}prospectDetail({{ prospect_id }}){% endblock %}

{% block content %}
{{ loading_state('Loading prospect...') }}
{{ error_state('Error loading prospect') }}

<template x-if="!loading && !error && prospect">
<div class="space-y-6">
    <!-- Header -->
    <div class="flex flex-col sm:flex-row sm:items-center justify-between my-6 gap-4">
        <div class="flex items-center space-x-4">
            <a href="/admin/prospecting/prospects"
               class="flex items-center justify-center p-2 text-gray-500 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
               title="Back to prospects">
                <span x-html="$icon('arrow-left', 'w-5 h-5')"></span>
            </a>
            <div class="relative hidden w-10 h-10 rounded-full md:block">
                <div class="absolute inset-0 rounded-full bg-purple-100 dark:bg-purple-600 flex items-center justify-center">
                    <span class="text-sm font-semibold text-purple-600 dark:text-purple-100"
                          x-text="(prospect.business_name || prospect.domain_name)?.charAt(0).toUpperCase() || '?'"></span>
                </div>
            </div>
            <div>
                <h2 class="text-2xl font-semibold text-gray-700 dark:text-gray-200"
                    x-text="prospect.business_name || prospect.domain_name"></h2>
                <p class="text-sm text-gray-500 dark:text-gray-400" x-show="prospect.domain_name && prospect.business_name"
                   x-text="prospect.domain_name"></p>
            </div>
            <span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
                  :class="prospect.channel === 'digital'
                      ? 'text-blue-700 bg-blue-100 dark:text-blue-100 dark:bg-blue-700'
                      : 'text-purple-700 bg-purple-100 dark:text-purple-100 dark:bg-purple-700'"
                  x-text="prospect.channel"></span>
        </div>
        <!-- Score Badge -->
        <div x-show="prospect.score" class="text-center">
            <div class="text-3xl font-bold" :class="scoreColor(prospect.score?.score)"
                 x-text="prospect.score?.score"></div>
            <div class="text-xs text-gray-500 dark:text-gray-400 uppercase"
                 x-text="prospect.score?.lead_tier?.replace('_', ' ')"></div>
        </div>
    </div>

    <!-- Status Bar -->
    <div class="flex flex-col sm:flex-row items-start sm:items-center gap-3 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
        <div class="flex items-center gap-3">
            <label class="text-sm font-medium text-gray-700 dark:text-gray-400">Status:</label>
            <select x-model="prospect.status" @change="updateStatus()"
                    class="px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
                <option value="pending">Pending</option>
                <option value="active">Active</option>
                <option value="contacted">Contacted</option>
                <option value="converted">Converted</option>
                <option value="inactive">Inactive</option>
            </select>
        </div>
        <button type="button" @click="runEnrichment()" x-show="prospect.channel === 'digital'"
                class="sm:ml-auto inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none">
            <span x-html="$icon('globe-alt', 'w-4 h-4 mr-2')"></span>
            Run Scan
        </button>
    </div>

    <!-- Tabs -->
    {{ tab_header([
        {'id': 'overview', 'label': 'Overview', 'icon': 'eye'},
        {'id': 'security', 'label': 'Security', 'icon': 'shield-check'},
        {'id': 'interactions', 'label': 'Interactions', 'icon': 'chat'},
        {'id': 'campaigns', 'label': 'Campaigns', 'icon': 'mail'},
    ], active_var='activeTab') }}

    <!-- Tab: Overview -->
    <div x-show="activeTab === 'overview'" class="grid gap-6 md:grid-cols-2">
        <!-- Contact Info -->
        <div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
            {{ section_header('Contact Info', icon='phone') }}
            <template x-for="c in prospect.contacts || []" :key="c.id">
                <div class="flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0">
                    <span class="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase" x-text="c.contact_type"></span>
                    <span class="text-sm text-gray-700 dark:text-gray-300" x-text="c.value"></span>
                </div>
            </template>
            <p x-show="!prospect.contacts?.length" class="text-sm text-gray-400 text-center py-4">No contacts found</p>
        </div>

        <!-- Score Breakdown -->
        <div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
            {{ section_header('Opportunity Score', icon='chart-bar') }}
            <p class="text-xs text-gray-400 dark:text-gray-500 mb-3">Higher = more issues = better sales opportunity</p>
            <template x-if="prospect.score">
                <div class="space-y-4">
                    <template x-for="cat in scoreCategories()" :key="cat.key">
                        <div>
                            <div class="flex justify-between text-sm mb-1">
                                <span class="font-medium text-gray-700 dark:text-gray-300" x-text="cat.label"></span>
                                <span class="font-semibold text-gray-700 dark:text-gray-200" x-text="cat.score + '/' + cat.max"></span>
                            </div>
                            <!-- Progress bar -->
                            <div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-1.5 mb-2">
                                <div class="h-1.5 rounded-full" :class="cat.score > 0 ? 'bg-purple-500' : 'bg-gray-300 dark:bg-gray-600'"
                                     :style="'width:' + Math.round(cat.score / cat.max * 100) + '%'"></div>
                            </div>
                            <!-- Per-flag details -->
                            <template x-if="cat.flags.length > 0">
                                <div class="space-y-0.5 ml-2">
                                    <template x-for="[flag, pts] in cat.flags" :key="flag">
                                        <div class="flex items-center justify-between text-xs">
                                            <span class="text-gray-500 dark:text-gray-400" x-text="flag.replaceAll('_', ' ')"></span>
                                            <span class="font-semibold px-1.5 py-0.5 rounded"
                                                  :class="cat.positive.includes(flag)
                                                      ? 'text-green-700 bg-green-50 dark:text-green-300 dark:bg-green-900/30'
                                                      : 'text-orange-700 bg-orange-50 dark:text-orange-300 dark:bg-orange-900/30'"
                                                  x-text="pts + ' pts'"></span>
                                        </div>
                                    </template>
                                </div>
                            </template>
                            <p x-show="cat.flags.length === 0" class="text-xs ml-2"
                               :class="cat.score === 0 ? 'text-green-500' : 'text-gray-400'"
                               x-text="cat.score === 0 ? '✓ No issues found — low opportunity' : 'No data available'"></p>
                        </div>
                    </template>
                </div>
            </template>
            <p x-show="!prospect.score" class="text-sm text-gray-400 text-center py-4">Not scored yet</p>
        </div>

        <!-- Tech Profile Summary -->
        <div x-show="prospect.tech_profile" class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
            {{ section_header('Technology', icon='code') }}
            <!-- CMS badge (prominent) -->
            <div x-show="prospect.tech_profile?.cms" class="mb-3 flex items-center gap-2">
                <span class="px-3 py-1.5 text-sm font-semibold rounded-lg bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300"
                      x-text="(prospect.tech_profile?.cms || '').charAt(0).toUpperCase() + (prospect.tech_profile?.cms || '').slice(1) + (prospect.tech_profile?.cms_version ? ' ' + prospect.tech_profile.cms_version : '')"></span>
                <span x-show="prospect.tech_profile?.ecommerce_platform"
                      class="px-2 py-1 text-xs font-medium rounded-lg bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"
                      x-text="prospect.tech_profile?.ecommerce_platform"></span>
            </div>
            <p x-show="!prospect.tech_profile?.cms" class="mb-3 text-sm text-gray-500 dark:text-gray-400">Custom / Unknown CMS</p>
            <div class="space-y-2 text-sm">
                <template x-for="[key, val] in techProfileEntries()" :key="key">
                    <div class="flex justify-between">
                        <span class="text-gray-600 dark:text-gray-400" x-text="key"></span>
                        <span class="font-medium text-gray-700 dark:text-gray-300" x-text="val"></span>
                    </div>
                </template>
                <div x-show="prospect.tech_profile?.cert_issuer" class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">SSL Issuer</span>
                    <span class="font-medium text-gray-700 dark:text-gray-300" x-text="prospect.tech_profile?.cert_issuer"></span>
                </div>
                <div x-show="prospect.tech_profile?.cert_expires_at" class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">SSL Expires</span>
                    <span class="font-medium text-gray-700 dark:text-gray-300"
                          x-text="prospect.tech_profile?.cert_expires_at ? new Date(prospect.tech_profile.cert_expires_at).toLocaleDateString() : '—'"></span>
                </div>
            </div>
        </div>

        <!-- Performance Summary -->
        <div x-show="prospect.performance_profile" class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
            {{ section_header('Performance', icon='chart-bar') }}
            <!-- Scan error -->
            <div x-show="prospect.performance_profile?.scan_error" class="p-3 mb-3 text-sm text-orange-700 bg-orange-50 rounded-lg dark:bg-orange-900/20 dark:text-orange-300">
                <span class="font-medium">Scan failed:</span>
                <span x-text="prospect.performance_profile?.scan_error"></span>
            </div>
            <!-- Scores (only when real data exists) -->
            <div x-show="!prospect.performance_profile?.scan_error && (prospect.performance_profile?.performance_score > 0 || prospect.performance_profile?.seo_score > 0)" class="space-y-2 text-sm">
                <div class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">Performance</span>
                    <span class="font-semibold" :class="scoreColor(prospect.performance_profile?.performance_score)"
                          x-text="prospect.performance_profile?.performance_score + '/100'"></span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">Accessibility</span>
                    <span class="font-semibold text-gray-700 dark:text-gray-200" x-text="prospect.performance_profile?.accessibility_score + '/100'"></span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">Best Practices</span>
                    <span class="font-semibold text-gray-700 dark:text-gray-200" x-text="prospect.performance_profile?.best_practices_score + '/100'"></span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">SEO</span>
                    <span class="font-semibold text-gray-700 dark:text-gray-200" x-text="prospect.performance_profile?.seo_score + '/100'"></span>
                </div>
                <div class="flex justify-between">
                    <span class="text-gray-600 dark:text-gray-400">Mobile Friendly</span>
                    <span x-text="prospect.performance_profile?.is_mobile_friendly == null ? '—' : prospect.performance_profile?.is_mobile_friendly ? 'Yes' : 'No'"
                          :class="prospect.performance_profile?.is_mobile_friendly ? 'text-green-600 dark:text-green-400' : prospect.performance_profile?.is_mobile_friendly === false ? 'text-red-600 dark:text-red-400' : 'text-gray-400'"
                          class="font-medium"></span>
                </div>
            </div>
            <p x-show="!prospect.performance_profile?.scan_error && prospect.performance_profile?.performance_score === 0 && prospect.performance_profile?.seo_score === 0"
               class="text-sm text-gray-400 text-center py-4">No performance data — configure PAGESPEED_API_KEY in .env</p>
        </div>
    </div>

    <!-- Tab: Security -->
    <div x-show="activeTab === 'security'" class="space-y-6">
        <!-- Action buttons -->
        <div class="flex justify-end gap-3">
            <button type="button" x-show="prospect.security_audit" @click="openSecurityReport()"
                    class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none">
                <span x-html="$icon('document-text', 'w-4 h-4 mr-2')"></span>
                Generate Report
            </button>
            <button type="button" @click="runSecurityAudit()" :disabled="auditRunning"
                    class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-yellow-600 border border-transparent rounded-lg hover:bg-yellow-700 focus:outline-none disabled:opacity-50">
                <span x-show="!auditRunning" x-html="$icon('shield-check', 'w-4 h-4 mr-2')"></span>
                <span x-show="auditRunning" x-html="$icon('spinner', 'w-4 h-4 mr-2')"></span>
                <span x-text="auditRunning ? 'Scanning...' : 'Run Security Audit'"></span>
            </button>
        </div>

        <template x-if="prospect.security_audit">
            <div class="grid gap-6 md:grid-cols-2">
                <!-- Grade Card -->
                <div class="p-6 bg-white rounded-lg shadow-xs dark:bg-gray-800 text-center">
                    <div class="text-5xl font-bold mb-2" :class="gradeColor(prospect.security_audit.grade)"
                         x-text="prospect.security_audit.grade"></div>
                    <div class="text-sm text-gray-500 dark:text-gray-400 mb-3">Security Grade</div>
                    <div class="text-2xl font-semibold text-gray-700 dark:text-gray-200"
                         x-text="prospect.security_audit.score + '/100'"></div>
                    <!-- Severity counts -->
                    <div class="flex justify-center gap-3 mt-4">
                        <span x-show="prospect.security_audit.findings_count_critical > 0"
                              class="px-2 py-1 text-xs font-bold rounded bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300"
                              x-text="prospect.security_audit.findings_count_critical + ' critical'"></span>
                        <span x-show="prospect.security_audit.findings_count_high > 0"
                              class="px-2 py-1 text-xs font-bold rounded bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300"
                              x-text="prospect.security_audit.findings_count_high + ' high'"></span>
                        <span x-show="prospect.security_audit.findings_count_medium > 0"
                              class="px-2 py-1 text-xs font-bold rounded bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300"
                              x-text="prospect.security_audit.findings_count_medium + ' medium'"></span>
                        <span x-show="prospect.security_audit.findings_count_low > 0"
                              class="px-2 py-1 text-xs font-bold rounded bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"
                              x-text="prospect.security_audit.findings_count_low + ' low'"></span>
                    </div>
                    <p x-show="prospect.security_audit.scan_error" class="mt-3 text-xs text-red-500" x-text="prospect.security_audit.scan_error"></p>
                </div>

                <!-- Quick Info -->
                <div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
                    {{ section_header('Quick Overview', icon='shield-check') }}
                    <div class="space-y-2 text-sm">
                        <div class="flex justify-between">
                            <span class="text-gray-600 dark:text-gray-400">HTTPS</span>
                            <span class="font-medium" :class="prospect.security_audit.has_https ? 'text-green-600' : 'text-red-600'"
                                  x-text="prospect.security_audit.has_https ? 'Yes' : 'No'"></span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-600 dark:text-gray-400">SSL Valid</span>
                            <span class="font-medium" :class="prospect.security_audit.has_valid_ssl ? 'text-green-600' : prospect.security_audit.has_valid_ssl === false ? 'text-red-600' : 'text-gray-400'"
                                  x-text="prospect.security_audit.has_valid_ssl == null ? '—' : prospect.security_audit.has_valid_ssl ? 'Yes' : 'No'"></span>
                        </div>
                        <div x-show="prospect.security_audit.ssl_expires_at" class="flex justify-between">
                            <span class="text-gray-600 dark:text-gray-400">SSL Expires</span>
                            <span class="font-medium text-gray-700 dark:text-gray-300"
                                  x-text="new Date(prospect.security_audit.ssl_expires_at).toLocaleDateString()"></span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-600 dark:text-gray-400">Missing Headers</span>
                            <span class="font-medium text-gray-700 dark:text-gray-200"
                                  x-text="(prospect.security_audit.missing_headers || []).length"></span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-600 dark:text-gray-400">Exposed Files</span>
                            <span class="font-medium"
                                  :class="(prospect.security_audit.exposed_files || []).length > 0 ? 'text-red-600' : 'text-green-600'"
                                  x-text="(prospect.security_audit.exposed_files || []).length"></span>
                        </div>
                        <div x-show="(prospect.security_audit.technologies || []).length > 0" class="pt-2 border-t border-gray-100 dark:border-gray-700">
                            <span class="text-gray-600 dark:text-gray-400 text-xs uppercase">Technologies</span>
                            <div class="flex flex-wrap gap-1 mt-1">
                                <template x-for="tech in prospect.security_audit.technologies || []" :key="tech">
                                    <span class="px-2 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded" x-text="tech"></span>
                                </template>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Findings List (full width) -->
                <div class="md:col-span-2 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
                    {{ section_header('Findings', icon='clipboard-list') }}
                    <div class="space-y-2">
                        <template x-for="finding in (prospect.security_audit.findings || []).filter(f => !f.is_positive)" :key="finding.title">
                            <div class="flex items-start gap-3 py-2 border-b border-gray-100 dark:border-gray-700 last:border-0">
                                <span class="mt-0.5 px-2 py-0.5 text-xs font-bold rounded shrink-0"
                                      :class="severityBadge(finding.severity)"
                                      x-text="finding.severity"></span>
                                <div>
                                    <p class="text-sm font-medium text-gray-700 dark:text-gray-200" x-text="finding.title"></p>
                                    <p class="text-xs text-gray-500 dark:text-gray-400" x-text="finding.detail"></p>
                                </div>
                            </div>
                        </template>
                        <p x-show="(prospect.security_audit.findings || []).filter(f => !f.is_positive).length === 0"
                           class="text-sm text-green-600 text-center py-4">No security issues found</p>
                    </div>
                </div>
            </div>
        </template>
        <p x-show="!prospect.security_audit" class="text-sm text-gray-400 text-center py-8">No security audit yet. Click "Run Security Audit" to scan.</p>
    </div>

    <!-- Tab: Interactions -->
    <div x-show="activeTab === 'interactions'" class="space-y-4">
        <div class="flex justify-end">
            <button type="button" @click="showInteractionModal = true"
                    class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
                <span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
                Log Interaction
            </button>
        </div>
        <!-- Timeline -->
        <div class="space-y-4">
            <template x-for="interaction in interactions" :key="interaction.id">
                <div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800 border-l-4 transition-shadow hover:shadow-md"
                     :class="interaction.outcome === 'positive' ? 'border-green-500' : interaction.outcome === 'negative' ? 'border-red-500' : 'border-gray-300 dark:border-gray-600'">
                    <div class="flex items-center justify-between mb-2">
                        <span class="px-2.5 py-0.5 text-xs font-medium rounded-full bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400"
                              x-text="interaction.interaction_type.replace('_', ' ')"></span>
                        <span class="text-xs text-gray-500 dark:text-gray-400" x-text="new Date(interaction.created_at).toLocaleDateString()"></span>
                    </div>
                    <p x-show="interaction.subject" class="text-sm font-semibold text-gray-700 dark:text-gray-200" x-text="interaction.subject"></p>
                    <p x-show="interaction.notes" class="text-sm text-gray-600 dark:text-gray-400 mt-1" x-text="interaction.notes"></p>
                    <p x-show="interaction.next_action" class="text-xs text-purple-600 dark:text-purple-400 mt-2">
                        Next: <span x-text="interaction.next_action"></span>
                        <span x-show="interaction.next_action_date" x-text="' — ' + interaction.next_action_date"></span>
                    </p>
                </div>
            </template>
            <p x-show="interactions.length === 0" class="text-sm text-gray-400 text-center py-8">No interactions yet</p>
        </div>
    </div>

    <!-- Tab: Campaigns -->
    <div x-show="activeTab === 'campaigns'" class="space-y-4">
        <div class="flex justify-end">
            <button type="button" @click="showSendCampaignModal = true"
                    class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-lg hover:bg-green-700 focus:outline-none">
                <span x-html="$icon('mail', 'w-4 h-4 mr-2')"></span>
                Send Campaign
            </button>
        </div>
        <template x-for="send in campaignSends" :key="send.id">
            <div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow">
                <div class="flex items-center justify-between">
                    <span class="text-sm font-semibold text-gray-700 dark:text-gray-200" x-text="send.rendered_subject || 'No subject'"></span>
                    <span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
                          :class="send.status === 'sent'
                              ? 'bg-green-100 text-green-700 dark:bg-green-700 dark:text-green-100'
                              : 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400'"
                          x-text="send.status"></span>
                </div>
                <p class="text-xs text-gray-500 dark:text-gray-400 mt-1" x-text="send.sent_at ? new Date(send.sent_at).toLocaleString() : 'Draft'"></p>
            </div>
        </template>
        <p x-show="campaignSends.length === 0" class="text-sm text-gray-400 text-center py-8">No campaigns sent yet</p>
    </div>
</div>
</template>

<!-- Interaction Modal -->
{% call modal('interactionModal', 'Log Interaction', show_var='showInteractionModal', size='md', show_footer=false) %}
    <div class="space-y-4">
        <div>
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Type</label>
            <select x-model="newInteraction.interaction_type"
                    class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
                <option value="note">Note</option>
                <option value="call">Phone Call</option>
                <option value="email_sent">Email Sent</option>
                <option value="email_received">Email Received</option>
                <option value="meeting">Meeting</option>
                <option value="visit">Visit</option>
                <option value="proposal_sent">Proposal Sent</option>
            </select>
        </div>
        <div>
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Subject</label>
            <input type="text" x-model="newInteraction.subject"
                   class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
        </div>
        <div>
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Notes</label>
            <textarea x-model="newInteraction.notes" rows="3"
                      class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300"></textarea>
        </div>
        <div>
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Outcome</label>
            <select x-model="newInteraction.outcome"
                    class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
                <option value="">Not specified</option>
                <option value="positive">Positive</option>
                <option value="neutral">Neutral</option>
                <option value="negative">Negative</option>
                <option value="no_answer">No Answer</option>
            </select>
        </div>
        <div>
            <label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Next Action</label>
            <input type="text" x-model="newInteraction.next_action" placeholder="Follow up by..."
                   class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
        </div>
    </div>

    <!-- Footer Actions -->
    <div class="flex justify-end mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 space-x-3">
        <button type="button" @click="showInteractionModal = false"
                class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">
            Cancel
        </button>
        <button type="button" @click="createInteraction()"
                class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple transition-colors duration-150">
            <span x-html="$icon('check', 'w-4 h-4 mr-2')"></span>
            Save Interaction
        </button>
    </div>
{% endcall %}
{% endblock %}

{% block extra_scripts %}
<script defer src="{{ url_for('prospecting_static', path='admin/js/prospect-detail.js') }}"></script>
{% endblock %}
