<?php $__env->startSection('content'); ?>
    <section class="page">
        <div class="section-header">
            <div>
                <h1>Dashboard</h1>
                <p class="muted" style="margin: 0;">Welcome back, <?php echo e(auth()->user()->name); ?>.</p>
            </div>
            <div style="display: flex; gap: 12px; align-items: center;">
                <div style="position: relative;">
                    <button class="button secondary" type="button" onclick="document.getElementById('theme-menu').style.display = document.getElementById('theme-menu').style.display === 'none' ? 'block' : 'none'">
                        <i class="ph ph-palette" style="margin-right: 6px;"></i> Theme
                    </button>
                    <div id="theme-menu" class="dropdown-menu" style="display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: rgba(255, 255, 255, 0.95); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 100; min-width: 160px; padding: 8px 0;">
                        <a href="#" onclick="setTheme('weather-default'); return false;" onmouseover="this.style.background='var(--surface-hover)'" onmouseout="this.style.background='transparent'" style="display: block; padding: 8px 12px; color: var(--text); text-decoration: none; font-size: 13px;">⚪ Standard</a>
                        <a href="#" onclick="setTheme('live'); return false;" onmouseover="this.style.background='var(--surface-hover)'" onmouseout="this.style.background='transparent'" style="display: block; padding: 8px 12px; color: var(--text); text-decoration: none; font-size: 13px;">⛅ Live Weather</a>
                        <a href="#" onclick="setTheme('weather-sunny'); return false;" onmouseover="this.style.background='var(--surface-hover)'" onmouseout="this.style.background='transparent'" style="display: block; padding: 8px 12px; color: var(--text); text-decoration: none; font-size: 13px;">☀️ Sunlight</a>
                        <a href="#" onclick="setTheme('weather-rainy'); return false;" onmouseover="this.style.background='var(--surface-hover)'" onmouseout="this.style.background='transparent'" style="display: block; padding: 8px 12px; color: var(--text); text-decoration: none; font-size: 13px;">🌧️ Rainy</a>
                    </div>
                </div>
                <a class="button" href="<?php echo e(route('conversations.index')); ?>">Open inbox</a>
            </div>
        </div>



        <div class="grid" style="margin-bottom: 16px;">
            <article class="card metric-card">
                <span class="metric-label">Open conversations</span>
                <strong class="metric-value"><?php echo e($openConversationsCount); ?></strong>
                <span class="muted">Active bot-led threads</span>
            </article>
            <article class="card metric-card">
                <span class="metric-label">Human handoffs</span>
                <strong class="metric-value"><?php echo e($pendingHumanCount); ?></strong>
                <span class="muted">Waiting for an agent</span>
            </article>
            <article class="card metric-card">
                <span class="metric-label">Unknown questions</span>
                <strong class="metric-value"><?php echo e($unknownQuestionsCount); ?></strong>
                <span class="muted">Need training review</span>
            </article>
            <article class="card metric-card">
                <span class="metric-label">Callback requests</span>
                <strong class="metric-value"><?php echo e($callbackRequestsCount); ?></strong>
                <span class="muted">Open customer follow-ups</span>
            </article>
        </div>

        <div class="grid" style="grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);">
            <section class="panel">
                <div class="panel-header">
                    <div>
                        <h2>Recent conversations</h2>
                        <span class="muted">Latest customer activity</span>
                    </div>
                    <a class="button secondary" href="<?php echo e(route('conversations.index')); ?>">View all</a>
                </div>
                <div class="panel-body">
                    <?php if($recentConversations->isEmpty()): ?>
                        <div class="empty-state">No conversations yet.</div>
                    <?php else: ?>
                        <div class="table-wrap">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Contact</th>
                                        <th>Channel</th>
                                        <th>Status</th>
                                        <th>Last message</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $recentConversations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $conversation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td>
                                                <a href="<?php echo e(route('conversations.show', $conversation)); ?>">
                                                    <strong><?php echo e($conversation->contact->name ?? $conversation->contact->phone ?? 'Unknown contact'); ?></strong>
                                                </a>
                                            </td>
                                            <td><?php echo e(ucfirst($conversation->channel)); ?></td>
                                            <td>
                                                <span class="<?php echo \Illuminate\Support\Arr::toCssClasses(['badge', 'warning' => $conversation->status === 'pending_human']); ?>">
                                                    <?php echo e(str_replace('_', ' ', ucfirst($conversation->status))); ?>

                                                </span>
                                            </td>
                                            <td class="muted"><?php echo e($conversation->last_message_at?->diffForHumans() ?? 'No messages'); ?></td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    <?php endif; ?>
                </div>
            </section>

            <aside class="stack">
                <section class="card">
                    <span class="metric-label">Bot resolution rate</span>
                    <strong class="metric-value"><?php echo e($botResolutionRate); ?>%</strong>
                    <span class="muted">Based on customer and bot messages</span>
                </section>

                <section class="card">
                    <span class="metric-label">Knowledge base</span>
                    <div class="activity-row">
                        <span>Active intents</span>
                        <strong><?php echo e($activeIntentsCount); ?></strong>
                    </div>
                    <div class="activity-row">
                        <span>Approved responses</span>
                        <strong><?php echo e($approvedResponsesCount); ?></strong>
                    </div>
                </section>
            </aside>
        </div>
    </section>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', [
    'title' => 'Dashboard | VejalNai',
    'topbarTitle' => 'Operations Dashboard',
    'topbarSubtitle' => 'Live support automation overview',
], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecom123/public_html/chat.shunnointernational.com/resources/views/dashboard.blade.php ENDPATH**/ ?>