<?php
    $layout = auth()->user()->role === 'super_admin' ? 'layouts.admin' : 'layouts.app';
?>



<?php $__env->startSection('title', $group->name); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid px-4 py-3">
    <!-- Header -->
    <div class="dashboard-header">
        <div class="container-fluid">
            <div class="row align-items-center dashboard-header-content">
                <div class="col-lg-6">
                    <h1 class="dashboard-title">
                        <i class="fas fa-tachometer-alt" style="color: var(--dhis2-blue-primary);"></i>
                        Group <?php echo e($group->name); ?> Details
                    </h1>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('component1.dashboard')); ?>">Component 1 Dashboard</a></li>
                            <li class="breadcrumb-item active">Groups</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container-fluid py-4">
    <!-- Header -->
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h3 class="text-success"><?php echo e($group->name); ?></h3>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('component1.groups.index')); ?>">Groups</a></li>
                    <li class="breadcrumb-item active"><?php echo e(Str::limit($group->name, 30)); ?></li>
                </ol>
            </nav>
        </div>
        <div>
            <a href="<?php echo e(route('component1.groups.edit', $group)); ?>" class="btn btn-outline-secondary me-2">
                Edit Group
            </a>
            <a href="<?php echo e(route('component1.members.create')); ?>?group_id=<?php echo e($group->id); ?>" class="btn btn-success">
                Add Member
            </a>
        </div>
    </div>

    <!-- Group Summary Card -->
    <div class="row g-4 mb-4">
        <div class="col-md-3">
            <div class="card border-0 shadow-sm text-center">
                <div class="card-body">
                    <h6 class="text-muted">Total Members</h6>
                    <h3 class="text-success"><?php echo e($group->members_count); ?></h3>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm text-center">
                <div class="card-body">
                    <h6 class="text-muted">Active Members</h6>
                    <h3 class="text-success"><?php echo e($group->members()->active()->count()); ?></h3>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm text-center">
                <div class="card-body">
                    <h6 class="text-muted">Formation Date</h6>
                    <h5 class="text-dark"><?php echo e($group->date_formation->format('d M Y')); ?></h5>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm text-center">
                <div class="card-body">
                    <h6 class="text-muted">Group Nature</h6>
                    <span class="badge bg-<?php echo e($group->nature == 'new' ? 'warning' : ($group->nature == 'progressing' ? 'info' : 'success')); ?> fs-6">
                        <?php echo e(ucfirst($group->nature)); ?>

                    </span>
                </div>
            </div>
        </div>
    </div>

    <!-- Group Details -->
    <div class="card border-0 shadow-sm mb-4">
        <div class="card-header bg-light">
            <h5 class="mb-0">Group Details</h5>
        </div>
        <div class="card-body">
            <div class="row g-4">
                <div class="col-md-6">
                    <table class="table table-borderless">
                        <tr>
                            <th width="40%">State</th>
                            <td><?php echo e($group->state); ?></td>
                        </tr>
                        <tr>
                            <th>County</th>
                            <td><?php echo e($group->county); ?></td>
                        </tr>
                        <tr>
                            <th>Payam</th>
                            <td><?php echo e($group->payam); ?></td>
                        </tr>
                        <tr>
                            <th>Establishing Org</th>
                            <td><?php echo e($group->establishing_org_name ?? '—'); ?></td>
                        </tr>
                    </table>
                </div>
                <div class="col-md-6">
                    <table class="table table-borderless">
                        <tr>
                            <th>Establishment Type</th>
                            <td><?php echo e(ucfirst($group->establishment_type)); ?></td>
                        </tr>
                        <tr>
                            <th>VSLA Registration</th>
                            <td><?php echo e($group->vsla_registration_date?->format('d M Y') ?? '—'); ?></td>
                        </tr>
                        <tr>
                            <th>Leadership</th>
                            <td>
                                <span class="badge bg-primary">
                                    <?php echo e($group->leadership == 'adolescent_girl' ? 'Adolescent Girl' : 'Woman'); ?>

                                </span>
                            </td>
                        </tr>
                        <tr>
                            <th>Snapshot Month</th>
                            <td><?php echo e(\Carbon\Carbon::parse($group->month)->format('F Y')); ?></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Members -->
    <div class="card border-0 shadow-sm">
        <div class="card-header bg-light d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Recent Members (<?php echo e($group->members()->active()->count()); ?> active)</h5>
            <a href="<?php echo e(route('component1.members.index')); ?>?group_id=<?php echo e($group->id); ?>" class="btn btn-sm btn-outline-success">
                View All Members
            </a>
        </div>
        <div class="card-body p-0">
            <?php if($group->members->count() > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Name</th>
                                <th>Gender</th>
                                <th>Age</th>
                                <th>Role</th>
                                <th>Status</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $group->members; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $member): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e($member->name); ?></td>
                                    <td>
                                        <span class="badge bg-<?php echo e($member->gender == 'female' ? 'pink' : 'info'); ?>">
                                            <?php echo e(ucfirst($member->gender)); ?>

                                        </span>
                                    </td>
                                    <td><?php echo e($member->age); ?></td>
                                    <td>
                                        <?php if($member->exec_committee): ?>
                                            <span class="badge bg-success">Exec Committee</span>
                                        <?php else: ?>
                                            —
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <span class="badge bg-<?php echo e($member->active ? 'success' : 'secondary'); ?>">
                                            <?php echo e($member->active ? 'Active' : 'Inactive'); ?>

                                        </span>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            <?php else: ?>
                <div class="text-center py-5 text-muted">
                    No members added yet.
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make($layout, array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\sswseepcomponents\resources\views/component1/groups/show.blade.php ENDPATH**/ ?>