<?php $__env->startSection('title', 'Notifications'); ?>

<?php $__env->startSection('content'); ?>
<?php $__env->startPush('styles'); ?>
<link rel="stylesheet" href="<?php echo e(asset('admin/css/notificationadmin.css')); ?>">
<?php $__env->stopPush(); ?>


<div class="notifications-page">
    <div class="notifications-wrap">

        <div class="notifications-head">
            <div class="notifications-title">
                <h1>Notifications</h1>

                <p>
                    <?php if($unreadCount > 0): ?>
                        <?php echo e($unreadCount); ?>

                        unread notification<?php echo e($unreadCount > 1 ? 's' : ''); ?>

                    <?php else: ?>
                        You're all caught up
                    <?php endif; ?>
                </p>
            </div>

            <?php if($unreadCount > 0): ?>
                <form method="POST" action="<?php echo e(route('notifications.read-all')); ?>">
                    <?php echo csrf_field(); ?>

                    <button type="submit" class="mark-all-btn">
                        ✓ Mark all as read
                    </button>
                </form>
            <?php endif; ?>
        </div>

        <?php if(session('success')): ?>
            <div style="
                padding:9px 11px;
                margin-bottom:10px;
                border-radius:9px;
                background:#eaf8f0;
                border:1px solid #ccebd9;
                color:#287646;
                font-size:8px;
                font-weight:700;
            ">
                <?php echo e(session('success')); ?>

            </div>
        <?php endif; ?>

        <div class="notification-list">

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

                <?php
                    $data = $notification->data ?? [];

                    $level = data_get($data, 'level', 'info');

                    if (!in_array(
                        $level,
                        ['success', 'warning', 'error', 'info'],
                        true
                    )) {
                        $level = 'info';
                    }

                    $title = data_get(
                        $data,
                        'title',
                        'Notification'
                    );

                    $message = data_get(
                        $data,
                        'message',
                        ''
                    );

                    $loanId = data_get(
                        $data,
                        'loan_id'
                    );

                    $loanNumber = data_get(
                        $data,
                        'loan_number'
                    );
                ?>

                <div class="notification-card <?php echo e($notification->read_at ? 'read' : 'unread'); ?>">

                    <div class="notification-dot"></div>

                    <div class="notification-content">

                        <div class="notification-title-row">

                            <div class="notification-title">
                                <?php echo e($title); ?>

                            </div>

                            <span class="notification-level level-<?php echo e($level); ?>">
                                <?php echo e($level); ?>

                            </span>

                        </div>

                        <div class="notification-message">
                            <?php echo e($message); ?>

                        </div>

                        <div class="notification-meta">
                            <?php echo e($notification->created_at?->format('d M Y, h:i A') ?? ''); ?>


                            <?php if($loanNumber): ?>
                                · <?php echo e($loanNumber); ?>

                            <?php endif; ?>
                        </div>

                    </div>

                    <?php if(!$notification->read_at || $loanId): ?>

                        <div class="notification-action">

                            <form
                                method="POST"
                                action="<?php echo e(route('notifications.read', $notification->id)); ?>"
                            >
                                <?php echo csrf_field(); ?>

                                <button type="submit">
                                    <?php echo e($notification->read_at ? 'View' : 'Open'); ?>

                                </button>
                            </form>

                        </div>

                    <?php endif; ?>

                </div>

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                <div class="empty-notifications">
                    <strong>🔔 No notifications</strong>
                    New loan and payment updates will appear here.
                </div>

            <?php endif; ?>

        </div>

        <?php if($notifications->hasPages()): ?>
            <div class="pagination">
                <?php echo e($notifications->onEachSide(1)->links()); ?>

            </div>
        <?php endif; ?>

    </div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/eduintxshop/public_html/loan.eduintx.shop/resources/views/notifications/index.blade.php ENDPATH**/ ?>