<?php $__env->startSection('title', 'Monetization'); ?>
<?php $__env->startSection('heading', 'تحليلات الربح والاستخدام'); ?>
<?php $__env->startSection('subheading', 'مؤشرات الاشتراك، استخدام AI، والنقاط'); ?>

<?php $__env->startSection('content'); ?>
    <div class="mb-6 grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">إجمالي المستخدمين</p>
            <p class="mt-2 text-3xl font-bold text-madar-950"><?php echo e(number_format($totalUsers)); ?></p>
        </div>
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">مقدّر Free (غير مدفوع)</p>
            <p class="mt-2 text-3xl font-bold text-zinc-800"><?php echo e(number_format($freeUsersApprox)); ?></p>
        </div>
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">مشتركون (خطة غير Free)</p>
            <p class="mt-2 text-3xl font-bold text-teal-700"><?php echo e(number_format($paidUsers)); ?></p>
        </div>
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">رسائل AI اليوم</p>
            <p class="mt-2 text-3xl font-bold text-madar-950"><?php echo e(number_format($messagesToday)); ?></p>
        </div>
    </div>

    <div class="mb-6 grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">طلبات AI (إجمالي)</p>
            <p class="mt-2 text-2xl font-bold"><?php echo e(number_format($aiRequestsTotal)); ?></p>
        </div>
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">Tokens هذا الشهر</p>
            <p class="mt-2 text-2xl font-bold"><?php echo e(number_format($tokensMonth)); ?></p>
        </div>
        <div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
            <p class="text-sm font-medium text-zinc-500">DAU تقريبي (حدّث اليوم)</p>
            <p class="mt-2 text-2xl font-bold"><?php echo e(number_format($dauApprox)); ?></p>
        </div>
    </div>

    <div class="mb-8 rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm">
        <h2 class="mb-3 font-bold text-zinc-900">أرصدة المحافظ (مجمّع)</h2>
        <p class="text-2xl font-mono text-teal-800"><?php echo e(number_format((float) $walletTotal, 2)); ?></p>
        <p class="mt-2 text-xs text-zinc-500">Revenue الفعلي يتطلب ربط بوابات الدفع — انظر config/monetization.php</p>
    </div>

    <div class="grid gap-8 lg:grid-cols-2">
        <div class="rounded-2xl border border-zinc-200 bg-white shadow-sm">
            <div class="border-b border-zinc-100 px-5 py-4">
                <h2 class="font-bold text-zinc-900">توزيع الخطط (اشتراكات نشطة)</h2>
            </div>
            <ul class="divide-y divide-zinc-100">
                <?php $__empty_1 = true; $__currentLoopData = $topPlans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <li class="flex justify-between px-5 py-3 text-sm">
                        <span class="font-medium"><?php echo e($row['plan']); ?> <span class="text-zinc-400">(<?php echo e($row['slug']); ?>)</span></span>
                        <span class="font-mono"><?php echo e(number_format($row['count'])); ?></span>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <li class="px-5 py-6 text-sm text-zinc-500">لا بيانات بعد.</li>
                <?php endif; ?>
            </ul>
        </div>

        <div class="rounded-2xl border border-zinc-200 bg-white shadow-sm">
            <div class="border-b border-zinc-100 px-5 py-4">
                <h2 class="font-bold text-zinc-900">آخر طلبات AI</h2>
            </div>
            <ul class="divide-y divide-zinc-100">
                <?php $__empty_1 = true; $__currentLoopData = $recentAi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <li class="px-5 py-3 text-xs">
                        <span class="font-mono text-zinc-600">#<?php echo e($r->id); ?></span>
                        <span class="text-zinc-400">· <?php echo e($r->status); ?> · <?php echo e($r->tokens_used); ?> tok</span>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <li class="px-5 py-6 text-sm text-zinc-500">لا طلبات.</li>
                <?php endif; ?>
            </ul>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\madar-backend\resources\views\admin\monetization.blade.php ENDPATH**/ ?>