

<?php $__env->startSection('content'); ?>

<div class="bg-white/10 backdrop-blur-lg border border-white/10 rounded-2xl shadow-2xl p-6">

    <!-- HEADER -->
    <div class="flex justify-between items-center mb-6">
        <h2 class="text-2xl font-bold text-white tracking-wide">
            ⚡ Feeder Control Panel
        </h2>

        <a href="<?php echo e(url('/feeder/create')); ?>"
           class="bg-gradient-to-r from-indigo-500 to-purple-600 hover:scale-105 transition text-white px-5 py-2 rounded-lg shadow-lg">
           + Add Feeder
        </a>
    </div>

    <!-- TABLE -->
    <div class="overflow-x-auto rounded-xl">
        <table class="w-full text-sm text-left text-gray-300">

            <thead class="bg-white/10 text-gray-200 uppercase text-xs tracking-wider">
                <tr>
                    <th class="px-4 py-3">Name</th>
                    <th class="px-4 py-3">Company</th>
                    <th class="px-4 py-3">IMEI</th>
                    <th class="px-4 py-3">Phase</th>
                    <th class="px-4 py-3">Status</th>
                    <th class="px-4 py-3 text-center">Control</th>
                    <th class="px-4 py-3">Last Alert</th>
                    <th class="px-4 py-3 text-center">View</th>
                </tr>
            </thead>

            <tbody>

            <?php $__empty_1 = true; $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

            <!-- MAIN ROW -->
            <tr class="border-b border-white/10 hover:bg-white/5 transition">

                <td class="px-4 py-3 text-white font-semibold">
                    <?php echo e($row->feeder_name); ?>

                </td>

                <td class="px-4 py-3">
                    <?php echo e($row->discom_name); ?>

                </td>

                <td class="px-4 py-3 font-mono text-indigo-300">
                    <?php echo e($row->imei_number); ?>

                </td>

                <td class="px-4 py-3">
                    <span class="bg-yellow-500/20 text-yellow-300 px-2 py-1 rounded text-xs">
                        <?php echo e($row->meter_phase); ?>

                    </span>
                </td>

                <!-- STATUS -->
                <td class="px-4 py-3">
                    <span class="px-2 py-1 rounded text-xs font-semibold
                    <?php echo e($row->feeder_on_off_status == 'ON' ? 'bg-green-500/20 text-green-300' : 'bg-red-500/20 text-red-300'); ?>">
                    <?php echo e($row->feeder_on_off_status); ?>

                    </span>
                </td>

                <!-- CONTROL -->
                <td class="px-4 py-3 text-center">
                    <a href="<?php echo e(url('/toggle/'.$row->id)); ?>"
                       class="px-4 py-1 rounded-lg text-white text-xs
                       <?php echo e($row->feeder_on_off_status == 'ON'
                            ? 'bg-red-600 hover:bg-red-700'
                            : 'bg-green-600 hover:bg-green-700'); ?>">
                       <?php echo e($row->feeder_on_off_status == 'ON' ? 'Turn OFF' : 'Turn ON'); ?>

                    </a>
                </td>

                <!-- ALERT -->
                <td class="px-4 py-3">
                    <div><?php echo e($row->alert_type); ?></div>
                    <div class="text-xs text-gray-400"><?php echo e($row->alert_time); ?></div>
                </td>

                <!-- EXPAND BUTTON -->
                <td class="px-4 py-3 text-center">
                    <button onclick="toggleRow(<?php echo e($row->id); ?>)"
                        class="bg-indigo-500 hover:bg-indigo-600 text-white px-3 py-1 rounded text-xs">
                        View
                    </button>
                </td>
                <td class="px-4 py-3 text-center">
    <a href="<?php echo e(url('/feeder/'.$row->id.'/edit')); ?>"
       class="bg-indigo-500 hover:bg-indigo-600 text-white px-3 py-1 rounded text-xs flex items-center justify-center gap-1">

    Edit

    </a>
</td>

            </tr>

            <!-- DETAILS ROW (ALL FIELDS) -->
            <tr id="details-<?php echo e($row->id); ?>" class="hidden bg-black/40">
                <td colspan="8" class="px-6 py-4 text-xs text-gray-300">

                    <div class="grid grid-cols-4 gap-4">

                        <!-- BASIC -->
                        <div>
                            <b>Feeder Code:</b> <?php echo e($row->feeder_code); ?><br>
                            <b>Type:</b> <?php echo e($row->feeder_type); ?><br>
                            <b>Voltage:</b> <?php echo e($row->voltage_level); ?><br>
                            <b>Substation:</b> <?php echo e($row->substation_name); ?><br>
                            <b>Substation Code:</b> <?php echo e($row->substation_code); ?><br>
                            <b>Length:</b> <?php echo e($row->feeder_length); ?> km<br>
                            <b>Category:</b> <?php echo e($row->feeder_category); ?>

                        </div>

                        <!-- LOCATION -->
                        <div>
                            <b>State:</b> <?php echo e($row->state); ?><br>
                            <b>District:</b> <?php echo e($row->district); ?><br>
                            <b>City:</b> <?php echo e($row->city); ?><br>
                            <b>Zone:</b> <?php echo e($row->zone); ?><br>
                            <b>Circle:</b> <?php echo e($row->circle); ?><br>
                            <b>Division:</b> <?php echo e($row->division); ?><br>
                            <b>Subdivision:</b> <?php echo e($row->subdivision); ?><br>
                            <b>Lat:</b> <?php echo e($row->latitude); ?><br>
                            <b>Lng:</b> <?php echo e($row->longitude); ?>

                        </div>

                        <!-- CONSUMER -->
                        <div>
                            <b>Consumer ID:</b> <?php echo e($row->consumer_id); ?><br>
                            <b>Account:</b> <?php echo e($row->account_number); ?><br>
                            <b>Name:</b> <?php echo e($row->customer_name); ?><br>
                            <b>Type:</b> <?php echo e($row->connection_type); ?><br>
                            <b>Load:</b> <?php echo e($row->load_sanctioned); ?> kW<br>
                            <b>Contract:</b> <?php echo e($row->contract_demand); ?><br>
                            <b>Tariff:</b> <?php echo e($row->tariff_category); ?>

                        </div>

                        <!-- ELECTRICAL -->
                        <div>
                            <b>Transformer:</b> <?php echo e($row->transformer_capacity); ?> kVA<br>
                            <b>Connected:</b> <?php echo e($row->connected_load); ?><br>
                            <b>Peak:</b> <?php echo e($row->peak_load); ?><br>
                            <b>Average:</b> <?php echo e($row->average_load); ?><br>
                            <b>PF:</b> <?php echo e($row->power_factor); ?><br>
                            <b>Freq:</b> <?php echo e($row->frequency); ?>

                        </div>

                        <!-- PHASE -->
                        <div>
                            <b>Voltage R:</b> <?php echo e($row->voltage_r_phase); ?><br>
                            <b>Voltage Y:</b> <?php echo e($row->voltage_y_phase); ?><br>
                            <b>Voltage B:</b> <?php echo e($row->voltage_b_phase); ?><br>
                            <b>Current R:</b> <?php echo e($row->current_r_phase); ?><br>
                            <b>Current Y:</b> <?php echo e($row->current_y_phase); ?><br>
                            <b>Current B:</b> <?php echo e($row->current_b_phase); ?>

                        </div>

                        <!-- METER -->
                        <div>
                            <b>Meter No:</b> <?php echo e($row->meter_serial_number); ?><br>
                            <b>Make:</b> <?php echo e($row->meter_make); ?><br>
                            <b>Type:</b> <?php echo e($row->meter_type); ?><br>
                            <b>Phase:</b> <?php echo e($row->meter_phase); ?><br>
                            <b>Installed:</b> <?php echo e($row->meter_installation_date); ?><br>
                            <b>Status:</b> <?php echo e($row->meter_status); ?>

                        </div>

                        <!-- MODEM -->
                        <div>
                            <b>IMEI:</b> <?php echo e($row->imei_number); ?><br>
                            <b>Serial:</b> <?php echo e($row->modem_serial_number); ?><br>
                            <b>Make:</b> <?php echo e($row->modem_make); ?><br>
                            <b>Model:</b> <?php echo e($row->modem_model); ?><br>
                            <b>SIM:</b> <?php echo e($row->sim_number); ?><br>
                            <b>Network:</b> <?php echo e($row->network_provider); ?><br>
                            <b>Signal:</b> <?php echo e($row->signal_strength); ?><br>
                            <b>IP:</b> <?php echo e($row->ip_address); ?><br>
                            <b>APN:</b> <?php echo e($row->apn); ?><br>
                            <b>Firmware:</b> <?php echo e($row->firmware_version); ?><br>
                            <b>Status:</b> <?php echo e($row->modem_status); ?><br>
                            <b>Last Comm:</b> <?php echo e($row->last_communication_time); ?>

                        </div>

                        <!-- ENERGY -->
                        <div>
                            <b>Import:</b> <?php echo e($row->energy_import); ?><br>
                            <b>Export:</b> <?php echo e($row->energy_export); ?><br>
                            <b>Loss:</b> <?php echo e($row->losses); ?><br>
                            <b>Total Units:</b> <?php echo e($row->total_units); ?><br>
                            <b>Billed:</b> <?php echo e($row->billed_units); ?><br>
                            <b>Revenue:</b> <?php echo e($row->collected_revenue); ?>

                        </div>

                        <!-- MAINTENANCE -->
                        <div>
                            <b>Last Maint:</b> <?php echo e($row->last_maintenance_date); ?><br>
                            <b>Next:</b> <?php echo e($row->next_maintenance_date); ?><br>
                            <b>Fault:</b> <?php echo e($row->fault_type); ?><br>
                            <b>Location:</b> <?php echo e($row->fault_location); ?><br>
                            <b>History:</b> <?php echo e($row->fault_history); ?>

                        </div>

                        <!-- OPERATOR -->
                        <div>
                            <b>Operator:</b> <?php echo e($row->operator_name); ?><br>
                            <b>ID:</b> <?php echo e($row->operator_id); ?><br>
                            <b>Engineer:</b> <?php echo e($row->assigned_engineer); ?><br>
                            <b>Contact:</b> <?php echo e($row->contact_number); ?>

                        </div>

                    </div>

                </td>
            </tr>

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="8" class="text-center py-6 text-gray-400">
                        No feeders available
                    </td>
                </tr>
            <?php endif; ?>

            </tbody>

        </table>
    </div>

</div>

<!-- JS TOGGLE -->
<script>
function toggleRow(id) {
    let row = document.getElementById('details-' + id);
    row.classList.toggle('hidden');
}
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home2/jitrealx/public_html/amccms/resources/views/feeder/index.blade.php ENDPATH**/ ?>