<div class="card border-0 shadow-sm">
    <div class="card-body">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <div>
                <h4 class="fw-bold mb-1">Provisional Value</h4>
                <p class="text-muted mb-0">
                    AI-generated provisional Redress Scotland estimate based on care settings and impact factors.
                </p>
            </div>

            @can('claims.edit')
                <button
                    type="button"
                    class="btn btn-primary"
                    wire:click="generate"
                    wire:loading.attr="disabled"
                >
                    <span wire:loading.remove wire:target="generate">
                        Generate Estimate
                    </span>

                    <span wire:loading wire:target="generate">
                        Generating...
                    </span>
                </button>
            @endcan
        </div>

        @if($claim->redressEstimate)
            @php($estimate = $claim->redressEstimate)

            <div class="row g-3">
                <div class="col-md-3">
                    <div class="border rounded p-3 h-100">
                        <div class="text-muted small">Estimated Level</div>
                        <div class="fs-5 fw-bold">{{ $estimate->level }}</div>
                    </div>
                </div>

                <div class="col-md-3">
                    <div class="border rounded p-3 h-100">
                        <div class="text-muted small">Estimated Value</div>
                        <div class="fs-5 fw-bold">
                            £{{ number_format($estimate->value_min) }}
                            @if($estimate->value_max !== $estimate->value_min)
                                - £{{ number_format($estimate->value_max) }}
                            @endif
                        </div>
                    </div>
                </div>

                <div class="col-md-3">
                    <div class="border rounded p-3 h-100">
                        <div class="text-muted small">Confidence</div>
                        <div class="fs-5 fw-bold">{{ $estimate->confidence }}</div>
                    </div>
                </div>

                <div class="col-md-3">
                    <div class="border rounded p-3 h-100">
                        <div class="text-muted small">Last Generated</div>
                        <div class="fs-6 fw-bold">
                            {{ $estimate->updated_at?->format('d/m/Y H:i') }}
                        </div>
                    </div>
                </div>
            </div>

            <div class="mt-4">
                <h5 class="fw-bold">Short Rationale</h5>
                <p class="mb-0">{{ $estimate->rationale }}</p>
            </div>
        @else
            <div class="text-center p-5 text-muted">
                <i class="bi bi-cash-coin opacity-25" style="font-size: 64px;"></i>
                <p class="mt-3 fw-bold">No provisional value generated yet.</p>
                <p class="small mb-0">Click “Generate Estimate” after care settings and impact factors are complete.</p>
            </div>
        @endif
    </div>
</div>