@extends('layouts.aura-main')

@section('main-content')
<div class="max-w-3xl mx-auto pb-20">
    <div class="mb-8 border-b border-slate-200 pb-4">
        <h1 class="text-2xl font-bold text-slate-900 tracking-tight">Reverse Expense</h1>
        <p class="text-rose-600 text-[11px] font-bold uppercase tracking-widest">Transaction Reversal Protocol</p>
    </div>

    <div class="bg-white border border-slate-300 rounded-sm shadow-sm overflow-hidden">
        <div class="p-4 bg-rose-50 border-b border-rose-100 flex items-center gap-3">
            <svg class="w-5 h-5 text-rose-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.268 14c-.77 1.333.192 3 1.732 3z"/>
            </svg>
            <p class="text-xs font-bold text-rose-800 uppercase italic">Warning: This action will generate balancing ledger entries and cannot be undone.</p>
        </div>

        <form action="{{ route('suppliers.expenses.reverse.store', $expense->id) }}" method="POST" class="p-6">
            @csrf
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                <div>
                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1 tracking-wider">Original Reference</label>
                    <div class="bg-slate-50 border border-slate-200 rounded px-3 py-2 text-xs font-mono text-slate-600">
                        {{ $expense->reference_no }}
                    </div>
                </div>
                <div>
                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1 tracking-wider">Amount to Reverse</label>
                    <div class="bg-slate-50 border border-slate-200 rounded px-3 py-2 text-xs font-bold text-slate-900">
                        ZMW {{ number_format($expense->total_amount, 2) }}
                    </div>
                </div>
            </div>

            <div class="space-y-6">
                <div>
                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1 tracking-wider">Reversal Date</label>
                    <input type="date" name="reversal_date" value="{{ date('Y-m-d') }}" 
                           class="w-full border border-slate-300 rounded px-3 py-2 text-xs focus:border-rose-500 outline-none shadow-sm transition" required>
                    <p class="mt-1 text-[10px] text-slate-400 italic font-medium">The date the reversal will be effective in the General Ledger.</p>
                </div>

                <div>
                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1 tracking-wider">Reason for Reversal</label>
                    <textarea name="reversal_reason" rows="4" 
                              placeholder="e.g., Duplicated entry, wrong supplier selected, or incorrect amount..."
                              class="w-full border border-slate-300 rounded p-3 text-xs focus:border-rose-500 outline-none shadow-sm transition" required></textarea>
                </div>
            </div>

            <div class="mt-8 pt-6 border-t border-slate-100 flex justify-between items-center">
                <a href="{{ route('suppliers.expenses.index') }}" class="text-[11px] font-bold text-slate-400 uppercase hover:text-slate-600 transition">Go Back</a>
                
                <button type="submit" class="bg-rose-600 text-white px-8 py-2.5 rounded text-[11px] font-bold shadow-sm hover:bg-rose-700 transition uppercase tracking-tighter flex items-center gap-2">
                    Confirm & Execute Reversal
                </button>
            </div>
        </form>
    </div>
</div>
@endsection