<div class="space-y-6">
    <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
        <div>
            <flux:heading size="xl">{{ $editingId ? 'Edit website' : 'Add website' }}</flux:heading>
            <flux:text class="mt-1 text-zinc-600 dark:text-zinc-400">Editorial verdict, long-form analysis, and optional manual trust score override.</flux:text>
        </div>
        <flux:button href="{{ route('admin.reviewed-websites.index') }}" variant="ghost" wire:navigate>Back to list</flux:button>
    </div>

    @if (session('success'))
        <flux:callout variant="success" icon="check-circle">{{ session('success') }}</flux:callout>
    @endif

    <flux:card class="p-6 space-y-5">
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <flux:field>
                <flux:label>Display name</flux:label>
                <flux:input wire:model="name" placeholder="Example Deals LLC" />
                <flux:error name="name" />
            </flux:field>
            <flux:field>
                <flux:label>URL slug</flux:label>
                <div class="flex gap-2">
                    <flux:input wire:model="slug" placeholder="example-deals" class="flex-1" />
                    <flux:button type="button" wire:click="generateSlugFromName" variant="outline" size="sm" class="shrink-0">From name</flux:button>
                </div>
                <flux:error name="slug" />
            </flux:field>
        </div>

        <flux:field>
            <flux:label>Website URL</flux:label>
            <flux:input wire:model="website_url" placeholder="https://example.com" />
            <flux:error name="website_url" />
        </flux:field>

        <flux:field>
            <flux:label>Industry</flux:label>
            <flux:text class="text-xs text-zinc-600 dark:text-zinc-400 mb-1">Used when bulk-generating community reviews so wording matches the sector (e.g. payments for fintech, rooms for hospitality).</flux:text>
            <flux:select wire:model="industry" variant="listbox">
                @foreach ($industryLabels as $value => $label)
                    <flux:select.option value="{{ $value }}">{{ $label }}</flux:select.option>
                @endforeach
            </flux:select>
            <flux:error name="industry" />
        </flux:field>

        <flux:card class="p-4 space-y-4 border border-dashed border-zinc-300 dark:border-zinc-600 bg-zinc-50/50 dark:bg-zinc-900/30">
            <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
                <div>
                    <flux:heading size="sm">Search (Google) — this listing</flux:heading>
                    <flux:text class="text-xs text-zinc-600 dark:text-zinc-400 mt-0.5">Custom title and snippet help the trust page rank when people search the brand or domain.</flux:text>
                </div>
                <flux:button type="button" wire:click="suggestSeoFromContent" variant="outline" size="sm">Suggest from name &amp; summary</flux:button>
            </div>
            <flux:field>
                <flux:label>Meta title (optional)</flux:label>
                <flux:input wire:model="meta_title" placeholder="Full &lt;title&gt; line, e.g. BrandName trust check | YourSite" />
                <flux:error name="meta_title" />
            </flux:field>
            <flux:field>
                <flux:label>Meta description (optional)</flux:label>
                <flux:textarea wire:model="meta_description" rows="3" placeholder="Search snippet (~155 characters works well)" />
                <flux:error name="meta_description" />
            </flux:field>
        </flux:card>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <flux:field>
                <flux:label>Editorial verdict</flux:label>
                <flux:select wire:model="editorial_verdict" variant="listbox">
                    @foreach ($verdictLabels as $value => $label)
                        <flux:select.option value="{{ $value }}">{{ $label }}</flux:select.option>
                    @endforeach
                </flux:select>
                <flux:error name="editorial_verdict" />
            </flux:field>
            <flux:field>
                <flux:label>Status</flux:label>
                <flux:select wire:model="status" variant="listbox">
                    <flux:select.option value="{{ \App\Models\ReviewedWebsite::STATUS_DRAFT }}">Draft</flux:select.option>
                    <flux:select.option value="{{ \App\Models\ReviewedWebsite::STATUS_PUBLISHED }}">Published</flux:select.option>
                    <flux:select.option value="{{ \App\Models\ReviewedWebsite::STATUS_ARCHIVED }}">Archived</flux:select.option>
                </flux:select>
                <flux:error name="status" />
            </flux:field>
        </div>

        <flux:field>
            <flux:label>Manual trust score override (optional)</flux:label>
            <flux:input type="number" wire:model="manual_trust_score" min="0" max="100" placeholder="Leave empty to use community average" />
            <flux:text class="text-xs text-zinc-500 mt-1">
                When set, public pages use this value instead of the average from approved reviews. The legitimacy meter uses a 0–100 scale on a bar split
                <strong>30% Scam · 30% Good · 40% Legit</strong>: scores under 30 read as Scam, 30–59 as Good, and 60+ as Legit.
            </flux:text>
            <flux:error name="manual_trust_score" />
        </flux:field>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <flux:field>
                <flux:label>Featured on trust directory</flux:label>
                <flux:switch wire:model.live="is_featured" />
                <flux:text class="text-xs text-zinc-500 mt-1">Featured sites sort first on the public /websites page.</flux:text>
                <flux:error name="is_featured" />
            </flux:field>
            <flux:field>
                <flux:label>Featured order</flux:label>
                <flux:input type="number" wire:model="featured_order" min="0" max="99999" />
                <flux:text class="text-xs text-zinc-500 mt-1">Lower numbers appear first among featured (0 = last within featured group).</flux:text>
                <flux:error name="featured_order" />
            </flux:field>
        </div>

        <flux:field>
            <flux:label>Short summary</flux:label>
            <flux:textarea wire:model="editorial_summary" rows="2" placeholder="One-paragraph takeaway for cards and hero." />
            <flux:error name="editorial_summary" />
        </flux:field>

        <flux:field>
            <flux:label>Full write-up (HTML allowed)</flux:label>
            <flux:textarea wire:model="editorial_content" rows="12" placeholder="Detailed investigation, evidence, and links." />
            <flux:error name="editorial_content" />
        </flux:field>

        <flux:button wire:click="save" variant="primary">{{ $editingId ? 'Save changes' : 'Create website' }}</flux:button>
    </flux:card>
</div>
