<?php
    $churchProfile = \App\Models\ChurchProfile::first();
    $churchName = $churchProfile?->church_name ?? 'Anglican Church St Peter and Paul';
    $churchLocation = $churchProfile?->location ?? 'Mwenge Kijitonyama';
    $currentUser = auth()->user();
    $currentInitials = $currentUser
        ? strtoupper(substr($currentUser->first_name ?: $currentUser->name, 0, 1).substr($currentUser->last_name ?: '', 0, 1))
        : 'AC';
    $currentInitials = trim($currentInitials) ?: 'AC';

    $navItems = [
        ['title' => 'Dashboard', 'icon' => 'layout-dashboard', 'route' => 'dashboard', 'active' => 'dashboard'],
        ['title' => 'Jumuiya', 'icon' => 'network', 'route' => 'jumuiyas.index', 'active' => 'jumuiyas.*'],
        ['title' => 'Members', 'icon' => 'users-round', 'route' => 'members.index', 'active' => 'members.*'],
        ['title' => 'Services', 'icon' => 'calendar-days', 'route' => 'services.index', 'active' => 'services.*'],
        ['title' => 'Attendance', 'icon' => 'scan-qr-code', 'route' => 'attendance.qr', 'active' => 'attendance.*'],
        ['title' => 'Sacrament', 'icon' => 'cross', 'route' => 'sacrament.index', 'active' => 'sacrament.*'],
        ['title' => 'Reports', 'icon' => 'bar-chart-3', 'route' => 'reports.attendance', 'active' => 'reports.*'],
        ['title' => 'Users', 'icon' => 'shield-check', 'route' => 'users.index', 'active' => 'users.*'],
        ['title' => 'Settings', 'icon' => 'settings', 'route' => 'settings.church-profile', 'active' => 'settings.*'],
    ];
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <title><?php echo $__env->yieldContent('title', 'Dashboard'); ?> · <?php echo e($churchName); ?></title>
    <?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.css', 'resources/js/app.js']); ?>
</head>
<body
    data-attendance-url="<?php echo e(route('attendance.mark')); ?>"
    data-success-message="<?php echo e(session('success')); ?>"
    data-error-message="<?php echo e(session('error')); ?>"
>
    <div id="page-loader" aria-hidden="true">
        <div>
            <div class="church-loader mx-auto"></div>
            <div class="mt-3 text-center fw-bold text-muted">Loading church office...</div>
        </div>
    </div>

    <div class="app-shell" id="app-shell">
        <aside class="app-sidebar" id="app-sidebar">
            <div class="brand-block d-flex align-items-center gap-3">
                <div class="brand-mark">AC</div>
                <div class="min-w-0">
                    <div class="brand-title"><?php echo e($churchName); ?></div>
                    <div class="brand-subtitle"><?php echo e($churchLocation); ?></div>
                </div>
                <button class="sidebar-close-button ms-auto" type="button" data-sidebar-close aria-label="Close menu">
                    <i data-lucide="x"></i>
                </button>
            </div>

            <nav class="sidebar-section">
                <?php $__currentLoopData = $navItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <a class="sidebar-link <?php echo e(request()->routeIs($item['active']) ? 'active' : ''); ?>" href="<?php echo e(route($item['route'])); ?>">
                        <i data-lucide="<?php echo e($item['icon']); ?>"></i>
                        <span><?php echo e($item['title']); ?></span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </nav>
        </aside>
        <div class="sidebar-overlay" data-sidebar-close aria-hidden="true"></div>

        <main class="app-main">
            <header class="topbar d-flex align-items-center justify-content-between gap-3">
                <div class="d-flex align-items-center gap-3 flex-grow-1">
                    <button class="top-icon-button sidebar-toggle-button" type="button" title="Menu" data-sidebar-toggle aria-controls="app-sidebar" aria-pressed="false">
                        <i data-lucide="menu"></i>
                    </button>
                    <form class="top-search" method="GET" action="<?php echo e(route('members.index')); ?>">
                        <i data-lucide="search"></i>
                        <input type="search" name="search" placeholder="Search members, jumuiya..." value="<?php echo e(request('search')); ?>">
                        <span>Ctrl K</span>
                    </form>
                </div>
                <div class="d-flex align-items-center gap-2 topbar-actions">
                    <?php echo $__env->yieldContent('module-actions'); ?>
                    <div class="dropdown">
                        <button class="top-button dropdown-toggle" type="button" data-bs-toggle="dropdown">
                            <i data-lucide="globe-2"></i>
                            <span>English</span>
                        </button>
                        <div class="dropdown-menu dropdown-menu-end">
                            <span class="dropdown-item active">English</span>
                            <span class="dropdown-item">Kiswahili</span>
                        </div>
                    </div>
                    <div class="dropdown">
                        <button class="top-icon-button" type="button" data-bs-toggle="dropdown" title="Quick add">
                            <i data-lucide="plus"></i>
                        </button>
                        <div class="dropdown-menu dropdown-menu-end">
                            <button class="dropdown-item" type="button" data-modal-url="<?php echo e(route('members.create')); ?>"><i data-lucide="user-plus"></i> Member</button>
                            <button class="dropdown-item" type="button" data-modal-url="<?php echo e(route('jumuiyas.create')); ?>"><i data-lucide="network"></i> Jumuiya</button>
                            <button class="dropdown-item" type="button" data-modal-url="<?php echo e(route('services.create')); ?>"><i data-lucide="calendar-plus"></i> Service</button>
                        </div>
                    </div>
                    <button class="top-icon-button" type="button" title="Notifications"><i data-lucide="bell"></i></button>
                    <button class="top-icon-button" type="button" title="Theme"><i data-lucide="moon"></i></button>
                    <div class="dropdown">
                        <button class="profile-button" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <div class="avatar-initials"><?php echo e($currentInitials); ?></div>
                            <span>
                                <strong><?php echo e($currentUser?->full_name ?? 'Church Admin'); ?></strong>
                                <em><?php echo e($currentUser?->position?->name ?? $currentUser?->role?->name ?? 'Admin'); ?></em>
                            </span>
                            <i data-lucide="chevron-down"></i>
                        </button>
                        <div class="dropdown-menu dropdown-menu-end profile-menu">
                            <div class="profile-menu-head">
                                <div class="avatar-initials"><?php echo e($currentInitials); ?></div>
                                <div>
                                    <strong><?php echo e($currentUser?->full_name); ?></strong>
                                    <span><?php echo e($currentUser?->email); ?></span>
                                </div>
                            </div>
                            <a class="dropdown-item" href="<?php echo e(route('profile.show')); ?>"><i data-lucide="user"></i> Profile</a>
                            <form method="POST" action="<?php echo e(route('logout')); ?>">
                                <?php echo csrf_field(); ?>
                                <button class="dropdown-item" type="submit"><i data-lucide="log-out"></i> Logout</button>
                            </form>
                        </div>
                    </div>
                </div>
            </header>

            <section class="page-content">
                <div class="content-heading">
                    <h1><?php echo $__env->yieldContent('title', 'Dashboard'); ?></h1>
                    <p><?php echo $__env->yieldContent('kicker', 'Church Membership, Attendance and Sacrament Management'); ?></p>
                </div>

                <?php if($errors->any()): ?>
                    <div class="alert alert-danger">
                        <strong>Angalia taarifa hizi:</strong>
                        <ul class="mb-0 mt-2">
                            <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li><?php echo e($error); ?></li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                    </div>
                <?php endif; ?>

                <?php echo $__env->yieldContent('content'); ?>
            </section>
        </main>
    </div>

    <div class="modal fade" id="remoteFormModal" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog modal-xl modal-dialog-scrollable">
            <div class="modal-content remote-modal-content"></div>
        </div>
    </div>
</body>
</html>
<?php /**PATH /var/www/html/anglican/resources/views/layouts/app.blade.php ENDPATH**/ ?>