@extends('layouts.app')

@section('title', 'ব্যয় বিস্তারিত - আমবাগান যুব কল্যাণ সমিতি')

@section('styles')
<style>
    .detail-card {
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
    }
    
    .detail-label {
        font-weight: 600;
        color: #495057;
        margin-bottom: 5px;
    }
    
    .detail-value {
        color: #212529;
        font-size: 1.1rem;
    }
    
    .amount-display {
        font-size: 1.5rem;
        font-weight: 700;
        color: #dc3545;
        text-align: center;
        padding: 20px;
        background-color: #f8f9fa;
        border-radius: 8px;
    }
</style>
@endsection

@section('breadcrumbs')
<nav aria-label="breadcrumb">
    <ol class="breadcrumb bg-light">
        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">ড্যাশবোর্ড</a></li>
        <li class="breadcrumb-item"><a href="{{ route('expenses.index') }}">ব্যয় ব্যবস্থাপনা</a></li>
        <li class="breadcrumb-item active">ব্যয় বিস্তারিত</li>
    </ol>
</nav>
@endsection

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-file-invoice-dollar me-2"></i>ব্যয় বিস্তারিত
                    </h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-12 mb-4">
                            <div class="amount-display">
                                {{ number_format($expense->amount, 2) }} টাকা
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">শিরোনাম</div>
                                <div class="detail-value">{{ $expense->title }}</div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">ক্যাটাগরি</div>
                                <div class="detail-value">
                                    @if($expense->category)
                                    {{ $expense->category->name_in_bangla }}
                                    @else
                                    <span class="text-muted">N/A</span>
                                    @endif
                                </div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">তারিখ</div>
                                <div class="detail-value">{{ date('d/m/Y', strtotime($expense->date)) }}</div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">পেমেন্ট পদ্ধতি</div>
                                <div class="detail-value">{{ $expense->payment_method_in_bangla }}</div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">রেফারেন্স নম্বর</div>
                                <div class="detail-value">{{ $expense->reference_no ?: 'N/A' }}</div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">স্ট্যাটাস</div>
                                <div class="detail-value">
                                    <span class="badge bg-{{ $expense->status }}">{{ $expense->status_in_bangla }}</span>
                                </div>
                            </div>
                        </div>
                        
                        @if($expense->description)
                        <div class="col-md-12 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">বর্ণনা</div>
                                <div class="detail-value">{{ $expense->description }}</div>
                            </div>
                        </div>
                        @endif
                        
                        @if($expense->notes)
                        <div class="col-md-12 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">নোট</div>
                                <div class="detail-value">{{ $expense->notes }}</div>
                            </div>
                        </div>
                        @endif
                        
                        @if($expense->receipt_attachment)
                        <div class="col-md-12 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">রিসিট সংযুক্তি</div>
                                <div class="detail-value">
                                    <a href="{{ asset('storage/' . $expense->receipt_attachment) }}" 
                                       target="_blank" class="btn btn-outline-primary btn-sm">
                                        <i class="fas fa-download me-2"></i>ডাউনলোড করুন
                                    </a>
                                </div>
                            </div>
                        </div>
                        @endif
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">তৈরি করেছেন</div>
                                <div class="detail-value">
                                    @if($expense->user)
                                    {{ $expense->user->name }}
                                    @else
                                    <span class="text-muted">N/A</span>
                                    @endif
                                </div>
                            </div>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="detail-card">
                                <div class="detail-label">তৈরির তারিখ</div>
                                <div class="detail-value">{{ $expense->created_at->format('d/m/Y H:i:s') }}</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="d-flex justify-content-between mt-4">
                        <a href="{{ route('expenses.index') }}" class="btn btn-secondary">
                            <i class="fas fa-arrow-left me-2"></i>ফিরে যান
                        </a>
                        
                        @if(in_array(auth()->user()->user_type, ['committee', 'admin']))
                        <div class="btn-group">
                            <a href="{{ route('expenses.edit', $expense) }}" class="btn btn-warning">
                                <i class="fas fa-edit me-2"></i>সম্পাদনা
                            </a>
                            <form action="{{ route('expenses.destroy', $expense) }}" method="POST" class="d-inline delete-form">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-danger" onclick="return confirm('আপনি কি নিশ্চিত?')">
                                    <i class="fas fa-trash me-2"></i>ডিলিট
                                </button>
                            </form>
                        </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col-md-4">
            <!-- অতিরিক্ত তথ্য -->
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-info-circle me-2"></i>অতিরিক্ত তথ্য
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-info">
                        <h6><i class="fas fa-lightbulb me-2"></i>মন্তব্য</h6>
                        <p class="mb-0">এই ব্যয় রেকর্ডটি {{ $expense->created_at->diffForHumans() }} তৈরি করা হয়েছে।</p>
                    </div>
                    
                    @if($expense->receipt_attachment)
                    <div class="text-center">
                        <img src="{{ asset('storage/' . $expense->receipt_attachment) }}" 
                             alt="Receipt" class="img-fluid rounded" style="max-height: 200px;">
                        <p class="mt-2 text-muted">রিসিট প্রিভিউ</p>
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
@endsection