@extends('layouts.admin')

@section('title', 'Expense ' . $expense->expense_number)

@section('page-title', 'Expense Details')

@section('content')
<div class="max-w-3xl mx-auto space-y-6">
    <div class="bg-white rounded-xl shadow-sm border border-[#e5e7eb] p-6">
        <div class="flex justify-between items-start mb-6">
            <div>
                <h2 class="text-2xl font-bold text-[#111418] text-gray-900 mb-2">{{ $expense->expense_number }}</h2>
                <p class="text-sm text-[#617589]">Date: {{ $expense->expense_date->format('M d, Y') }}</p>
            </div>
            <span class="px-3 py-1 rounded-lg text-sm font-medium {{ $expense->status === 'approved' ? 'bg-green-100 text-green-800' : ($expense->status === 'paid' ? 'bg-blue-100 text-blue-800' : 'bg-gray-100 text-gray-800') }}">
                {{ ucfirst($expense->status) }}
            </span>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <div>
                <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Account</p>
                <p class="text-sm text-[#111418] text-gray-900">{{ $expense->account->name }} ({{ $expense->account->code }})</p>
            </div>
            @if($expense->vendor)
                <div>
                    <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Vendor</p>
                    <p class="text-sm text-[#111418] text-gray-900">{{ $expense->vendor->name }}</p>
                </div>
            @endif
            <div>
                <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Payment Method</p>
                <p class="text-sm text-[#111418] text-gray-900">{{ ucfirst(str_replace('_', ' ', $expense->payment_method)) }}</p>
            </div>
            <div>
                <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Amount</p>
                <p class="text-2xl font-bold text-primary">{{ $expense->currency }} {{ number_format($expense->total, 2) }}</p>
            </div>
            @if($expense->description)
                <div class="md:col-span-2">
                    <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Description</p>
                    <p class="text-sm text-[#617589]">{{ $expense->description }}</p>
                </div>
            @endif
            @if($expense->notes)
                <div class="md:col-span-2">
                    <p class="text-xs font-semibold text-[#617589] uppercase tracking-wider mb-2">Notes</p>
                    <p class="text-sm text-[#617589] whitespace-pre-line">{{ $expense->notes }}</p>
                </div>
            @endif
        </div>

        @if($expense->status === 'draft')
            <div class="mt-6 pt-6 border-t border-[#e5e7eb]">
                <form method="POST" action="{{ route('admin.expenses.approve', $expense) }}">
                    @csrf
                    <button type="submit" class="px-4 py-2 bg-green-100 text-green-800 rounded-lg hover:bg-green-200 transition-colors">
                        Approve Expense
                    </button>
                </form>
            </div>
        @endif
    </div>
</div>
@endsection



