@extends('layouts.app')

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

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-user-edit me-2"></i>
                        সদস্য সম্পাদনা: {{ $member->name }}
                    </h5>
                </div>
                <div class="card-body">
                    <form action="{{ route('members.update', $member) }}" method="POST" enctype="multipart/form-data">
                        @csrf
                        @method('PUT')
                        
                        <div class="row">
                            <!-- ব্যক্তিগত তথ্য -->
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header bg-light">
                                        <h6 class="mb-0"><i class="fas fa-user me-2"></i>ব্যক্তিগত তথ্য</h6>
                                    </div>
                                    <div class="card-body">
                                        <div class="mb-3">
                                            <label for="name" class="form-label">নাম <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" id="name" name="name" value="{{ old('name', $member->name) }}" required>
                                        </div>
                                        
                                        <div class="row">
                                            <div class="col-md-6 mb-3">
                                                <label for="father_name" class="form-label">পিতার নাম <span class="text-danger">*</span></label>
                                                <input type="text" class="form-control" id="father_name" name="father_name" value="{{ old('father_name', $member->father_name) }}" required>
                                            </div>
                                            <div class="col-md-6 mb-3">
                                                <label for="mother_name" class="form-label">মাতার নাম <span class="text-danger">*</span></label>
                                                <input type="text" class="form-control" id="mother_name" name="mother_name" value="{{ old('mother_name', $member->mother_name) }}" required>
                                            </div>
                                        </div>
                                        
                                        <div class="row">
                                            <div class="col-md-6 mb-3">
                                                <label for="date_of_birth" class="form-label">জন্ম তারিখ <span class="text-danger">*</span></label>
                                                <input type="date" class="form-control" id="date_of_birth" name="date_of_birth" value="{{ old('date_of_birth', $member->date_of_birth) }}" required>
                                            </div>
                                            <div class="col-md-6 mb-3">
                                                <label for="gender" class="form-label">লিঙ্গ <span class="text-danger">*</span></label>
                                                <select class="form-select" id="gender" name="gender" required>
                                                    <option value="male" {{ old('gender', $member->gender) == 'male' ? 'selected' : '' }}>পুরুষ</option>
                                                    <option value="female" {{ old('gender', $member->gender) == 'female' ? 'selected' : '' }}>মহিলা</option>
                                                    <option value="other" {{ old('gender', $member->gender) == 'other' ? 'selected' : '' }}>অন্যান্য</option>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="photo" class="form-label">ছবি</label>
                                            <input type="file" class="form-control" id="photo" name="photo" accept="image/*">
                                            @if($member->photo)
                                            <div class="mt-2">
                                                <img src="{{ asset('storage/' . $member->photo) }}" alt="Member Photo" class="img-thumbnail" width="100">
                                            </div>
                                            @endif
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- যোগাযোগ তথ্য -->
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header bg-light">
                                        <h6 class="mb-0"><i class="fas fa-address-card me-2"></i>যোগাযোগ তথ্য</h6>
                                    </div>
                                    <div class="card-body">
                                        <div class="mb-3">
                                            <label for="phone" class="form-label">মোবাইল নম্বর <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" id="phone" name="phone" value="{{ old('phone', $member->phone) }}" required>
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="email" class="form-label">ইমেইল</label>
                                            <input type="email" class="form-control" id="email" name="email" value="{{ old('email', $member->email) }}">
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="nid" class="form-label">জাতীয় পরিচয়পত্র নম্বর <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" id="nid" name="nid" value="{{ old('nid', $member->nid) }}" required>
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="present_address" class="form-label">বর্তমান ঠিকানা <span class="text-danger">*</span></label>
                                            <textarea class="form-control" id="present_address" name="present_address" rows="2" required>{{ old('present_address', $member->present_address) }}</textarea>
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="permanent_address" class="form-label">স্থায়ী ঠিকানা</label>
                                            <textarea class="form-control" id="permanent_address" name="permanent_address" rows="2">{{ old('permanent_address', $member->permanent_address) }}</textarea>
                                        </div>
                                        
                                        <div class="mb-3">
                                            <label for="occupation" class="form-label">পেশা <span class="text-danger">*</span></label>
                                            <input type="text" class="form-control" id="occupation" name="occupation" value="{{ old('occupation', $member->occupation) }}" required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- নমিনি তথ্য -->
                        <div class="card mb-4">
                            <div class="card-header bg-light">
                                <h6 class="mb-0"><i class="fas fa-users me-2"></i>নমিনি তথ্য</h6>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-4 mb-3">
                                        <label for="nominee_name" class="form-label">নমিনির নাম <span class="text-danger">*</span></label>
                                        <input type="text" class="form-control" id="nominee_name" name="nominee_name" value="{{ old('nominee_name', $member->nominee_name) }}" required>
                                    </div>
                                    
                                    <div class="col-md-4 mb-3">
                                        <label for="nominee_relation" class="form-label">সম্পর্ক <span class="text-danger">*</span></label>
                                        <input type="text" class="form-control" id="nominee_relation" name="nominee_relation" value="{{ old('nominee_relation', $member->nominee_relation) }}" required>
                                    </div>
                                    
                                    <div class="col-md-4 mb-3">
                                        <label for="nominee_nid" class="form-label">নমিনির এনআইডি <span class="text-danger">*</span></label>
                                        <input type="text" class="form-control" id="nominee_nid" name="nominee_nid" value="{{ old('nominee_nid', $member->nominee_nid) }}" required>
                                    </div>
                                </div>
                                
                                <div class="mb-3">
                                    <label for="nominee_photo" class="form-label">নমিনির ছবি</label>
                                    <input type="file" class="form-control" id="nominee_photo" name="nominee_photo" accept="image/*">
                                    @if($member->nominee_photo)
                                    <div class="mt-2">
                                        <img src="{{ asset('storage/' . $member->nominee_photo) }}" alt="Nominee Photo" class="img-thumbnail" width="100">
                                    </div>
                                    @endif
                                </div>
                            </div>
                        </div>
                        
                        <!-- আর্থিক ও প্রশাসনিক তথ্য -->
                        <div class="card mb-4">
                            <div class="card-header bg-light">
                                <h6 class="mb-0"><i class="fas fa-cog me-2"></i>আর্থিক ও প্রশাসনিক তথ্য</h6>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-4 mb-3">
                                        <label for="status" class="form-label">স্ট্যাটাস <span class="text-danger">*</span></label>
                                        <select class="form-select" id="status" name="status" required>
                                            <option value="active" {{ old('status', $member->status) == 'active' ? 'selected' : '' }}>সক্রিয়</option>
                                            <option value="inactive" {{ old('status', $member->status) == 'inactive' ? 'selected' : '' }}>নিষ্ক্রিয়</option>
                                            <option value="terminated" {{ old('status', $member->status) == 'terminated' ? 'selected' : '' }}>বাতিল</option>
                                            <option value="pending" {{ old('status', $member->status) == 'pending' ? 'selected' : '' }}>অপেক্ষমান</option>
                                        </select>
                                    </div>
                                    
                                    <div class="col-md-4 mb-3">
                                        <label for="approval_status" class="form-label">অনুমোদন স্ট্যাটাস <span class="text-danger">*</span></label>
                                        <select class="form-select" id="approval_status" name="approval_status" required>
                                            <option value="pending" {{ old('approval_status', $member->approval_status) == 'pending' ? 'selected' : '' }}>অপেক্ষমান</option>
                                            <option value="approved" {{ old('approval_status', $member->approval_status) == 'approved' ? 'selected' : '' }}>অনুমোদিত</option>
                                            <option value="rejected" {{ old('approval_status', $member->approval_status) == 'rejected' ? 'selected' : '' }}>প্রত্যাখ্যান</option>
                                        </select>
                                    </div>
                                    
                                    <div class="col-md-4 mb-3">
                                        <label for="form_fee_paid" class="form-label">ফর্ম ফি পরিশোধিত</label>
                                        <select class="form-select" id="form_fee_paid" name="form_fee_paid">
                                            <option value="0" {{ old('form_fee_paid', $member->form_fee_paid ? '1' : '0') == '0' ? 'selected' : '' }}>না</option>
                                            <option value="1" {{ old('form_fee_paid', $member->form_fee_paid ? '1' : '0') == '1' ? 'selected' : '' }}>হ্যাঁ</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="row">
                                    <div class="col-md-6 mb-3">
                                        <label for="monthly_saving" class="form-label">মাসিক সঞ্চয় <span class="text-danger">*</span></label>
                                        <input type="number" class="form-control" id="monthly_saving" name="monthly_saving" value="{{ old('monthly_saving', $member->monthly_saving) }}" required>
                                    </div>
                                    
                                    <div class="col-md-6 mb-3">
                                        <label for="form_fee" class="form-label">ফর্ম ফি <span class="text-danger">*</span></label>
                                        <input type="number" class="form-control" id="form_fee" name="form_fee" value="{{ old('form_fee', $member->form_fee) }}" required>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="d-flex justify-content-between">
                            <a href="{{ route('members.index') }}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left me-2"></i>ফিরে যান
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save me-2"></i>সেভ করুন
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection