<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    
<p><strong>Male Voters: </strong> {{ $maleCount }}  <strong>Female Voters: </strong> {{ $femaleCount }}  <strong>Total Entries of this user: </strong> {{ $maleCount + $femaleCount }} </p>

<div class="container-fluid">
<table id="voterTable" class="table table-bordered" >
    <thead>
        <tr>
            <th>#</th>
            <th>Silsila Number</th>
            <th>Gharana Number</th>
            <th>Name</th>
            <th>Father's Name</th>
            <th>CNIC</th>
            <th>Age</th>
            <th>Block Code</th>
            <th>Ward No</th>
            <th>Address</th>
                                <th>Gender</th>
            <th>Actions</th>
            
        </tr>
    </thead>
    <tbody>
        @foreach($voters as $voter)
            <tr>
                <td>{{ $loop->iteration }}</td>
                <td>{{ $voter->silsila_number }}</td>
                <td>{{ $voter->gharana_number }}</td>
                <td>{{ $voter->name }}</td>
                <td>{{ $voter->father_name }}</td>
                <td>{{ (strpos($voter->cnic, '-') !== false || strpos($voter->cnic, '–') !== false) ? str_replace(['-', '–'], '', $voter->cnic) : $voter->cnic }}</td>
                <td>{{ $voter->age }}</td>
                <td>{{ $voter->block_code }}</td>
                <td>{{ $voter->ward_no }}</td>
                <td>{{ $voter->address }}</td>
                <td>{{ $voter->gender }}</td>
                <td>
                                <!-- Edit Button -->
                                <a href="{{ route('admin.editVoter', $voter->id) }}" class="btn btn-warning btn-sm">Edit</a>
                                <a href="{{ route('admin.showVoter', $voter->id) }}" class="btn btn-info btn-sm">View</a>
                                <!-- Delete Button -->
                                <form action="{{ route('admin.deleteVoter', $voter->id) }}" method="POST" style="display:inline;">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this record?')">Delete</button>
                                </form>
                            </td>
            </tr>
        @endforeach
    </tbody>
</table>
</div>