@extends('layouts.parent')
@section('title', 'Family Profile')
@section('page_title', 'Family Profile')

@section('content')
    <div class="row g-3">
        <div class="col-lg-7">
            <div class="card"><div class="card-header"><i class="bi bi-house-heart me-1"></i>{{ $family->family_code }}</div><div class="card-body">
                <dl class="row small mb-0">
                    <dt class="col-5 text-muted">Father</dt><dd class="col-7">{{ $family->father_name ?: '—' }}</dd>
                    <dt class="col-5 text-muted">Father Mobile</dt><dd class="col-7">{{ $family->father_mobile ?: '—' }}</dd>
                    <dt class="col-5 text-muted">Mother</dt><dd class="col-7">{{ $family->mother_name ?: '—' }}</dd>
                    <dt class="col-5 text-muted">Guardian</dt><dd class="col-7">{{ $family->guardian_name ?: '—' }}</dd>
                    <dt class="col-5 text-muted">Email</dt><dd class="col-7">{{ $family->email ?: '—' }}</dd>
                    <dt class="col-5 text-muted">Address</dt><dd class="col-7">{{ $family->address ?: '—' }}</dd>
                </dl>
            </div></div>

            <div class="card mt-3"><div class="card-header"><i class="bi bi-mortarboard me-1"></i>Children</div><div class="card-body p-0">
                <table class="table table-sm align-middle mb-0">
                    <thead><tr><th>Name</th><th>Adm #</th><th>Class</th><th>Status</th></tr></thead>
                    <tbody>
                        @foreach($family->students as $s)
                            <tr>
                                <td class="fw-semibold">{{ $s->name }}</td>
                                <td class="small">{{ $s->admission_number }}</td>
                                <td class="small">{{ $s->schoolClass?->name ?? '—' }}{{ $s->section ? ' / '.$s->section->name : '' }}</td>
                                <td><span class="badge bg-soft-{{ $s->status_color }} text-capitalize">{{ str_replace('_',' ',$s->status) }}</span></td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div></div>
        </div>
        <div class="col-lg-5">
            <div class="card"><div class="card-header"><i class="bi bi-shield-lock me-1"></i>Change Password</div><div class="card-body">
                <form method="POST" action="{{ route('parent.profile.password') }}">
                    @csrf @method('PATCH')
                    <div class="mb-2"><label class="form-label small">Current Password</label><input type="password" name="current_password" class="form-control" required></div>
                    <div class="mb-2"><label class="form-label small">New Password</label><input type="password" name="password" class="form-control" required></div>
                    <div class="mb-2"><label class="form-label small">Confirm Password</label><input type="password" name="password_confirmation" class="form-control" required></div>
                    <button class="btn btn-primary"><i class="bi bi-key me-1"></i>Update Password</button>
                </form>
            </div></div>
        </div>
    </div>
@endsection
