
<?php $__env->startSection('title', 'Customer Support'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-header"><h1>Customer Support</h1><p>Message clients in real time</p></div>

<form class="toolbar" method="POST" action="<?php echo e(route('admin.support.start')); ?>">
    <?php echo csrf_field(); ?>
    <select name="user_id" class="md-select" required>
        <option value="">Start chat with client...</option>
        <?php $__currentLoopData = $clients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </select>
    <button type="submit" class="md-btn md-btn-tonal">Open Chat</button>
</form>

<div class="support-layout">
    <div class="support-list">
        <p style="padding:1rem;font-weight:700;border-bottom:1px solid var(--md-outline)">Chats</p>
        <div class="support-list-scroll">
            <?php $__empty_1 = true; $__currentLoopData = $conversations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $conv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <a href="<?php echo e(route('admin.support.index', ['conversation' => $conv->id])); ?>" class="contact-item <?php echo e($selected?->id === $conv->id ? 'active' : ''); ?>">
                <strong><?php echo e($conv->user->name); ?></strong>
                <small><?php echo e($conv->messages_count); ?> messages</small>
            </a>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <p style="padding:1rem;color:var(--md-on-surface-variant)">No conversations yet</p>
            <?php endif; ?>
        </div>
    </div>

    <div class="support-chat">
        <?php if($selected): ?>
        <div class="support-chat-header"><?php echo e($selected->user->name); ?> · <?php echo e($selected->user->email); ?></div>
        <?php endif; ?>
        <div class="support-messages <?php echo e($selected ? '' : 'support-messages--empty'); ?>">
            <?php if($selected): ?>
                <?php $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $msg): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="chat-bubble <?php echo e($msg->is_admin ? 'admin' : 'user'); ?>"><?php echo e($msg->body); ?></div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <p>Please select a chat to start messaging.</p>
            <?php endif; ?>
        </div>
        <?php if($selected): ?>
        <form class="support-compose" method="POST" action="<?php echo e(route('admin.support.message', $selected)); ?>">
            <?php echo csrf_field(); ?>
            <input type="text" name="body" class="md-input" placeholder="Type a message..." required style="flex:1">
            <button type="submit" class="md-btn md-btn-filled">Send</button>
        </form>
        <?php endif; ?>
    </div>

    <div class="support-list support-list--details">
        <p style="padding:1rem;font-weight:700;border-bottom:1px solid var(--md-outline)">User Details</p>
        <div class="support-list-scroll">
            <?php if($selected): ?>
            <div style="padding:1rem;font-size:0.9rem">
                <p><strong>Name:</strong> <?php echo e($selected->user->name); ?></p>
                <p style="margin-top:0.5rem"><strong>Email:</strong> <?php echo e($selected->user->email); ?></p>
                <p style="margin-top:0.5rem"><strong>Balance:</strong> $<?php echo e(number_format($selected->user->balance, 2)); ?></p>
                <p style="margin-top:0.5rem"><strong>Status:</strong> <?php echo e(ucfirst($selected->user->status)); ?></p>
            </div>
            <?php else: ?>
            <p style="padding:1rem;color:var(--md-on-surface-variant)">Select a conversation</p>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\SkyApps\Projects\Laravel_projects\web3derp\resources\views/admin/support/index.blade.php ENDPATH**/ ?>