 @extends('admin.layouts.main-layout')
 @section('css-content')
 <style>
 
 .card-body {
     overflow: auto;
 }
     .colls p {
    margin-bottom: 0px;
    font-size: 19px;
    border: solid 1px #000;
    padding: 5px 0px;
    text-align: center;
}
.colls .col-sm {
    margin-left: 0px;
    margin-right: 0px;
    padding-right: 0px;
    padding-left: 0px;
}
.colls .col-sm {
    width: 20%;
}
.colls .row {
    margin-left: 0px;
    margin-right: 0px;
}

.bluebox {
    background: blue;
    padding-left: 2px;
    padding-right: 2px;
    border-radius: 7px;
    color: white;
}
.redbox {
    background: red;
    padding-left: 2px;
    padding-right: 2px;
    border-radius: 7px;
    color: white;
}

 </style>
 @endsection
 @section('content')
<div class="card">
      <div class="card-body">
        
        <h5>OC Cutting</h5>
        
        </div>
    
        
        <div class="card-body">
            
            <form action="" method="GET">

            <div class="row">

                <!-- Date -->
                <div class="col-md-4 mb-3">
                    <label><strong>Date</strong></label>
                    <input type="date" 
                           name="date" 
                           class="form-control"
                           value="{{ request('date') ?? date('Y-m-d') }}">
                </div>

                <!-- Game -->
                <div class="col-md-4 mb-3">
                    <label><strong>Game</strong></label>
                    <select name="stores_id" class="form-control select2">
                        <option value="">Select an option</option>

                        @foreach(storeList() as $game)
                            <option value="{{ $game->id }}"  {{request('stores_id') == $game->id ? 'selected':''}}>
                                {{ $game->name }}
                            </option>
                        @endforeach
                    </select>
                </div>

                <!-- Game -->
                <div class="col-md-4 mb-3">
                    <label><strong>Session</strong></label>
                    <select name="type" class="form-control select2">
                        

                            <option value="open"  {{request('type') == "open" ? 'selected':''}}>
                                Open
                            </option>
                            <option value="close"  {{request('type') == "close" ? 'selected':''}}>
                                Close
                            </option>
                        
                    </select>
                </div>
                <!-- Game -->
                <div class="col-md-4 mb-3">
                    <label><strong>Game Type</strong></label>
                    <select name="game_id" class="form-control select2">

                        
                            <option value="all" {{request('game_id') == "all" ? 'selected':''}}>
                                All
                            </option>
                             <option value="single"{{request('game_id') == "single" ? 'selected':''}}>Single</option>
                             <option value="jodi"{{request('game_id') == "jodi" ? 'selected':''}}>Jodi</option>
                             <option value="pana"{{request('game_id') == "pana" ? 'selected':''}}>Pana</option>
                             <option value="halfsangam"{{request('game_id') == "halfsangam" ? 'selected':''}}>Half Sangam</option>
                             <option value="fullsangam"{{request('game_id') == "fullsangam" ? 'selected':''}}>Full Sangam</option>
                    </select>
                </div>



                <!-- Save Button -->
                <div class="col-md-12 mt-2">
                    <button type="submit" class="btn btn-primary px-4">
                        Apply Filters
                    </button>
                    <a href="{{url('admin/oc-cutting')}}">
                    <button type="button" class="btn btn-primary px-4">
                        Reset Filters
                    </button>
                    </a>
                </div>

            </div>
        </form>
            
           
            <div id="example1_wrapper" class=" dt-bootstrap4">
                <div class="row">
                    <div class="col-sm-12">
                         <div class='tablescroll'>
                            <div class="table-responsive">
                                <!-- OVERALL SUMMARY -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Overall Summary</strong>
                                            
                                            <div>
                                                
                                                <input type="hidden" value="{{ $all_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy All Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY CARDS -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                        <div class="d-flex">
                                                            <h4>₹{{ $total_summary_bet_amount ?? 0 }} </h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $total_summary_bet ?? 0 }})</sub>
                                                        </div>
                                                        
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                        <div class="d-flex">
                                                            <h4>₹{{ $total_summary_win_amount ?? 0 }} </h4>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <div class="d-flex">
                                                            <h4>₹{{ $total_summary_bet_amount - $total_summary_win_amount?? 0 }} </h4>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                        </div>
                                    </div>
                                    
                                    
                                    @if(request('game_id') == 'all' || request('game_id') == 'single')
                                    <!-- SINGLE Digit SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Single Digit</strong>
                                    
                                            <div>
                                                <input type="hidden" value="{{ $single_ank_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Single Ank Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $single_ank_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $single_ank_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $single_digit_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $single_ank_total - $single_digit_win_amount ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($single_bits)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(1, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    @endif
                                    
                                    @if(request('game_id') == 'all' || request('game_id') == 'pana')
                                    <!-- SINGLE Pana SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Single Pana</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $single_pana_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Single Pana Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $single_pana_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $single_pana_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $single_pana_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $single_pana_total - $single_pana_win_amount ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($single_pannas)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                   
                                    <!-- DOUBLE Pana SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Double Pana</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $double_pana_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Double Pana Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $double_pana_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $double_pana_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $double_pana_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $double_pana_total - $double_pana_win_amount ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($double_pannas)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    
                                    <!-- TRIPLE Pana SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Triple Pana</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $triple_pana_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Triple Pana Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $triple_pana_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $triple_pana_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $triple_pana_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $triple_pana_total - $triple_pana_win_amount  ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($triple_pannas)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    @endif
                                    
                                    
                                     @if(request('game_id') == 'all' || request('game_id') == 'jodi')
                                    <!-- Jodia SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Jodi</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $jodi_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Jodi Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $jodi_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $jodi_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $jodi_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $jodi_total - $jodi_win_amount ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($jodi_bits)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    @endif
                                    
                                    
                                     @if(request('game_id') == 'all' || request('game_id') == 'halfsangam')
                                    <!-- Half Sangam SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Half Sangam</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $half_sangam_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Half Sangam Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $half_sangam_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $half_sangam_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $half_sangam_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $half_sangam_total - $half_sangam_win_amount?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($half_sangam)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place_panna }}-{{ $row->bit_place_single }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    @endif
                                    
                                     @if(request('game_id') == 'all' || request('game_id') == 'fullsangam')
                                    <!-- Full Sangam SECTION -->
                                    <div class="card mt-3">
                                        <div class="card-header d-flex justify-content-between">
                                            <strong>Full Sangam</strong>
                                    
                                            <div>
                                                 <input type="hidden" value="{{ $full_sangam_copy }}">
                                                    <button type="button"
                                                            class="btn btn-sm btn-primary copy-btn">
                                                        Copy Full Sangam Data
                                                    </button>
                                            </div>
                                        </div>
                                    
                                        <div class="card-body">
                                    
                                            <!-- SUMMARY -->
                                            <div class="row mb-3">
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-info text-white rounded">
                                                        <h6>Total Amount</h6>
                                                       <div class="d-flex">
                                                            <h4>₹{{ $full_sangam_total ?? 0 }}</h4>
                                                            <sub class="mt-3"> (Total Bids - {{ $full_sangam_total_bits ?? 0 }})</sub>
                                                        </div>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-warning text-dark rounded">
                                                        <h6>Winning Amount</h6>
                                                            <h4>₹{{ $full_sangam_win_amount ?? 0 }} </h4>
                                                    </div>
                                                </div>
                                    
                                                <div class="col-md-4">
                                                    <div class="p-3 bg-danger text-white rounded">
                                                        <h6>Total Profit</h6>
                                                        <h4>₹{{ $full_sangam_total - $full_sangam_win_amount ?? 0 }}</h4>
                                                    </div>
                                                </div>
                                    
                                            </div>
                                    
                                            <!-- TABLE -->
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-striped">
                                    
                                                    <thead>
                                                        <tr>
                                                            <th>Digit</th>
                                                            <th>Total Bids</th>
                                                            <th>Total Amount</th>
                                                            <th>Winning Amount</th>
                                                            <th>Predicted Winning</th>
                                                            <th>Profit</th>
                                                            <th>Loss</th>
                                                        </tr>
                                                    </thead>
                                    
                                                    <tbody>
                                    
                                                       @foreach(collect($full_sangam)->sortByDesc(function ($row) {
                                                            return $row->win_amount ?? 0;
                                                        }) as $row)
                                                        
                                                            @php
                                                                $win_amount = $row->win_amount ?? 0;
                                                                $pnl = $win_amount - $row->total_amount;
                                                            @endphp
                                                        
                                                            <tr>
                                                                <td>{{ $row->bit_place_panna }}-{{ $row->bit_place_single }}</td>
                                                                <td><a href="#">View</a></td>
                                                                <td>₹{{ $row->total_amount }}</td>
                                                                <td>₹{{ $win_amount }}</td>
                                                                <td>₹{{ predictWin(5, $row->total_amount) }}</td>
                                                                <td>₹{{ $pnl < 0 ? abs($pnl) : 0 }}</td>
                                                                <td>₹{{ $pnl > 0 ? $pnl : 0 }}</td>
                                                            </tr>
                                                        
                                                        @endforeach
                                    
                                                    </tbody>
                                    
                                                </table>
                                            </div>
                                    
                                        </div>
                                    </div>
                                    @endif
                                    
                                   
                            </div>
                        </div>
                  </div>
                </div>
              </div>
            </div>
          </div>


 @endsection
@section('js-content')

<script>
    document.addEventListener('DOMContentLoaded', function () {

        document.querySelectorAll('.copy-btn').forEach(function (button) {

            button.addEventListener('click', function () {

                let text = this.previousElementSibling.value;

                navigator.clipboard.writeText(text).then(function () {
                    alert('Copied successfully');
                }).catch(function (err) {
                    console.error('Copy failed', err);
                });

            });

        });

    });
</script>
@endsection