
{{-- resources/views/layouts/superadmin.blade.php --}}
<!DOCTYPE html>
<html lang="ar" dir="rtl">
@php
  $linkBase = 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition';
    $onAiAnalyticsUser = request()->routeIs('ai.analytics.user.report');


    /* ============================================================
       ✅ GLOBAL SAFE DEFAULTS (prevents Undefined variable errors)
       Put ONCE in: resources/views/layouts/superadmin.blade.php
       Above the sidebar blocks.
       ============================================================ */
$rSystemErd  = $rSystemErd  ?? 'superadmin.falcon-room.system-erd.index';
$onSystemErd = $onSystemErd ?? request()->routeIs($rSystemErd.'*');
    // -------- WhatsApp routes (defaults) --------
    $rWaLives        = $rWaLives        ?? 'superadmin.falcon-room.whatsapp-lives.index';
    $rWaMeetings     = $rWaMeetings     ?? 'superadmin.whatsapp.meetings.index';
    $rWaDailyReading = $rWaDailyReading ?? 'superadmin.whatsapp.daily-reading.index';
    $rWaSystem       = $rWaSystem       ?? 'superadmin.whatsapp.system.index';
    $rWaQuick        = $rWaQuick        ?? 'superadmin.whatsapp.quick.index';
    $rWaStatement    = $rWaStatement    ?? 'superadmin.whatsapp.statement.index';

    $rWhatsAbs        = $rWhatsAbs        ?? 'superadmin.whatsapp.absences.index';
    $rWhatsGuestHours = $rWhatsGuestHours ?? 'superadmin.whatsapp.guests-hours.index';
    $rWhatsPresence   = $rWhatsPresence   ?? 'superadmin.whatsapp.presence.index';
    $rWhatsTests      = $rWhatsTests      ?? 'superadmin.whatsapp.tests.index';
    $rWhatsDecisions  = $rWhatsDecisions  ?? 'superadmin.whatsapp.decisions.index';
    $rWhatsRisk       = $rWhatsRisk       ?? 'superadmin.whatsapp.risk.index';
  $zuhraOpen = request()->routeIs('superadmin.zuhra.*');
    // -------- WhatsApp active flags (defaults) --------
    $onWhatsAbs        = $onWhatsAbs        ?? request()->routeIs($rWhatsAbs);
    $onWhatsGuestHours = $onWhatsGuestHours ?? request()->routeIs($rWhatsGuestHours);
    $onWhatsPresence   = $onWhatsPresence   ?? request()->routeIs($rWhatsPresence.'*');
    $onWhatsTests      = $onWhatsTests      ?? request()->routeIs($rWhatsTests);
    $onWhatsDecisions  = $onWhatsDecisions  ?? request()->routeIs($rWhatsDecisions.'*');
    $onWhatsRisk       = $onWhatsRisk       ?? request()->routeIs($rWhatsRisk);

    // -------- EES routes (defaults) --------
    $rEesAttendanceHeatmap  = $rEesAttendanceHeatmap  ?? 'superadmin.falcon-room.ees.attendance-heatmap';
    $rEesEngagementIntent   = $rEesEngagementIntent   ?? 'superadmin.falcon-room.ees.engagement-intent';
    $rEesInfluenceMapping   = $rEesInfluenceMapping   ?? 'superadmin.falcon-room.ees.influence-mapping';
    $rEesConsistencyDetector= $rEesConsistencyDetector?? 'superadmin.falcon-room.ees.consistency-detector';
    $rEesProactivePerf      = $rEesProactivePerf      ?? 'superadmin.falcon-room.ees.proactive-performance';
    $rEesTestsAnalytics      = $rEesTestsAnalytics     ?? 'superadmin.falcon-room.ees.tests-analytics';
    $rEesMember360          = $rEesMember360          ?? 'superadmin.falcon-room.ees.member360';
    $rEesFraudRadar         = $rEesFraudRadar         ?? 'superadmin.falcon-room.ees.fraud-radar';
    $rEesExperiments        = $rEesExperiments        ?? 'superadmin.falcon-room.ees.experiments';
    $rEesSmartSearch        = $rEesSmartSearch        ?? 'superadmin.falcon-room.ees.smart-search';

    // -------- EES active flags (defaults) --------
    $onEesAttendanceHeatmap   = $onEesAttendanceHeatmap   ?? request()->routeIs($rEesAttendanceHeatmap.'*');
    $onEesEngagementIntent    = $onEesEngagementIntent    ?? request()->routeIs($rEesEngagementIntent.'*');
    $onEesInfluenceMapping    = $onEesInfluenceMapping    ?? request()->routeIs($rEesInfluenceMapping.'*');
    $onEesConsistencyDetector = $onEesConsistencyDetector ?? request()->routeIs($rEesConsistencyDetector.'*');
    $onEesProactivePerf       = $onEesProactivePerf       ?? request()->routeIs($rEesProactivePerf.'*');
    $onEesTestsAnalytics      = $onEesTestsAnalytics      ?? request()->routeIs($rEesTestsAnalytics.'*');
    $onEesMember360           = $onEesMember360           ?? request()->routeIs($rEesMember360.'*');
    $onEesFraudRadar          = $onEesFraudRadar          ?? request()->routeIs($rEesFraudRadar.'*');
    $onEesExperiments         = $onEesExperiments         ?? request()->routeIs($rEesExperiments.'*');
    $onEesSmartSearch         = $onEesSmartSearch         ?? request()->routeIs($rEesSmartSearch.'*');

    // -------- Other flags used in your blocks (defaults) --------
    $onAiAnalytics      = $onAiAnalytics      ?? request()->routeIs('ai.analytics.index');
    $onAiAnalyticsUser  = $onAiAnalyticsUser  ?? (request()->routeIs('ai.analytics.index') && str_contains(request()->fullUrl(), '#user-report'));
    $onEesLivePulse     = $onEesLivePulse     ?? request()->routeIs('superadmin.falcon-room.ees.live-pulse');
    $onEesTaateerRadar  = $onEesTaateerRadar  ?? request()->routeIs('superadmin.falcon-room.ees.taateer-radar');
    $onEesMomentumDashboard = $onEesMomentumDashboard ?? request()->routeIs('superadmin.falcon-room.ees.momentum-dashboard');

    // Base class used in some old blocks (if you still reference it)
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

    $adminSectionOpen = $adminSectionOpen ?? request()->routeIs([
        'superadmin.evaluations.*',
        'superadmin.meetings.*',
        'superadmin.absences.*',
        'superadmin.high-level-requests.*',
        'superadmin.violations.*',
        'superadmin.reports-objections.*',
        'superadmin.notifications-monitor.*',
        'superadmin.notification-systems.*',
        'superadmin.system-notifications.*',
        'superadmin.daily-operations.*',
        'superadmin.promotion-warning-center.*',
        'superadmin.golden-achievements.*',
        'superadmin.falcon-room.team-stability.*',
        'superadmin.falcon-room.critical-cases.*',
        'superadmin.falcon-room.high-command.*',
        'site-updates.admin.*',
        // إذا عندك هاي الروتات استخدمها كمان:
        // 'superadmin.falcon-room.lives-insights.dll.*',
        // 'superadmin.falcon-room.system-erd.*',
        // 'superadmin.falcon-room.member-insights.*',
        // 'superadmin.falcon-room.member-reality.*',
    ]);

    $rReadAnalytics  = $rReadAnalytics  ?? 'superadmin.daily-reading.analytics.index';
    $onReadAnalytics = $onReadAnalytics ?? request()->routeIs($rReadAnalytics.'*');
    $readUrl         = \Illuminate\Support\Facades\Route::has($rReadAnalytics) ? route($rReadAnalytics) : '#';



$linkBase = 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition';

/* ====== الروتات الصحيحة حسب اللي عندك فعليًا بالكود ====== */
$rReadAnalytics     = 'superadmin.daily-reading-analytics.index';
$rAdminAudit        = 'superadmin.falcon-room.admin-audit-logs.index';
$rMemberInsights    = 'superadmin.falcon-room.member-insights.index';
$rMemberReality     = 'superadmin.falcon-room.member-reality.index';
$rInternalActivity  = 'superadmin.internal-activities.index';
$rSystemErd         = 'superadmin.falcon-room.system-erd.index';
$rDLL               = 'superadmin.falcon-room.lives-insights.dll.index';

$rHCPresence   = 'superadmin.falcon-room.high-command.presence';
$rHCRiskRadar  = 'superadmin.falcon-room.high-command.risk-radar';
$rHCDecisions  = 'superadmin.falcon-room.high-command.decisions';

$rNotifMonitor = 'superadmin.notifications-monitor.index';
$rNotifSystems = 'superadmin.notification-systems.index';
$rSysNoti      = 'superadmin.system-notifications.index';

/* ====== URL آمن (لو الروت مش موجود يرجع #) ====== */
$readUrl = Route::has($rReadAnalytics) ? route($rReadAnalytics) : '#';
$dllUrl  = Route::has($rDLL) ? route($rDLL) : '#';
$erdUrl  = Route::has($rSystemErd) ? route($rSystemErd) : '#';

/* ====== Active ====== */
$onReadAnalytics    = request()->routeIs('superadmin.daily-reading-analytics.*');
$onAdminAudit       = request()->routeIs('superadmin.falcon-room.admin-audit-logs.*');
$onMemberInsights   = request()->routeIs('superadmin.falcon-room.member-insights.*');
$onMemberReality    = request()->routeIs('superadmin.falcon-room.member-reality.*');
$onInternalActivity = request()->routeIs('superadmin.internal-activities.*');
$onSystemErd        = request()->routeIs('superadmin.falcon-room.system-erd.*');
$onDLL              = request()->routeIs('superadmin.falcon-room.lives-insights.dll.*');

$onHCPresence  = request()->routeIs($rHCPresence);
$onHCRiskRadar = request()->routeIs($rHCRiskRadar);
$onHCDecisions = request()->routeIs($rHCDecisions);

$onNotifMonitor = request()->routeIs($rNotifMonitor.'*');
$onNotifSystems = request()->routeIs($rNotifSystems.'*');
$onSysNoti      = request()->routeIs($rSysNoti.'*');

/* ====== فتح سكشن الإدارة العليا ====== */
$adminSectionOpen =
    $onReadAnalytics || $onAdminAudit || $onMemberInsights || $onMemberReality || $onInternalActivity || $onSystemErd || $onDLL
    || request()->routeIs('superadmin.evaluations.*')
    || request()->routeIs('superadmin.meetings.*')
    || request()->routeIs('superadmin.absences.*')
    || request()->routeIs('superadmin.high-level-requests.*')
    || request()->routeIs('superadmin.violations.*')
    || request()->routeIs('superadmin.reports-objections.*')
    || request()->routeIs('superadmin.falcon-room.high-command.*')
    || $onNotifMonitor || $onNotifSystems || $onSysNoti;
@endphp
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', 'لوحة الإدارة العليا - نظام فريق الوفاء الذهبي')</title>
    @php


if (!function_exists('safe_route')) {
    function safe_route(string $name, array $params = [], bool $absolute = true, string $fallback = '#'): string
    {
        try {
            return Route::has($name) ? route($name, $params, $absolute) : $fallback;
        } catch (\Throwable $e) {
            return $fallback;
        }
    }
}
@endphp
    {{-- Theme & Enhancement CSS --}}
    <link rel="stylesheet" href="{{ asset('css/theme-variables.css') }}">
    <link rel="stylesheet" href="{{ asset('css/skeletons.css') }}">
    <link rel="stylesheet" href="{{ asset('css/animations.css') }}">
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdn.tailwindcss.com"></script>
@auth
    @php
        // هذا هو المحتوى الحقيقي داخل @section('title')
        $pageTitle = trim($__env->yieldContent('title'));

        // المستخدم الحالي
        $u = auth()->user();

        // احفظ المكان فقط إذا تغيّر
        if ($u && $pageTitle && $u->current_place !== $pageTitle) {
            $u->forceFill(['current_place' => $pageTitle])->save();
        }
    @endphp
@endauth
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        primary: {
                            50: '#eff6ff', 100: '#dbeafe', 200: '#bfdbfe', 300: '#93c5fd',
                            400: '#60a5fa', 500: '#3b82f6', 600: '#2563eb', 700: '#1d4ed8',
                            800: '#1e40af', 900: '#1e3a8a',
                        },
                        superadmin: {
                            50: '#faf5ff', 100: '#f3e8ff', 200: '#e9d5ff', 300: '#d8b4fe',
                            400: '#c084fc', 500: '#a855f7', 600: '#9333ea', 700: '#7c3aed',
                            800: '#6b21a8', 900: '#581c87',
                        }
                    },
                    fontFamily: {
                        arabic: ['Cairo', 'Tajawal', 'sans-serif'],
                    }
                }
            }
        }
    </script>
@php
    try {
        $widgetChatResponse = app(\App\Http\Controllers\General\WidgetChatController::class)->init(request());
        $widgetChatData = $widgetChatResponse->getData(true); // ['chats' => ..., 'unread' => ...]
    } catch (\Throwable $e) {
        $widgetChatData = ['chats' => [], 'unread' => 0];
    }
@endphp
    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" crossorigin="anonymous" />

<style>
    body {
        font-family: 'Cairo', sans-serif;
        background: linear-gradient(135deg, #faf5ff 0%, #eff6ff 100%);
    }
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}
    /* Sidebar Transitions */
.sidebar-transition {
    transition: transform 0.22s cubic-bezier(0.55, 0.06, 0.68, 0.19);
}
#sidebar {

    color: #e5e7eb;

    background:
        radial-gradient(140% 90% at 10% 5%, rgba(56,189,248,0.45), transparent 60%),
        radial-gradient(140% 90% at 90% 10%, rgba(168,85,247,0.45), transparent 60%),
        radial-gradient(140% 90% at 40% 95%, rgba(16,185,129,0.30), transparent 65%),
        linear-gradient(180deg, #020617 0%, #040b1a 45%, #020617 100%);

    border-left: 1px solid rgba(255,255,255,0.12);

    box-shadow:
        0 0 0 1px rgba(15,23,42,0.9),
        0 30px 80px rgba(2,6,23,0.85);
}

/* Aurora Glow Layer */
#sidebar::before {

    background:
        radial-gradient(circle at 25% 20%, rgba(99,102,241,0.35), transparent 60%),
        radial-gradient(circle at 75% 25%, rgba(236,72,153,0.28), transparent 60%),
        radial-gradient(circle at 50% 85%, rgba(34,197,94,0.22), transparent 65%);
}

/* Content above background */



#sidebar .sidebar-header {
    background: linear-gradient(
        135deg,
        rgba(99,102,241,0.35),
        rgba(139,92,246,0.45)
    );
    border-bottom: 1px solid rgba(255,255,255,0.15);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.05);
}



#sidebar summary.nav-link::-webkit-details-marker {
    display: none;
}
#sidebar details[open] > summary.nav-link {
    background: linear-gradient(
        120deg,
        rgba(56,189,248,0.30),
        rgba(139,92,246,0.45)
    );
    border: 1px solid rgba(139,92,246,0.5);
    box-shadow: 0 14px 34px rgba(15,23,42,0.95);
}
#sidebar .nav-link.active {
    background: linear-gradient(
        120deg,
        rgba(56,189,248,0.35),
        rgba(129,140,248,0.45)
    );
    border: 1px solid rgba(99,102,241,0.55);
    box-shadow: 0 12px 32px rgba(15,23,42,0.9);
    color: #f9fafb;
}

/* Icons */
#sidebar .nav-link svg,
#sidebar .nav-link i {
    opacity: 0.95;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
#sidebar .nav-link:hover svg,
#sidebar .nav-link:hover i {
    opacity: 1;
    transform: translateX(-1px);
}

/*

  /* Dropdown Menu */
    .dropdown-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }
    .dropdown-menu.active { max-height: 2000px; }

    /* Navigation Link Hover Effect */
    .nav-link {
        position: relative;
        overflow: hidden;
        transition: all 0.3s ease;
    }
    .nav-link::before {
        content: '';
        position: absolute;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: right 0.5s;
    }
    .nav-link:hover::before { right: 100%; }

    /* Glass Effect */
    .glass-effect {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .sidebar-scroll {
        overflow-y: auto;
        overflow-x: hidden;
        height: calc(100vh - 80px - 120px);
        padding-bottom: 2.5rem;
        -webkit-overflow-scrolling: touch;
    }
    @media (max-width: 1024px) {
        .sidebar-scroll {
            height: calc(100vh - 80px - 140px);
            padding-bottom: 3rem;
        }
        .sidebar-transition {
            transform: translateX(100%);
        }
        .sidebar-transition.open {
            transform: translateX(0);
        }
    }
    @supports (-webkit-touch-callout: none) {
        .sidebar-scroll {
            height: calc(100vh - 80px - 140px);
            padding-bottom: max(2.5rem, env(safe-area-inset-bottom) + 1rem);
        }
        #sidebar { padding-bottom: env(safe-area-inset-bottom); }
        .sidebar-scroll { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
    }

    /* Scrollbar Styling */
/* ===== Sidebar Scrollbar | Neon Edge ===== */
.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: #05070f;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(
        to bottom,
        #22d3ee,
        #6366f1,
        #a855f7
    );
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(99,102,241,0.6);
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    box-shadow: 0 0 16px rgba(168,85,247,0.9);
}

/* Firefox */
.sidebar-scroll {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 #05070f;
}


/* ===== Active Link | Command Indicator ===== */
.nav-link.active {
    background: linear-gradient(
        90deg,
        rgba(99,102,241,0.25),
        rgba(168,85,247,0.15)
    );

    border-left: 3px solid #6366f1;

    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.05),
        0 6px 18px rgba(99,102,241,0.35);

    position: relative;
}

/* glowing dot */
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    box-shadow: 0 0 10px #6366f1;
}

    /* Active Link Indicator */
    .nav-link.active {
        background: linear-gradient(to left, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    /* Badge Animation */
    @keyframes pulse-scale { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
    .animate-pulse-scale { animation: pulse-scale 2s infinite; }

    .menu-section-title {
        font-size: 0.625rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255, 255, 255, 0.5);
        padding: 0.375rem 1rem;
        margin-top: 0.25rem;
    }

    /* Logout button spacing */
    nav.sidebar-scroll > div > div:last-child { margin-bottom: 2rem; }
</style>
</head>

<style>
    /* ===== AmirOS SuperAdmin Sidebar — جمال + تنظيم بدون تغيير المحتوى ===== */

    /* سكول بار أنعم لقائمة الجانب */
    #sidebar .sidebar-scroll {
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, 0.8) transparent;
    }

    #sidebar .sidebar-scroll::-webkit-scrollbar {
        width: 6px;
    }

    #sidebar .sidebar-scroll::-webkit-scrollbar-track {
        background: transparent;
    }

    #sidebar .sidebar-scroll::-webkit-scrollbar-thumb {
        background: linear-gradient(
            to bottom,
            rgba(148, 163, 184, 0.9),
            rgba(148, 163, 184, 0.35)
        );
        border-radius: 999px;
    }

    /* روابط القائمة الأساسية */
    #sidebar .nav-link {
        position: relative;
        border-radius: 0.85rem;
        transition:
            background 150ms ease,
            color 150ms ease,
            transform 120ms ease,
            box-shadow 150ms ease,
            border-color 150ms ease;
        cursor: pointer;
    }

    #sidebar .nav-link:hover {
        background: rgba(148, 163, 184, 0.08);
        transform: translateX(-1px);
    }

    #sidebar .nav-link svg,
    #sidebar .nav-link i {
        opacity: 0.92;
        transition:
            transform 120ms ease,
            opacity 120ms ease;
    }

    #sidebar .nav-link:hover svg,
    #sidebar .nav-link:hover i {
        opacity: 1;
        transform: translateX(-1px);
    }

    /* حالة الأكتيف (class="active") */
    #sidebar .nav-link.active {
        background: linear-gradient(
            120deg,
            rgba(56, 189, 248, 0.24),
            rgba(129, 140, 248, 0.32)
        );
        box-shadow: 0 14px 36px rgba(15, 23, 42, 0.9);
        color: #f9fafb;
        border: 1px solid rgba(56, 189, 248, 0.55);
    }

    #sidebar .nav-link.active svg,
    #sidebar .nav-link.active i {
        opacity: 1;
    }

    /* لتفاصيل الـ <details>/<summary> تبع الأقسام */
    #sidebar summary.nav-link::-webkit-details-marker {
        display: none;
    }

    #sidebar details[open] > summary.nav-link {
        background: linear-gradient(
            120deg,
            rgba(56, 189, 248, 0.18),
            rgba(139, 92, 246, 0.4)
        );
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.95);
        color: #f9fafb;
        border: 1px solid rgba(139, 92, 246, 0.5);
    }

    #sidebar details[open] > summary.nav-link svg {
        opacity: 1;
    }

    /* عناوين الأقسام الصغيرة (التقارير الإيجابية / السلبية ..إلخ) */
    #sidebar .menu-section-title,
    #sidebar .px-4.pt-2.pb-1.text-\[11px\].font-semibold.text-white\/40 {
        font-size: 0.7rem;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        color: rgba(148, 163, 184, 0.9);
    }

    /* كارد المستخدم في أسفل السايدبار */
    #sidebar .user-profile-card {
        border-radius: 0.9rem;
        background: linear-gradient(
            135deg,
            rgba(15, 23, 42, 0.9),
            rgba(30, 64, 175, 0.85)
        );
        border: 1px solid rgba(148, 163, 184, 0.4);
        box-shadow:
            0 18px 40px rgba(15, 23, 42, 0.95),
            0 0 0 1px rgba(15, 23, 42, 0.9);
    }

    /* زرّ تسجيل الخروج */
    #sidebar .logout-btn {
        transition:
            background 150ms ease,
            color 150ms ease,
            transform 120ms ease;
        border-radius: 0.6rem;
    }

    #sidebar .logout-btn:hover {
        background: rgba(248, 113, 113, 0.12);
        color: #fecaca;
        transform: translateY(-1px);
    }
</style>
    @stack('styles')

<body class="bg-gradient-to-br from-superadmin-50 to-primary-50 font-arabic antialiased" dir="rtl">

    <!-- Sidebar -->
<div id="sidebar"
     class="fixed inset-y-0 right-0 z-50 w-80 text-white sidebar-transition shadow-2xl lg:translate-x-0
            bg-gradient-to-b from-primary-800 via-primary-900 to-superadmin-900
            border-l border-white/10
            ring-1 ring-black/10 dark:ring-white/5
            isolate overflow-hidden">

    {{-- Aura خارجية خفيفة (زيادة فقط) --}}
    <div class="pointer-events-none absolute -top-24 -right-24 w-64 h-64 rounded-full bg-fuchsia-400/10 blur-3xl"></div>
    <div class="pointer-events-none absolute -bottom-24 -left-24 w-64 h-64 rounded-full bg-sky-400/10 blur-3xl"></div>

    <!-- Header -->
    <div class="relative flex items-center justify-center h-20
                bg-gradient-to-r from-primary-900 to-superadmin-800
                border-b border-primary-700 shadow-lg overflow-hidden">

        <!-- Glow خفيف وآمن (ما بلمس المحتوى) -->
        <div class="pointer-events-none absolute -top-16 -right-16 w-40 h-40 rounded-full bg-indigo-400/15 blur-3xl"></div>
        <div class="pointer-events-none absolute -bottom-16 -left-16 w-40 h-40 rounded-full bg-emerald-400/10 blur-3xl"></div>
        <div class="pointer-events-none absolute inset-0 bg-gradient-to-b from-white/5 via-transparent to-transparent"></div>

        {{-- Hairline shine (Enterprise) --}}
        <div class="pointer-events-none absolute inset-0 opacity-70
                    [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
             style="background:linear-gradient(90deg, transparent, rgba(255,255,255,.38), transparent);"></div>

        {{-- Subtle noise layer (اختياري لكن رسمي) --}}
        <div class="pointer-events-none absolute inset-0 opacity-[0.07] mix-blend-overlay"
             style="background-image:radial-gradient(rgba(255,255,255,.35) 1px, transparent 1px); background-size:12px 12px;"></div>

        <div class="relative flex items-center gap-3 px-6">
            <div class="relative w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center shadow-lg ring-2 ring-white/30
                        border border-white/10
                        shadow-[0_18px_60px_rgba(0,0,0,0.35)]">

                {{-- Inner highlight --}}
                <div class="pointer-events-none absolute inset-0 rounded-xl opacity-60
                            [mask-image:linear-gradient(to_bottom,black,transparent)]"
                     style="background:linear-gradient(180deg, rgba(255,255,255,.35), transparent);"></div>

                <svg class="w-7 h-7 text-white drop-shadow-[0_10px_25px_rgba(0,0,0,0.35)]" fill="currentColor" viewBox="0 0 24 24">
                    <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
                </svg>

            </div>

            <div class="text-right min-w-0">
                <h1 class="text-lg font-bold text-white tracking-tight truncate">الإدارة العليا</h1>

                <p class="text-xs text-white/80 truncate flex items-center gap-2 justify-end">
                    <span class="inline-flex items-center gap-2 px-2 py-0.5 rounded-full
                                 bg-white/10 border border-white/10 backdrop-blur
                                 shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]">
                        <span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>
                        نظام فريق الوفاء الذهبي
                    </span>
                </p>
            </div>
        </div>
    </div>

        <!-- Navigation -->
        <nav class="sidebar-scroll overflow-y-auto h-[calc(100vh-13rem)] sm:h-[calc(100vh-14rem)]
                    px-3 sm:px-4 py-4">
            <div class="space-y-1.5">
                <div class="space-y-2">
                @php
    /** @var \App\Models\User $user */
    $user = auth()->user();
    $role = $user->membership_status ?? $user->role ?? 'member';

    $isSuperAdmin = $role === 'super-admin' || $user->hasRole('super-admin');

    // لفتح مجموعة الدعوات لو نحن داخل إحدى صفحاتها
    $invitesSectionOpen = request()->routeIs([
        'invites.*',
        'member.invites.*',
        'superadmin.invites.*',
    ]);

    // عداد حالة الدعوات (خليه يجي من الكنترولر لو حابب، وإلا صفر)
    $pendingInvitesCount = $pendingInvitesCount ?? 0;
@endphp
@php $gsOpen = request()->routeIs('guest-submissions.participations.*'); @endphp
@php
    $socraticOpen = request()->routeIs('superadmin.socratic.*');
@endphp
@php

    use Carbon\Carbon;
    use Illuminate\Support\Facades\DB;
    use Illuminate\Support\Facades\Route;

    $tz    = config('app.timezone','Asia/Jerusalem');
    $today = Carbon::now($tz)->toDateString();

    try {
        $proTodayActiveNow = (int) DB::table('proactive_schedules')
            ->whereDate('event_date', $today)
            ->where('status','active')
            ->count();

        $proTodayTotal = (int) DB::table('proactive_schedules')
            ->whereDate('event_date', $today)
            ->whereIn('status',['upcoming','active'])
            ->count();

        $plusTodayCount = (int) DB::table('proactive_schedules')
            ->where('event_type','plus')
            ->whereIn('status',['upcoming','active'])
            ->whereDate('event_date',$today)
            ->count();
    } catch (\Throwable $e) {
        $proTodayActiveNow = 0;
        $proTodayTotal     = 0;
        $plusTodayCount    = 0;
    }

    $notesToday = $falconRolaNotesToday ?? 0;

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

    $rDashboard     = 'superadmin.falconRolaNotes.review.lock';
    $rReportsIndex  = 'superadmin.proactive.reports.index';
    $rReportCreate  = 'superadmin.proactive.report.create';
    $rStats         = 'superadmin.proactive.stats';
    $rSchedIndex    = 'superadmin.proactive.schedules.index';
    $rGrid          = 'superadmin.proactive.schedules.grid';
    $rPlusGrid      = 'superadmin.proactive.plus.grid';
    $rNews          = 'superadmin.proactive.news';
    $rUnitHours     = 'superadmin.unit-hours.index';
    $rFRN           = 'superadmin.falconRolaNotes.index';

    $proactiveOpen =
        request()->routeIs('superadmin.proactive.*')
        || request()->routeIs('superadmin.proactive-plus.*')
        || request()->routeIs('superadmin.unit-hours.*')
        || request()->routeIs('superadmin.falconRolaNotes.*')
        || request()->routeIs($rDashboard)
        || request()->routeIs($rReportsIndex)
        || request()->routeIs($rReportCreate)
        || request()->routeIs($rStats)
        || request()->routeIs($rSchedIndex)
        || request()->routeIs($rGrid)
        || request()->routeIs($rPlusGrid)
        || request()->routeIs($rNews);

    $href = function ($name, $fallback = '#') {
        return Route::has($name) ? route($name) : $fallback;
    };
@endphp

@if(auth()->check() && auth()->user()->hasRole('super-admin'))
{{-- لوحة التحكم — ستايل سقراط --}}
<a href="{{ route('superadmin.dashboard') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition
          {{ request()->routeIs('superadmin.dashboard')
                ? 'bg-white/15 text-white shadow-sm'
                : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    {{-- أيقونة كبسولة --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-indigo-500/15 border border-indigo-400/25 shadow-sm">
        <i class="fa-solid fa-gauge-high text-[12px] text-indigo-200"></i>
    </span>

    {{-- النص --}}
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">لوحة التحكم</span>
        <span class="text-[10px] opacity-70 truncate">
            نظرة عامة على النظام، الحالة، والإحصائيات
        </span>
    </div>

    {{-- مؤشر Active --}}
    @if(request()->routeIs('superadmin.dashboard'))
        <span class="ml-auto px-2 py-0.5 rounded-full text-[10px]
                     bg-indigo-500/20 text-indigo-200">
            نشِط
        </span>
    @endif
</a>
@php
    $msgMonitorOpen = request()->routeIs('superadmin.messages-monitor.*');
@endphp
@php
  $sentinelOpen = request()->routeIs('superadmin.sentinel.*');
@endphp
@php
  $imanRoomOpen = request()->routeIs('superadmin.iman.*');
@endphp

{{-- ✅ Pokemon System Sidebar Section (Details) --}}
@php
  $pokemonOpen = request()->routeIs('superadmin.pokemon.*');
@endphp

@php
  $academyOpen = request()->routeIs('superadmin.academy.*');
@endphp

<details class="relative group" @if($academyOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $academyOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-cyan-500/15 text-cyan-200 border border-cyan-400/30 shadow-sm">
        <i class="fa-solid fa-graduation-cap text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">الأكاديمية</span>
        <span class="text-[11px] opacity-70">Command Room • Analytics • Grades</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">
    <a href="{{ route('superadmin.academy.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.academy.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <span class="font-bold">لوحة الأكاديمية</span>
    </a>

    <a href="{{ route('superadmin.academy.courses.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.academy.courses.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-layer-group text-[12px]"></i>
      </span>
      <span class="font-bold">البرامج</span>
    </a>

    <a href="{{ route('superadmin.academy.grades.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.academy.grades.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-star text-[12px]"></i>
      </span>
      <span class="font-bold">الدرجات</span>
    </a>

    <a href="{{ route('superadmin.academy.analytics') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.academy.analytics') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-chart-simple text-[12px]"></i>
      </span>
      <span class="font-bold">الإحصائيات + AI</span>
    </a>

    <a href="{{ route('superadmin.academy.announcements.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.academy.announcements.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
        <i class="fa-solid fa-bullhorn text-[12px]"></i>
      </span>
      <span class="font-bold">إشعارات الأكاديمية</span>
    </a>
  </div>
</details>


@if($user->hasRole('academy-team'))
<a href="https://collage.amir-os.com" target="_blank"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          text-white/70 hover:text-white hover:bg-white/10">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-graduation-cap text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0">
        <div class="flex items-center gap-2">
            <span class="font-bold truncate">أكاديمية التيم</span>

            {{-- ✅ Badge --}}
            <span class="inline-flex items-center px-2 py-0.5 rounded-full
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200 text-[10px] font-extrabold">
                Academy
            </span>
        </div>

        <span class="text-[10px] opacity-70 truncate">College • Courses • Grades • Progress</span>
    </div>
</a>
@endif

<details class="relative group" @if($zuhraOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $zuhraOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
        <i class="fa-solid fa-crown text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">نظام زُهرة</span>
        <span class="text-[11px] opacity-70">SuperAdmin • Meetings + AI + Analytics</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">

    <a href="{{ route('superadmin.zuhra.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.zuhra.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة زُهرة</span>
        <span class="text-[10px] opacity-70">نظرة عامة + إنذارات</span>
      </div>
    </a>

    <a href="{{ route('superadmin.zuhra.meetings.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.zuhra.meetings.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
        <i class="fa-solid fa-calendar-check text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الاجتماعات</span>
        <span class="text-[10px] opacity-70">إدارة + فلترة</span>
      </div>
    </a>

    <a href="{{ route('superadmin.zuhra.analytics.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.zuhra.analytics.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-chart-pie text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الإحصائيات</span>
        <span class="text-[10px] opacity-70">AI + עוגות ותרשימים</span>
      </div>
    </a>

    <a href="{{ route('superadmin.zuhra.monitor.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.zuhra.monitor.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">المراقبة</span>
        <span class="text-[10px] opacity-70">تنبيهات + متابعة</span>
      </div>
    </a>

  </div>
</details>
<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>
{{-- ✅ ProActive Heroes Sidebar Section (Details) --}}
@php
  $proHeroesOpen = request()->routeIs('superadmin.proactiveHeroes.*');
@endphp

<details class="relative group" @if($proHeroesOpen) open @endif>
  <summary
    class="nav-link w-full flex items-center justify-between px-3 py-2 text-[13px] rounded-xl cursor-pointer list-none
           {{ $proHeroesOpen ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <div class="flex items-center gap-3 min-w-0">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-violet-500/15 border border-violet-400/25 text-violet-200">
        <i class="fa-solid fa-crown text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-extrabold truncate">أبطال الديجتال — ProActive</span>
        <span class="text-[10px] opacity-70 truncate">Score • Monitor • Bulk Decisions • Drawer</span>
      </div>
    </div>

    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">
    <a href="{{ route('superadmin.proactiveHeroes.index') }}"
       class="nav-link flex items-center gap-2 px-3 py-2 rounded-xl text-[12px]
              {{ request()->fullUrlIs(route('superadmin.proactiveHeroes.index')) ? 'bg-white/10 text-white' : 'text-white/70 hover:bg-white/10 hover:text-white' }}">
      <i class="fa-solid fa-gauge-high text-[12px] opacity-80"></i>
      <span>لوحة الجودة (Quality Hub)</span>
    </a>

    <a href="{{ route('superadmin.proactiveHeroes.index', ['tab'=>'reports','status'=>'pending']) }}"
       class="nav-link flex items-center gap-2 px-3 py-2 rounded-xl text-[12px]
              text-white/70 hover:bg-white/10 hover:text-white">
      <i class="fa-regular fa-clock text-[12px] opacity-80"></i>
      <span>تقارير تحت المراجعة</span>
    </a>

    <a href="{{ route('superadmin.proactiveHeroes.index', ['tab'=>'reports','risk'=>'high']) }}"
       class="nav-link flex items-center gap-2 px-3 py-2 rounded-xl text-[12px]
              text-white/70 hover:bg-white/10 hover:text-white">
      <i class="fa-solid fa-triangle-exclamation text-[12px] opacity-80"></i>
      <span>تقارير بخطر (High Risk)</span>
    </a>

    <a href="{{ route('superadmin.proactiveHeroes.index', ['tab'=>'notes','status'=>'pending']) }}"
       class="nav-link flex items-center gap-2 px-3 py-2 rounded-xl text-[12px]
              text-white/70 hover:bg-white/10 hover:text-white">
      <i class="fa-solid fa-notes-medical text-[12px] opacity-80"></i>
      <span>ملاحظات الصقر/رولا تحت المراجعة</span>
    </a>
  </div>
</details>
<details class="relative group" @if(request()->routeIs('superadmin.control-room.*')) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ request()->routeIs('superadmin.control-room.*') ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
        <i class="fa-solid fa-chess-queen text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">نظام أثينا Athena</span>
        <span class="text-[11px] opacity-70">غرفة قيادة • AI + Radar + Analytics</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">

    <a href="{{ route('superadmin.control-room.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.control-room.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة القيادة</span>
        <span class="text-[10px] opacity-70">KPIs + نبض النظام</span>
      </div>
    </a>

    <a href="{{ route('superadmin.control-room.ai') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.control-room.ai') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-brain text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">AI تحليلات</span>
        <span class="text-[10px] opacity-70">نصائح + مخاطر + فرص</span>
      </div>
    </a>

    <a href="{{ route('superadmin.control-room.analytics') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.control-room.analytics') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-chart-pie text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الإحصائيات</span>
        <span class="text-[10px] opacity-70">עוגות ותרשמים</span>
      </div>
    </a>

    <a href="{{ route('superadmin.control-room.live') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.control-room.live') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
        <i class="fa-solid fa-satellite-dish text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">مراقبة مباشرة</span>
        <span class="text-[10px] opacity-70">Live Sessions + Pages</span>
      </div>
    </a>

    <a href="{{ route('superadmin.control-room.security') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.control-room.security') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-shield-halved text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الأمان + الإشعارات</span>
        <span class="text-[10px] opacity-70">Audit + Broadcast</span>
      </div>
    </a>

  </div>
</details>
@php
  $ramadanOpen = $ramadanOpen ?? request()->routeIs('superadmin.ramadan.*');

  // بادج "قريبًا" — موحّد لكل البنود
  $soonText  = 'قريبًا';
  $soonClass = 'bg-indigo-500/18 border-indigo-400/25 text-indigo-200';

  // Helper صغير لتخفيف التكرار
  $isActive = fn($pattern) => request()->routeIs($pattern);

  $linkBase = 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl';
  $linkOn   = 'bg-white/15 text-white';
  $linkOff  = 'text-white/70 hover:text-white hover:bg-white/10';

  $badgeSoon = fn() => '<span class="inline-flex items-center justify-center min-w-[64px] h-6 px-2 rounded-full text-[11px] font-black border '.$soonClass.'">'.$soonText.'</span>';
@endphp

<details class="relative group" @if($ramadanOpen) open @endif>
    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $ramadanOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-moon text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">رمضان هلّ هلاله</span>
                <span class="text-[11px] opacity-70">مسابقات • سجلات • أوقات • تكريمات</span>
            </div>

            {{-- بادج عام للقسم (اختياري) --}}
            <span class="inline-flex items-center justify-center min-w-[64px] h-5 px-2 rounded-full
                         bg-indigo-500/20 text-indigo-200 border border-indigo-400/25 text-[11px] font-extrabold">
                قريبًا
            </span>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    {{-- الروابط --}}
    <div class="mt-2 space-y-1 px-2 pb-2">
{{-- 📑 تقارير المسابقات (مهم جدًا) --}}
<a href="{{ route('superadmin.ramadan.competitions.reports.index') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.ramadan.competitions.reports.*') ? $linkOn : $linkOff }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-clipboard-check text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <div class="flex items-center gap-2 min-w-0">
            <span class="font-extrabold truncate">تقارير المسابقات</span>

            {{-- ✅ BADGE --}}
            <span class="shrink-0 inline-flex items-center justify-center min-w-[72px] h-6 px-2 rounded-full
                         border border-amber-400/25 bg-amber-500/12 text-amber-200 text-[11px] font-black">
                مهم جدًا
            </span>
        </div>
        <span class="text-[10px] opacity-70 truncate">توثيق • ذكاء • مشاكل/تقدم • ترحيب</span>
    </div>

    <i class="fa-solid fa-chevron-left text-[11px] opacity-60"></i>
</a>

{{-- ✅ Sidebar: نظام الميزان الرمضاني الذكي --}}
<a href="{{ route('superadmin.ramadan.systems.balance') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.ramadan.systems.balance') ? $linkOn : $linkOff }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-scale-balanced text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <div class="flex items-center gap-2 min-w-0">
            <span class="font-extrabold truncate">نظام الميزان الرمضاني</span>

            <span class="shrink-0 inline-flex items-center justify-center min-w-[96px] h-6 px-2 rounded-full
                         border border-cyan-400/25 bg-cyan-500/12 text-cyan-200 text-[11px] font-black">
                ذكاء + ترحيب
            </span>
        </div>
        <span class="text-[10px] opacity-70 truncate">ترحيب • نقاط 9/10 • تأثير التوثيق • خطوات</span>
    </div>

    <i class="fa-solid fa-chevron-left text-[11px] opacity-60"></i>
</a>

{{-- ✅ Sidebar: نظام البوصلة القيادية --}}
<a href="{{ route('superadmin.ramadan.systems.compass') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.ramadan.systems.compass') ? $linkOn : $linkOff }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-compass-drafting text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <div class="flex items-center gap-2 min-w-0">
            <span class="font-extrabold truncate">نظام البوصلة القيادية</span>

            <span class="shrink-0 inline-flex items-center justify-center min-w-[72px] h-6 px-2 rounded-full
                         border border-fuchsia-400/25 bg-fuchsia-500/12 text-fuchsia-200 text-[11px] font-black">
                مهم
            </span>
        </div>
        <span class="text-[10px] opacity-70 truncate">إيجابيات • سلبيات • قرارات • أولويات</span>
    </div>

    <i class="fa-solid fa-chevron-left text-[11px] opacity-60"></i>
</a>
{{-- ✅ Sidebar: نظام الرادار السيادي للأعضاء --}}
<a href="{{ route('superadmin.ramadan.systems.member_radar') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.ramadan.systems.member_radar') ? $linkOn : $linkOff }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
        <i class="fa-solid fa-radar text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <div class="flex items-center gap-2 min-w-0">
            <span class="font-extrabold truncate">نظام الرادار السيادي</span>

            <span class="shrink-0 inline-flex items-center justify-center min-w-[92px] h-6 px-2 rounded-full
                         border border-indigo-400/25 bg-indigo-500/12 text-indigo-200 text-[11px] font-black">
                تحت الضوء
            </span>
        </div>
        <span class="text-[10px] opacity-70 truncate">قرارات فورية • سلوك/نقاط • تحفيز/متابعة</span>
    </div>

    <i class="fa-solid fa-chevron-left text-[11px] opacity-60"></i>
</a>
        {{-- 1. مسابقات رمضانية --}}
        <a href="{{ route('superadmin.ramadan.competitions.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.competitions.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-trophy text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">مسابقات رمضانية</span>
                <span class="text-[10px] opacity-70 truncate">إنشاء • إدارة • نتائج • أرشفة</span>
            </div>
            {!! $badgeSoon() !!}
        </a>
{{-- داخل <div class="mt-2 space-y-1 px-2 pb-2"> تبع رمضان --}}

{{-- 🎁 هدايا وميزانية --}}
<a href="{{ route('superadmin.ramadan.competitions.financial') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.competitions.financial') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-gift text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">هدايا وميزانية المسابقة</span>
        <span class="text-[10px] opacity-70 truncate">تحديد الجوائز • ضبط المصاريف • متابعة التكاليف</span>
    </div>
</a>


{{-- 📑 سجلات مالية --}}
<a href="{{ route('superadmin.ramadan.competitions.records') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.competitions.records') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-book text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">سجلات الهدايا والميزانية</span>
        <span class="text-[10px] opacity-70 truncate">تقارير صرف • مراجعة مالية • أرشفة العمليات</span>
    </div>
</a>
{{-- =========================
   ✅ أزرار السايدبار (كود واحد) — حسب روتاتكم بالضبط
========================= --}}

{{-- زوار رمضان --}}
<a href="{{ route('superadmin.ramadan.visitors.store') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.visitors.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-user-tag text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">زوار رمضان</span>
        <span class="text-[10px] opacity-70 truncate">إضافة زائر • إدارة • حذف</span>
    </div>
</a>

{{-- نقاط المسابقات اليومية --}}
<a href="{{ route('superadmin.ramadan.scores.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.scores.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-bolt text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">نقاط المسابقات اليومية</span>
        <span class="text-[10px] opacity-70 truncate">أعضاء + زوار • نقاط • دقائق</span>
    </div>
</a>

{{-- الأبطال (اليوم/الأسبوع/رمضان) --}}
<a href="{{ route('superadmin.ramadan.champions.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.champions.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-crown text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">الأبطال</span>
        <span class="text-[10px] opacity-70 truncate">بطل اليوم • بطل الأسبوع • بطل رمضان</span>
    </div>
</a>

{{-- كتالوج هدايا تيك توك --}}
<a href="{{ route('superadmin.ramadan.gifts.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.gifts.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-gift text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">هدايا تيك توك</span>
        <span class="text-[10px] opacity-70 truncate">Coins • عملات متعددة • صور</span>
    </div>
</a>

{{-- الجوائز/التوزيع (Awards) --}}
<a href="{{ route('superadmin.ramadan.gifts.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.awards.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-sky-500/15 border border-sky-400/25 text-sky-200">
        <i class="fa-solid fa-trophy text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">توزيع الجوائز</span>
        <span class="text-[10px] opacity-70 truncate">تحديد هدية • تسليم • توثيق</span>
    </div>
</a>

{{-- أوراق/مهام البرنامج --}}
<a href="{{ route('superadmin.ramadan.papers.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.papers.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
        <i class="fa-solid fa-file-lines text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">أوراق البرنامج</span>
        <span class="text-[10px] opacity-70 truncate">حسب الوقت • مهام • ملفات</span>
    </div>
</a>
{{-- 🎥 صور وفيديوهات --}}
<a href="{{ route('superadmin.ramadan.competitions.media') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.ramadan.competitions.media') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
        <i class="fa-solid fa-photo-film text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">صور وفيديوهات المسابقات</span>
        <span class="text-[10px] opacity-70 truncate">توثيق • تحميل • عرض • أرشفة</span>
    </div>
</a>
        {{-- 2. سجل رمضان --}}
        <a href="{{ route('superadmin.ramadan.log.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.log.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-book-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">سجل رمضان</span>
                <span class="text-[10px] opacity-70 truncate">توثيق • أحداث • ملاحظات • يوميات</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 3. المشاركين --}}
        <a href="{{ route('superadmin.ramadan.participants.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.participants.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-users text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">المشاركين</span>
                <span class="text-[10px] opacity-70 truncate">تسجيل • تدقيق • رتب • حالات</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 4. احصائيات المشاركين --}}
        <a href="{{ route('superadmin.ramadan.participants.stats') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.participants.stats') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">إحصائيات المشاركين</span>
                <span class="text-[10px] opacity-70 truncate">حضور • نقاط • التزام • نشاط</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 5. توب 10 حسب الاوقات --}}
        <a href="{{ route('superadmin.ramadan.top.time') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.top.time') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-stopwatch text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">Top 10 حسب الأوقات</span>
                <span class="text-[10px] opacity-70 truncate">الأسرع • الأكثر التزامًا • الأكثر نشاطًا</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 6. توب 10 حسب المسابقات --}}
        <a href="{{ route('superadmin.ramadan.top.competitions') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.top.competitions') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-purple-500/15 border border-purple-400/25 text-purple-200">
                <i class="fa-solid fa-medal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">Top 10 حسب المسابقات</span>
                <span class="text-[10px] opacity-70 truncate">أكثر فوز • أكثر مشاركة • أكثر إنجاز</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 7. بابا غنوج --}}
        <a href="{{ route('superadmin.ramadan.baba-ghanouj.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.baba-ghanouj.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-pepper-hot text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">بابا غنوج</span>
                <span class="text-[10px] opacity-70 truncate">قسم خاص • فعاليات خفيفة • مفاجآت</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 8. ساعات وجدول الأوقات --}}
        <a href="{{ route('superadmin.ramadan.schedule.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.schedule.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-calendar-days text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">ساعات وجدول الأوقات</span>
                <span class="text-[10px] opacity-70 truncate">جدولة • نوبات • تذكيرات • تنسيق</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 9. شهادات تقدير --}}
        <a href="{{ route('superadmin.ramadan.certificates.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.certificates.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-teal-500/15 border border-teal-400/25 text-teal-200">
                <i class="fa-solid fa-certificate text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">شهادات تقدير</span>
                <span class="text-[10px] opacity-70 truncate">تصميم • توليد • طباعة • تسليم</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 10. تكريمات وسهرات --}}
        <a href="{{ route('superadmin.ramadan.honors.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.honors.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
                <i class="fa-solid fa-star text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">تكريمات وسهرات</span>
                <span class="text-[10px] opacity-70 truncate">تكريم • حفلات • فعاليات • صور</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- ✅ +3 أقسام مهمة (إضافية) --}}

        {{-- 11. تنبيهات رمضان --}}
        <a href="{{ route('superadmin.ramadan.alerts.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.alerts.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-400/25 text-orange-200">
                <i class="fa-solid fa-bell text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">تنبيهات رمضان</span>
                <span class="text-[10px] opacity-70 truncate">إشعارات • تذكير • تنبيه نوبات</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 12. مهام الإدارة الرمضانية --}}
        <a href="{{ route('superadmin.ramadan.missions.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.missions.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-lime-500/15 border border-lime-400/25 text-lime-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">مهام الإدارة</span>
                <span class="text-[10px] opacity-70 truncate">توزيع مسؤوليات • متابعة • إنجاز</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

        {{-- 13. أرشيف رمضان (صور/ملفات/فيديو) --}}
        <a href="{{ route('superadmin.ramadan.archive.index') }}"
           class="{{ $linkBase }} {{ $isActive('superadmin.ramadan.archive.*') ? $linkOn : $linkOff }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-box-archive text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-extrabold truncate">أرشيف رمضان</span>
                <span class="text-[10px] opacity-70 truncate">صور • ملفات • لقطات • ملخصات</span>
            </div>
            {!! $badgeSoon() !!}
        </a>

    </div>
</details>
<details class="relative group" @if($invitesSectionOpen) open @endif>
    {{-- الهيدر الرئيسي لمجموعة الدعوات --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $invitesSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            {{-- أيقونة رئيسية --}}
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl bg-emerald-500/15
                         text-emerald-300 border border-emerald-400/30 shadow-sm">
                <i class="fa-solid fa-gift text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">
                    دعوة الأصدقاء واكسب
                </span>
                <span class="text-[11px] opacity-70">
                    شارك رابطك وتابع إنجازات الدعوات
                </span>
            </div>
        </div>

        <div class="flex items-center gap-2">
            {{-- بادج حالة الدعوات للعضو --}}
            @if($pendingInvitesCount > 0)
                <span class="inline-flex items-center justify-center px-2 py-0.5 rounded-full
                             bg-amber-500/90 text-[10px] font-bold text-slate-900 shadow-md">
                    {{ $pendingInvitesCount > 99 ? '99+' : $pendingInvitesCount }} قيد المتابعة
                </span>
            @endif

            {{-- سهم الفتح / الإغلاق --}}
            <svg class="w-4 h-4 transition-transform duration-300 flex-shrink-0 group-open:rotate-180"
                 fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                      d="M19 9l-7 7-7-7"/>
            </svg>
        </div>
    </summary>

    {{-- الروابط الفرعية --}}
    <div class="mt-1 space-y-1 pb-3 pr-4 pl-12 text-[13px]">

        {{-- دعوات الأصدقاء (الرابط الرئيسي) --}}
        <a href="{{ route('invites.index') }}"
           class="flex items-center justify-between px-2 py-1.5 rounded-lg
                  {{ request()->routeIs('invites.index') ? 'bg-emerald-500/15 text-emerald-200' : 'text-gray-200 hover:bg-white/5' }}">
            <span class="flex items-center gap-2">
                <i class="fa-solid fa-link text-[11px] opacity-80"></i>
                <span>دعوات الأصدقاء</span>
            </span>
        </a>

        {{-- إحصائياتك --}}
        <a href="{{ route('invites.stats') }}"
           class="flex items-center justify-between px-2 py-1.5 rounded-lg
                  {{ request()->routeIs('invites.stats') ? 'bg-emerald-500/15 text-emerald-200' : 'text-gray-200 hover:bg-white/5' }}">
            <span class="flex items-center gap-2">
                <i class="fa-solid fa-chart-line text-[11px] opacity-80"></i>
                <span>إحصائياتك</span>
            </span>
        </a>

        {{-- ملاحظات إدارية --}}
        <a href="{{ route('invites.notes') }}"
           class="flex items-center justify-between px-2 py-1.5 rounded-lg
                  {{ request()->routeIs('invites.notes') ? 'bg-emerald-500/15 text-emerald-200' : 'text-gray-200 hover:bg-white/5' }}">
            <span class="flex items-center gap-2">
                <i class="fa-solid fa-note-sticky text-[11px] opacity-80"></i>
                <span>ملاحظات إدارية</span>
            </span>
        </a>

        {{-- حالة دعواتك + بادج صغيرة --}}
        <a href="{{ route('invites.status') }}"
           class="flex items-center justify-between px-2 py-1.5 rounded-lg
                  {{ request()->routeIs('invites.status') ? 'bg-emerald-500/15 text-emerald-200' : 'text-gray-200 hover:bg-white/5' }}">
            <span class="flex items-center gap-2">
                <i class="fa-solid fa-hourglass-half text-[11px] opacity-80"></i>
                <span>حالة دعواتك</span>
            </span>

            @if($pendingInvitesCount > 0)
                <span class="inline-flex items-center justify-center min-w-[20px] h-5 px-1 rounded-full
                             bg-rose-500 text-[10px] font-bold text-white shadow">
                    {{ $pendingInvitesCount > 9 ? '9+' : $pendingInvitesCount }}
                </span>
            @endif
        </a>

        {{-- 🔥 قسم خاص بالسوبر أدمين فقط --}}
        @if($isSuperAdmin)
            <div class="pt-2 mt-2 border-t border-white/10 space-y-1">
                {{-- موافقة الدعوات --}}
                <a href="{{ route('superadmin.invites.approvals') }}"
                   class="flex items-center justify-between px-2 py-1.5 rounded-lg
                          {{ request()->routeIs('superadmin.invites.approvals') ? 'bg-cyan-500/15 text-cyan-200' : 'text-gray-200 hover:bg-white/5' }}">
                    <span class="flex items-center gap-2">
                        <i class="fa-solid fa-user-check text-[11px] opacity-80"></i>
                        <span>موافقة الدعوات</span>
                    </span>

                    {{-- ممكن تستخدم نفس عداد pending من الكنترولر للسوبر أدمين --}}
                    @if(($adminPendingInvitesCount ?? 0) > 0)
                        <span class="inline-flex items-center justify-center min-w-[22px] h-5 px-1 rounded-full
                                     bg-amber-500 text-[10px] font-bold text-slate-900 shadow">
                            {{ ($adminPendingInvitesCount ?? 0) > 9 ? '9+' : $adminPendingInvitesCount }}
                        </span>
                    @endif
                </a>

                {{-- لوحة إشراف الدعوات --}}
                <a href="{{ route('superadmin.invites.overview') }}"
                   class="flex items-center justify-between px-2 py-1.5 rounded-lg
                          {{ request()->routeIs('superadmin.invites.overview') ? 'bg-cyan-500/15 text-cyan-200' : 'text-gray-200 hover:bg-white/5' }}">
                    <span class="flex items-center gap-2">
                        <i class="fa-solid fa-table-list text-[11px] opacity-80"></i>
                        <span>لوحة نظام الدعوات</span>
                    </span>
                </a>

                {{-- أشياء مهمّة أخرى (إعدادات / نقاط / قواعد) --}}
                <a href="{{ route('superadmin.invites.settings') }}"
                   class="flex items-center justify-between px-2 py-1.5 rounded-lg
                          {{ request()->routeIs('superadmin.invites.settings') ? 'bg-cyan-500/15 text-cyan-200' : 'text-gray-200 hover:bg-white/5' }}">
                    <span class="flex items-center gap-2">
                        <i class="fa-solid fa-sliders text-[11px] opacity-80"></i>
                        <span>إعدادات ونقاط الدعوات</span>
                    </span>
                </a>
            </div>
        @endif
    </div>
</details>
@php
    // فتح القائمة تلقائياً إذا كنا داخل أحد مسارات الأنشطة أو نظام اللايفات الجديد
    $activitiesSectionOpen = request()->routeIs([
        'live-activities.*',
        'guest-submissions.review.*',
        'superadmin.falcon-room.lives-new.*',
    ]);

    $linkBase = 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition-colors';
@endphp
{{-- ====== الغيابات (سوبر أدمن) ====== --}}
@php
    $absencesOpen = request()->routeIs('superadmin.absences.*');
@endphp
@php
  $chikenOpen = request()->routeIs('superadmin.control-room.*') || request()->routeIs('superadmin.chiken.*');
@endphp

@php
  // ✅ فتح القائمة لو أي صفحة من الجاجي مفتوحة
  $chikenOpen = request()->routeIs('superadmin.chiken.*') || request()->routeIs('superadmin.control-room.*');

  // ✅ Helpers: إذا رووت الجاجي موجود استخدمه، وإلا استخدم القديم (لو عامل alias)
  $r = function(string $chiken, string $legacy) {
      return \Illuminate\Support\Facades\Route::has($chiken)
          ? route($chiken)
          : route($legacy);
  };
@endphp

<details class="relative group" @if($chikenOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $chikenOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-rose-500/15 text-rose-200 border border-rose-400/30 shadow-sm">
        <i class="fa-solid fa-drumstick-bite text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">نظام الجاجي Chiken</span>
        <span class="text-[11px] opacity-70">SuperAdmin • Dashboard + Analytics + Monitor + Broadcast</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>
  <div class="mt-2 space-y-1 px-2 pb-2">
{{-- ✅ Pokemon System Sidebar Section (Details) --}}
@php
  $pokemonOpen = request()->routeIs('superadmin.pokemon.*');
@endphp

<details class="relative group" @if($pokemonOpen) open @endif>
  <summary
    class="nav-link w-full flex items-center justify-between px-3 py-2 text-[13px] rounded-xl cursor-pointer list-none
           {{ $pokemonOpen ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <div class="flex items-center gap-3 min-w-0">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-bolt text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">نظام البوكيمون</span>
        <span class="text-[10px] opacity-70 truncate">إنذارات • متابعة • تقارير</span>
      </div>
    </div>

    <span class="ms-2 inline-flex items-center justify-center w-7 h-7 rounded-xl
                 bg-white/5 border border-white/10 text-white/70 group-open:text-white group-open:bg-white/10 transition">
      <i class="fa-solid fa-chevron-down text-[11px] transition group-open:rotate-180"></i>
    </span>
  </summary>

  {{-- ✅ Sub Links --}}
  <div class="mt-2 ms-2 ps-2 border-s border-white/10 space-y-1">

    <a href="{{ route('superadmin.pokemon.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.index') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-grid-2 text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">اللوحة الرئيسية</span>
        <span class="text-[10px] opacity-70 truncate">ملخص الإدارة + فلترة</span>
      </div>
    </a>

    <a href="{{ route('superadmin.pokemon.pikachu') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.pikachu') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
        <i class="fa-solid fa-bolt text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">قسم بيكاتشو</span>
        <span class="text-[10px] opacity-70 truncate">إنذارات فورية + أولويات</span>
      </div>
    </a>

    <a href="{{ route('superadmin.pokemon.charmander') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.charmander') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-orange-500/15 border border-orange-400/25 text-orange-200">
        <i class="fa-solid fa-fire text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">قسم شامندر</span>
        <span class="text-[10px] opacity-70 truncate">متابعة الحالات + المهام القادمة</span>
      </div>
    </a>

    <a href="{{ route('superadmin.pokemon.ash') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.ash') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-hat-cowboy text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">قسم أش</span>
        <span class="text-[10px] opacity-70 truncate">تقرير جاهز للإرسال</span>
      </div>
    </a>

    {{-- ✅ أقسام إضافية “ما عملتوها” (للمتابعة والتقارير) --}}
    <div class="h-px bg-gradient-to-r from-transparent via-white/10 to-transparent my-2"></div>

    <a href="{{ route('superadmin.pokemon.evolution') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.evolution') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-flask text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">مختبر التطوّر</span>
        <span class="text-[10px] opacity-70 truncate">جدولة + إثباتات + توثيق</span>
      </div>
    </a>

    <a href="{{ route('superadmin.pokemon.reports') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[12px] rounded-xl
              {{ request()->routeIs('superadmin.pokemon.reports') ? 'bg-white/12 text-white' : 'text-white/65 hover:text-white hover:bg-white/8' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                   bg-sky-500/15 border border-sky-400/25 text-sky-200">
        <i class="fa-solid fa-file-lines text-[12px]"></i>
      </span>
      <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">مصنع التقارير</span>
        <span class="text-[10px] opacity-70 truncate">PDF/CSV + قوالب جاهزة</span>
      </div>
    </a>

  </div>
</details>
  <div class="mt-2 space-y-1 px-2 pb-2">

    {{-- ✅ Dashboard --}}
    <a href="{{ $r('superadmin.chiken.dashboard','superadmin.control-room.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ (request()->routeIs('superadmin.chiken.dashboard') || request()->routeIs('superadmin.control-room.dashboard'))
                  ? 'bg-white/15 text-white'
                  : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة الجاجي</span>
        <span class="text-[10px] opacity-70">Health + AI Tips</span>
      </div>
    </a>

    {{-- ✅ Analytics --}}
    <a href="{{ $r('superadmin.chiken.analytics','superadmin.chiken.analytics') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ (request()->routeIs('superadmin.chiken.analytics') || request()->routeIs('superadmin.control-room.analytics'))
                  ? 'bg-white/15 text-white'
                  : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-chart-simple text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">إحصائيات الجاجي</span>
        <span class="text-[10px] opacity-70">Indices + Risks</span>
      </div>
    </a>

    {{-- ✅ Monitor --}}
    <a href="{{ $r('superadmin.chiken.monitor','superadmin.chiken.monitor') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ (request()->routeIs('superadmin.chiken.monitor') || request()->routeIs('superadmin.control-room.monitor'))
                  ? 'bg-white/15 text-white'
                  : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-satellite-dish text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">مراقبة الجاجي</span>
        <span class="text-[10px] opacity-70">Online + Tracking + Queue</span>
      </div>
    </a>

    {{-- ✅ Broadcast Wizard --}}
    <a href="{{ $r('superadmin.chiken.broadcast','superadmin.control-room.broadcast') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ (request()->routeIs('superadmin.chiken.broadcast') || request()->routeIs('superadmin.control-room.broadcast'))
                  ? 'bg-white/15 text-white'
                  : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-bullhorn text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">Wizard الإشعارات</span>
        <span class="text-[10px] opacity-70">Send to All/Girls/…</span>
      </div>
    </a>

    {{-- ✅ Quick Chips (اختياري — ملحمي وسريع) --}}
    <div class="pt-2 mt-2 border-t border-white/10 flex flex-wrap gap-2">
      <a href="{{ $r('superadmin.chiken.dashboard','superadmin.control-room.dashboard') }}?gender=female"
         class="inline-flex items-center gap-2 px-3 py-2 rounded-2xl bg-rose-200/10 border border-rose-300/20 text-rose-100 text-[11px] hover:bg-rose-200/15 transition">
        <i class="fa-solid fa-heart text-[11px]"></i>
        وضع الصبايا 🎀
      </a>
      <a href="{{ $r('superadmin.chiken.dashboard','superadmin.control-room.dashboard') }}?gender=male"
         class="inline-flex items-center gap-2 px-3 py-2 rounded-2xl bg-cyan-200/10 border border-cyan-300/20 text-cyan-100 text-[11px] hover:bg-cyan-200/15 transition">
        <i class="fa-solid fa-user text-[11px]"></i>
        وضع الشباب
      </a>
    </div>

  </div>
</details>
<details class="relative group" @if($absencesOpen) open @endif>
    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $absencesOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-rose-500/15 text-rose-200 border border-rose-400/30 shadow-sm">
                <i class="fa-solid fa-clipboard-list text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الغيابات</span>
                <span class="text-[11px] opacity-70">طلبات + متابعة + تقارير</span>
            </div>

            {{-- Badge للطلبات المعلقة --}}
            @if(isset($pendingAbsencesCount) && $pendingAbsencesCount > 0)
                <span class="inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-500/30 text-[11px] font-bold">
                    {{ $pendingAbsencesCount }}
                </span>
            @endif
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    {{-- الروابط --}}
    <div class="mt-2 space-y-1 px-2 pb-2">
@php
  // اختياري: لو بدك البادج يجي من الكنترول (recommended)
  $absencesMembersBadge = $absencesMembersBadge ?? null; // ['count'=>12,'tone'=>'danger'|'warn'|'ok']
  $badgeCount = (int)($absencesMembersBadge['count'] ?? 0);
  $badgeTone  = (string)($absencesMembersBadge['tone'] ?? 'warn');

  $badgeClass = match($badgeTone){
    'danger' => 'bg-rose-500/20 border-rose-400/25 text-rose-200',
    'ok'     => 'bg-emerald-500/20 border-emerald-400/25 text-emerald-200',
    default  => 'bg-amber-500/20 border-amber-400/25 text-amber-200',
  };
@endphp

<a href="{{ route('superadmin.absences.members.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.absences.members.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-user-clock text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-extrabold truncate">غيابات الأعضاء</span>
        <span class="text-[10px] opacity-70 truncate">بدون عذر • مع عذر • طلبات • إحصائيات</span>
    </div>

    {{-- BADGE --}}
    <span class="inline-flex items-center justify-center min-w-[28px] h-6 px-2 rounded-full text-[11px] font-black
                 border {{ $badgeClass }} {{ $badgeCount>0 ? '' : 'opacity-40' }}">
      {{ $badgeCount }}
    </span>
</a>

        {{-- وضع غياب مباشر --}}
        <a href="{{ route('superadmin.absences.direct') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.direct') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-user-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وضع غياب مباشر</span>
                <span class="text-[10px] opacity-70 truncate">تسجيل غياب بسرعة للإدارة</span>
            </div>
        </a>

        {{-- موافقة طلبات الأعضاء --}}
        <a href="{{ route('superadmin.absences.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.index') || request()->routeIs('superadmin.absences.show') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">موافقة طلبات الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة + قبول/رفض</span>
            </div>
        </a>

        {{-- إحصائيات الطلبات --}}
        <a href="{{ route('superadmin.absences.stats') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.stats') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إحصائيات الطلبات</span>
                <span class="text-[10px] opacity-70 truncate">مؤشرات + نسب</span>
            </div>
        </a>

        {{-- غيابات اليوم + القادم --}}
        <a href="{{ route('superadmin.absences.today') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.today') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
                <i class="fa-solid fa-sun text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">غيابات اليوم + القادم</span>
                <span class="text-[10px] opacity-70 truncate">متابعة مباشرة للجدول</span>
            </div>
        </a>

        {{-- كشف التعارضات --}}
        <a href="{{ route('superadmin.absences.conflicts') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.conflicts') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">كشف التعارضات</span>
                <span class="text-[10px] opacity-70 truncate">تصادمات تواريخ + إنذارات</span>
            </div>
        </a>

        {{-- تصدير CSV --}}
        <a href="{{ route('superadmin.absences.export', request()->only(['from','to','status'])) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  text-white/70 hover:text-white hover:bg-white/10">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-file-csv text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تصدير CSV</span>
                <span class="text-[10px] opacity-70 truncate">تحميل النتائج حسب الفلاتر</span>
            </div>
        </a>

        {{-- ملفي (للإدارة) --}}
        <a href="{{ route('superadmin.absences.member', auth()->id()) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.member') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-id-badge text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ملفي (للإدارة)</span>
                <span class="text-[10px] opacity-70 truncate">سجل غياباتي كمسؤول</span>
            </div>
        </a>

        {{-- غيابات أسبوعية (جدول) --}}
        <a href="{{ route('superadmin.absences.weekly') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.absences.weekly') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-calendar-week text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">غيابات أسبوعية (جدول)</span>
                <span class="text-[10px] opacity-70 truncate">عرض أسبوعي سريع</span>
            </div>
        </a>

    </div>
</details>

<details class="relative group" @if($imanRoomOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $imanRoomOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
        <i class="fa-solid fa-crown text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">غرفة إيمان الملكاوي</span>
        <span class="text-[11px] opacity-70">Socratic Room • إدارة + مراقبة + AI</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">

    {{-- Dashboard --}}
    <a href="{{ route('superadmin.iman.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.iman.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة الغرفة</span>
        <span class="text-[10px] opacity-70">AI + Charts + مؤشرات</span>
      </div>
    </a>

    <div class="my-2 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent"></div>

@php
  $imanSections = [
    ['k'=>'team_stats',       't'=>'إحصائيات التيم',        'i'=>'fa-chart-pie',            'c'=>'cyan'],

    // ✅ الجديد: أدوات مساعدة (تقييمات + قستات)
    ['k'=>'helper_tools',     't'=>'أدوات مساعدة',          'i'=>'fa-toolbox',              'c'=>'violet'],

    // ✅ الجديد: جدول البرامج بتوقيت الأردن
    ['k'=>'programs_jordan',  't'=>'جدول البرامج — الأردن', 'i'=>'fa-clock',                'c'=>'amber'],
    ['k'=>'team_stats',        't'=>'إحصائيات التيم',          'i'=>'fa-chart-pie',             'c'=>'cyan'],

    // ✅ الأربعة الجدد
    ['k'=>'members_files',     't'=>'ملفات الأعضاء',           'i'=>'fa-folder-open',           'c'=>'slate'],
    ['k'=>'online_on_program', 't'=>'المتواجدون على البرنامج', 'i'=>'fa-signal-stream',         'c'=>'emerald'],
    ['k'=>'ai_alerts_issues',  't'=>'AI: إنذارات ومشاكل',      'i'=>'fa-triangle-exclamation',  'c'=>'rose'],
    ['k'=>'ai_eval_analysis',  't'=>'AI: التقييمات تحليل',     'i'=>'fa-brain',                 'c'=>'violet'],

    ['k'=>'boys_follow',      't'=>'متابعة شباب التيم',     'i'=>'fa-user-shield',          'c'=>'emerald'],
    ['k'=>'girls_follow',     't'=>'متابعة صبايا التيم',    'i'=>'fa-user-astronaut',       'c'=>'pink'],
    ['k'=>'members_results',  't'=>'نتائج الأعضاء',         'i'=>'fa-ranking-star',         'c'=>'fuchsia'],
    ['k'=>'reports_ideas',    't'=>'تقارير وأفكار',         'i'=>'fa-lightbulb',            'c'=>'amber'],
    ['k'=>'members_messages', 't'=>'رسائل للأعضاء',  'i'=>'fa-paper-plane',   'c'=>'sky'],
    ['k'=>'agency_transfer',  't'=>'نقل وكالة',      'i'=>'fa-right-left',    'c'=>'amber'],
    ['k'=>'agency_revoke',    't'=>'سحب وكالة',      'i'=>'fa-ban',           'c'=>'rose'],
    ['k'=>'usernames_center', 't'=>'مركز اليوزرنيم', 'i'=>'fa-at',            'c'=>'violet'],
    ['k'=>'issues_solutions', 't'=>'مشاكل وحلول',           'i'=>'fa-triangle-exclamation', 'c'=>'rose'],
    ['k'=>'iman_diary',       't'=>'مذكرات إيمان',          'i'=>'fa-book',                 'c'=>'indigo'],
    ['k'=>'members_hours',    't'=>'ساعات الأعضاء',         'i'=>'fa-clock',                'c'=>'sky'],
    ['k'=>'members_goals',    't'=>'أهداف الأعضاء',         'i'=>'fa-bullseye',             'c'=>'lime'],
    ['k'=>'members_logs',     't'=>'سجلات الأعضاء',         'i'=>'fa-scroll',               'c'=>'slate'],
    ['k'=>'members_marks',    't'=>'علامات الأعضاء',        'i'=>'fa-tags',                 'c'=>'violet'],
    ['k'=>'proactive',        't'=>'ProActive',             'i'=>'fa-satellite-dish',       'c'=>'teal'],
    ['k'=>'risk_map',         't'=>'خريطة المخاطر',         'i'=>'fa-radar',                'c'=>'orange'],
    ['k'=>'decisions_board',  't'=>'لوحة القرارات',         'i'=>'fa-gavel',                'c'=>'yellow'],
    ['k'=>'notify_center',    't'=>'مركز الإشعارات',        'i'=>'fa-bell',                 'c'=>'cyan'],
  ];
@endphp

    @foreach($imanSections as $it)
      <a href="{{ route('superadmin.iman.section', $it['k']) }}"
         class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                {{ request()->routeIs('superadmin.iman.section') && request()->route('key') === $it['k'] ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
        <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                     bg-{{ $it['c'] }}-500/15 border border-{{ $it['c'] }}-400/25 text-{{ $it['c'] }}-200">
          <i class="fa-solid {{ $it['i'] }} text-[12px]"></i>
        </span>
        <span class="font-semibold">{{ $it['t'] }}</span>
      </a>

      {{-- HR ملحمي بعد كل عنصر --}}
      <div class="h-px bg-gradient-to-r from-transparent via-white/10 to-transparent my-1"></div>
    @endforeach

  </div>
</details>
{{-- غرفة الصقر — ستايل details/summary مثل مثال الواتساب (كامل بدون نقصان) --}}
@php
    // ===== Routes + Active Flags (نفس اللي عندك) =====
    $rRisk        = 'superadmin.risk-radar.index';              $onRisk        = request()->routeIs($rRisk);
    $rFalconNotes = 'superadmin.falcon-diary.index';            $onFalconNotes = request()->routeIs($rFalconNotes);
    $rSignals     = 'superadmin.falcon-room.signals';           $onSig         = request()->routeIs($rSignals);

    $onAdvisorTips = request()->routeIs('superadmin.advisor-tips.*');

    $rMaint       = 'superadmin.falcon-room.maintenance';       $onMaint       = request()->routeIs($rMaint);
    $rLive        = 'superadmin.falcon-room.live';              $onLive        = request()->routeIs($rLive);
    $rServerMonitor = 'server.monitor';                         $onServerMonitor = request()->routeIs($rServerMonitor);
    $rLogs        = 'superadmin.falcon-room.maintenance.logs';  $onLogs        = request()->routeIs($rLogs);
    $rDevIps      = 'superadmin.falcon-room.devices-ips';       $onDevIps      = request()->routeIs($rDevIps);
    $rPerf        = 'superadmin.falcon-room.performance';       $onPerf        = request()->routeIs($rPerf);

    $rOnlineMembers = 'superadmin.falcon-room.online-members';  $onOnlineMembers = request()->routeIs($rOnlineMembers);
    $rMembers       = 'superadmin.falcon-room.members';         $onMembers     = request()->routeIs($rMembers);

    $onMemberCare = request()->routeIs('superadmin.falcon.member_care.*');
    $onTeamAlerts = request()->routeIs('superadmin.falcon.team_alerts.*');

    $rMods        = 'superadmin.falcon-room.moderators';        $onMods        = request()->routeIs($rMods);
    $rUsernames   = 'superadmin.falcon.usernames.index';        $onUsernames   = request()->routeIs($rUsernames);

    $rPasswords   = 'superadmin.falcon.passwords.index';
    $onPasswords  = request()->routeIs('superadmin.falcon.passwords.*') || request()->routeIs($rPasswords);

    $onQuickEdit  = request()->routeIs('superadmin.falcon.members.quick_edit');

    $rBanCenter   = 'superadmin.falcon.bans.index';             $onBan         = request()->routeIs($rBanCenter);

    $rSmartPulse  = 'superadmin.falcon.smart-pulse.index';      $onSmartPulse  = request()->routeIs($rSmartPulse);

    $rAdminAudit  = 'superadmin.falcon-room.admin-audit-logs.index'; $onAdminAudit = request()->routeIs($rAdminAudit);

    $rLogisticCenter = 'superadmin.falcon.logistic-center.index'; $onLogistic = request()->routeIs($rLogisticCenter);

    $rAgencyTr    = 'superadmin.falcon-room.agency-transfer';   $onAgencyTr    = request()->routeIs($rAgencyTr);
    $rAgencyRv    = 'superadmin.falcon-room.agency-revoke';     $onAgencyRv    = request()->routeIs($rAgencyRv);

    $rGen         = 'superadmin.analytics.gender-compare';      $onGen         = request()->routeIs($rGen);
    $rLoyal       = 'superadmin.analytics.loyalty';             $onLoyal       = request()->routeIs($rLoyal);

    $rBoysDash    = 'superadmin.boys.dashboard';                $onBD          = request()->routeIs($rBoysDash);
    $rBoysPresence= 'superadmin.falcon-boys.presence';          $onBP          = request()->routeIs($rBoysPresence);
    $rBoysInsights= 'superadmin.falcon-boys.insights';          $onBI          = request()->routeIs($rBoysInsights);
    $rBoysRevival = 'superadmin.falcon-boys.revival';           $isRevival     = request()->routeIs($rBoysRevival);
    $rBRev        = 'superadmin.boys.revival';                  $onBR          = request()->routeIs($rBRev);
    $rBehavior    = 'superadmin.falcon-boys.behavior';          $onBehavior    = request()->routeIs($rBehavior);

    // ===== Open state for details (نفس اللي عندك) =====
    $falconSectionOpen =
        $onRisk || $onFalconNotes || $onSig || $onAdvisorTips ||
        $onMaint || $onLive || $onServerMonitor || $onLogs || $onDevIps || $onPerf ||
        $onOnlineMembers || $onMembers || $onMemberCare || $onTeamAlerts || $onMods ||
        $onUsernames || $onPasswords || $onQuickEdit || $onBan ||
        $onSmartPulse || $onAdminAudit || $onLogistic ||
        $onAgencyTr || $onAgencyRv ||
        $onGen || $onLoyal || $onBD || $onBP || $onBI || $isRevival || $onBR || $onBehavior;

    // ===== ستايل سقراط (مهم) =====
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

    $falconItem = function(
        string $href,
        bool $on,
        string $iconBg,     // مثال: bg-rose-500/15
        string $iconBorder, // مثال: border-rose-400/25
        string $iconText,   // مثال: text-rose-200
        string $iconHtml,   // مثال: <i class="fa-solid fa-radar text-[12px]"></i>
        string $title,
        string $subtitle,
        ?string $badge = null,
        string $badgeClass = 'bg-amber-500/20 text-amber-200 border border-amber-400/30'
    ) use ($linkBase) {
        $cls = $linkBase . ' ' . ($on ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10');

        $badgeHtml = '';
        if ($badge) {
            $badgeHtml = '<span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold '.$badgeClass.'">'.$badge.'</span>';
        }

        return '
        <a href="'.$href.'" class="'.$cls.'">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl '.$iconBg.' '.$iconText.' border '.$iconBorder.' shadow-sm">
                '.$iconHtml.'
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">'.e($title).'</span>
                <span class="text-[10px] opacity-70 truncate">'.e($subtitle).'</span>
            </div>
            '.$badgeHtml.'
        </a>';
    };
@endphp

<details class="relative group" @if($falconSectionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $falconSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-cyan-500/15 text-cyan-200 border border-cyan-400/30 shadow-sm">
                <i class="fa-solid fa-shield-halved text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">غرفة الصقر</span>
                <span class="text-[11px] opacity-70">مراقبة • سيرفر • أعضاء • لوجستي • شباب</span>
            </div>
        </div>
{{-- 🛡️ Sidebar: Security Command Center --}}

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">أشياء شخصية للصقر</div>

<a href="{{ route('superadmin.security.index') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.security.*') ? $linkOn : $linkOff }}">

    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-gradient-to-br from-fuchsia-600/20 to-cyan-500/20
                 border border-fuchsia-400/30 text-fuchsia-200">
        <i class="fa-solid fa-user-shield text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0 flex-1">
        <div class="flex items-center gap-2 min-w-0">
            <span class="font-extrabold truncate">مركز الحماية</span>

            <span class="shrink-0 inline-flex items-center justify-center min-w-[100px] h-6 px-2 rounded-full
                         border border-cyan-400/25 bg-cyan-500/12 text-cyan-200 text-[11px] font-black">
                Enterprise Mode
            </span>
        </div>
        <span class="text-[10px] opacity-70 truncate">
            مراقبة الهيكل • تنبيهات • تنظيف ذكي
        </span>
    </div>

    <i class="fa-solid fa-chevron-left text-[11px] opacity-60"></i>
</a>


        {!! $falconItem(
            route($rRisk),
            $onRisk,
            'bg-rose-500/15','border-rose-400/25','text-rose-200',
            '<i class="fa-solid fa-radar text-[12px]"></i>',
            'رادار المخاطر',
            'تنبيهات + تحذيرات + متابعة دقيقة'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rFalconNotes) ? route($rFalconNotes) : '#',
            $onFalconNotes,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-book-open text-[12px]"></i>',
            'مذكّرات وملاحظات الصقر',
            'توثيق يومي • ملاحظات تشغيل • أرشفة'
        ) !!}

        {!! $falconItem(
            route($rSignals),
            $onSig,
            'bg-amber-500/15','border-amber-400/25','text-amber-200',
            '<i class="fa-solid fa-tower-broadcast text-[12px]"></i>',
            'إشارات القيادة',
            'متابعة قرارات القيادة داخل النظام',
            $onSig ? 'نشط' : null,
            'bg-amber-500/20 text-amber-200 border border-amber-400/30'
        ) !!}

        {!! $falconItem(
            route('superadmin.advisor-tips.index'),
            $onAdvisorTips,
            'bg-yellow-500/15','border-yellow-400/25','text-yellow-200',
            '<i class="fa-solid fa-lightbulb text-[12px]"></i>',
            'متابعة نصائح المستشارين',
            'جمع • مراجعة • تطبيق'
        ) !!}

        {!! $falconItem(
            route('superadmin.advisor-tips.index'),
            $onAdvisorTips,
            'bg-sky-500/15','border-sky-400/25','text-sky-200',
            '<i class="fa-solid fa-user-tie text-[12px]"></i>',
            'متابعة المستشارين',
            'حضور • أداء • متابعة'
        ) !!}

        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">إدارة السيرفر والتنظيف</div>

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rMaint) ? route($rMaint) : '#',
            $onMaint,
            'bg-amber-500/15','border-amber-400/25','text-amber-200',
            '<i class="fa-solid fa-screwdriver-wrench text-[12px]"></i>',
            'صيانة وأوامر السيرفر',
            'تنظيف • أوامر • صيانة',
            'أدوات'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rLive) ? route($rLive) : '#',
            $onLive,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-wave-square text-[12px]"></i>',
            'مركز الأداء الحي',
            'Live Pulse • متابعة فورية',
            'لايف',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rServerMonitor) ? route($rServerMonitor) : '#',
            $onServerMonitor,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-server text-[12px]"></i>',
            'مراقبة السيرفر',
            'CPU/RAM • Services • Ping',
            'Monitor',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rLogs) ? route($rLogs) : '#',
            $onLogs,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-clipboard-list text-[12px]"></i>',
            'سجلّ الصيانة',
            'أرشيف الصيانة • مراجعة الإجراءات'
        ) !!}

        {!! $falconItem(
            route($rDevIps),
            $onDevIps,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-desktop text-[12px]"></i>',
            'مراقبة الأجهزة والـ IPs',
            'Devices • Sessions • IP Tracking',
            'جاهز',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route($rPerf),
            $onPerf,
            'bg-violet-500/15','border-violet-400/25','text-violet-200',
            '<i class="fa-solid fa-bolt text-[12px]"></i>',
            'إحصائيات الأداء والتحميل',
            'Performance • Load • Stats',
            'جاهز',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">إدارة المشرفين والأعضاء</div>

        {!! $falconItem(
            route($rOnlineMembers),
            $onOnlineMembers,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-user-group text-[12px]"></i>',
            'الأعضاء المتواجدون الآن',
            'مركز حضور مباشر داخل النظام',
            'مباشر',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route($rMembers),
            $onMembers,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-users text-[12px]"></i>',
            'مراقبة الأعضاء',
            'متابعة • حضور • نشاط',
            'جاهز',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has('superadmin.falcon.member_care.index') ? route('superadmin.falcon.member_care.index') : '#',
            $onMemberCare,
            'bg-teal-500/15','border-teal-400/25','text-teal-200',
            '<i class="fa-solid fa-hand-holding-heart text-[12px]"></i>',
            'متابعة الأعضاء',
            'Care • متابعة دقيقة • تنبيه مبكر',
            'جديد',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route('superadmin.falcon.team_alerts.index'),
            $onTeamAlerts,
            'bg-rose-500/15','border-rose-400/25','text-rose-200',
            '<i class="fa-solid fa-triangle-exclamation text-[12px]"></i>',
            'تنبيهات حرجة للتيم',
            'إنذارات • حالات طارئة • متابعة'
        ) !!}

        {!! $falconItem(
            route($rMods),
            $onMods,
            'bg-violet-500/15','border-violet-400/25','text-violet-200',
            '<i class="fa-solid fa-user-shield text-[12px]"></i>',
            'مراقبة المشرفين',
            'أداء • التزام • متابعة',
            'جاهز',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route($rUsernames),
            $onUsernames,
            'bg-sky-500/15','border-sky-400/25','text-sky-200',
            '<i class="fa-solid fa-at text-[12px]"></i>',
            'أسماء المستخدمين',
            'اليوزر الرسمي عند الدخول'
        ) !!}

        {!! $falconItem(
            route('superadmin.falcon.passwords.index'),
            $onPasswords,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-key text-[12px]"></i>',
            'باسوردات الأعضاء',
            'عرض مباشر • تحديث سريع',
            'مباشر',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has('superadmin.falcon.members.quick_edit') ? route('superadmin.falcon.members.quick_edit') : '#',
            $onQuickEdit,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-pen-to-square text-[12px]"></i>',
            'تعديل الأعضاء',
            'Quick Edit • تحديث بيانات • حالات',
            'جاهز',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route($rBanCenter),
            $onBan,
            'bg-rose-500/15','border-rose-400/25','text-rose-200',
            '<i class="fa-solid fa-user-slash text-[12px]"></i>',
            'نظام الحظر',
            'إدارة • حظر • فك حظر',
            'جديد',
            'bg-rose-500/20 text-rose-200 border border-rose-400/30'
        ) !!}

        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">لوجستي التيم</div>

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rSmartPulse) ? route($rSmartPulse) : '#',
            $onSmartPulse,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-heart-pulse text-[12px]"></i>',
            'نبض التيم الذكي',
            'لايفات + متابعة أعضاء + تقرير يومي',
            'جديد',
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rAdminAudit) ? route($rAdminAudit) : '#',
            $onAdminAudit,
            'bg-sky-500/15','border-sky-400/25','text-sky-200',
            '<i class="fa-solid fa-clipboard-list text-[12px]"></i>',
            'سجلات الإدارة',
            'كل حركة • كل قرار • أرشيف رسمي',
            'مراقبة',
            'bg-sky-500/20 text-sky-200 border border-sky-400/30'
        ) !!}

        {!! $falconItem(
            route($rLogisticCenter),
            $onLogistic,
            'bg-fuchsia-500/15','border-fuchsia-400/25','text-fuchsia-200',
            '<i class="fa-solid fa-layer-group text-[12px]"></i>',
            'المركز اللوجستي',
            'تطوير • تحديات • خريطة حرارة',
            'جديد',
            'bg-amber-500/20 text-amber-200 border border-amber-400/30'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rAgencyTr) ? route($rAgencyTr) : '#',
            $onAgencyTr,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-right-left text-[12px]"></i>',
            'تحويل الأعضاء إلى الوكالة',
            'نقل • تنظيم • تحويل',
            'قريبًا'
        ) !!}

        {!! $falconItem(
            \Illuminate\Support\Facades\Route::has($rAgencyRv) ? route($rAgencyRv) : '#',
            $onAgencyRv,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-user-minus text-[12px]"></i>',
            'إزالة الأعضاء من الوكالة',
            'سحب • تنظيم • مراجعة',
            'قريبًا'
        ) !!}

        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">إدارة شباب التيم</div>

        {!! $falconItem(
            route($rGen),
            $onGen,
            'bg-fuchsia-500/15','border-fuchsia-400/25','text-fuchsia-200',
            '<i class="fa-solid fa-venus-mars text-[12px]"></i>',
            'مقارنة الشباب × الصبايا',
            'تحليل مقارنة • مؤشرات • فروقات'
        ) !!}

        {!! $falconItem(
            route($rLoyal),
            $onLoyal,
            'bg-yellow-500/15','border-yellow-400/25','text-yellow-200',
            '<i class="fa-solid fa-star text-[12px]"></i>',
            'مؤشر الولاء والانتماء الذهبي',
            'Loyalty • ولاء • انتماء'
        ) !!}

        {!! $falconItem(
            route($rBoysDash),
            $onBD,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-gauge text-[12px]"></i>',
            'إحصائيات شباب التيم',
            'Dashboard • تقارير • نتائج'
        ) !!}

        {!! $falconItem(
            route($rBoysPresence),
            $onBP,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-regular fa-clock text-[12px]"></i>',
            'تواجد الشباب',
            'حضور/غياب • ساعات • متابعة',
            $onBP ? 'نشِط' : null,
            'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
        ) !!}

        {!! $falconItem(
            route($rBoysInsights),
            $onBI,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-chart-line text-[12px]"></i>',
            'تحليل القوة والنشاط',
            'تحليل نشاط • قوة • مؤشرات'
        ) !!}

        {!! $falconItem(
            route($rBoysRevival),
            $isRevival,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-heart-pulse text-[12px]"></i>',
            'خطة الإنعاش (Revival Plan)',
            'عودة نشاط • متابعة • أهداف',
            $isRevival ? 'نشِط' : 'جاهز',
            $isRevival
                ? 'bg-emerald-500/20 text-emerald-200 border border-emerald-400/30'
                : 'bg-sky-500/15 text-sky-200 border border-sky-400/25'
        ) !!}

        {!! $falconItem(
            route($rBRev),
            $onBR,
            'bg-emerald-500/15','border-emerald-400/25','text-emerald-200',
            '<i class="fa-solid fa-life-ring text-[12px]"></i>',
            'خطة الإنعاش (نسخة ثانية)',
            'تطوير لاحق • تحسينات',
            'قريبًا'
        ) !!}

        {!! $falconItem(
            route($rBehavior),
            $onBehavior,
            'bg-cyan-500/15','border-cyan-400/25','text-cyan-200',
            '<i class="fa-solid fa-brain text-[12px]"></i>',
            'تحليل الانضباط والسلوك',
            'Behavior • Discipline • Consistency'
        ) !!}

        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">إدارة الوكالة</div>

        {!! $falconItem('#', false, 'bg-amber-500/15','border-amber-400/25','text-amber-200',
            '<i class="fa-solid fa-building text-[12px]"></i>',
            'إدارة الوكالة',
            'لوحة الوكالة • إعدادات',
            'قريبًا'
        ) !!}

        {!! $falconItem('#', false, 'bg-amber-500/15','border-amber-400/25','text-amber-200',
            '<i class="fa-solid fa-layer-group text-[12px]"></i>',
            'ترتيب أعضاء الوكالة',
            'فرز • مجموعات • تصنيف',
            'قريبًا'
        ) !!}

    </div>
</details>
@php
    $rolaOpen = request()->routeIs([
        'superadmin.rola.*',
        'superadmin.rola-room.*',
        'superadmin.analytics.loyalty',
        'superadmin.falcon-room.online-members',
        'superadmin.falcon.member_care.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

    $rLoyal       = 'superadmin.analytics.loyalty';           $onLoyal = request()->routeIs($rLoyal);
    $rOnline      = 'superadmin.falcon-room.online-members';  $onOnline = request()->routeIs($rOnline);
    $onMemberCare = request()->routeIs('superadmin.falcon.member_care.*');

    $rDash     = 'superadmin.rola.dashboard';  $onDash = request()->routeIs($rDash);
    $rDiaries  = 'superadmin.rola.diaries';    $onDiaries = request()->routeIs($rDiaries);
    $rPresence = 'superadmin.rola.presence';   $onPresence = request()->routeIs($rPresence);
    $rMot      = 'superadmin.rola.motivation'; $onMot = request()->routeIs($rMot);
    $rStrength = 'superadmin.rola.strengths';  $onStrength = request()->routeIs($rStrength);
    $rTop      = 'superadmin.rola.top';        $onTop = request()->routeIs($rTop);
    $rComms    = 'superadmin.rola.comms';      $onComms = request()->routeIs($rComms);
    $rSupport  = 'superadmin.rola.support';    $onSupport = request()->routeIs($rSupport);
    $rNotes    = 'superadmin.rola.notes';      $onNotes = request()->routeIs($rNotes);
    $rDrop     = 'superadmin.rola.dropouts';   $onDrop = request()->routeIs($rDrop);
    $rRevival  = 'superadmin.rola.revival';    $onRevival = request()->routeIs($rRevival);
    $rEvents   = 'superadmin.rola.events';     $onEvents = request()->routeIs($rEvents);
@endphp

<details class="relative group" @if($rolaOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $rolaOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-pink-500/15 text-pink-200 border border-pink-400/30 shadow-sm">
                <i class="fa-solid fa-crown text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">غرفة رولا</span>
                <span class="text-[11px] opacity-70">صبايا • حضور • دعم • إنعاش • سهرات</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- مؤشرات عامة --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">مؤشرات عامة</div>

        <a href="{{ route($rLoyal) }}"
           class="{{ $linkBase }} {{ $onLoyal ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
                <i class="fa-solid fa-star text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر الولاء والانتماء الذهبي</span>
                <span class="text-[10px] opacity-70 truncate">نِسَب الولاء • الاستقرار • التذبذب</span>
            </div>
        </a>

        <a href="{{ route($rOnline) }}"
           class="{{ $linkBase }} {{ $onOnline ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">الأعضاء المتواجدون الآن</span>
                <span class="text-[10px] opacity-70 truncate">مركز حضور مباشر داخل النظام</span>
            </div>
            <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                مباشر
            </span>
        </a>

        <a href="{{ \Illuminate\Support\Facades\Route::has('superadmin.falcon.member_care.index') ? route('superadmin.falcon.member_care.index') : '#' }}"
           class="{{ $linkBase }} {{ $onMemberCare ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-teal-500/15 border border-teal-400/25 text-teal-200">
                <i class="fa-solid fa-hand-holding-heart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">متابعة الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">Care • حالات تحتاج تدخل • متابعة دقيقة</span>
            </div>
            <span class="ms-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold
                         bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                <span class="h-2 w-2 rounded-full bg-emerald-300 animate-pulse"></span>
                جديد
            </span>
        </a>

        {{-- إدارة رولا --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">إدارة رولا</div>

        <a href="{{ route($rDash) }}"
           class="{{ $linkBase }} {{ $onDash ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-pink-500/15 border border-pink-400/25 text-pink-200">
                <i class="fa-solid fa-chart-column text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إحصائيات صبايا التيم</span>
                <span class="text-[10px] opacity-70 truncate">Dashboard صبايا • أداء • التزام</span>
            </div>
        </a>

        <a href="{{ route($rDiaries) }}"
           class="{{ $linkBase }} {{ $onDiaries ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-book-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">يوميات القائدة رولا</span>
                <span class="text-[10px] opacity-70 truncate">توثيق • ملاحظات • قرارات يومية</span>
            </div>
        </a>

        <a href="{{ route($rPresence) }}"
           class="{{ $linkBase }} {{ $onPresence ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-pink-500/15 border border-pink-400/25 text-pink-200">
                <i class="fa-solid fa-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ساعات التواجد اليومية</span>
                <span class="text-[10px] opacity-70 truncate">تواجد • متابعة • مقارنة يومية</span>
            </div>
        </a>

        <a href="{{ route($rMot) }}"
           class="{{ $linkBase }} {{ $onMot ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-heart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">نظام التحفيز والتشجيع</span>
                <span class="text-[10px] opacity-70 truncate">رسائل تحفيز + متابعة التأثير</span>
            </div>
        </a>

        <a href="{{ route($rStrength) }}"
           class="{{ $linkBase }} {{ $onStrength ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-dumbbell text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليل نقاط القوة والضعف</span>
                <span class="text-[10px] opacity-70 truncate">Strengths/Weaknesses • توصيات</span>
            </div>
        </a>

        <a href="{{ route($rTop) }}"
           class="{{ $linkBase }} {{ $onTop ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
                <i class="fa-solid fa-trophy text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أفضل صبية هذا الأسبوع</span>
                <span class="text-[10px] opacity-70 truncate">Top أداء + نقاط + التزام</span>
            </div>
        </a>

        <a href="{{ route($rComms) }}"
           class="{{ $linkBase }} {{ $onComms ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-comments text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">متابعة التواصل</span>
                <span class="text-[10px] opacity-70 truncate">رسائل • تفاعل • ردود</span>
            </div>
        </a>

        <a href="{{ route($rSupport) }}"
           class="{{ $linkBase }} {{ $onSupport ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-hand-holding-heart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الدعم المعنوي</span>
                <span class="text-[10px] opacity-70 truncate">حالات تحتاج دعم • متابعة مباشرة</span>
            </div>
        </a>

        <a href="{{ route($rNotes) }}"
           class="{{ $linkBase }} {{ $onNotes ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-note-sticky text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ملاحظات القائدة رولا</span>
                <span class="text-[10px] opacity-70 truncate">Notes + ملفات متابعة</span>
            </div>
        </a>

        <a href="{{ route($rDrop) }}"
           class="{{ $linkBase }} {{ $onDrop ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-face-frown text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">حالات الضعف والانقطاع</span>
                <span class="text-[10px] opacity-70 truncate">Dropouts • ضعف • غياب • حلول</span>
            </div>
        </a>

        <a href="{{ route($rRevival) }}"
           class="{{ $linkBase }} {{ $onRevival ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-life-ring text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">خطة الإنعاش</span>
                <span class="text-[10px] opacity-70 truncate">Revival Plan • متابعة • أهداف</span>
            </div>
        </a>

        <a href="{{ route($rEvents) }}"
           class="{{ $linkBase }} {{ $onEvents ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-calendar-days text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">جدول السهرات</span>
                <span class="text-[10px] opacity-70 truncate">سهرات • ترتيب • متابعة أسبوعية</span>
            </div>
        </a>

    </div>
</details>
<details class="relative group" @if($adminSectionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $adminSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-crown text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الإدارة العليا (مهم)</span>
                <span class="text-[11px] opacity-70">لوحات + نزاهة + رادارات + متابعة</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">
        @php
            // نفس اللي عندك (بدون تغيير منطق): فقط توحيد مكانه داخل الـdetails
            $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

            $rHCPresence   = 'superadmin.falcon-room.high-command.presence';
            $rHCRiskRadar  = 'superadmin.falcon-room.high-command.risk-radar';
            $rHCDecisions  = 'superadmin.falcon-room.high-command.decisions';

            $onHCPresence  = request()->routeIs($rHCPresence);
            $onHCRiskRadar = request()->routeIs($rHCRiskRadar);
            $onHCDecisions = request()->routeIs($rHCDecisions);

            $rNotifMonitor   = 'superadmin.notifications-monitor.index';
            $rNotifSystems   = 'superadmin.notification-systems.index';
            $rSysNoti        = 'superadmin.system-notifications.index';

            $onNotifMonitor  = request()->routeIs($rNotifMonitor . '*');
            $onNotifSystems  = request()->routeIs($rNotifSystems . '*');
            $onSysNoti       = request()->routeIs($rSysNoti . '*');

            $rInternalActivity  = 'superadmin.internal-activities.index';
            $onInternalActivity = request()->routeIs($rInternalActivity);
        @endphp

        {{-- تحليلات اقرأني --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rReadAnalytics) ? route($rReadAnalytics) : '#' }}"
           class="{{ $linkBase }} {{ $onReadAnalytics ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-chart-column text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليلات اقرأني</span>
                <span class="text-[10px] opacity-70 truncate">من قرأ، من لم يقرأ، ونِسَب الالتزام بالمقالات</span>
            </div>
        </a>

        {{-- التقييمات --}}
        <a href="{{ route('superadmin.evaluations.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.evaluations.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-clipboard-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التقييمات</span>
                <span class="text-[10px] opacity-70 truncate">إدارة التقييمات وربط الحضور بالنقاط</span>
            </div>
        </a>

        {{-- تحليلات المقيمين --}}
        <a href="{{ route('superadmin.evaluations.evaluators-analytics') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.evaluations.evaluators-analytics') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-user-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليلات المقيمين</span>
                <span class="text-[10px] opacity-70 truncate">أداء المقيمين، متوسط النقاط، نسب الغياب والاعتراضات</span>
            </div>
        </a>

        {{-- نزاهة التقييمات --}}
        <a href="{{ route('superadmin.evaluations.integrity') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.evaluations.integrity') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">نزاهة التقييمات</span>
                <span class="text-[10px] opacity-70 truncate">كشف تناقضات الحضور/النقاط/الغياب الرسمي</span>
            </div>
        </a>

        {{-- إصلاح أخطاء التقييمات --}}
        <a href="{{ route('superadmin.evaluations.integrity.fix') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.evaluations.integrity.fix*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-screwdriver-wrench text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إصلاح أخطاء التقييمات</span>
                <span class="text-[10px] opacity-70 truncate">تصحيح التناقضات + إشعار رسمي</span>
            </div>
        </a>

        {{-- الاجتماعات الإدارية --}}
        <a href="{{ route('superadmin.meetings.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.meetings.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-people-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الاجتماعات الإدارية</span>
                <span class="text-[10px] opacity-70 truncate">تنظيم الاجتماعات والمتابعة التنفيذية</span>
            </div>
        </a>

        {{-- طلبات الغياب --}}
        <a href="{{ route('superadmin.absences.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.absences.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-calendar-xmark text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">طلبات الغياب</span>
                <span class="text-[10px] opacity-70 truncate">إدارة الغيابات والأعذار الرسمية</span>
            </div>
        </a>

        {{-- طلبات القيادة العليا --}}
        <a href="{{ route('superadmin.high-level-requests.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.high-level-requests.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-shield text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">طلبات القيادة العليا</span>
                <span class="text-[10px] opacity-70 truncate">طلبات حساسة تتطلب موافقة عليا</span>
            </div>
        </a>

        {{-- المخالفات --}}
        <a href="{{ route('superadmin.violations.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.violations.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">المخالفات</span>
                <span class="text-[10px] opacity-70 truncate">تسجيل ومتابعة المخالفات السلوكية</span>
            </div>
        </a>

        {{-- البلاغات والاعتراضات --}}
        <a href="{{ route('superadmin.reports-objections.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.reports-objections.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-flag text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">البلاغات والاعتراضات</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة البلاغات والاعتراضات الرسمية</span>
            </div>
        </a>

        {{-- DLL --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rDLL) ? route($rDLL) : '#' }}"
           class="{{ $linkBase }} {{ $onDLL ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-database text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجل ملاحظات اللايفات (DLL)</span>
                <span class="text-[10px] opacity-70 truncate">تحليل شامل لكل ملاحظات اللايفات</span>
            </div>
        </a>

        {{-- التحديثات الإلزامية --}}
        <a href="{{ route('site-updates.admin.stats') }}"
           class="{{ $linkBase }} {{ request()->routeIs('site-updates.admin.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التحديثات الإلزامية</span>
                <span class="text-[10px] opacity-70 truncate">من قرأ التحديثات ومن لم يقرأ بعد</span>
            </div>
        </a>

        {{-- النشاطات الداخلية --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rInternalActivity) ? route($rInternalActivity) : '#' }}"
           class="{{ $linkBase }} {{ $onInternalActivity ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-bolt text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">النشاطات الداخلية</span>
                <span class="text-[10px] opacity-70 truncate">كل حركة الأعضاء داخل النظام</span>
            </div>
        </a>

        {{-- سجلات الإدارة --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rAdminAudit) ? route($rAdminAudit) : '#' }}"
           class="{{ $linkBase }} {{ $onAdminAudit ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-clipboard-list text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجلات الإدارة</span>
                <span class="text-[10px] opacity-70 truncate">مراقبة كاملة لكل حركة إدارية</span>
            </div>
        </a>

        {{-- ERD --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rSystemErd) ? route($rSystemErd) : '#' }}"
           class="{{ $linkBase }} {{ $onSystemErd ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-project-diagram text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مخطط النظام (ERD)</span>
                <span class="text-[10px] opacity-70 truncate">علاقات الجداول بشكل واضح</span>
            </div>
        </a>

        {{-- Member Insights --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMemberInsights) ? route($rMemberInsights) : '#' }}"
           class="{{ $linkBase }} {{ $onMemberInsights ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-user-chart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ملف تحليلي للأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">نظرة عميقة على أداء كل عضو</span>
            </div>
        </a>

        {{-- Member Reality --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMemberReality) ? route($rMemberReality) : '#' }}"
           class="{{ $linkBase }} {{ $onMemberReality ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-brain text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تقييم واقعي للأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">الصورة الحقيقية لالتزام العضو</span>
            </div>
        </a>

        {{-- لوحة التواجد والغياب --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rHCPresence) ? route($rHCPresence) : '#' }}"
           class="{{ $linkBase }} {{ $onHCPresence ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة التواجد والغياب</span>
                <span class="text-[10px] opacity-70 truncate">نظرة إستراتيجية على الالتزام</span>
            </div>
        </a>

        {{-- رادار المخاطر --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rHCRiskRadar) ? route($rHCRiskRadar) : '#' }}"
           class="{{ $linkBase }} {{ $onHCRiskRadar ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">رادار المخاطر</span>
                <span class="text-[10px] opacity-70 truncate">كشف الحالات الحرجة</span>
            </div>
        </a>

        {{-- سجل قرارات الإدارة --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rHCDecisions) ? route($rHCDecisions) : '#' }}"
           class="{{ $linkBase }} {{ $onHCDecisions ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-scroll text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجل قرارات الإدارة</span>
                <span class="text-[10px] opacity-70 truncate">توثيق رسمي لقرارات القيادة</span>
            </div>
        </a>

        {{-- نظام التعتير --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">
            نظام التعتير الرقمي
        </div>

        <a href="{{ route('superadmin.taateer.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.taateer.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-hashtag text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة أرقام التعتير</span>
                <span class="text-[10px] opacity-70 truncate">عرض جميع الأعضاء الذين لديهم رقم تعتير</span>
            </div>
        </a>

        <a href="{{ route('superadmin.taateer.logs') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.taateer.logs') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-wand-magic-sparkles text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجلات التعتير</span>
                <span class="text-[10px] opacity-70 truncate">رؤية تفاصيل إنشاء التعاتير للأعضاء</span>
            </div>
        </a>

        <a href="{{ route('superadmin.taateer.members-overview') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.taateer.members-overview') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-ban text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعضاء الفعّالة</span>
                <span class="text-[10px] opacity-70 truncate">قائمة الأعضاء الذين لديهم رقم تعتير</span>
            </div>
        </a>



        {{-- أنظمة الإشعارات --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">
            أنظمة الإشعارات
        </div>

        <a href="{{ route($rNotifMonitor) }}"
           class="{{ $linkBase }} {{ $onNotifMonitor ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-envelope-open-text text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">متابعة الإشعارات</span>
                <span class="text-[10px] opacity-70 truncate">من قرأ الإشعار ومن لم يقرأه بعد</span>
            </div>
        </a>

        <a href="{{ route($rNotifSystems) }}"
           class="{{ $linkBase }} {{ $onNotifSystems ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-layer-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة أنظمة الإشعارات</span>
                <span class="text-[10px] opacity-70 truncate">Bulk · Smart · Activity Feed</span>
            </div>
        </a>

        <a href="{{ \Illuminate\Support\Facades\Route::has($rSysNoti) ? route($rSysNoti) : '#' }}"
           class="{{ $linkBase }} {{ $onSysNoti ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-bell-concierge text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إشعارات النظام</span>
                <span class="text-[10px] opacity-70 truncate">تنبيهات تقنية وأحداث النظام</span>
            </div>
        </a>

        {{-- غرفة العمليات اليومية --}}
        <a href="{{ route('superadmin.daily-operations.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.daily-operations.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-chart-line text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">غرفة العمليات اليومية</span>
                <span class="text-[10px] opacity-70 truncate">لايفات • ProActive • اختبارات • اجتماعات</span>
            </div>
        </a>

        {{-- مركز القضايا الحرجة --}}
        @php
            $rCriticalCenter = 'superadmin.falcon-room.critical-cases.index';
            $onCriticalCenter = request()->routeIs($rCriticalCenter);
        @endphp
        <a href="{{ route($rCriticalCenter) }}"
           class="{{ $linkBase }} {{ $onCriticalCenter ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-hands-holding-heart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مركز القضايا الحرجة</span>
                <span class="text-[10px] opacity-70 truncate">حالات تحتاج تدخل مباشر</span>
            </div>
        </a>

        {{-- لوحة استقرار الفرق --}}
        <a href="{{ route('superadmin.falcon-room.team-stability.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.falcon-room.team-stability.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-sitemap text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة استقرار الفرق</span>
                <span class="text-[10px] opacity-70 truncate">تحويلات • رتب • مغادرين</span>
            </div>
        </a>

        {{-- مركز الترقيات والإنذارات --}}
        <a href="{{ route('superadmin.promotion-warning-center.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.promotion-warning-center.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-medal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مركز الترقيات والإنذارات</span>
                <span class="text-[10px] opacity-70 truncate">ترشيحات + توصيات القيادة</span>
            </div>
        </a>

        {{-- أرشيف الإنجازات الذهبية --}}
        <a href="{{ route('superadmin.golden-achievements.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.golden-achievements.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-trophy-star text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أرشيف الإنجازات الذهبية</span>
                <span class="text-[10px] opacity-70 truncate">توثيق أقوى إنجازات التيم</span>
            </div>
        </a>

    </div>
</details>
<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>
@php
  $proSocratesOpen = request()->routeIs('superadmin.proactive.socrates.*');
@endphp

<details class="relative group" @if($proSocratesOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $proSocratesOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-amber-500/15 text-amber-200 border border-amber-400/30 shadow-sm">
        <i class="fa-solid fa-feather-pointed text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">سقراط — ProActive</span>
        <span class="text-[11px] opacity-70">Hours • Achievements • Analytics • AI</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">

    <a href="{{ route('superadmin.proactive.socrates.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة سقراط</span>
        <span class="text-[10px] opacity-70">نظرة عامة + إنذارات</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.achievements') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.achievements') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-trophy text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">إنجازات ProActive</span>
        <span class="text-[10px] opacity-70">Leaderboard + أداء القادة</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.hours.all') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.hours.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-stopwatch text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">ساعات ProActive (موحّد)</span>
        <span class="text-[10px] opacity-70">Cards/Grid/Table/Cluster</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.hours.regular') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.hours.regular') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/12 border border-amber-300/20 text-amber-100">
        <i class="fa-solid fa-bolt text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">ساعات ProActive (عادي)</span>
        <span class="text-[10px] opacity-70">Regular only</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.hours.plus') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.hours.plus') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-plus text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">ساعات ProActive+ (بلس)</span>
        <span class="text-[10px] opacity-70">Plus only</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.hours.extra') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.hours.extra') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
        <i class="fa-solid fa-medal text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">Extra Badge</span>
        <span class="text-[10px] opacity-70">قريبًا</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.hours.fayrouz') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.hours.fayrouz') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
        <i class="fa-solid fa-music text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">فيروز</span>
        <span class="text-[10px] opacity-70">قريبًا</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.analytics.overall') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.analytics.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-chart-pie text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الإحصائيات (كلية)</span>
        <span class="text-[10px] opacity-70">Charts + Tables</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.analytics.regular') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.analytics.regular') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/12 border border-amber-300/20 text-amber-100">
        <i class="fa-solid fa-chart-column text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">ترشيم العادي</span>
        <span class="text-[10px] opacity-70">Regular charts</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.analytics.plus') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.analytics.plus') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/12 border border-fuchsia-300/20 text-fuchsia-100">
        <i class="fa-solid fa-chart-line text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">ترشيم البلس</span>
        <span class="text-[10px] opacity-70">Plus charts</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.team.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.team.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-white/10 border border-white/15 text-white/85">
        <i class="fa-solid fa-people-group text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">تحليل تقارير التيم</span>
        <span class="text-[10px] opacity-70">Team vs Reports</span>
      </div>
    </a>

    <a href="{{ route('superadmin.proactive.socrates.ai.overview') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.proactive.socrates.ai.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-brain text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الذكاء الاصطناعي</span>
        <span class="text-[10px] opacity-70">Overview + Trends + Top/Low</span>
      </div>
    </a>

  </div>
</details>
<details class="relative group" @if($proactiveOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $proactiveOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3 min-w-0">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-emerald-500/15 text-emerald-200 border border-emerald-400/30 shadow-sm">
                <i class="fa-solid fa-bolt text-sm"></i>
            </span>

            <div class="flex flex-col min-w-0">
                <span class="text-[13px] font-semibold truncate">لوحة ProActive & الفعاليات</span>
                <span class="text-[11px] opacity-70 truncate">مواعيد • تقارير • إحصائيات • +Plus</span>
            </div>

            {{-- بادج اليوم (مثل سقراط) --}}
            @if($proTodayActiveNow > 0)
                <span class="ms-2 inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold
                             bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                    نشِطة: {{ $proTodayActiveNow }}
                </span>
            @elseif($proTodayTotal > 0)
                <span class="ms-2 inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold
                             bg-amber-500/20 text-amber-200 border border-amber-400/30">
                    اليوم: {{ $proTodayTotal }}
                </span>
            @endif
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- عنوان --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">
            لوحة تحكم • نظرة عامة
        </div>
<a href="{{ safe_route('superadmin.proactive.compliance') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.compliance') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-file-waveform text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">لوحة التقارير</span>
        <span class="text-[10px] opacity-70 truncate">بانيل + مودال • AI + رادار • كاتب التقرير</span>
    </div>

    <span class="ms-auto inline-flex items-center justify-center w-8 h-8 rounded-xl border border-white/10 bg-white/5 text-white/70">
        <i class="fa-solid fa-chevron-left text-[11px]"></i>
    </span>
</a>

        {{-- مراقبة مواعيد ProActive --}}
        <a href="{{ route('superadmin.proactive.sessions.monitor') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.sessions.monitor') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-regular fa-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مراقبة مواعيد ProActive</span>
                <span class="text-[10px] opacity-70 truncate">من حضر؟ مين تأخر؟ ومين لازم تنبيه</span>
            </div>
        </a>
        <a href="{{ route('superadmin.proactive.schedules.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive.schedules.create')
                      ? 'bg-white/15 text-white'
                      : 'text-white/70 hover:text-white hover:bg-white/10' }}">

            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-regular fa-clock text-[12px]"></i>
            </span>

            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">
                    إنشاء مواعيد ProActive + ProActive Plus
                </span>
                <span class="text-[10px] opacity-70 truncate">
                    إنشاء يدوي بدون ذكاء اصطناعي
                </span>
            </div>
        </a>

        {{-- لوحة تحكم ProActive --}}
        <a href="{{ $href($rDashboard) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rDashboard) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-gauge-high text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة تحكم ProActive</span>
                <span class="text-[10px] opacity-70 truncate">نظرة شاملة + أهم الإشارات اليوم</span>
            </div>
        </a>

        {{-- إحصائيات ProActive --}}
        <a href="{{ $href($rStats) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rStats) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إحصائيات ProActive</span>
                <span class="text-[10px] opacity-70 truncate">حضور • إنجاز • مقارنة • اتجاهات</span>
            </div>
        </a>

        {{-- ساعات الكلية --}}
        <a href="{{ $href($rUnitHours) }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.unit-hours.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ساعات الكلية</span>
                <span class="text-[10px] opacity-70 truncate">ترتيب شامل + كشف التأخير بالنشاط</span>
            </div>
            <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-rose-500/20 text-rose-200 border border-rose-400/30">
                مهم
            </span>
        </a>

        {{-- عنوان AI --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            ProActive • ذكاء اصطناعي
        </div>

        @php
            $rProactiveMain  = 'superadmin.proactiveIntelligence.index';
            $rProactiveCore  = 'superadmin.proactiveIntelligence.suggestions';
            $rProactivePulse = 'superadmin.proactiveIntelligence.pulse';
            $rProactiveDeep  = 'superadmin.proactiveAI.deep';
            $rDeepReports    = 'superadmin.proactiveAI.deepReports.index';
            $rProactiveSummary = 'superadmin.proactiveAI.summary';
            $rProactiveClinic  = 'superadmin.proactiveAI.clinic';
        @endphp

        <a href="{{ $href($rProactiveMain) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rProactiveMain) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-brain text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة ذكاء ProActive</span>
                <span class="text-[10px] opacity-70 truncate">تحليل ذكي لسلوك الالتزام بالمواعيد</span>
            </div>
        </a>

        <a href="{{ $href($rProactivePulse) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rProactivePulse) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-heart-pulse text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">نبض ProActive الذكي</span>
                <span class="text-[10px] opacity-70 truncate">آخر 30 يوم: صعود/هبوط + تنبيه مبكر</span>
            </div>
        </a>

        <a href="{{ $href($rProactiveClinic) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rProactiveClinic) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-hospital-user text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مستشفى ProActive الذكي</span>
                <span class="text-[10px] opacity-70 truncate">تشخيص شامل للحالات الضعيفة والمتعثرة</span>
            </div>
        </a>

        {{-- عنوان التقارير --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            تقارير • محتوى
        </div>

        <a href="{{ $href($rReportsIndex) }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.reports.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-folder-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجل تقارير ProActive</span>
                <span class="text-[10px] opacity-70 truncate">كل التقارير + فلترة + متابعة الأداء</span>
            </div>
        </a>

        <a href="{{ $href($rReportCreate) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rReportCreate) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-square-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إنشاء تقرير ProActive</span>
                <span class="text-[10px] opacity-70 truncate">تقرير جديد بسرعة (نماذج جاهزة)</span>
            </div>
        </a>

        <a href="{{ $href($rFRN) }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.falconRolaNotes.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-regular fa-note-sticky text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ملاحظات الصقر ورولا</span>
                <span class="text-[10px] opacity-70 truncate">سجل الملاحظات + مراجعة اليوم</span>
            </div>
            @if($notesToday > 0)
                <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/20 text-amber-200 border border-amber-400/30">
                    اليوم: {{ $notesToday }}
                </span>
            @endif
        </a>

        {{-- عنوان المواعيد --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            مواعيد ProActive • عادي / Plus
        </div>

        <a href="{{ $href($rSchedIndex) }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.schedules.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-regular fa-calendar-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مواعيد ProActive (عادي/بلس)</span>
                <span class="text-[10px] opacity-70 truncate">عرض/تعديل/تأكيد مواعيد اليوم والأسبوع</span>
            </div>
            @if($proTodayActiveNow > 0)
                <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                    نشِطة: {{ $proTodayActiveNow }}
                </span>
            @elseif($proTodayTotal > 0)
                <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/20 text-amber-200 border border-amber-400/30">
                    اليوم: {{ $proTodayTotal }}
                </span>
            @endif
        </a>

        <a href="{{ $href($rGrid) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rGrid) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-table-cells-large text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">شبكة المواعيد (الأسبوع)</span>
                <span class="text-[10px] opacity-70 truncate">عرض أسبوعي سريع بطريقة Grid</span>
            </div>
        </a>

        <a href="{{ $href($rPlusGrid) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rPlusGrid) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-sparkles text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مواعيد ProActive+ (Grid)</span>
                <span class="text-[10px] opacity-70 truncate">فعاليات +Plus فقط مع عداد اليوم</span>
            </div>
            @if($plusTodayCount > 0)
                <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                    اليوم: {{ $plusTodayCount }}
                </span>
            @endif
        </a>

        <a href="{{ $href($rNews) }}"
           class="{{ $linkBase }} {{ request()->routeIs($rNews) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أخبار القائد وتحديثات</span>
                <span class="text-[10px] opacity-70 truncate">إعلانات وتحديثات خاصة بالفعالية</span>
            </div>
            <span class="ms-auto px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/20 text-amber-200 border border-amber-400/30">
                قريبًا
            </span>
        </a>

    </div>
</details>
@php
    $proExtraOpen = request()->routeIs('superadmin.proactive-extra.*');
@endphp

<details class="relative group" @if($proExtraOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $proExtraOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-violet-500/15 text-violet-200 border border-violet-400/30 shadow-sm">
                <i class="fa-solid fa-sparkles text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">ProActive Extra</span>
                <span class="text-[11px] opacity-70">تحالفات + حملات + مجموعات أحداث (موافقة user #1)</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- 0) لوحة التحكم --}}
        <a href="{{ route('superadmin.proactive-extra.dashboard') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.dashboard')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-gauge-high text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">لوحة Extra</span>
                <span class="text-[10px] opacity-70 truncate">نظرة عامة على التحالفات والحملات والأحداث</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.dashboard'))
                <span class="mr-auto px-2 py-0.5 bg-cyan-500/20 text-cyan-100 text-[10px] rounded-full border border-cyan-400/20">نشِط</span>
            @endif
        </a>

        {{-- 1) بناء تقرير جديد --}}
        <a href="{{ route('superadmin.proactive-extra.reports.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.reports.create')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-square-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">بناء تقرير جديد</span>
                <span class="text-[10px] opacity-70 truncate">تقرير لحملة/تحالف/حدث + مخرجات واضحة</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.reports.create'))
                <span class="mr-auto px-2 py-0.5 bg-emerald-500/20 text-emerald-100 text-[10px] rounded-full border border-emerald-400/20">نشِط</span>
            @endif
        </a>

        {{-- 2) ملاحظات جديدة --}}
        <a href="{{ route('superadmin.proactive-extra.notes.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.notes.create')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-regular fa-note-sticky text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">ملاحظات جديدة</span>
                <span class="text-[10px] opacity-70 truncate">ملاحظة على تيم/حدث/حملة + حالة متابعة</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.notes.create'))
                <span class="mr-auto px-2 py-0.5 bg-amber-500/20 text-amber-100 text-[10px] rounded-full border border-amber-400/20">نشِط</span>
            @endif
        </a>

        {{-- 3) حالات الملاحظات --}}
        <a href="{{ route('superadmin.proactive-extra.notes.status') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.notes.status')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">حالات الملاحظات</span>
                <span class="text-[10px] opacity-70 truncate">مفتوحة • قيد المعالجة • مغلقة + فلترة</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.notes.status'))
                <span class="mr-auto px-2 py-0.5 bg-sky-500/20 text-sky-100 text-[10px] rounded-full border border-sky-400/20">نشِط</span>
            @endif
        </a>

        {{-- 4) مجموعات Extra --}}
        <a href="{{ route('superadmin.proactive-extra.groups.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.groups.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-layer-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">المجموعات</span>
                <span class="text-[10px] opacity-70 truncate">إنشاء مجموعات أحداث وتحديد الفريق/الهدف</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.groups.*'))
                <span class="mr-auto px-2 py-0.5 bg-violet-500/20 text-violet-100 text-[10px] rounded-full border border-violet-400/20">نشِط</span>
            @endif
        </a>

        {{-- 5) جدول الأحداث / المواعيد --}}
        <a href="{{ route('superadmin.proactive-extra.campaigns.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.campaigns.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-regular fa-calendar-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">الحملات / المواعيد</span>
                <span class="text-[10px] opacity-70 truncate">حملات تكبيس/نشاط + تحديد الوقت والهدف</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.campaigns.*'))
                <span class="mr-auto px-2 py-0.5 bg-indigo-500/20 text-indigo-100 text-[10px] rounded-full border border-indigo-400/20">نشِط</span>
            @endif
        </a>

        {{-- 6) متابعة التقارير --}}
        <a href="{{ route('superadmin.proactive-extra.reports.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.reports.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-folder-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">متابعة التقارير</span>
                <span class="text-[10px] opacity-70 truncate">فلترة + حالات + اعتماد عبر user #1</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.reports.*'))
                <span class="mr-auto px-2 py-0.5 bg-cyan-500/20 text-cyan-100 text-[10px] rounded-full border border-cyan-400/20">نشِط</span>
            @endif
        </a>

        {{-- 7) التحالفات --}}
        <a href="{{ route('superadmin.proactive-extra.alliances.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.alliances.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-handshake text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">التحالفات</span>
                <span class="text-[10px] opacity-70 truncate">إضافة تيمات + شروط + سجل تعاون</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.alliances.*'))
                <span class="mr-auto px-2 py-0.5 bg-fuchsia-500/20 text-fuchsia-100 text-[10px] rounded-full border border-fuchsia-400/20">نشِط</span>
            @endif
        </a>

        {{-- 8) أوامر القيادة --}}
        <a href="{{ route('superadmin.proactive-extra.orders.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.orders.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-scroll text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">أوامر القيادة</span>
                <span class="text-[10px] opacity-70 truncate">قرارات مرتبطة بحملات/تحالفات Extra</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.orders.*'))
                <span class="mr-auto px-2 py-0.5 bg-emerald-500/20 text-emerald-100 text-[10px] rounded-full border border-emerald-400/20">نشِط</span>
            @endif
        </a>

        {{-- 9) موافقات user #1 --}}
        <a href="{{ route('superadmin.proactive-extra.approvals.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.approvals.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-gavel text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">مركز الموافقات</span>
                <span class="text-[10px] opacity-70 truncate">اعتماد/رفض (فقط user #1) + سبب القرار</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.approvals.*'))
                <span class="mr-auto px-2 py-0.5 bg-amber-500/20 text-amber-100 text-[10px] rounded-full border border-amber-400/20">نشِط</span>
            @endif
        </a>

        {{-- 10) أوامر الذكاء الاصطناعي --}}
        <a href="{{ route('superadmin.proactive-extra.ai.commands') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.ai.commands')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-terminal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">أوامر AI</span>
                <span class="text-[10px] opacity-70 truncate">Preset Commands + Logs لحملات Extra</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.ai.commands'))
                <span class="mr-auto px-2 py-0.5 bg-indigo-500/20 text-indigo-100 text-[10px] rounded-full border border-indigo-400/20">نشِط</span>
            @endif
        </a>

        {{-- 11) تحليل الذكاء الاصطناعي --}}
        <a href="{{ route('superadmin.proactive-extra.ai.analysis') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.proactive-extra.ai.analysis')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-robot text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">تحليل AI</span>
                <span class="text-[10px] opacity-70 truncate">Insights + توصيات لتحسين التحالفات والحملات</span>
            </div>
            @if(request()->routeIs('superadmin.proactive-extra.ai.analysis'))
                <span class="mr-auto px-2 py-0.5 bg-fuchsia-500/20 text-fuchsia-100 text-[10px] rounded-full border border-fuchsia-400/20">نشِط</span>
            @endif
        </a>

    </div>
</details>
{{-- ProActive Command Add-on (تابع للنظام ومهم) --}}
<details class="relative group" @if($proactiveCommandOpen ?? false) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ ($proactiveCommandOpen ?? false) ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3 min-w-0">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-sky-500/15 text-sky-200 border border-sky-400/30 shadow-sm">
                <i class="fa-solid fa-shield-halved text-sm"></i>
            </span>

            <div class="flex flex-col min-w-0">
                <span class="text-[13px] font-semibold truncate">قيادة ProActive</span>
                <span class="text-[11px] opacity-70 truncate">قرارات • تصعيد • إثباتات • قواعد • قوالب</span>
            </div>

            {{-- بادج “حرج” --}}
            @if(($proEscalationsDue ?? 0) > 0)
                <span class="ms-2 inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold
                             bg-rose-500/20 text-rose-200 border border-rose-400/30">
                    تصعيد: {{ $proEscalationsDue }}
                </span>
            @elseif(($proConflictsCount ?? 0) > 0)
                <span class="ms-2 inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold
                             bg-amber-500/20 text-amber-200 border border-amber-400/30">
                    تعارض: {{ $proConflictsCount }}
                </span>
            @endif
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- عنوان --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">
            مركز القيادة — أهم الأدوات
        </div>

        {{-- 1) Command Center --}}
        <a href="{{ safe_route('superadmin.proactive.command') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.command') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-gauge-high text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مركز القيادة (Command Center)</span>
                <span class="text-[10px] opacity-70 truncate">نظرة موحّدة: اليوم • القادم • المتأخر • العالق</span>
            </div>
        </a>

        {{-- 2) Conflict Detector --}}
        <a href="{{ safe_route('superadmin.proactive.conflicts') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.conflicts') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">كاشف التعارضات</span>
                <span class="text-[10px] opacity-70 truncate">تعارض وقت • تكرار مسؤول • ازدحام يوم</span>
            </div>
        </a>

        {{-- 3) Escalation Ladder --}}
        <a href="{{ safe_route('superadmin.proactive.escalations') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.escalations') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-siren-on text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سُلّم التصعيد</span>
                <span class="text-[10px] opacity-70 truncate">تنبيه 1 → تنبيه 2 → تحويل للإدارة → قرار</span>
            </div>
        </a>

        {{-- عنوان --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            الالتزام — إثباتات — قرارات
        </div>

        {{-- 4) Proof Vault --}}
        <a href="{{ safe_route('superadmin.proactive.proofs') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.proofs') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-folder-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مستودع الإثباتات</span>
                <span class="text-[10px] opacity-70 truncate">روابط • صور • مرفقات • توثيق سريع</span>
            </div>
        </a>

        {{-- 5) Decisions Log --}}
        <a href="{{ safe_route('superadmin.proactive.decisions') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.decisions') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-stamp text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجل القرارات</span>
                <span class="text-[10px] opacity-70 truncate">مين قرر؟ ليش؟ متى؟ + ملاحظات</span>
            </div>
        </a>

        {{-- 6) Compliance Dashboard --}}
<a href="{{ safe_route('superadmin.proactive.compliance') }}"
   class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.compliance') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-file-waveform text-[12px]"></i>
    </span>

    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">لوحة التقارير</span>
        <span class="text-[10px] opacity-70 truncate">بانيل + مودال • AI + رادار • كاتب التقرير</span>
    </div>

    <span class="ms-auto inline-flex items-center justify-center w-8 h-8 rounded-xl border border-white/10 bg-white/5 text-white/70">
        <i class="fa-solid fa-chevron-left text-[11px]"></i>
    </span>
</a>

        {{-- عنوان --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            تلقائي — قوالب — قواعد
        </div>

        {{-- 7) Templates --}}
        <a href="{{ safe_route('superadmin.proactive.templates') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.templates') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-layer-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قوالب خطط ProActive</span>
                <span class="text-[10px] opacity-70 truncate">أسبوع جاهز • شهر جاهز • موسم</span>
            </div>
        </a>

        {{-- 8) Auto Rules --}}
        <a href="{{ safe_route('superadmin.proactive.rules') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.proactive.rules') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-sliders text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قواعد تلقائية</span>
                <span class="text-[10px] opacity-70 truncate">قبل الموعد • بعد الموعد • لو ما في إثبات</span>
            </div>
        </a>

        {{-- 9) Notification Bridge (ربط NotifyHub) --}}
        <a href="{{ safe_route('superadmin.notifyhub.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.notifyhub.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-bell text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قناة التذكير والإشعارات</span>
                <span class="text-[10px] opacity-70 truncate">ربط ProActive مع NotifyHub + سجلات</span>
            </div>
        </a>

    </div>
</details>
<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>
@php 
  $rGoal = 'superadmin.goal-tracker.index'; 
  $isGoal = request()->routeIs($rGoal) || request()->routeIs('superadmin.goal-tracker.*'); 
  $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition';
  $active = 'bg-white/10 text-white'; $inactive = 'text-white/70 hover:text-white hover:bg-white/10';
$onAiAnalytics='nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition';

@endphp

@php
  // الراوت الخاص بسجلات الإدارة
  $rAdminAudit  = 'superadmin.falcon-room.admin-audit-logs.index';
  $onAdminAudit = request()->routeIs($rAdminAudit);

  // كلاس الأساس + النشط + العادي
  $baseClasses   = 'group flex items-center gap-4 p-3 rounded-xl transition active:scale-[.98]';
  $activeClasses = 'bg-white/10 text-white shadow-lg shadow-cyan-500/20 border border-cyan-400/40';
  $idleClasses   = 'text-white/80 hover:text-white hover:bg-white/5';
@endphp
@php
  // اسم الراوت
  $rAdminAudit      = 'superadmin.falcon-room.admin-audit-logs.index';
  $rMemberInsights  = 'superadmin.falcon-room.member-insights.index';

  // هل الراوت الحالي فعّال؟
  $onAdminAudit     = request()->routeIs($rAdminAudit);
  $onMemberInsights = request()->routeIs($rMemberInsights) || request()->routeIs('superadmin.falcon.member_insights.*');

  // كلاسات الأساس + النشط + العادي (موجودة أصلاً عندك)
  // $baseClasses, $activeClasses, $idleClasses
@endphp
{{-- 🌟 قسم الإدارة العليا - غرفة الصقر --}}
@php
  $rAdminAudit     = 'superadmin.falcon-room.admin-audit-logs.index';
  $rMemberInsights = 'superadmin.falcon-room.member-insights.index';
  $rMemberReality  = 'superadmin.falcon-room.member-reality.index';

  $onAdminAudit     = request()->routeIs($rAdminAudit);
  $onMemberInsights = request()->routeIs($rMemberInsights);
  $onMemberReality  = request()->routeIs($rMemberReality);

  // افتح القائمة تلقائياً إذا واحد من الروابط الداخلية أكتيف
  $adminSectionOpen = $onAdminAudit || $onMemberInsights || $onMemberReality;
@endphp
@php
    $rReadAnalytics    = 'superadmin.daily-reading-analytics.index';
    $onReadAnalytics   = request()->routeIs('superadmin.daily-reading-analytics.*');
@endphp
@php
    $rLivesGeneral = 'lives.general';
    $onLivesGeneral = request()->routeIs($rLivesGeneral);
@endphp
@php
    $openLivesGroup =
        request()->routeIs('superadmin.falcon-room.lives-new.members-hours')
        || (isset($onLivesGeneral) && $onLivesGeneral);
@endphp

@php
    $livesCenterOpen =
        request()->routeIs('superadmin.falcon-room.lives-new.members-hours')
        || (isset($onLivesGeneral) && $onLivesGeneral)
        || (isset($rLivesGeneral) && request()->fullUrlIs(route($rLivesGeneral)));
@endphp

<details class="relative group" @if($livesCenterOpen) open @endif>
    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $livesCenterOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-tower-broadcast text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">مركز اللايفات</span>
                <span class="text-[11px] opacity-70">ساعات + عرض عام</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    {{-- الروابط --}}
    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- ساعات الأعضاء --}}
        <a href="{{ route('superadmin.falcon-room.lives-new.members-hours') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.members-hours')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-ranking-star text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ساعات الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">ترتيب الساعات + إجمالي الوقت + مؤشرات نشاط</span>
            </div>

            @if(request()->routeIs('superadmin.falcon-room.lives-new.members-hours'))
                <span class="mr-auto px-2 py-0.5 bg-indigo-500/20 text-indigo-100 text-[10px] rounded-full border border-indigo-400/20">
                    نشِط
                </span>
            @endif
        </a>

        {{-- عرض اللايفات (عام) --}}
        <a href="{{ route($rLivesGeneral) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ (isset($onLivesGeneral) && $onLivesGeneral)
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-video text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">عرض اللايفات (عام)</span>
                <span class="text-[10px] opacity-70 truncate">جدول لايفات كل الأعضاء حسب الأيام</span>
            </div>

            @if(isset($onLivesGeneral) && $onLivesGeneral)
                <span class="mr-auto px-2 py-0.5 bg-sky-500/20 text-sky-100 text-[10px] rounded-full border border-sky-400/20">
                    نشِط
                </span>
            @endif
        </a>

    </div>
</details>
@php
    // فتح القائمة تلقائياً إذا كنا داخل أحد مسارات الأنشطة أو نظام اللايفات الجديد
    $activitiesSectionOpen = request()->routeIs([
        'live-activities.*',
        'guest-submissions.review.*',
        'superadmin.falcon-room.lives-new.*',
    ]);

    $linkBase = 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition-colors';
@endphp
<details class="relative group" @if($activitiesSectionOpen) open @endif>

    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $activitiesSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-sky-500/15 text-sky-200 border border-sky-400/30 shadow-sm">
                <i class="fa-solid fa-bolt text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الأنشطة واللايفات</span>
                <span class="text-[11px] opacity-70">أنشطة + لايفات + أدوات متابعة</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    {{-- القائمة الداخلية --}}
    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- ================= الأنشطة ================= --}}
        <div class="px-3 pt-2 pb-1 text-[11px] font-semibold text-white/55">
            الأنشطة
        </div>

        {{-- الجدول الأسبوعي --}}
        <a href="{{ route('live-activities.weekly-schedule') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('live-activities.weekly-schedule') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-calendar-week text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الجدول الأسبوعي</span>
                <span class="text-[10px] opacity-70 truncate">عرض وتنظيم أسبوع الأنشطة</span>
            </div>
        </a>

        {{-- مؤشرات الأعضاء --}}
        <a href="{{ route('reports.members.kpi') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('reports.members.kpi') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-chart-line text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشرات الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">KPI + أداء + حضور</span>
            </div>
        </a>

        {{-- الأعذار --}}
        <a href="{{ route('superadmin.falcon-room.lives-tools.excuses.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-tools.excuses.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-file-signature text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعذار</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة أعذار اللايفات/الأنشطة</span>
            </div>

            @if(isset($pendingExcusesCount) && $pendingExcusesCount > 0)
                <span class="mr-auto inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-500/30 text-[11px] font-bold">
                    {{ $pendingExcusesCount }}
                </span>
            @endif
        </a>

        {{-- تعديل غير المؤكدة --}}
        <a href="{{ route('superadmin.falcon-room.lives-tools.unconfirmed.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-tools.unconfirmed.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-pen-to-square text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تعديل غير المؤكدة</span>
                <span class="text-[10px] opacity-70 truncate">تصحيح سجلات قبل التأكيد</span>
            </div>

            @if(isset($unconfirmedLivesCount) && $unconfirmedLivesCount > 0)
                <span class="mr-auto inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-amber-500/20 text-amber-200 border border-amber-400/30 text-[11px] font-bold">
                    {{ $unconfirmedLivesCount }}
                </span>
            @endif
        </a>

        {{-- إنشاء نشاط جديد --}}
        <a disabled href="{{ route('live-activities.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('live-activities.create') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إنشاء نشاط جديد</span>
                <span class="text-[10px] opacity-70 truncate">إضافة نشاط + إعداد التفاصيل</span>
            </div>
        </a>

        {{-- الطلبات --}}
        <a href="{{ route('live-activities.requests.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('live-activities.requests.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-inbox text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الطلبات</span>
                <span class="text-[10px] opacity-70 truncate">طلبات الأنشطة + الموافقات</span>
            </div>

            @if(isset($pendingRequestsCount) && $pendingRequestsCount > 0)
                <span class="mr-auto inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-500/30 text-[11px] font-bold">
                    {{ $pendingRequestsCount }}
                </span>
            @endif
        </a>

        {{-- أنشطتي --}}
        <a href="{{ route('live-activities.my-activities') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('live-activities.my-activities') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أنشطتي</span>
                <span class="text-[10px] opacity-70 truncate">عرض نشاطاتي ومتابعة حالتها</span>
            </div>
        </a>

        {{-- مراجعة بيانات الضيوف (للسوبر/المود) --}}
        @if(auth()->user()->hasRole(['super-admin', 'moderator']))
        <a href="{{ route('guest-submissions.review.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('guest-submissions.review.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-clipboard-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مراجعة بيانات الضيوف</span>
                <span class="text-[10px] opacity-70 truncate">تدقيق واعتماد المشاركات</span>
            </div>
        </a>
        @endif

        {{-- ================= اللايفات (نظام جديد) ================= --}}
        <div class="px-3 pt-4 pb-1 text-[11px] font-semibold text-white/55">
            اللايفات (نظام جديد)
        </div>

        <a href="{{ route('superadmin.falcon-room.lives-insights.templates.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-insights.templates.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-file-lines text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قوالب اللايفات</span>
                <span class="text-[10px] opacity-70 truncate">Templates + إعدادات جاهزة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-insights.feedback.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-insights.feedback.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-message text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">دفتر ملاحظات اللايفات</span>
                <span class="text-[10px] opacity-70 truncate">Feedback + ملاحظات</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-insights.feedback.analysis') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-insights.feedback.analysis') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-chart-pie text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليل ملاحظات اللايفات</span>
                <span class="text-[10px] opacity-70 truncate">ملخصات + اتجاهات</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.create') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إنشاء لايفات</span>
                <span class="text-[10px] opacity-70 truncate">إضافة لايفات حسب الجدول</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.confirm') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.confirm') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-circle-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تأكيد لايفات</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة الإثبات/العذر</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-delete.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-delete.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-trash-can text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">حذف لايفات</span>
                <span class="text-[10px] opacity-70 truncate">طلبات حذف + إدارة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-delete.logs') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-delete.logs') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-clipboard-list text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجل لايفات</span>
                <span class="text-[10px] opacity-70 truncate">Logs + مراجعة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-delete.approvals') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-delete.approvals') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-gavel text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">موافقة حذف لايفات</span>
                <span class="text-[10px] opacity-70 truncate">Approvals + قرارات</span>
            </div>

            @if(isset($pendingLiveDeleteCount) && $pendingLiveDeleteCount > 0)
                <span class="mr-auto inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-500/30 text-[11px] font-bold">
                    {{ $pendingLiveDeleteCount }}
                </span>
            @endif
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.stats.hours') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.stats.hours') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-chart-column text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إحصائيات ساعات</span>
                <span class="text-[10px] opacity-70 truncate">Hours + مؤشرات</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.stats.sahra') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.stats.sahra') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-fire text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سهرات التيم</span>
                <span class="text-[10px] opacity-70 truncate">إحصائيات + نشاط</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.programTable') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.programTable') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-table-list text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">جدول برامج لايفات</span>
                <span class="text-[10px] opacity-70 truncate">عرض البرامج اليومية</span>
            </div>
        </a>

        <a href="{{ route('superadmin.falcon-room.lives-new.programs.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.programs.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-calendar-days text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">برامج (تمبلت)</span>
                <span class="text-[10px] opacity-70 truncate">Templates + إعدادات</span>
            </div>
        </a>

        @if (Route::has('superadmin.falcon-room.lives-new.logs.index'))
        <a href="{{ route('superadmin.falcon-room.lives-new.logs.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.lives-new.logs.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-clock-rotate-left text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">سجلات اللايفات</span>
                <span class="text-[10px] opacity-70 truncate">Logs + عمليات</span>
            </div>
        </a>
        @endif

        {{-- ================= قستات ================= --}}
        <div class="px-3 pt-4 pb-1 text-[11px] font-semibold text-white/55">
            القستات
        </div>

        <a href="{{ route('guest-submissions.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('guest-submissions.create') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">رفع بيانات قيست</span>
                <span class="text-[10px] opacity-70 truncate">رفع الإثباتات والبيانات</span>
            </div>
        </a>

        <a href="{{ route('guest-submissions.my-submissions') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('guest-submissions.my-submissions') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-folder-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">بياناتي المرفوعة</span>
                <span class="text-[10px] opacity-70 truncate">عرض الحالة + الملاحظات</span>
            </div>
        </a>

        @if(auth()->user()->hasRole(['super-admin', 'moderator']))
        <a href="{{ route('guest-submissions.review.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('guest-submissions.review.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-clipboard-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مراجعة بيانات قيستات</span>
                <span class="text-[10px] opacity-70 truncate">Review + اعتماد</span>
            </div>
        </a>
        @endif

    </div>
</details>
{{-- سلايد/مجموعة: علامات الاختبارات (مهم) --}}
@php
    $testsMarksOpen = request()->routeIs('tests.marks.*')
        || request()->routeIs('tests.ai.analysis')
        || request()->routeIs('tests.special.one')
        || request()->routeIs('tests.special.two');

    $rMarksOverview = 'tests.marks.overview';
    $rMarksPerTest  = 'tests.marks.per-test';
    $rMarksAvg      = 'tests.marks.averages';
    $rMarksGender   = 'tests.marks.gender';
    $rMarksFails    = 'tests.marks.fails';
    $rMarksMissing  = 'tests.marks.missing';
@endphp

<details class="relative group" @if($testsMarksOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $testsMarksOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-emerald-500/15 text-emerald-200 border border-emerald-400/30 shadow-sm">
                <i class="fa-solid fa-square-poll-vertical text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">علامات الاختبارات</span>
                <span class="text-[11px] opacity-70">إحصائيات + مقارنة + AI</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- 1) علامات الاختبارات الكلّية --}}
        <a href="{{ route($rMarksOverview) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksOverview) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-gauge text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">علامات الاختبارات الكلّية</span>
                <span class="text-[10px] opacity-70 truncate">معدل نجاح العضو في كل الاختبارات</span>
            </div>
        </a>

        {{-- 2) علامات حسب كل اختبار --}}
        <a href="{{ route($rMarksPerTest) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksPerTest) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">علامات حسب كل اختبار</span>
                <span class="text-[10px] opacity-70 truncate">نتائجك في كل اختبار على حدة</span>
            </div>
        </a>

        {{-- 3) معدّل العلامات العام --}}
        <a href="{{ route($rMarksAvg) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksAvg) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-percent text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">معدّل العلامات</span>
                <span class="text-[10px] opacity-70 truncate">متوسط درجاتك في كل المحاولات</span>
            </div>
        </a>

        {{-- 4) معدل الشباب والصبايا --}}
        <a href="{{ route($rMarksGender) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksGender) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-venus-mars text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">معدّل الشباب والصبايا</span>
                <span class="text-[10px] opacity-70 truncate">مقارنة أداء الجنسين في الاختبارات</span>
            </div>
        </a>

        {{-- 5) معدل الفشل --}}
        <a href="{{ route($rMarksFails) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksFails) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">معدل الفشل</span>
                <span class="text-[10px] opacity-70 truncate">نسبة الرسوب حسب الاختبارات والأعضاء</span>
            </div>
        </a>

        {{-- 6) من لم يعمل اختبارات؟ --}}
        <a href="{{ route($rMarksMissing) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rMarksMissing) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-user-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">من لم يعمل اختبارات؟</span>
                <span class="text-[10px] opacity-70 truncate">قائمة الأعضاء اللي ما دخلوا ولا اختبار</span>
            </div>
        </a>

        {{-- AI Analysis --}}
        <a href="{{ route('tests.ai.analysis') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('tests.ai.analysis') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-robot text-[12px]"></i>
            </span>
            <span class="font-bold">تحليل الذكاء الاصطناعي</span>
        </a>

        {{-- Special 1 --}}
        <a href="{{ route('tests.special.one') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('tests.special.one') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-chart-pie text-[12px]"></i>
            </span>
            <span class="font-bold">تقرير الأداء الاحترافي</span>
        </a>

        {{-- Special 2 --}}
        <a href="{{ route('tests.special.two') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('tests.special.two') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-bolt text-[12px]"></i>
            </span>
            <span class="font-bold">تحليل التزام الفريق</span>
        </a>

    </div>
</details>

<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>


<details class="relative group" @if($gsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $gsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-cyan-500/15 text-cyan-200 border border-cyan-400/30 shadow-sm">
                <i class="fa-solid fa-camera-retro text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">معطياتي بالتيم</span>
                <span class="text-[11px] opacity-70">مشتركة للجميع • بدون المرفوض</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">
        <a href="{{ route('guest-submissions.participations.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('guest-submissions.participations.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-images text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">قستاتي</span>
                <span class="text-[10px] opacity-70">عرض الإثبات والحالة</span>
            </div>
        </a>
		<a href="{{ route('surveys.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('surveys.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
        <i class="fa-solid fa-square-poll-vertical text-[12px]"></i>
    </span>
    <div class="flex flex-col">
        <span class="font-bold">استطلاعاتي</span>
        <span class="text-[10px] opacity-70">عرض مشاركاتي وحالتي</span>
    </div>
</a>

<a href="{{ route('member.my-lives.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('member.my-lives.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-sky-500/15 border border-sky-400/25 text-sky-200">
        <i class="fa-solid fa-video text-[12px]"></i>
    </span>
    <div class="flex flex-col">
        <span class="font-bold">لايفاتي</span>
        <span class="text-[10px] opacity-70">حالة اللايف والساعات</span>
    </div>
</a>
<a href="{{ route('my-evaluations.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('my-evaluations.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-clipboard-check text-[12px]"></i>
    </span>
    <div class="flex flex-col">
        <span class="font-bold">تقييماتي</span>
        <span class="text-[10px] opacity-70">فقط المعتمد + المقيم</span>
    </div>
</a>
<a href="{{ route('my-posts.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('my-posts.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    {{-- أيقونة --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200 shadow-sm">
        <i class="fa-solid fa-pen-nib text-[12px]"></i>
    </span>

    {{-- نص --}}
    <div class="flex flex-col leading-tight">
        <span class="font-bold">منشوراتي</span>
        <span class="text-[10px] opacity-70">
            عرض منشوراتك فقط
        </span>
    </div>
</a>
<a href="{{ route('my-tests.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('my-tests.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
        <i class="fa-solid fa-square-poll-vertical text-[12px]"></i>
    </span>
    <div class="flex flex-col">
        <span class="font-bold">اختباراتي</span>
        <span class="text-[10px] opacity-70">النتائج + المعدّل</span>
    </div>
</a>
@php
    $onMyMarks = request()->routeIs('general.my-marks.index');
@endphp

<a href="{{ route('general.my-marks.index') }}"
   class="{{ $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition' }}
          {{ $onMyMarks ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}
          group relative overflow-hidden">

    {{-- Glow --}}
    <span class="pointer-events-none absolute -inset-1 rounded-2xl
                 bg-sky-400/20 blur-md opacity-0 group-hover:opacity-100 transition duration-500"></span>

    <span class="relative z-10 inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-sky-500/15 border border-sky-400/25 text-sky-200 shadow-sm
                 transition-all duration-300 group-hover:scale-110 group-hover:rotate-3">
        <i class="fa-solid fa-chart-line text-[12px]"></i>
    </span>

    <div class="relative z-10 flex flex-col">
        <span class="font-bold tracking-wide">علاماتي</span>
        <span class="text-[10px] opacity-70">صافي + مصادر النقاط</span>
    </div>

    <div class="absolute left-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity">
        <span class="relative flex h-2 w-2">
            <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"></span>
            <span class="relative inline-flex rounded-full h-1.5 w-1.5 bg-white"></span>
        </span>
    </div>
</a>
@php
    $onMyRequests = request()->routeIs('general.my-requests.index');
@endphp

<a href="{{ route('general.my-requests.index') }}"
   class="{{ $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition' }}
          {{ $onMyRequests ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}
          group relative overflow-hidden">

    <span class="pointer-events-none absolute -inset-1 rounded-2xl
                 bg-fuchsia-400/20 blur-md opacity-0 group-hover:opacity-100 transition duration-500"></span>

    <span class="relative z-10 inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200 shadow-sm
                 transition-all duration-300 group-hover:scale-110 group-hover:rotate-3">
        <i class="fa-solid fa-inbox text-[12px]"></i>
    </span>

    <div class="relative z-10 flex flex-col">
        <span class="font-bold tracking-wide">طلباتي</span>
        <span class="text-[10px] opacity-70">الإدارة • المشرف • الغياب • البلاغات</span>
    </div>

    <div class="absolute left-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity">
        <span class="relative flex h-2 w-2">
            <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"></span>
            <span class="relative inline-flex rounded-full h-1.5 w-1.5 bg-white"></span>
        </span>
    </div>
</a>
    </div>
</details>

                <!-- Dashboard -->

@php
    $usersOpen = request()->routeIs([
        'superadmin.users.*',
        'superadmin.roles.*',
        'superadmin.ranks.*'
    ]);
@endphp

@if(auth()->check() && auth()->user()->hasRole('super-admin'))
<details class="relative group" @if($usersOpen) open @endif>
    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $usersOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-sky-500/15 text-sky-200 border border-sky-400/30 shadow-sm">
                <i class="fa-solid fa-users text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">المستخدمين والصلاحيات</span>
                <span class="text-[11px] opacity-70">إدارة الحسابات • الأدوار • الرتب</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    {{-- المحتوى --}}
    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- المستخدمين --}}
        <a href="{{ route('superadmin.users.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
           {{ request()->routeIs('superadmin.users.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">المستخدمين</span>
                <span class="text-[10px] opacity-70">إدارة الحسابات</span>
            </div>
        </a>

        {{-- الأدوار --}}
        <a href="{{ route('superadmin.roles.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
           {{ request()->routeIs('superadmin.roles.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الأدوار</span>
                <span class="text-[10px] opacity-70">صلاحيات النظام</span>
            </div>
        </a>

        {{-- الرتب --}}
        <a href="{{ route('superadmin.ranks.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
           {{ request()->routeIs('superadmin.ranks.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-star text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الرتب</span>
                <span class="text-[10px] opacity-70">الترقية والتصنيف</span>
            </div>
        </a>

    </div>
</details>
@endif


<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>

<details class="relative group" @if($sentinelOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $sentinelOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
        <i class="fa-solid fa-eye text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">نظام المراقبة Socratic Sentinel</span>
        <span class="text-[11px] opacity-70">SuperAdmin فقط • Audit + Tracking + AI + Charts</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">
    <a href="{{ route('superadmin.sentinel.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.sentinel.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">لوحة Sentinel</span>
        <span class="text-[10px] opacity-70">AI + KPI + عيون على النظام</span>
      </div>
    </a>

    <a href="{{ route('superadmin.sentinel.explorer') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.sentinel.explorer') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
        <i class="fa-solid fa-magnifying-glass-chart text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">Explorer</span>
        <span class="text-[10px] opacity-70">Audit + Tracking + Jobs</span>
      </div>
    </a>

    <a href="{{ route('superadmin.sentinel.incidents') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.sentinel.incidents') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
        <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">Incidents</span>
        <span class="text-[10px] opacity-70">حالات + معالجة + توثيق</span>
      </div>
    </a>

    <a href="{{ route('superadmin.sentinel.broadcast') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.sentinel.broadcast') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-bullhorn text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">Broadcast للجميع</span>
        <span class="text-[10px] opacity-70">إشعار واحد يوصل للكل</span>
      </div>
    </a>
  </div>
</details>
<details class="relative group" @if($msgMonitorOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $msgMonitorOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-cyan-500/15 text-cyan-200 border border-cyan-400/30 shadow-sm">
                <i class="fa-solid fa-eye text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">مراقبة الرسائل</span>
                <span class="text-[11px] opacity-70">SuperAdmin فقط • Monitor + Analytics + Forbidden</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        <a href="{{ route('superadmin.messages-monitor.dashboard') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-gauge-high text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">لوحة المراقبة</span>
                <span class="text-[10px] opacity-70">نظرة سريعة + صحة النظام</span>
            </div>
        </a>

        <a href="{{ route('superadmin.messages-monitor.messages') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.messages*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-white/10 border border-white/15 text-white">
                <i class="fa-solid fa-inbox text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">كل الرسائل</span>
                <span class="text-[10px] opacity-70">بحث + فلترة + إدارة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.messages-monitor.forbidden') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.forbidden*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">مراقبة الممنوعات</span>
                <span class="text-[10px] opacity-70">Passwords + OTP + Tokens…</span>
            </div>
        </a>

        <a href="{{ route('superadmin.messages-monitor.archives') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.archives*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-box-archive text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الأرشيفات</span>
                <span class="text-[10px] opacity-70">إدارة الأرشفة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.messages-monitor.members') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.members*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-users text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">إحصائيات الأعضاء</span>
                <span class="text-[10px] opacity-70">صفحة لكل عضو فعال</span>
            </div>
        </a>

        <a href="{{ route('superadmin.messages-monitor.analytics') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.messages-monitor.analytics*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">تحليلات ومخططات</span>
                <span class="text-[10px] opacity-70">رسوم بيانية + توصيات</span>
            </div>
        </a>

    </div>
</details>
@php
  $notifyHubOpen = request()->routeIs('superadmin.notifyhub.*');
@endphp

<details class="relative group" @if($notifyHubOpen) open @endif>
  <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                  text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                  {{ $notifyHubOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
    <div class="flex items-center gap-3">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                   bg-rose-500/15 text-rose-200 border border-rose-400/30 shadow-sm">
        <i class="fa-solid fa-bullhorn text-sm"></i>
      </span>
      <div class="flex flex-col">
        <span class="text-[13px] font-semibold">مركز الإشعارات NotificationHub</span>
        <span class="text-[11px] opacity-70">SuperAdmin • Decisions + Lives + Tests + Readings</span>
      </div>
    </div>
    <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
  </summary>

  <div class="mt-2 space-y-1 px-2 pb-2">
    <a href="{{ route('superadmin.notifyhub.dashboard') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.notifyhub.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-gauge-high text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">اللوحة</span>
        <span class="text-[10px] opacity-70">KPIs + AI + Charts</span>
      </div>
    </a>

    <a href="{{ route('superadmin.notifyhub.notifications.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.notifyhub.notifications.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
        <i class="fa-solid fa-paper-plane text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">الإشعارات</span>
        <span class="text-[10px] opacity-70">إنشاء / جدولة / إرسال</span>
      </div>
    </a>

    <a href="{{ route('superadmin.notifyhub.rules.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.notifyhub.rules.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-wand-magic-sparkles text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">القواعد التلقائية</span>
        <span class="text-[10px] opacity-70">Auto Triggers</span>
      </div>
    </a>

    <a href="{{ route('superadmin.notifyhub.logs.index') }}"
       class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
              {{ request()->routeIs('superadmin.notifyhub.logs.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
      <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-slate-500/15 border border-white/15 text-slate-200">
        <i class="fa-solid fa-list-check text-[12px]"></i>
      </span>
      <div class="flex flex-col">
        <span class="font-bold">السجل</span>
        <span class="text-[10px] opacity-70">Logs + Monitoring</span>
      </div>
    </a>
  </div>
</details>
@php
    $falconAuthOpen = request()->routeIs('superadmin.falcon-room.failed-logins.*');
@endphp

<details class="relative group" @if($falconAuthOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $falconAuthOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-rose-500/15 text-rose-200 border border-rose-400/30 shadow-sm">
                <i class="fa-solid fa-user-lock text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">محاولات الدخول الفاشلة</span>
                <span class="text-[11px] opacity-70">IP الحقيقي • الجهاز والمتصفح • ملاحظات الإدارة</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">
        <a href="{{ route('superadmin.falcon-room.failed-logins.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.failed-logins.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-bug-slash text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">سجل المحاولات</span>
                <span class="text-[10px] opacity-70">بحث • فلترة • تقييم خطر</span>
            </div>
        </a>
<a href="{{ route('superadmin.falcon-room.failed-logins.targets') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ request()->routeIs('superadmin.falcon-room.failed-logins.targets') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-crosshairs text-[12px]"></i>
    </span>
    <div class="flex flex-col">
        <span class="font-bold">قائمة الأهداف</span>
        <span class="text-[10px] opacity-70">من حاولوا عليهم • تجميع ذكي</span>
    </div>
</a>
    </div>
</details>
<div class="my-4">
  <div class="h-px bg-gradient-to-r from-transparent via-fuchsia-400/30 to-transparent"></div>
</div>
{{-- ✅ قسم السيرفرات (مثل محاولات الدخول الفاشلة) --}}
@php
    // افتح القائمة تلقائيًا إذا كنت داخل صفحات السيرفرات
    $serversOpen = request()->routeIs('superadmin.servers.*');
@endphp

<details class="relative group" @if($serversOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $serversOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">

        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-server text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">إدارة السيرفرات</span>
                <span class="text-[11px] opacity-70">تفعيل • توجيه • صلاحيات • ترتيب</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- 1) قائمة السيرفرات --}}
        <a href="{{ route('superadmin.servers.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.servers.index') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-list-ul text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">قائمة السيرفرات</span>
                <span class="text-[10px] opacity-70">عرض • تعديل • تفعيل/تعطيل</span>
            </div>
        </a>

        {{-- 2) إضافة سيرفر --}}
        <a href="{{ route('superadmin.servers.create') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.servers.create') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">إضافة سيرفر</span>
                <span class="text-[10px] opacity-70">مفتاح • Route • Redirect</span>
            </div>
        </a>

        {{-- 3) سجلات التحويل/الدخول للسيرفرات --}}
        <a href="{{ route('superadmin.servers.logs') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.servers.logs') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-clock-rotate-left text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">سجلات السيرفرات</span>
                <span class="text-[10px] opacity-70">من دخل؟ وين تحوّل؟ ولماذا</span>
            </div>
        </a>

        {{-- 4) قواعد وصلاحيات السيرفر --}}
        <a href="{{ route('superadmin.servers.permissions') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.servers.permissions') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">صلاحيات السيرفر</span>
                <span class="text-[10px] opacity-70">allowed_roles • قواعد الوصول</span>
            </div>
        </a>

    </div>
</details>




<details class="relative group" @if($socraticOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $socraticOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
                <i class="fa-solid fa-brain text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">نظام سقراط</span>
                <span class="text-[11px] opacity-70">SuperAdmin فقط • جلسات + أسئلة + إحصائيات</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">
        <a href="{{ route('superadmin.socratic.dashboard') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.dashboard') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-gauge-high text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">لوحة سقراط</span>
                <span class="text-[10px] opacity-70">نظرة سريعة</span>
            </div>
        </a>

        <a href="{{ route('superadmin.socratic.sessions.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.sessions.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-comments text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الجلسات والإجابات</span>
                <span class="text-[10px] opacity-70">فلترة + عرض التفاصيل</span>
            </div>
        </a>

        <a href="{{ route('superadmin.socratic.questions.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.questions.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-circle-question text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">بنك الأسئلة</span>
                <span class="text-[10px] opacity-70">إضافة/تعديل/تفعيل</span>
            </div>
        </a>

        <a href="{{ route('superadmin.socratic.rules.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.rules.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-sliders text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">قواعد التفعيل</span>
                <span class="text-[10px] opacity-70">Triggers + Limits</span>
            </div>
        </a>

        <a href="{{ route('superadmin.socratic.progress.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.progress.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-user-check text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">Progress</span>
                <span class="text-[10px] opacity-70">مستوى كل عضو</span>
            </div>
        </a>

        <a href="{{ route('superadmin.socratic.analytics.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.socratic.analytics.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الإحصائيات</span>
                <span class="text-[10px] opacity-70">Trends + Top</span>
            </div>
        </a>
    </div>
</details>
@endif

@php
    $surveysOpen = request()->routeIs('superadmin.surveys.*');
@endphp

@php
    $surveysOpen = request()->routeIs('superadmin.surveys.*');
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

@if(auth()->check() && auth()->user()->hasRole('super-admin'))
<details class="relative group" @if($surveysOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $surveysOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-poll text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الاستطلاعات</span>
                <span class="text-[11px] opacity-70">لوحات + إنشاء + إدارة + نتائج</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- لوحة الإحصائيات --}}
        <a href="{{ route('superadmin.surveys.dashboard') }}"
           class="{{ $linkBase }}
                  {{ request()->routeIs('superadmin.surveys.dashboard')
                        ? 'bg-white/15 text-white shadow-sm'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-chart-pie text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة الإحصائيات</span>
                <span class="text-[10px] opacity-70 truncate">Charts + نسب + مقارنة الأقسام</span>
            </div>
        </a>

        {{-- إدارة الاستطلاعات --}}
        <a href="{{ route('superadmin.surveys.index') }}"
           class="{{ $linkBase }}
                  {{ request()->routeIs('superadmin.surveys.index')
                        ? 'bg-white/15 text-white shadow-sm'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة الاستطلاعات</span>
                <span class="text-[10px] opacity-70 truncate">تفعيل/إغلاق + استهداف + فلترة</span>
            </div>
        </a>

        {{-- إنشاء استطلاع --}}
        <a href="{{ route('superadmin.surveys.create') }}"
           class="{{ $linkBase }}
                  {{ request()->routeIs('superadmin.surveys.create')
                        ? 'bg-white/15 text-white shadow-sm'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-square-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إنشاء استطلاع</span>
                <span class="text-[10px] opacity-70 truncate">أسئلة + أقسام + خيارات + مدة</span>
            </div>
        </a>

    </div>
</details>
@endif



                


{{-- ====== END الغيابات ====== --}}



@php
    $marksOpen = request()->routeIs('superadmin.falcon-room.marks.*');
@endphp

<details class="relative group" @if($marksOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $marksOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-amber-500/15 text-amber-200 border border-amber-400/30 shadow-sm">
                <i class="fa-solid fa-medal text-sm"></i>
            </span>
            <span class="text-[13px] font-semibold">منظومة العلامات</span>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        <x-mark-item route="superadmin.falcon-room.marks.power" icon="fa-bolt"
            title="قوة العضو" subtitle="تقييم شامل + نسبة من المتصدر" />

        <x-mark-item route="superadmin.falcon-room.marks.growth" icon="fa-chart-line"
            title="نمو العلامات" subtitle="زيادة / نقصان العلامات" />

        <x-mark-item route="superadmin.falcon-room.marks.distribution" icon="fa-chart-pie"
            title="توزيع العلامات" subtitle="صورة كاملة لفئات الفريق" />

        <x-mark-item route="superadmin.falcon-room.marks.stars" icon="fa-star"
            title="النجوم الذهبية" subtitle="تصنيفات حسب القوة" />

        <x-mark-item route="superadmin.falcon-room.marks.breakdown" icon="fa-list"
            title="تفصيل العلامات" subtitle="التحليل الكامل للعلامات" />

        <x-mark-item route="superadmin.falcon-room.marks.levels" icon="fa-layer-group"
            title="مستويات العضوية" subtitle="Elite / Pro / Active / Weak" />

        <x-mark-item route="superadmin.falcon-room.marks.monthly" icon="fa-calendar"
            title="علامات الشهر" subtitle="أقوى 10 خلال الشهر" />

    </div>
</details>
<details class="relative group" @if($adminSectionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $adminSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-whatsapp text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">واتساب بالذكاء الاصطناعي</span>
                <span class="text-[11px] opacity-70">رسائل جاهزة • تقارير • نشر سريع</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        <a href="{{ route($rWaLives) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.falcon-room.whatsapp-lives.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-tower-broadcast text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لايفات واتساب</span>
                <span class="text-[10px] opacity-70 truncate">سهرة اليوم + برنامج اليوم + تقارير جاهزة</span>
            </div>
        </a>

        <a href="{{ route($rWaMeetings) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rWaMeetings)
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-calendar-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">اجتماعات واتساب</span>
                <span class="text-[10px] opacity-70 truncate">تذكير • ملخص • حضور/غياب • متابعة</span>
            </div>
        </a>

        <a href="{{ route($rWaDailyReading) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.whatsapp.daily-reading.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-book-open-reader text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">اقرأني (واتساب)</span>
                <span class="text-[10px] opacity-70 truncate">إرسال مقال كامل/ملخص + سجل الإرسالات</span>
            </div>
        </a>

        <a href="{{ route('superadmin.whatsapp.insights-hub.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.whatsapp.insights-hub.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-chart-line text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليلات واتساب</span>
                <span class="text-[10px] opacity-70 truncate">نبض + رادار + رسائل جاهزة</span>
            </div>
        </a>

        <a href="{{ route($rWaSystem) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.whatsapp.system.*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-server text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إشعارات النظام</span>
                <span class="text-[10px] opacity-70 truncate">فتح/إغلاق + تنبيهات + أعطال</span>
            </div>
        </a>

        <a href="{{ route($rWaQuick) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rWaQuick.'*')
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إعلانات واتساب</span>
                <span class="text-[10px] opacity-70 truncate">قوالب جاهزة • نشر سريع • (10 كبسات)</span>
            </div>
        </a>

        <a href="{{ route($rWaStatement) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rWaStatement)
                        ? 'bg-white/15 text-white'
                        : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">بيان رسمي</span>
                <span class="text-[10px] opacity-70 truncate">صياغة وإرسال بيان رسمي للجروب</span>
            </div>
        </a>

        <a href="{{ route($rWhatsAbs) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onWhatsAbs ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-user-xmark text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تقرير الغياب</span>
                <span class="text-[10px] opacity-70 truncate">بعذر/بدون عذر + وضع مبسّط/متقدم</span>
            </div>
        </a>

        <a href="{{ route($rWhatsPresence) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onWhatsPresence ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-signal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تواجد الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">تقارير جاهزة للتواجد والتفاعل</span>
            </div>
        </a>

        <a href="{{ route($rWhatsGuestHours) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onWhatsGuestHours ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-clock text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ساعات القستات</span>
                <span class="text-[10px] opacity-70 truncate">سطر لكل هوست + توزيع ساعات</span>
            </div>
        </a>

        <a href="{{ route($rWhatsRisk) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onWhatsRisk ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-red-500/15 border border-red-400/25 text-red-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قائمة الخطر</span>
                <span class="text-[10px] opacity-70 truncate">إرسال أخطر الأعضاء كتقرير للجروب</span>
            </div>
        </a>

    </div>
</details>
@php
    $linkBase = 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition-colors group';

    // Routes
    $rEesMember360          = 'superadmin.falcon-room.ees.member360';
    $rEesFraudRadar         = 'superadmin.falcon-room.ees.fraud-radar';
    $rEesExperiments        = 'superadmin.falcon-room.ees.experiments';
    $rEesSmartSearch        = 'superadmin.falcon-room.ees.smart-search';

    $rEesAttendanceHeatmap  = 'superadmin.falcon-room.ees.attendance-heatmap';
    $rEesProactivePerf      = 'superadmin.falcon-room.ees.proactive-performance';
    $rEesTestsAnalytics     = 'superadmin.falcon-room.ees.tests-analytics';

    $rEesLivePulse          = 'superadmin.falcon-room.ees.live-pulse';
    $rEesTaateerRadar       = 'superadmin.falcon-room.ees.taateer-radar';
    $rEesMomentumDashboard  = 'superadmin.falcon-room.ees.momentum-dashboard';

    // Active states
    $onEesMember360         = request()->routeIs($rEesMember360);
    $onEesFraudRadar        = request()->routeIs($rEesFraudRadar);
    $onEesExperiments       = request()->routeIs($rEesExperiments);
    $onEesSmartSearch       = request()->routeIs($rEesSmartSearch);

    $onEesAttendanceHeatmap = request()->routeIs($rEesAttendanceHeatmap);
    $onEesProactivePerf     = request()->routeIs($rEesProactivePerf);
    $onEesTestsAnalytics    = request()->routeIs($rEesTestsAnalytics);

    $onEesLivePulse         = request()->routeIs($rEesLivePulse);
    $onEesTaateerRadar      = request()->routeIs($rEesTaateerRadar);
    $onEesMomentumDashboard = request()->routeIs($rEesMomentumDashboard);

    $eesSectionOpen =
        $onEesMember360 || $onEesFraudRadar || $onEesExperiments || $onEesSmartSearch ||
        $onEesAttendanceHeatmap || $onEesProactivePerf || $onEesTestsAnalytics ||
        $onEesLivePulse || $onEesTaateerRadar || $onEesMomentumDashboard;
@endphp


<details class="relative group" @if($eesSectionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $eesSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-emerald-500/15 text-emerald-200 border border-emerald-400/30 shadow-sm">
                <i class="fa-solid fa-bolt text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">منظومة الذكاء (EES)</span>
                <span class="text-[11px] opacity-70">تحليل • رادارات • مؤشرات</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- Attendance Heatmap --}}
        <a href="{{ route($rEesAttendanceHeatmap) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesAttendanceHeatmap ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-calendar-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Heatmap الحضور</span>
                <span class="text-[10px] opacity-70 truncate">حضور / غياب حسب الأيام</span>
            </div>
        </a>

        {{-- التحليل التنبؤي (AI) --}}
        <a href="{{ route('ai.analytics.index') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onAiAnalytics ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-microchip text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التحليل التنبؤي (AI)</span>
                <span class="text-[10px] opacity-70 truncate">رادار كشف الخمول والانسحاب</span>
            </div>
        </a>

        {{-- تحليل عضو (AI) --}}
        <a href="{{ route('ai.analytics.index') }}#user-report"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onAiAnalyticsUser ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-chart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليل عضو (AI)</span>
                <span class="text-[10px] opacity-70 truncate">تقرير فردي – خمول / انسحاب</span>
            </div>
        </a>

        {{-- Live Pulse --}}
        <a href="{{ route('superadmin.falcon-room.ees.live-pulse') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesLivePulse ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-heart-pulse text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Live Pulse</span>
                <span class="text-[10px] opacity-70 truncate">من المتواجد الآن داخل النظام</span>
            </div>
        </a>

        {{-- نية التفاعل --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesEngagementIntent) ? route($rEesEngagementIntent) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesEngagementIntent ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-bolt text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">نية التفاعل</span>
                <span class="text-[10px] opacity-70 truncate">متابعة جدّية الإدارة داخل النظام</span>
            </div>
        </a>

        {{-- خريطة التأثير --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesInfluenceMapping) ? route($rEesInfluenceMapping) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesInfluenceMapping ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-people-arrows text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">خريطة التأثير</span>
                <span class="text-[10px] opacity-70 truncate">تقاطعات وتواصل الإدارة</span>
            </div>
        </a>

        {{-- ثبات الأداء --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesConsistencyDetector) ? route($rEesConsistencyDetector) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesConsistencyDetector ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ثبات الأداء (Consistency)</span>
                <span class="text-[10px] opacity-70 truncate">حضور + لايف + اختبارات + تحذيرات</span>
            </div>
        </a>

        {{-- Taateer Radar --}}
        <a href="{{ route('superadmin.falcon-room.ees.taateer-radar') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesTaateerRadar ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-id-card-clip text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Taateer Radar</span>
                <span class="text-[10px] opacity-70 truncate">مراقبة الأكواد الانضباطية</span>
            </div>
        </a>

        {{-- Momentum --}}
        <a href="{{ route('superadmin.falcon-room.ees.momentum-dashboard') }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesMomentumDashboard ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Momentum</span>
                <span class="text-[10px] opacity-70 truncate">زخم التيم حسب الأيام</span>
            </div>
        </a>

        {{-- ProActive Performance --}}
        <a href="{{ route($rEesProactivePerf) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesProactivePerf ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-paper-plane text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أداء ProActive</span>
                <span class="text-[10px] opacity-70 truncate">منصات، Plus، أصدقاء جدد</span>
            </div>
        </a>

        {{-- Tests Analytics --}}
        <a href="{{ route($rEesTestsAnalytics) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesTestsAnalytics ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-file-circle-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تحليل الاختبارات</span>
                <span class="text-[10px] opacity-70 truncate">مشاركون، متوسط، أعلى وأقل</span>
            </div>
        </a>

        {{-- Member 360 --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesMember360) ? route($rEesMember360) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesMember360 ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-gear text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Member 360</span>
                <span class="text-[10px] opacity-70 truncate">سجل حياة العضو بالكامل</span>
            </div>
        </a>

        {{-- Fraud Radar --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesFraudRadar) ? route($rEesFraudRadar) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesFraudRadar ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-radar text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Fraud Radar</span>
                <span class="text-[10px] opacity-70 truncate">سلوك مشبوه + تكرار حسابات</span>
            </div>
        </a>

        {{-- Experiments --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesExperiments) ? route($rEesExperiments) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesExperiments ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-vial-circle-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Experiments</span>
                <span class="text-[10px] opacity-70 truncate">تجارب A/B على التدخلات</span>
            </div>
        </a>

        {{-- Smart Search --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rEesSmartSearch) ? route($rEesSmartSearch) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onEesSmartSearch ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-magnifying-glass-chart text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">Smart Search</span>
                <span class="text-[10px] opacity-70 truncate">بحث موحّد + Tags ذكية</span>
            </div>
        </a>

    </div>
</details>



{{-- JS بسيط للدروبداون --}}
@php
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-4 py-2.5 text-sm rounded-lg transition-colors';

    $rMinYouth      = 'superadmin.falcon-room.ministries.youth';
    $rMinGirls      = 'superadmin.falcon-room.ministries.girls';
    $rMinEconomy    = 'superadmin.falcon-room.ministries.economy';
    $rMinInterior   = 'superadmin.falcon-room.ministries.interior';
    $rMinForeign    = 'superadmin.falcon-room.ministries.foreign';
    $rTikTokSupport = 'superadmin.falcon-room.ministries.tiktok-support';

    $onMinYouth      = request()->routeIs($rMinYouth . '*');
    $onMinGirls      = request()->routeIs($rMinGirls . '*');
    $onMinEconomy    = request()->routeIs($rMinEconomy . '*');
    $onMinInterior   = request()->routeIs($rMinInterior . '*');
    $onMinForeign    = request()->routeIs($rMinForeign . '*');
    $onTikTokSupport = request()->routeIs($rTikTokSupport . '*');

    $rTikTokTeamBudgets  = 'superadmin.ministries.tiktok-team-budgets';
    $onTikTokTeamBudgets = \Illuminate\Support\Facades\Route::currentRouteNamed($rTikTokTeamBudgets);

    $ministriesSectionOpen =
        $onMinYouth || $onMinGirls || $onMinEconomy || $onMinInterior || $onMinForeign || $onTikTokSupport || $onTikTokTeamBudgets;
@endphp

<details class="relative group" @if($ministriesSectionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $ministriesSectionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-sky-500/15 text-sky-200 border border-sky-400/30 shadow-sm">
                <i class="fa-solid fa-building-columns text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الوزارات</span>
                <span class="text-[11px] opacity-70">إدارة الشباب • الصبايا • الاقتصاد • الداخلية • الخارجية</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- وزارة الشباب --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMinYouth) ? route($rMinYouth) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onMinYouth ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-people-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وزارة الشباب</span>
                <span class="text-[10px] opacity-70 truncate">نشاط • تفاعل • فعاليات • متابعة الشباب</span>
            </div>
        </a>

        {{-- وزارة الصبايا --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMinGirls) ? route($rMinGirls) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onMinGirls ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-person-dress text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وزارة الصبايا</span>
                <span class="text-[10px] opacity-70 truncate">نشاط • تفاعل • فعاليات • متابعة الصبايا</span>
            </div>
        </a>

        {{-- وزارة الاقتصاد --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMinEconomy) ? route($rMinEconomy) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onMinEconomy ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-coins text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وزارة الاقتصاد</span>
                <span class="text-[10px] opacity-70 truncate">الدعم • التحويلات • تنظيم الموارد</span>
            </div>
        </a>

        {{-- وزارة الداخلية --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMinInterior) ? route($rMinInterior) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onMinInterior ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وزارة الداخلية</span>
                <span class="text-[10px] opacity-70 truncate">تنظيم داخلي • انضباط • متابعة</span>
            </div>
        </a>

        {{-- وزارة الخارجية --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMinForeign) ? route($rMinForeign) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onMinForeign ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-globe text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">وزارة الخارجية</span>
                <span class="text-[10px] opacity-70 truncate">علاقات • تحالفات • تنسيق خارجي</span>
            </div>
        </a>

        {{-- دعم تيكتوك والهدايا --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rTikTokSupport) ? route($rTikTokSupport) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onTikTokSupport ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-pink-500/15 border border-pink-400/25 text-pink-200">
                <i class="fa-solid fa-gift text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">دعم تيكتوك والهدايا</span>
                <span class="text-[10px] opacity-70 truncate">حسابات الدعم + ملخصات + تقارير</span>
            </div>
        </a>

        {{-- ميزانيات دعم تيكتوك للتيم --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rTikTokTeamBudgets) ? route($rTikTokTeamBudgets) : '#' }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ $onTikTokTeamBudgets ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-sack-dollar text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ميزانيات دعم تيكتوك للتيم</span>
                <span class="text-[10px] opacity-70 truncate">يومي/أسبوعي/شهري/سنوي + إجمالي</span>
            </div>
        </a>

    </div>
</details>


{{-- تحديثات الموقع (ستايل سقراط) --}}
@php
    $onSiteUpdates = request()->routeIs('site-updates.admin.*');
@endphp

<a href="{{ route('site-updates.admin.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ $onSiteUpdates ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
        <i class="fa-solid fa-bullhorn text-[12px]"></i>
    </span>
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">تحديثات الموقع</span>
        <span class="text-[10px] opacity-70 truncate">إدارة السلايد / التحديثات الإلزامية</span>
    </div>
</a>


{{-- resources/views/superadmin/partials/ai-settings-menu.blade.php --}}
@php
    $aiOpen = request()->routeIs([
        'superadmin.ai.settings',
        'superadmin.ai.guidelines',
        'superadmin.ai.sources',
        'superadmin.whatsapp.bridge.*',
    ]);

    $rAiSettings = 'superadmin.ai.settings';
    $rAiGuides   = 'superadmin.ai.guidelines';
    $rAiSources  = 'superadmin.ai.sources';
    $rWaBridge   = 'superadmin.whatsapp.bridge.index';
@endphp

<details class="relative group" @if($aiOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $aiOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-emerald-500/15 text-emerald-200 border border-emerald-400/30 shadow-sm">
                <i class="fa-solid fa-microchip text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">AmirOS AI</span>
                <span class="text-[11px] opacity-70">إعدادات • توجيهات • مصادر • فحص واتساب</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- إعدادات الذكاء الاصطناعي --}}
        <a href="{{ route($rAiSettings) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rAiSettings) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-gear text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إعدادات الذكاء الاصطناعي</span>
                <span class="text-[10px] opacity-70 truncate">معلومات الخادم وحالة التحليلات</span>
            </div>
        </a>

        {{-- فحص ربط الواتساب --}}
        <a href="{{ route($rWaBridge) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.whatsapp.bridge.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-plug-circle-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">فحص ربط الواتساب</span>
                <span class="text-[10px] opacity-70 truncate">حالة حيّة + اختبار إرسال + إعداد البورت</span>
            </div>
        </a>

        {{-- توجيهات الذكاء الاصطناعي --}}
        <a href="{{ route($rAiGuides) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rAiGuides) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-compass-drafting text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">توجيهات الذكاء الاصطناعي</span>
                <span class="text-[10px] opacity-70 truncate">كيف يفكر AmirOS AI داخل التيم</span>
            </div>
        </a>

        {{-- ربط مصادر خارجية --}}
        <a href="{{ route($rAiSources) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rAiSources) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-plug text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">ربط مصادر خارجية</span>
                <span class="text-[10px] opacity-70 truncate">منصات وقواعد بيانات يمكن توصيلها لاحقًا</span>
            </div>
        </a>

    </div>
</details>                <!-- إدارة المستخدمين والصلاحيات -->


{{-- غرفة المؤشرات --}}
@php
    $indicatorsOpen = request()->routeIs('superadmin.indicators.*');

    $rLiveIndicators = 'superadmin.indicators.live-lives';
    $rRisk           = 'superadmin.indicators.risk.index';
    $rInfluence      = 'superadmin.indicators.influence.index';
    $rGrowth         = 'superadmin.indicators.growth.index';
    $rStability      = 'superadmin.indicators.honors';
    $rViolations     = 'superadmin.indicators.violations.index';
    $rEvalIndicator  = 'superadmin.indicators.evaluations';
    $rEngagement     = 'superadmin.indicators.engagement';
@endphp

<details class="relative group" @if($indicatorsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $indicatorsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-gauge-high text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">غرفة المؤشرات</span>
                <span class="text-[11px] opacity-70">لايفات • خطر • تأثير • نمو • استقرار</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- مؤشرات اللايفات --}}
        <a href="{{ route($rLiveIndicators) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rLiveIndicators) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-tower-broadcast text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشرات اللايفات</span>
                <span class="text-[10px] opacity-70 truncate">عذر/بدون عذر + ساعات مقارنة بالشهر السابق</span>
            </div>
        </a>

        {{-- مؤشر الخطر --}}
        <a href="{{ route($rRisk) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rRisk) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر الخطر</span>
                <span class="text-[10px] opacity-70 truncate">احتمال بقاء العضو أو خروجه من التيم</span>
            </div>
        </a>

        {{-- مؤشر التأثير --}}
        <a href="{{ route($rInfluence) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rInfluence) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-users-rays text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر التأثير</span>
                <span class="text-[10px] opacity-70 truncate">من هم سفراء الفريق وجالبو الحياة؟</span>
            </div>
        </a>

        {{-- مؤشر النمو --}}
        <a href="{{ route($rGrowth) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rGrowth) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-rocket text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر النمو</span>
                <span class="text-[10px] opacity-70 truncate">تطور العضو وإمكانيات المستقبل</span>
            </div>
        </a>

        {{-- مؤشر الاستقرار --}}
        <a href="{{ route($rStability) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rStability) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-heart-pulse text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر الاستقرار</span>
                <span class="text-[10px] opacity-70 truncate">ثبات العضو واستمرار وجوده بدون هزّات قوية</span>
            </div>
        </a>

        {{-- مؤشر المخالفات --}}
        <a href="{{ route($rViolations) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rViolations) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-red-500/15 border border-red-400/25 text-red-200">
                <i class="fa-solid fa-ban text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر المخالفات</span>
                <span class="text-[10px] opacity-70 truncate">ضغط المخالفات واتجاه السلوك العام</span>
            </div>
        </a>

        {{-- مؤشر التقييمات --}}
        <a href="{{ route($rEvalIndicator) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rEvalIndicator) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-star-half-stroke text-[12px]"></i>
            </span>
            <span class="font-bold">مؤشر التقييمات</span>
        </a>

        {{-- مؤشر التفاعلات --}}
        <a href="{{ route($rEngagement) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rEngagement) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-wave-square text-[12px]"></i>
            </span>
            <span class="font-bold">مؤشر التفاعلات</span>
        </a>

    </div>
</details>
@php


    // عدد القرارات الفعّالة
    $decisionsActiveCount = DB::table('high_command_decisions')
        ->where('status', 'active')
        ->count();

    $rDecisions = 'general.decisions.index';
    $onDecisions = request()->routeIs($rDecisions);
@endphp

<a href="{{ route($rDecisions) }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
          {{ $onDecisions ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    {{-- أيقونة --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-emerald-500/15 border border-emerald-400/25 text-emerald-200 shadow-sm">
        <i class="fa-solid fa-scroll text-[12px]"></i>
    </span>

    {{-- النص --}}
    <div class="flex flex-col min-w-0 flex-1">
        <span class="font-bold truncate">القرارات الإدارية</span>
        <span class="text-[10px] opacity-70 truncate">
            عرض جميع القرارات الفعّالة والتفاصيل الكاملة
        </span>
    </div>

    {{-- Badge العدّاد --}}
    @if($decisionsActiveCount > 0)
        <span class="inline-flex items-center justify-center px-2 py-0.5
                     rounded-full text-[10px] font-bold
                     bg-emerald-500/20 text-emerald-200
                     border border-emerald-400/40
                     shadow-[0_0_12px_rgba(16,185,129,0.35)]">
            {{ $decisionsActiveCount }}
        </span>
    @endif
</a>
{{-- إدارة الأهداف ProMission --}}
{{-- إدارة الأهداف ProMission --}}
@php
    $promissionOpen = request()->routeIs('superadmin.promission.*');

    $rPmIndex    = 'superadmin.promission.index';
    $rPmPersonal = 'superadmin.promission.personal.index';
    $rPmRadar    = 'superadmin.promission.radar.index';
    $rPmForecast = 'superadmin.promission.forecast.index';
    $rPmCoach    = 'superadmin.promission.coach.index';
    $rPmStuck    = 'superadmin.promission.stuck.index';

    $rPmInsightsIndex      = 'superadmin.promission.insights.index';
    $rPmInsightsCommitment = 'superadmin.promission.insights.commitment';
    $rPmInsightsStreaks    = 'superadmin.promission.insights.streaks';
    $rPmInsightsRoles      = 'superadmin.promission.insights.roles';
    $rPmInsightsMicrogoals = 'superadmin.promission.insights.microgoals';
    $rPmInsightsAlerts     = 'superadmin.promission.insights.alerts';
@endphp

<details class="relative group" @if($promissionOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $promissionOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-bullseye-arrow text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">إدارة الأهداف ProMission</span>
                <span class="text-[11px] opacity-70">لوحات + رادار + توقّع + Coach + Insights</span>
            </div>
        </div>
        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- لوحة أهداف الفريق --}}
        <a href="{{ route($rPmIndex) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmIndex) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-chart-line text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">لوحة أهداف الفريق</span>
                <span class="text-[10px] opacity-70 truncate">نظرة شاملة على تقدّم التيم وتحقيق الأهداف</span>
            </div>
        </a>

        {{-- الأهداف الفردية --}}
        <a href="{{ route($rPmPersonal) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.promission.personal.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">قائمة الأهداف الفردية</span>
                <span class="text-[10px] opacity-70 truncate">متابعة هدف كل عضو + حالته + ملاحظاته</span>
            </div>
        </a>

        {{-- رادار الهدف --}}
        <a href="{{ route($rPmRadar) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.promission.radar.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-radar text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">رادار الهدف</span>
                <span class="text-[10px] opacity-70 truncate">كشف العالق/المتأخر/المهدد قبل ما يفلت</span>
            </div>
        </a>

        {{-- توقّع نهاية الشهر --}}
        <a href="{{ route($rPmForecast) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.promission.forecast.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-arrow-trend-up text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">توقّع نهاية الشهر</span>
                <span class="text-[10px] opacity-70 truncate">هل بنلحق؟ توقعات + نسب + توصيات</span>
            </div>
        </a>

        {{-- الأوتو-كوتش --}}
        <a href="{{ route($rPmCoach) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.promission.coach.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-wand-magic-sparkles text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأوتو-كوتش</span>
                <span class="text-[10px] opacity-70 truncate">اقتراحات ذكية: شو تعمل اليوم/الأسبوع</span>
            </div>
        </a>

        {{-- الحالات العالقة --}}
        <a href="{{ route($rPmStuck) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs('superadmin.promission.stuck.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الحالات العالقة / المتأخرة</span>
                <span class="text-[10px] opacity-70 truncate">قائمة تحتاج تدخل إداري سريع</span>
            </div>
        </a>

        {{-- عنوان Insights --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            PRO MISSION • INSIGHTS
        </div>

        <a href="{{ route($rPmInsightsIndex) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsIndex) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-layer-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مركز الإضافات الذكية</span>
                <span class="text-[10px] opacity-70 truncate">لوحة التحليلات المتقدمة للأهداف</span>
            </div>
        </a>

        <a href="{{ route($rPmInsightsCommitment) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsCommitment) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-handshake text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مؤشر الالتزام</span>
                <span class="text-[10px] opacity-70 truncate">قياس جدّية العضو بالهدف</span>
            </div>
        </a>

        <a href="{{ route($rPmInsightsStreaks) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsStreaks) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-fire text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الاستمرارية</span>
                <span class="text-[10px] opacity-70 truncate">Streaks + انقطاعات + رجعة</span>
            </div>
        </a>

        <a href="{{ route($rPmInsightsRoles) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsRoles) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-user-tag text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تصنيف الأعضاء الذكي</span>
                <span class="text-[10px] opacity-70 truncate">Roles based on performance</span>
            </div>
        </a>

        <a href="{{ route($rPmInsightsMicrogoals) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsMicrogoals) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">أهداف صغيرة تلقائية</span>
                <span class="text-[10px] opacity-70 truncate">تقسيم الهدف لمهام قصيرة واضحة</span>
            </div>
        </a>

        <a href="{{ route($rPmInsightsAlerts) }}"
           class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl
                  {{ request()->routeIs($rPmInsightsAlerts) ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-bell text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التنبيهات الذكية</span>
                <span class="text-[10px] opacity-70 truncate">Alerts حسب حالة الهدف + توصيات</span>
            </div>
        </a>

    </div>
</details>
                
{{-- غرفة ProActive فعالية --}}
@php
    // عدد الإشعارات العامة غير المقروءة (كما هو)
    $generalUnread = \App\Http\Controllers\General\GeneralNotificationController::getUnreadNotificationsCount();

    $rGeneralIndex   = 'general-notifications.index';
    $generalOpen     = request()->routeIs('general-notifications.*');
    $isGeneralActive = request()->routeIs($rGeneralIndex);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($generalOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $generalOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-rose-500/15 text-rose-200 border border-rose-400/30 shadow-sm">
                <i class="fa-solid fa-bell text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الإشعارات العامة</span>
                <span class="text-[11px] opacity-70">تنبيهات النظام + الرسائل العامة</span>
            </div>

            @if($generalUnread > 0)
                <span class="ms-2 inline-flex items-center justify-center min-w-[22px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-400/30 text-[11px] font-bold">
                    {{ $generalUnread > 9 ? '9+' : $generalUnread }}
                </span>
            @endif
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- كل الإشعارات العامة --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rGeneralIndex) ? route($rGeneralIndex) : '#' }}"
           class="{{ $linkBase }} {{ $isGeneralActive ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-inbox text-[12px]"></i>
            </span>

            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">كل الإشعارات العامة</span>
                <span class="text-[10px] opacity-70 truncate">عرض القائمة + البحث + وضع كمقروء</span>
            </div>

            @if($generalUnread > 0)
                <span class="ms-auto inline-flex items-center justify-center min-w-[22px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-400/30 text-[11px] font-bold">
                    {{ $generalUnread > 9 ? '9+' : $generalUnread }}
                </span>
            @endif
        </a>

    </div>
</details>
                <!-- الرسائل الإدارية -->
@php
    $adminMsgsOpen = request()->routeIs([
        'superadmin.falcon-room.messages.*',
        'superadmin.falcon-room.admin-messages',
        'superadmin.leader-message.*',
        'superadmin.daily-reading.*',
        'superadmin.admin-messages.*',
    ]);

    $rMsgMembers    = 'superadmin.falcon-room.messages.members';
    $rMsgModerators = 'superadmin.falcon-room.messages.moderators';
    $rMsgLeader     = 'superadmin.falcon-room.messages.leader';
    $rMsgReaders    = 'superadmin.falcon-room.messages.readers';

    $rAllMsg        = 'superadmin.falcon-room.admin-messages';
    $rLeaderPage    = 'superadmin.leader-message.index';

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($adminMsgsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $adminMsgsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-amber-500/15 text-amber-200 border border-amber-400/30 shadow-sm">
                <i class="fa-solid fa-envelope-open-text text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">الرسائل الإدارية</span>
                <span class="text-[11px] opacity-70">أعضاء • مشرفين • القائد • القرّاء</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- رسائل إدارية للأعضاء --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMsgMembers) ? route($rMsgMembers) : '#' }}"
           class="{{ $linkBase }} {{ request()->routeIs($rMsgMembers) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-user-group text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">قسم رسائل الأعضاء</span>
                <span class="text-[10px] opacity-70 truncate">إرسال رسائل إدارية للأعضاء + أرشفة</span>
            </div>
            <span class="px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/20 text-amber-200 border border-amber-400/30">
                قريبًا
            </span>
        </a>

        {{-- اقرأني لليوم (للقائد فقط) --}}
        @can('manage-daily-reading')
            @php
                $rDailyReading  = 'superadmin.daily-reading.index';
                $onDailyReading = request()->routeIs('superadmin.daily-reading.*');
            @endphp

            <a href="{{ route($rDailyReading) }}"
               class="{{ $linkBase }} {{ $onDailyReading ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
                <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                             bg-rose-500/15 border border-rose-400/25 text-rose-200">
                    <i class="fa-solid fa-book-open-reader text-[12px]"></i>
                </span>
                <div class="flex flex-col min-w-0">
                    <span class="font-bold truncate">اقرأني لليوم</span>
                    <span class="text-[10px] opacity-70 truncate">القائد يكتب المقال اليومي للأعضاء</span>
                </div>
            </a>
        @endcan

        {{-- رسائل إدارية للمشرفين --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMsgModerators) ? route($rMsgModerators) : '#' }}"
           class="{{ $linkBase }} {{ request()->routeIs($rMsgModerators) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-user-shield text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">قسم رسائل المشرفين</span>
                <span class="text-[10px] opacity-70 truncate">تنبيهات الإدارة للمشرفين + تنظيم المهام</span>
            </div>
            <span class="px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/20 text-emerald-200 border border-emerald-400/30">
                فعال
            </span>
        </a>

        {{-- كتابة رسالة إدارية للجميع --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rAllMsg) ? route($rAllMsg) : '#' }}"
           class="{{ $linkBase }} {{ request()->routeIs($rAllMsg) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">رسالة إدارية للجميع</span>
                <span class="text-[10px] opacity-70 truncate">إرسال إعلان رسمي لكل الفريق دفعة واحدة</span>
            </div>
            <span class="px-2 py-0.5 rounded-full text-[10px] font-bold bg-cyan-500/20 text-cyan-200 border border-cyan-400/30">
                فعال
            </span>
        </a>

        {{-- رسائل القائد --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rLeaderPage) ? route($rLeaderPage) : '#' }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.leader-message.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-yellow-500/15 border border-yellow-400/25 text-yellow-200">
                <i class="fa-solid fa-bullhorn text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">رسائل القائد</span>
                <span class="text-[10px] opacity-70 truncate">إدارة رسائل القائد + نشر + أرشفة</span>
            </div>
        </a>

        {{-- من شاف رسايلنا؟ --}}
        <a href="{{ \Illuminate\Support\Facades\Route::has($rMsgReaders) ? route($rMsgReaders) : '#' }}"
           class="{{ $linkBase }} {{ request()->routeIs($rMsgReaders) ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-eye text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">من شاف رسايلنا؟</span>
                <span class="text-[10px] opacity-70 truncate">تتبع القرّاء: مين قرأ ومين تجاهل</span>
            </div>
            <span class="px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-500/20 text-amber-200 border border-amber-400/30">
                قريبًا
            </span>
        </a>

    </div>
</details>
<!-- غرفة الصقر (تصميم مثل الصورة) -->

{{-- تواصل ورسائل الأعضاء (رابط مستقل) — تحويل لسقراط --}}
@php
    $rMon = 'superadmin.monitor.index';
    $onMon = request()->routeIs($rMon);
@endphp

<a href="{{ route($rMon) }}"
   class="{{ $linkBase }} {{ $onMon ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                 bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
        <i class="fa-solid fa-eye text-[12px]"></i>
    </span>
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">المراقبة العامة</span>
        <span class="text-[10px] opacity-70 truncate">مراقبة التفاعل + النشاط + آخر التحركات</span>
    </div>
</a>
                <!-- الإدارة والطلبات -->

                <!-- الإشعارات -->
@php
    $notifOpen = request()->routeIs([
        'manual-notifications.*',
        'notifications.*',
        'superadmin.notifications.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($notifOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $notifOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-sky-500/15 text-sky-200 border border-sky-400/30 shadow-sm">
                <i class="fa-solid fa-bell-on text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">إدارة الإشعارات</span>
                <span class="text-[11px] opacity-70">يدوي • إشعاراتي • عدّاد غير مقروء</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- الإشعارات اليدوية --}}
        <a href="{{ route('manual-notifications.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('manual-notifications.*') || request()->routeIs('superadmin.notifications.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-pen-to-square text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">الإشعارات اليدوية</span>
                <span class="text-[10px] opacity-70 truncate">إنشاء/إرسال/أرشفة إشعارات للإدارة</span>
            </div>
        </a>

        {{-- الإشعارات المرسلة إلي + Badge --}}
        <a href="{{ route('notifications.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('notifications.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }} relative">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-inbox text-[12px]"></i>
            </span>

            <div class="flex flex-col min-w-0 flex-1">
                <span class="font-bold truncate">الإشعارات المرسلة إلي</span>
                <span class="text-[10px] opacity-70 truncate">عرض إشعاراتك + وضع كمقروء</span>
            </div>

            {{-- نفس بادجك الحالي بدون تغيير IDs --}}
            <span id="sidebar-notification-badge"
                  class="ms-auto hidden h-5 min-w-[20px] px-1.5 rounded-full
                         bg-rose-500 text-white text-[11px] font-bold
                         ring-1 ring-white/30 shadow-sm animate-pulse">
                <span id="sidebar-notification-count">0</span>
            </span>
        </a>

    </div>
</details>

                <!-- المسابقات -->
@php
    $competitionsOpen = request()->routeIs([
        'superadmin.competitions.*',
        'general.competitions.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($competitionsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $competitionsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-amber-500/15 text-amber-200 border border-amber-400/30 shadow-sm">
                <i class="fa-solid fa-trophy text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">المسابقات</span>
                <span class="text-[11px] opacity-70">إدارة • مشاركات • نتائج</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- إدارة المسابقات --}}
        <a href="{{ route('superadmin.competitions.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.competitions.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-screwdriver-wrench text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة المسابقات</span>
                <span class="text-[10px] opacity-70 truncate">إنشاء • تعديل • متابعة المشاركين</span>
            </div>
        </a>

        {{-- مسابقاتي --}}
        <a href="{{ route('general.competitions.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('general.competitions.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-medal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مسابقاتي</span>
                <span class="text-[10px] opacity-70 truncate">المشاركة • النتائج • حالة التقييم</span>
            </div>
        </a>

    </div>
</details>
{{-- محرر الأعضاء — Excel Editor --}}
{{-- محرر الأعضاء + محرر PDF --}}
@php
    $editorsOpen = request()->routeIs([
        'superadmin.members-sheet.*',
        'superadmin.text-editor.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($editorsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $editorsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-slate-500/15 text-slate-200 border border-slate-400/30 shadow-sm">
                <i class="fa-solid fa-pen-ruler text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">محررات الإدارة</span>
                <span class="text-[11px] opacity-70">Excel للأعضاء • محرر نصوص PDF</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- محرر الأعضاء — Excel --}}
        <a href="{{ route('superadmin.members-sheet.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.members-sheet.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-table-cells-large text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">محرر الأعضاء — Excel</span>
                <span class="text-[10px] opacity-70 truncate">تعديل بيانات جماعي • استيراد/تصدير</span>
            </div>
        </a>

        {{-- محرر نصوص — PDF --}}
        <a href="{{ route('superadmin.text-editor.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.text-editor.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-file-pdf text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">محرر نصوص — PDF</span>
                <span class="text-[10px] opacity-70 truncate">تحويل نص إلى PDF • قوالب جاهزة</span>
            </div>
        </a>

    </div>
</details>
{{-- إدارة الاختبارات (مقفلة بباسورد) --}}
@php
    $testsOpen = request()->routeIs([
        'tests.weekly.*',
        'tests.manage.*',
        'tests.questions.*',
        'tests.answers.*',
        'tests.results.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details id="tests-details" class="relative group" @if($testsOpen) open @endif>
    <summary onclick="toggleTestsDropdown(event)"
             class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $testsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-clipboard-question text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">إدارة الاختبارات</span>
                <span class="text-[11px] opacity-70">أسبوعي • أسئلة • إجابات • نتائج • إحصائيات</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        <a href="{{ route('tests.weekly.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.weekly.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-calendar-week text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الاختبارات الأسبوعية</span>
                <span class="text-[10px] opacity-70">عرض الاختبارات + التحكم بالحالة</span>
            </div>
        </a>

        <a href="{{ route('tests.manage.create') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.manage.create') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-square-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">إضافة اختبار جديد</span>
                <span class="text-[10px] opacity-70">إنشاء اختبار وتحديد المدة والجمهور</span>
            </div>
        </a>

        <a href="{{ route('tests.questions.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.questions.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-violet-500/15 border border-violet-400/25 text-violet-200">
                <i class="fa-solid fa-circle-question text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">إدارة الأسئلة</span>
                <span class="text-[10px] opacity-70">إضافة/تعديل/ترتيب الأسئلة</span>
            </div>
        </a>

        <a href="{{ route('tests.answers.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.answers.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-list-check text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">إجابات الأسئلة</span>
                <span class="text-[10px] opacity-70">تحديد الصح/الغلط وترتيب الخيارات</span>
            </div>
        </a>

        <a href="{{ route('tests.results.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.results.*') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-chart-column text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">نتائج الأعضاء</span>
                <span class="text-[10px] opacity-70">نتائج + ترتيب + تفاصيل المحاولات</span>
            </div>
        </a>

        <a href="{{ route('tests.manage.stats') }}"
           class="{{ $linkBase }} {{ request()->routeIs('tests.manage.stats') ? 'bg-white/15 text-white' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-chart-simple text-[12px]"></i>
            </span>
            <div class="flex flex-col">
                <span class="font-bold">الإحصائيات</span>
                <span class="text-[10px] opacity-70">متوسطات + أعلى/أقل + مشاركة</span>
            </div>
        </a>

    </div>
</details>
<script>
let testsSectionUnlocked = false;

document.addEventListener('DOMContentLoaded', function () {
  if (localStorage.getItem('testsSectionUnlocked') === '1') {
    testsSectionUnlocked = true;
  }
});

function toggleTestsDropdown(e){
  // عشان ما يفتح <details> تلقائيًا قبل الباسورد
  if (e) e.preventDefault();

  const details = document.getElementById('tests-details');
  if (!details) return;

  if (!testsSectionUnlocked) {
    const password = prompt('الرجاء إدخال كلمة المرور الخاصة بلوحة إدارة الاختبارات:');
    if (password !== '122334') {
      alert('كلمة المرور غير صحيحة ✅، حاول مرة أخرى.');
      return;
    }
    testsSectionUnlocked = true;
    localStorage.setItem('testsSectionUnlocked', '1');
  }

  // فتح/إغلاق بنفس ستايل سقراط (details)
  details.open = !details.open;
}
</script>

                <!-- السجلات والتقارير -->
@php
    $scoresOpen = request()->routeIs('score-records.*');
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($scoresOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $scoresOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-indigo-500/15 text-indigo-200 border border-indigo-400/30 shadow-sm">
                <i class="fa-solid fa-chart-column text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">السجلات والتقارير</span>
                <span class="text-[11px] opacity-70">سجلات • تقارير إيجابية/سلبية • تحليل شامل</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- السجلات --}}
        <a href="{{ route('score-records.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-clipboard-list text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">السجلات</span>
                <span class="text-[10px] opacity-70 truncate">كل العمليات والنقاط والتغييرات</span>
            </div>
        </a>

        {{-- إيجابي --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            التقارير الإيجابية
        </div>

        <a href="{{ route('score-records.reports.weekly-top') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.weekly-top') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-ranking-star text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعلى أسبوعياً</span>
                <span class="text-[10px] opacity-70 truncate">أفضل أعضاء الأسبوع بالنقاط</span>
            </div>
        </a>

        <a href="{{ route('score-records.reports.monthly-top') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.monthly-top') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-calendar-days text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعلى شهرياً</span>
                <span class="text-[10px] opacity-70 truncate">أفضل أعضاء الشهر بالنقاط</span>
            </div>
        </a>

        <a href="{{ route('score-records.reports.overall-best') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.overall-best') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-trophy text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأفضل على الإطلاق</span>
                <span class="text-[10px] opacity-70 truncate">أفضل النتائج عبر كل الفترات</span>
            </div>
        </a>

        {{-- سلبي --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            التقارير السلبية
        </div>

        <a href="{{ route('score-records.reports.most-violations') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.most-violations') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعلى في المخالفات</span>
                <span class="text-[10px] opacity-70 truncate">أكثر أعضاء سجلّ عليهم مخالفات</span>
            </div>
        </a>

        <a href="{{ route('score-records.reports.most-absences') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.most-absences') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-calendar-xmark text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأعلى في الغياب</span>
                <span class="text-[10px] opacity-70 truncate">غيابات أكثر + مقارنة زمنية</span>
            </div>
        </a>

        <a href="{{ route('score-records.reports.lowest-scores') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.lowest-scores') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-slate-500/15 border border-slate-400/25 text-slate-200">
                <i class="fa-solid fa-arrow-trend-down text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الأقل في النقاط</span>
                <span class="text-[10px] opacity-70 truncate">أضعف النتائج بالنقاط</span>
            </div>
        </a>

        {{-- أخرى --}}
        <div class="px-3 pt-3 pb-1 text-[11px] font-semibold text-white/55">
            تقارير أخرى
        </div>

        <a href="{{ route('score-records.reports.gender-comparison') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.gender-comparison') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-venus-mars text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">مقارنة الذكور والإناث</span>
                <span class="text-[10px] opacity-70 truncate">فروقات الأداء بالنقاط والغياب</span>
            </div>
        </a>

        <a href="{{ route('score-records.reports.comprehensive') }}"
           class="{{ $linkBase }} {{ request()->routeIs('score-records.reports.comprehensive') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-file-lines text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التقرير الشامل</span>
                <span class="text-[10px] opacity-70 truncate">ملخص كامل للأداء + مؤشرات عامة</span>
            </div>
        </a>

    </div>
</details>
                <!-- الأنشطة -->

                <!-- بيانات الضيوف -->
@php
    $guestsOpen = request()->routeIs('guest-submissions.*');
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($guestsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $guestsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-pink-500/15 text-pink-200 border border-pink-400/30 shadow-sm">
                <i class="fa-solid fa-users-rectangle text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">بيانات القيستات</span>
                <span class="text-[11px] opacity-70">رفع • متابعة • مراجعة (للإدارة/المود)</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- رفع بيانات قيست --}}
        <a href="{{ route('guest-submissions.create') }}"
           class="{{ $linkBase }} {{ request()->routeIs('guest-submissions.create') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-square-plus text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">رفع بيانات قيست</span>
                <span class="text-[10px] opacity-70 truncate">إضافة إثباتات + بيانات المشاركة</span>
            </div>
        </a>

        {{-- بياناتي المرفوعة --}}
        <a href="{{ route('guest-submissions.my-submissions') }}"
           class="{{ $linkBase }} {{ request()->routeIs('guest-submissions.my-submissions') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-cyan-500/15 border border-cyan-400/25 text-cyan-200">
                <i class="fa-solid fa-folder-open text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">بياناتي المرفوعة</span>
                <span class="text-[10px] opacity-70 truncate">عرض الحالة + الملاحظات + الرفض/القبول</span>
            </div>
        </a>

        {{-- مراجعة بيانات قيستات (سوبر أدمن/مود) --}}
        @if(auth()->user()->hasRole(['super-admin', 'moderator']))
            <a href="{{ route('guest-submissions.review.index') }}"
               class="{{ $linkBase }} {{ request()->routeIs('guest-submissions.review.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
                <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                             bg-rose-500/15 border border-rose-400/25 text-rose-200">
                    <i class="fa-solid fa-clipboard-check text-[12px]"></i>
                </span>
                <div class="flex flex-col min-w-0">
                    <span class="font-bold truncate">مراجعة بيانات قيستات</span>
                    <span class="text-[10px] opacity-70 truncate">تدقيق واعتماد المشاركات + قرارات</span>
                </div>
            </a>
        @endif

    </div>
</details>
                <!-- المنشورات -->
@php
    $postsOpen = request()->routeIs('posts.*');
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($postsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $postsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">
        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-fuchsia-500/15 text-fuchsia-200 border border-fuchsia-400/30 shadow-sm">
                <i class="fa-solid fa-newspaper text-sm"></i>
            </span>
            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">المنشورات </span>
                <span class="text-[11px] opacity-70">عرض • إدارة • صلاحيات • بلاغات</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- عرض المنشورات --}}
        <a href="{{ route('posts.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('posts.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-eye text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">عرض المنشورات</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة منشورات النظام والتفاعل</span>
            </div>
        </a>

        {{-- إدارة المنشورات --}}
        <a href="{{ route('posts.management.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('posts.management.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-screwdriver-wrench text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة المنشورات</span>
                <span class="text-[10px] opacity-70 truncate">إعدادات • تثبيت • حذف • تحكم كامل</span>
            </div>
        </a>

        {{-- صلاحيات النشر --}}
        <a href="{{ route('posts.management.permissions') }}"
           class="{{ $linkBase }} {{ request()->routeIs('posts.management.permissions') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-shield-halved text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">صلاحيات النشر</span>
                <span class="text-[10px] opacity-70 truncate">من يقدر ينشر؟ ومن يراجع؟</span>
            </div>
        </a>

        {{-- البلاغات --}}
        <a href="{{ route('posts.management.reports') }}"
           class="{{ $linkBase }} {{ request()->routeIs('posts.management.reports') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-rose-500/15 border border-rose-400/25 text-rose-200">
                <i class="fa-solid fa-triangle-exclamation text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">البلاغات</span>
                <span class="text-[10px] opacity-70 truncate">مراجعة بلاغات المنشورات واتخاذ إجراء</span>
            </div>
        </a>

    </div>
</details>

                <!-- الدردشة -->
@php
    $chatOpen = request()->routeIs('chat.*');
    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';
@endphp

<details class="relative group" @if($chatOpen) open @endif>

    {{-- الهيدر --}}
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $chatOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">

        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-cyan-500/15 text-cyan-200 border border-cyan-400/30 shadow-sm">
                <i class="fa-solid fa-comments text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">نظام الدردشة</span>
                <span class="text-[11px] opacity-70">محادثات • صلاحيات • إدارة</span>
            </div>
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200
                  group-open:rotate-180"></i>
    </summary>

    {{-- القائمة --}}
    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- الدردشات --}}
        <a href="{{ route('chat.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('chat.index') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-sky-500/15 border border-sky-400/25 text-sky-200">
                <i class="fa-solid fa-message text-[12px]"></i>
            </span>

            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">الدردشات</span>
                <span class="text-[10px] opacity-70 truncate">
                    عرض كل المحادثات الجارية داخل النظام
                </span>
            </div>
        </a>

        {{-- إدارة الصلاحيات --}}
        <a href="{{ route('chat.management.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('chat.management.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-user-shield text-[12px]"></i>
            </span>

            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة الصلاحيات</span>
                <span class="text-[10px] opacity-70 truncate">
                    تحديد من يكتب، من يقرأ، ومن يُدار
                </span>
            </div>
        </a>

    </div>
</details>
                <!-- التكريمات والمكافآت -->
@php
    $rewardsOpen = request()->routeIs([
        'my-honors-rewards.*',
        'superadmin.honors-rewards.*',
        'superadmin.evaluations.*',
        'received-tips.*',
    ]);

    $linkBase = $linkBase ?? 'nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition';

    // عدد النصائح غير المقروءة (نفس منطقك)
    $unreadTipsCount = 0;
    try {
        $unreadTipsCount = \App\Models\AdvisorTip::where('recipient_id', auth()->id())
            ->where('is_read', false)
            ->count();
    } catch (\Throwable $e) {
        $unreadTipsCount = 0;
    }
@endphp

<details class="relative group" @if($rewardsOpen) open @endif>
    <summary class="nav-link w-full flex items-center justify-between px-4 py-3 text-sm font-medium rounded-xl
                    text-white/80 hover:text-white hover:bg-white/10 cursor-pointer list-none
                    {{ $rewardsOpen ? 'bg-white/15 text-white shadow-sm' : '' }}">

        <div class="flex items-center gap-3">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                         bg-amber-500/15 text-amber-200 border border-amber-400/30 shadow-sm">
                <i class="fa-solid fa-trophy-star text-sm"></i>
            </span>

            <div class="flex flex-col">
                <span class="text-[13px] font-semibold">التكريمات والتقييمات</span>
                <span class="text-[11px] opacity-70">تكريمات • مكافآت • تقييمات • نصائح</span>
            </div>

            @if($unreadTipsCount > 0)
                <span class="ms-1 inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500/20 text-rose-200 border border-rose-500/30 text-[11px] font-bold">
                    {{ $unreadTipsCount > 99 ? '99+' : $unreadTipsCount }}
                </span>
            @endif
        </div>

        <i class="fa-solid fa-chevron-down text-[12px] opacity-70 transition-transform duration-200 group-open:rotate-180"></i>
    </summary>

    <div class="mt-2 space-y-1 px-2 pb-2">

        {{-- تكريماتي ومكافآتي --}}
        <a href="{{ route('my-honors-rewards.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('my-honors-rewards.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-amber-500/15 border border-amber-400/25 text-amber-200">
                <i class="fa-solid fa-medal text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">تكريماتي ومكافآتي</span>
                <span class="text-[10px] opacity-70 truncate">عرض تكريماتك ونقاط المكافآت</span>
            </div>
        </a>

        {{-- إدارة المكافآت والتكريمات --}}
        <a href="{{ route('superadmin.honors-rewards.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.honors-rewards.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-indigo-500/15 border border-indigo-400/25 text-indigo-200">
                <i class="fa-solid fa-screwdriver-wrench text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">إدارة المكافآت والتكريمات</span>
                <span class="text-[10px] opacity-70 truncate">إضافة/تعديل مكافآت وتكريمات للأعضاء</span>
            </div>
        </a>

        {{-- التقييمات --}}
        <a href="{{ route('superadmin.evaluations.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('superadmin.evaluations.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-fuchsia-500/15 border border-fuchsia-400/25 text-fuchsia-200">
                <i class="fa-solid fa-clipboard-check text-[12px]"></i>
            </span>
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">التقييمات</span>
                <span class="text-[10px] opacity-70 truncate">إدارة التقييمات وربط النقاط بالحضور</span>
            </div>
        </a>

        {{-- النصائح المقدمة لي --}}
        <a href="{{ route('received-tips.index') }}"
           class="{{ $linkBase }} {{ request()->routeIs('received-tips.*') ? 'bg-white/15 text-white shadow-sm' : 'text-white/70 hover:text-white hover:bg-white/10' }}">
            <span class="inline-flex items-center justify-center w-8 h-8 rounded-xl
                         bg-emerald-500/15 border border-emerald-400/25 text-emerald-200">
                <i class="fa-solid fa-lightbulb text-[12px]"></i>
            </span>
 
            <div class="flex flex-col min-w-0">
                <span class="font-bold truncate">النصائح المقدّمة لي</span>
                <span class="text-[10px] opacity-70 truncate">نصائح المستشارين + حالة القراءة</span>
            </div>

            @if($unreadTipsCount > 0)
                <span class="ms-auto inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 rounded-full
                             bg-rose-500 text-white text-[11px] font-bold animate-pulse-scale">
                    {{ $unreadTipsCount > 9 ? '9+' : $unreadTipsCount }}
                </span>
            @endif
        </a>

    </div>
</details>
                <!-- إعدادات النظام -->
<a href="{{ route('superadmin.settings.index') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition
          {{ request()->routeIs('superadmin.settings.*')
                ? 'bg-white/15 text-white shadow-sm'
                : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    {{-- أيقونة بأسلوب سقراط --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-indigo-500/15 text-indigo-200
                 border border-indigo-400/25 shadow-sm">
        <i class="fa-solid fa-gear text-[12px]"></i>
    </span>

    {{-- العنوان + الشرح --}}
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">إعدادات النظام</span>
        <span class="text-[10px] opacity-70 truncate">
            التحكم العام • الخصائص • الإعدادات الحساسة للنظام
        </span>
    </div>
</a>

                <!-- فاصل -->
{{-- ===== دعوات (ستايل سقراط) ===== --}}
<div class="border-t border-white/10 my-2"></div>

{{-- دعوة الأصدقاء لـ SoftDomi --}}
<a href="{{ route('softdomi.invite') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition
          text-white/70 hover:text-white hover:bg-white/10">

    {{-- أيقونة كبسولة --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-sky-500/15 border border-sky-400/25 shadow-sm">
        <img src="https://www.softdomi.com/logo.png"
             alt="SoftDomi"
             class="w-4 h-4 object-contain">
    </span>

    {{-- النص --}}
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">دعوة الأصدقاء لـ SoftDomi</span>
        <span class="text-[10px] opacity-70 truncate">
            مشاركة رابط SoftDomi وجلب مستخدمين جدد
        </span>
    </div>

    {{-- إشارة --}}
    <span class="ml-auto text-sky-300 text-xs">
        <i class="fa-solid fa-arrow-up-right-from-square"></i>
    </span>
</a>

{{-- دعوة الأصدقاء للتيم --}}
<a href="{{ route('team.invite') }}"
   class="nav-link flex items-center gap-3 px-3 py-2 text-[13px] rounded-xl transition
          {{ request()->routeIs('team.invite')
                ? 'bg-white/15 text-white shadow-sm'
                : 'text-white/70 hover:text-white hover:bg-white/10' }}">

    {{-- أيقونة كبسولة --}}
    <span class="inline-flex items-center justify-center w-8 h-8 rounded-2xl
                 bg-violet-500/15 border border-violet-400/25 shadow-sm">
        <i class="fa-solid fa-user-plus text-[12px] text-violet-200"></i>
    </span>

    {{-- النص --}}
    <div class="flex flex-col min-w-0">
        <span class="font-bold truncate">دعوة الأصدقاء</span>
        <span class="text-[10px] opacity-70 truncate">
            إضافة أعضاء جدد إلى التيم
        </span>
    </div>

    {{-- حالة --}}
    <span class="ml-auto px-2 py-0.5 rounded-full text-[10px]
                 bg-violet-500/15 text-violet-200">
        قريبًا
    </span>
</a>

            </div>

            <!-- User Profile Section (Bottom of Sidebar) -->
<div class="absolute bottom-0 right-0 left-0 p-4 bg-gradient-to-t from-primary-900/95 to-transparent backdrop-blur-md border-t border-white/10"
     style="padding-bottom: max(1rem, env(safe-area-inset-bottom));">
                <div class="flex items-center gap-3 p-3 bg-white/10 rounded-xl hover:bg-white/15 transition-all">
                    <img class="w-10 h-10 rounded-lg shadow-md ring-2 ring-white/30 object-cover" 
                         src="{{ auth()->user()->avatar ?? asset('images/default-avatar.png') }}" 
                         alt="{{ auth()->user()->name }}">
                    <div class="flex-1 min-w-0">
                        <p class="text-sm font-semibold text-white truncate">{{ auth()->user()->name }}</p>
                        <p class="text-xs text-white/70 truncate">الإدارة العليا</p>
                    </div>
                    <form method="POST" action="{{ route('logout') }}" class="inline">
                        @csrf
                        <button type="submit" class="p-2 text-white/70 hover:text-white rounded-lg hover:bg-white/10 transition-all">
                            <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/>
                            </svg>
                        </button>
                    </form>
                </div>
            </div>
        </nav>
    </div>


{{-- Messenger Chat Widget --}}
{{-- Messenger Chat Widget --}}

@auth
    @include('partials.daily-reading-footer')
@endauth

{{-- Messenger Chat Widget --}}

@auth
    @include('partials.private')
@endauth

<style>
/* ================================
   FIX: Sticky Topbar Not Sticking
   ================================ */

/* 1) خلي السكروول للصفحة نفسها (مش داخل حاويات) */
html, body{
  height: 100%;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* 2) أي Wrapper فوق الهيدر لا يقطع sticky */
body *{
  /* مهم: لا تفعّل هذا لو عندك عناصر لازم تكون overflow-hidden فعلاً (زي مودال/سلايدر)
     بس كحل سريع: بيكشف المشكلة ويصلحها */
}

/* الأفضل: استهدف الحاوية اللي عندك مباشرة */
.lg\\:mr-72,
.xl\\:mr-80{
  overflow: visible !important;
}

/* لو عندك Layout wrapper مشهور مثل app/root/main */
#app, .app, .layout, .page, .main-wrapper, .content-wrapper{
  overflow: visible !important;
  transform: none !important;      /* transform على الأب ممكن يكسر sticky */
  filter: none !important;
  will-change: auto !important;
}
#sidebar {
    position: fixed; /* أو absolute لو تفضل */
    top: 0;
    left: 0;
    z-index: 10000; /* أعلى من الهيدر اللي عنده z-index: 9999 */
}

/* 3) التوب بار نفسه */
.topbar-sticky,
header.sticky-topbar,
header[role="banner"]{
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
}

/* إذا ما بدك تغيّر كلاس، استهدف الهيدر مباشرة */
header{
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
}


</style>

    <!-- Main Content -->
    <div class="lg:mr-72 xl:mr-80">

<!-- Top Bar -->
<header
  class="sticky top-0 z-[999] border-b border-white/20 dark:border-white/10
         bg-gradient-to-b from-white/85 via-white/70 to-white/60
         dark:from-slate-950/90 dark:via-slate-900/85 dark:to-black/80
         backdrop-blur-xl shadow-[0_18px_55px_rgba(2,6,23,0.18)] dark:shadow-[0_18px_55px_rgba(0,0,0,0.55)]">

    {{-- خلفيات ملحمية (Visual فقط) --}}
    <div class="pointer-events-none absolute inset-0 opacity-60 dark:opacity-100">
        <div class="absolute -top-24 -right-20 h-72 w-72 rounded-full blur-3xl bg-cyan-400/20 dark:bg-cyan-500/12"></div>
        <div class="absolute -bottom-28 -left-20 h-80 w-80 rounded-full blur-3xl bg-fuchsia-400/15 dark:bg-fuchsia-500/10"></div>
        <div class="absolute inset-0 opacity-30 dark:opacity-20"
             style="background-image:
                 radial-gradient(40vmax 40vmax at 110% -10%, rgba(56,189,248,.25) 0, transparent 60%),
                 radial-gradient(35vmax 35vmax at -10% 120%, rgba(16,185,129,.20) 0, transparent 60%);">
        </div>
    </div>

    @php
        use App\Helpers\TestHelper;

        $siteLogo = \App\Models\SystemSetting::get('site_logo');
        $siteName = \App\Models\SystemSetting::get('site_name', 'لوحة التحكم المتقدمة');

        $unreadTipsCount = 0;
        $unreadManualNotificationsCount = 0;

        try {
            if (Schema::hasTable('advisor_tips')
                && Schema::hasColumn('advisor_tips', 'recipient_id')
                && Schema::hasColumn('advisor_tips', 'is_read')) {
                $unreadTipsCount = \App\Models\AdvisorTip::where('recipient_id', auth()->id())
                    ->where('is_read', false)
                    ->count();
            }
        } catch (Exception $e) {}

        try {
            if (Schema::hasTable('manual_notifications')
                && Schema::hasColumn('manual_notifications', 'is_read')) {
                $unreadManualNotificationsCount = \App\Models\ManualNotification::where('is_read', false)->count();
            }
        } catch (Exception $e) {}

        $recentNotifications       = \App\Http\Controllers\General\GeneralNotificationController::getRecentNotifications();
        $unreadNotificationsCount  = \App\Http\Controllers\General\GeneralNotificationController::getUnreadNotificationsCount();
        $testsCount                = TestHelper::countAvailableTests();
    @endphp

    <div class="relative px-3 sm:px-5 lg:px-8 py-2.5 sm:py-3.5">
        <div class="flex items-center justify-between gap-3 lg:gap-6">

            {{-- اليسار: زر القائمة + الشعار + عنوان الصفحة --}}
<div class="flex items-center gap-2.5 sm:gap-4 min-w-0 flex-1 relative isolate">

    {{-- Enterprise backplate (أكثر رسمية) --}}
    <div class="pointer-events-none absolute -inset-y-3 -inset-x-2 rounded-3xl
                bg-gradient-to-b from-white/70 via-white/55 to-white/35
                dark:from-white/7 dark:via-white/5 dark:to-white/0
                border border-slate-200/70 dark:border-white/10
                shadow-[0_18px_70px_rgba(2,6,23,0.10)]
                dark:shadow-[0_22px_90px_rgba(0,0,0,0.50)]
                backdrop-blur-2xl"></div>

    {{-- Hairline shine (Enterprise) --}}
    <div class="pointer-events-none absolute -inset-y-3 -inset-x-2 rounded-3xl opacity-70
                [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
         style="background:linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);"></div>

    {{-- Aura خلفية خفيفة (زيادة فقط) --}}
    <div class="pointer-events-none absolute -top-10 -left-10 w-40 h-40 rounded-full bg-indigo-500/8 blur-3xl"></div>
    <div class="pointer-events-none absolute -bottom-10 -right-10 w-40 h-40 rounded-full bg-fuchsia-500/8 blur-3xl"></div>

    {{-- زر القائمة للموبايل --}}
    <button id="sidebar-toggle"
            class="relative lg:hidden p-2 rounded-2xl flex-shrink-0
                   text-slate-700 hover:text-slate-950
                   dark:text-slate-200 dark:hover:text-white
                   bg-white/75 hover:bg-white/90
                   dark:bg-white/6 dark:hover:bg-white/10
                   border border-slate-200/80 dark:border-white/10
                   shadow-[0_10px_35px_rgba(2,6,23,0.10)]
                   transition-all
                   ring-1 ring-black/5 dark:ring-white/10
                   hover:shadow-[0_16px_55px_rgba(2,6,23,0.14)]
                   focus:outline-none focus:ring-2 focus:ring-indigo-300/60 dark:focus:ring-indigo-400/30"
            aria-label="فتح القائمة">
        <svg class="w-5 h-5 sm:w-6 sm:h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                  d="M4 6h16M4 12h16M4 18h16"/>
        </svg>
    </button>

    {{-- الشعار --}}
    @if($siteLogo)
        <div class="relative flex-shrink-0">
            <div class="relative p-[1.5px] rounded-2xl
                        bg-gradient-to-br from-slate-200 via-slate-100 to-slate-200
                        dark:from-white/10 dark:via-white/5 dark:to-white/10
                        shadow-[0_18px_70px_rgba(2,6,23,0.12)]
                        dark:shadow-[0_22px_90px_rgba(0,0,0,0.55)]
                        ring-1 ring-black/5 dark:ring-white/10">

                {{-- Shine border (هاد اللي بيعطي Enterprise فعليًا) --}}
                <div class="pointer-events-none absolute inset-0 rounded-2xl opacity-70
                            [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
                     style="background:linear-gradient(90deg, transparent, rgba(255,255,255,.30), transparent);"></div>

                <div class="bg-white/92 dark:bg-slate-950/50 rounded-2xl p-1
                            border border-white/70 dark:border-white/10
                            backdrop-blur-2xl
                            shadow-[inset_0_1px_0_rgba(255,255,255,0.55)]
                            dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]">
                    <img src="{{ asset('storage/' . $siteLogo) }}"
                         alt="{{ $siteName }}"
                         class="h-8 w-8 sm:h-10 sm:w-10 lg:h-11 lg:w-11 rounded-xl object-cover
                                ring-1 ring-black/5 dark:ring-white/10">
                </div>
            </div>
        </div>
    @endif

    {{-- عنوان الصفحة + وصف صغير --}}
    <div class="relative min-w-0 flex-1">
        <div class="flex items-center gap-2 mb-0.5 min-w-0">
            <h1 class="text-sm sm:text-lg lg:text-xl font-extrabold
                       text-slate-950 dark:text-white truncate
                       tracking-tight">
                @yield('page-title', 'لوحة السوبر أدمن')
            </h1>

            <span
                class="hidden sm:inline-flex items-center gap-2 px-2.5 py-0.5 rounded-full
                       text-[10px] font-extrabold
                       bg-white/80 text-slate-900 border border-slate-200/80
                       dark:bg-white/6 dark:text-white/85 dark:border-white/10
                       shadow-[0_12px_40px_rgba(2,6,23,0.10)]
                       dark:shadow-[0_16px_55px_rgba(0,0,0,0.45)]
                       ring-1 ring-black/5 dark:ring-white/10
                       backdrop-blur-2xl">

                <span class="relative w-1.5 h-1.5 rounded-full bg-emerald-400">
                    <span class="absolute inset-0 rounded-full bg-emerald-400/35 blur-[2px]"></span>
                </span>

                نظام {{ $siteName }}
            </span>
        </div>

        <p class="text-[10px] sm:text-xs lg:text-sm text-slate-600 dark:text-white/55 truncate">
            مرحباً بك في نظام {{ $siteName }} — مساحة إدارة متقدمة لمتابعة كل تفاصيل الفريق.
        </p>
    </div>
</div>


            {{-- اليمين: شريط الأيقونات --}}
            <div class="flex items-center gap-2 sm:gap-3 flex-shrink-0">
                
                {{-- الوقت الحالي (أقصى اليسار) --}}
                <div
                    class="hidden md:flex items-center gap-2 px-3 py-2
                           rounded-full border border-slate-200/70 dark:border-white/10
                           bg-white/70 dark:bg-black/35
                           shadow-sm">
                    <svg class="w-4 h-4 sm:w-5 sm:h-5 text-sky-600 dark:text-sky-300 flex-shrink-0"
                         fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                              d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                    <span id="current-time"
                          class="text-[10px] sm:text-xs lg:text-sm font-bold
                                 text-slate-800 dark:text-white/85 whitespace-nowrap"></span>
                </div>

                {{-- شريط الأيقونات --}}

<div class="relative mx-auto w-fit
            p-[1.5px] rounded-full
            bg-gradient-to-r from-slate-900/10 via-indigo-500/25 to-fuchsia-500/25
            dark:from-white/10 dark:via-indigo-400/20 dark:to-fuchsia-400/20
            shadow-[0_14px_55px_rgba(2,6,23,0.14)]
            dark:shadow-[0_18px_65px_rgba(0,0,0,0.60)]
            ring-1 ring-slate-900/5 dark:ring-white/10
            isolate">

  {{-- Aura (extra) --}}
  <div class="pointer-events-none absolute -top-10 -left-10 h-28 w-28 rounded-full bg-indigo-500/10 blur-3xl"></div>
  <div class="pointer-events-none absolute -bottom-10 -right-10 h-28 w-28 rounded-full bg-fuchsia-500/10 blur-3xl"></div>

  <div class="relative flex items-center gap-1.5 sm:gap-2 px-3 py-2 rounded-full
              bg-white/90 dark:bg-slate-950/45
              border border-white/70 dark:border-white/10
              backdrop-blur-2xl
              shadow-[inset_0_1px_0_rgba(255,255,255,0.65)]
              dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.10)]
              ring-1 ring-slate-900/5 dark:ring-white/10">

      {{-- Hairline highlight (Enterprise) --}}
      <div class="pointer-events-none absolute inset-0 rounded-full opacity-60
                  [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
           style="background:linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);"></div>

      {{-- Subtle inner divider --}}
      <div class="pointer-events-none absolute inset-y-1 left-0 right-0 opacity-35
                  [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
           style="background:linear-gradient(90deg, transparent, rgba(15,23,42,.20), transparent);"></div>

      {{-- Micro separators (extra) --}}
      <div class="pointer-events-none absolute inset-y-2 left-3 right-3 opacity-20
                  [mask-image:linear-gradient(to_right,transparent,black,transparent)]"
           style="background:linear-gradient(90deg, transparent, rgba(2,6,23,.25), transparent);"></div>

<div class="relative">
  <button id="glaPulseBtn_91b7"
          onclick="GLA_PULSE_91b7_toggle(event)"
          class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                 rounded-full
                 text-emerald-700 hover:text-emerald-950
                 dark:text-emerald-200 dark:hover:text-emerald-100
                 hover:bg-emerald-50/70 dark:hover:bg-emerald-500/10
                 transition-all
                 ring-1 ring-transparent hover:ring-emerald-200/60 dark:hover:ring-emerald-400/15
                 focus:outline-none focus:ring-2 focus:ring-emerald-300/60 dark:focus:ring-emerald-400/30"
          aria-label="نبض النظام"
          aria-haspopup="true"
          aria-expanded="false">

      <!-- FontAwesome (لو موجود) -->
      <i class="fa-solid fa-tower-broadcast text-[14px] sm:text-[15px]"></i>

      <!-- Fallback SVG (لو FA ما ظهر، لسه عندك شكل) -->
      <svg class="hidden" id="glaPulseSvg_91b7" width="18" height="18" viewBox="0 0 24 24" fill="none"
           xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
        <path d="M12 3v3" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
        <path d="M8 7c-2.5 2.5-2.5 7 0 9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
        <path d="M16 7c2.5 2.5 2.5 7 0 9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
        <path d="M12 9a3 3 0 0 1 0 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
        <circle cx="12" cy="17.5" r="1.5" fill="currentColor"/>
      </svg>

      <!-- BADGE (أوضح + ما بينقص) -->
    <span id="glaPulseBadge_91b7"
      class="hidden absolute -top-1.5 -right-1.5 z-20
             min-w-[20px] h-5 px-1.5 rounded-full
             bg-emerald-600 text-white text-[10px] font-extrabold leading-none
             grid place-items-center
             shadow-lg shadow-emerald-600/25
             ring-2 ring-white dark:ring-black">
  0
</span>


      <!-- Pulse dot -->
      <span class="absolute -bottom-0.5 -left-0.5 h-2.5 w-2.5 rounded-full bg-emerald-500
                   ring-2 ring-white dark:ring-black animate-pulse"></span>
  </button>

<div id="glaPulseDrop_91b7"
     onclick="event.stopPropagation()"
     class="hidden
            fixed top-16 left-[50vw] -translate-x-1/2
            w-[min(560px,calc(100vw-24px))]
            rounded-[24px] overflow-hidden
            bg-white dark:bg-slate-950
            border border-slate-200/80 dark:border-white/10
            ring-1 ring-slate-900/5 dark:ring-white/10
            shadow-[0_32px_140px_rgba(2,6,23,0.26)]
            dark:shadow-[0_40px_160px_rgba(0,0,0,0.78)]
            z-[9999]">

      <!-- Header (صغير جدًا) -->
      <div class="px-3 py-2.5 border-b border-slate-200/70 dark:border-white/10
                  bg-gradient-to-b from-white to-slate-50
                  dark:from-slate-950 dark:to-slate-950">
          <div class="flex items-center justify-between gap-2">
              <div class="min-w-0">
                  <div class="flex items-center gap-2">
                    <span class="h-8 w-8 rounded-2xl
                                 bg-gradient-to-br from-emerald-500/20 via-cyan-500/15 to-violet-500/15
                                 border border-emerald-400/20
                                 grid place-items-center text-emerald-800 dark:text-emerald-200">
                      <i class="fa-solid fa-wave-square text-[12px]"></i>
                    </span>
                    <div class="min-w-0">
                      <h3 class="text-[12px] font-extrabold text-slate-950 dark:text-white truncate">
                        Pulse • غرفة المتابعة
                      </h3>
                      <p class="text-[10px] text-slate-600 dark:text-white/55 truncate">
                        ملخص سريع + بادجات • بدون تفاصيل حساسة
                      </p>
                    </div>
                  </div>
              </div>

              <div class="flex items-center gap-1.5">
                  <!-- Mode (صغير للموبايل) -->
                  <div class="flex items-center gap-1 rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-1">
                      <button type="button" onclick="GLA_PULSE_91b7_setMode('day')" id="glaPulseMode_day_91b7"
                              class="px-2 py-1 rounded-xl text-[10px] font-extrabold text-slate-700 dark:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10">
                          يوم
                      </button>
                      <button type="button" onclick="GLA_PULSE_91b7_setMode('week')" id="glaPulseMode_week_91b7"
                              class="px-2 py-1 rounded-xl text-[10px] font-extrabold text-slate-700 dark:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10">
                          أسبوع
                      </button>
                      <button type="button" onclick="GLA_PULSE_91b7_setMode('month')" id="glaPulseMode_month_91b7"
                              class="hidden sm:inline-flex px-2 py-1 rounded-xl text-[10px] font-extrabold text-slate-700 dark:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10">
                          شهر
                      </button>
                  </div>

                  <button type="button" onclick="GLA_PULSE_91b7_close()"
                          class="h-8 w-8 rounded-2xl bg-slate-100 hover:bg-slate-200
                                 dark:bg-white/5 dark:hover:bg-white/10
                                 border border-slate-200/70 dark:border-white/10
                                 grid place-items-center transition"
                          aria-label="إغلاق">
                      <i class="fa-solid fa-xmark text-slate-700 dark:text-slate-200 text-[12px]"></i>
                  </button>
              </div>
          </div>

          <!-- status mini -->
          <div class="mt-2 rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 px-3 py-2">
            <div class="flex items-center justify-between gap-2">
              <div class="flex items-center gap-2 min-w-0">
                <span class="h-2 w-2 rounded-full bg-emerald-500 animate-pulse"></span>
                <span id="glaPulseStatus_91b7" class="text-[10px] font-extrabold text-slate-700 dark:text-white/80 truncate">
                  جاري التحميل…
                </span>
              </div>
              <div class="flex items-center gap-2 text-[10px] text-slate-600 dark:text-white/55 whitespace-nowrap">
                <span id="glaPulseLast_91b7">—</span>
                <button type="button" onclick="GLA_PULSE_91b7_refresh(true)"
                        class="font-extrabold text-emerald-700 hover:text-emerald-900 dark:text-emerald-200 dark:hover:text-emerald-100">
                  تحديث
                </button>
              </div>
            </div>
            <div class="mt-2 h-1 w-full bg-slate-200/70 dark:bg-white/10 rounded-full overflow-hidden">
              <div id="glaPulseProg_91b7" class="h-1 w-0 bg-emerald-500/80 rounded-full"></div>
            </div>
          </div>
      </div>

      <!-- Body (مضغوط) -->
      <div class="p-3 space-y-2 bg-white/90 dark:bg-slate-950/90">

        <!-- Grid: 2x2 (موبايل) -->
        <div class="grid grid-cols-2 gap-2">

          <!-- Lives -->
          <div class="rounded-[18px] p-3 border border-slate-200/70 dark:border-white/10
                      bg-gradient-to-br from-rose-50 to-white
                      dark:from-rose-500/10 dark:to-transparent">
            <div class="flex items-center justify-between">
              <div class="flex items-center gap-2">
                <span class="h-9 w-9 rounded-2xl bg-rose-500/10 border border-rose-400/20 grid place-items-center">
                  <i class="fa-solid fa-broadcast-tower text-rose-700 dark:text-rose-200 text-[11px]"></i>
                </span>
                <div class="min-w-0">
                  <div class="text-[11px] font-extrabold text-slate-950 dark:text-white truncate">لايفات</div>
                  <div class="text-[9px] text-slate-600 dark:text-white/55 truncate">مراجعة + بدون عذر</div>
                </div>
              </div>
              <span id="glaPulseLivesTotalBadge_91b7"
                    class="min-w-[22px] h-5 px-2 rounded-full text-[10px] font-extrabold grid place-items-center
                           bg-rose-600 text-white">
                0
              </span>
            </div>

            <div class="mt-2 grid grid-cols-2 gap-2">
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">مراجعة</div>
                <div id="glaPulseLivesPending_91b7" class="text-[14px] font-extrabold text-rose-700 dark:text-rose-200">—</div>
              </div>
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">بدون عذر</div>
                <div id="glaPulseLivesNoExcuse_91b7" class="text-[14px] font-extrabold text-rose-700 dark:text-rose-200">—</div>
              </div>
            </div>
          </div>

          <!-- Guests -->
          <div class="rounded-[18px] p-3 border border-slate-200/70 dark:border-white/10
                      bg-gradient-to-br from-indigo-50 to-white
                      dark:from-indigo-500/10 dark:to-transparent">
            <div class="flex items-center justify-between">
              <div class="flex items-center gap-2">
                <span class="h-9 w-9 rounded-2xl bg-indigo-500/10 border border-indigo-400/20 grid place-items-center">
                  <i class="fa-solid fa-id-badge text-indigo-700 dark:text-indigo-200 text-[11px]"></i>
                </span>
                <div class="min-w-0">
                  <div class="text-[11px] font-extrabold text-slate-950 dark:text-white truncate">قستات</div>
                  <div class="text-[9px] text-slate-600 dark:text-white/55 truncate">معلّق + موافق</div>
                </div>
              </div>
              <span id="glaPulseGuestsTotalBadge_91b7"
                    class="min-w-[22px] h-5 px-2 rounded-full text-[10px] font-extrabold grid place-items-center
                           bg-indigo-600 text-white">
                0
              </span>
            </div>

            <div class="mt-2 grid grid-cols-2 gap-2">
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">معلّق</div>
                <div id="glaPulseGuestsPending_91b7" class="text-[14px] font-extrabold text-indigo-700 dark:text-indigo-200">—</div>
              </div>
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">موافق</div>
                <div id="glaPulseGuestsApproved_91b7" class="text-[14px] font-extrabold text-indigo-700 dark:text-indigo-200">—</div>
              </div>
            </div>
          </div>

          <!-- Members -->
          <div class="rounded-[18px] p-3 border border-slate-200/70 dark:border-white/10
                      bg-gradient-to-br from-emerald-50 to-white
                      dark:from-emerald-500/10 dark:to-transparent">
            <div class="flex items-center justify-between">
              <div class="flex items-center gap-2">
                <span class="h-9 w-9 rounded-2xl bg-emerald-500/10 border border-emerald-400/20 grid place-items-center">
                  <i class="fa-solid fa-users text-emerald-700 dark:text-emerald-200 text-[11px]"></i>
                </span>
                <div class="min-w-0">
                  <div class="text-[11px] font-extrabold text-slate-950 dark:text-white truncate">أعضاء</div>
                  <div class="text-[9px] text-slate-600 dark:text-white/55 truncate">جدد/نشط/مغادرون</div>
                </div>
              </div>
              <span id="glaPulseMembersTotalBadge_91b7"
                    class="min-w-[22px] h-5 px-2 rounded-full text-[10px] font-extrabold grid place-items-center
                           bg-emerald-600 text-white">
                0
              </span>
            </div>

            <div class="mt-2 grid grid-cols-3 gap-2">
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">جدد</div>
                <div id="glaPulseMembersNew_91b7" class="text-[13px] font-extrabold text-emerald-700 dark:text-emerald-200">—</div>
              </div>
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">نشط</div>
                <div id="glaPulseMembersActive_91b7" class="text-[13px] font-extrabold text-emerald-700 dark:text-emerald-200">—</div>
              </div>
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">مغادر</div>
                <div id="glaPulseMembersLeft_91b7" class="text-[13px] font-extrabold text-emerald-700 dark:text-emerald-200">—</div>
              </div>
            </div>
          </div>

          <!-- ProActive -->
          <div class="rounded-[18px] p-3 border border-slate-200/70 dark:border-white/10
                      bg-gradient-to-br from-amber-50 to-white
                      dark:from-amber-500/10 dark:to-transparent">
            <div class="flex items-center justify-between">
              <div class="flex items-center gap-2">
                <span class="h-9 w-9 rounded-2xl bg-amber-500/10 border border-amber-400/20 grid place-items-center">
                  <i class="fa-solid fa-bolt text-amber-800 dark:text-amber-200 text-[11px]"></i>
                </span>
                <div class="min-w-0">
                  <div class="text-[11px] font-extrabold text-slate-950 dark:text-white truncate">ProActive</div>
                  <div class="text-[9px] text-slate-600 dark:text-white/55 truncate">جداول + تقارير</div>
                </div>
              </div>
              <span id="glaPulseProBadge_91b7"
                    class="min-w-[22px] h-5 px-2 rounded-full text-[10px] font-extrabold grid place-items-center
                           bg-amber-600 text-white">
                0
              </span>
            </div>

            <div class="mt-2 grid grid-cols-2 gap-2">
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">Active اليوم</div>
                <div id="glaPulseProActive_91b7" class="text-[14px] font-extrabold text-amber-800 dark:text-amber-200">—</div>
              </div>
              <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2">
                <div class="text-[9px] text-slate-600 dark:text-white/55">Pending تقارير</div>
                <div id="glaPulseProPending_91b7" class="text-[14px] font-extrabold text-amber-800 dark:text-amber-200">—</div>
              </div>
            </div>
          </div>

        </div>

        <!-- footer tiny -->
        <div class="rounded-2xl border border-slate-200/70 dark:border-white/10 bg-white/70 dark:bg-white/5 p-2.5">
          <div class="flex items-center justify-between gap-2">
            <div class="text-[10px] font-extrabold text-slate-900 dark:text-white truncate">
              ✅ البادج = (متابعة + جدد)
            </div>
            <div class="text-[10px] text-slate-600 dark:text-white/55 whitespace-nowrap">
              Mode: <span id="glaPulseSrc_91b7" class="font-extrabold">day</span>
            </div>
          </div>
        </div>

      </div>
  </div>
</div>

<script>
/* ✅ معزول بالكامل + AJAX XHR */
let GLA_PULSE_91b7_isOpen = false;
let GLA_PULSE_91b7_outside = null;
let GLA_PULSE_91b7_timer = null;
let GLA_PULSE_91b7_loading = false;
let GLA_PULSE_91b7_mode = 'day';

function GLA_PULSE_91b7_toggle(e){
  e.stopPropagation();
  e.preventDefault();

  // icon fallback (لو FA ما ظهر)
  try {
    const fa = document.querySelector('#glaPulseBtn_91b7 i.fa-solid');
    const svg = document.getElementById('glaPulseSvg_91b7');
    if (fa && svg) {
      const cs = window.getComputedStyle(fa);
      const visible = cs && cs.fontFamily && cs.fontFamily.toLowerCase().includes('font awesome');
      if (!visible) { fa.style.display = 'none'; svg.classList.remove('hidden'); }
    }
  } catch(e){}

  const dd  = document.getElementById('glaPulseDrop_91b7');
  const btn = document.getElementById('glaPulseBtn_91b7');
  if(!dd || !btn) return;

  const hidden = dd.classList.contains('hidden');

  if(hidden){
    dd.classList.remove('hidden');
    dd.setAttribute('aria-hidden','false');
    btn.setAttribute('aria-expanded','true');
    GLA_PULSE_91b7_isOpen = true;

    GLA_PULSE_91b7_refresh(true);

    GLA_PULSE_91b7_timer = setInterval(() => {
      if (GLA_PULSE_91b7_isOpen) GLA_PULSE_91b7_refresh(false);
    }, 20000);

    GLA_PULSE_91b7_outside = function(ev){
      if(!dd.contains(ev.target) && !btn.contains(ev.target)){
        GLA_PULSE_91b7_close();
      }
    };

    setTimeout(()=>{
      document.addEventListener('click', GLA_PULSE_91b7_outside);
      document.addEventListener('touchstart', GLA_PULSE_91b7_outside, {passive:true});
    }, 10);

    document.addEventListener('keydown', GLA_PULSE_91b7_esc);
  } else {
    GLA_PULSE_91b7_close();
  }
}

function GLA_PULSE_91b7_close(){
  const dd  = document.getElementById('glaPulseDrop_91b7');
  const btn = document.getElementById('glaPulseBtn_91b7');

  if(dd && !dd.classList.contains('hidden')){
    dd.classList.add('hidden');
    dd.setAttribute('aria-hidden','true');
  }
  if(btn) btn.setAttribute('aria-expanded','false');

  GLA_PULSE_91b7_isOpen = false;

  if(GLA_PULSE_91b7_outside){
    document.removeEventListener('click', GLA_PULSE_91b7_outside);
    document.removeEventListener('touchstart', GLA_PULSE_91b7_outside);
    GLA_PULSE_91b7_outside = null;
  }

  if (GLA_PULSE_91b7_timer){
    clearInterval(GLA_PULSE_91b7_timer);
    GLA_PULSE_91b7_timer = null;
  }

  document.removeEventListener('keydown', GLA_PULSE_91b7_esc);
}

function GLA_PULSE_91b7_esc(ev){
  if(ev.key === 'Escape' && GLA_PULSE_91b7_isOpen){
    GLA_PULSE_91b7_close();
  }
}

function GLA_PULSE_91b7_fmt(n){
  try { return new Intl.NumberFormat().format(Number(n || 0)); } catch(e){ return String(n || 0); }
}

function GLA_PULSE_91b7_setMode(mode){
  GLA_PULSE_91b7_mode = mode || 'day';

  ['day','week','month','all'].forEach(m => {
    const b = document.getElementById('glaPulseMode_'+m+'_91b7');
    if(!b) return;
    if(m === GLA_PULSE_91b7_mode){
      b.classList.add('bg-slate-900','text-white');
      b.classList.remove('text-slate-700');
      b.classList.add('dark:bg-white/15');
    } else {
      b.classList.remove('bg-slate-900','text-white','dark:bg-white/15');
      b.classList.add('text-slate-700');
    }
  });

  const src = document.getElementById('glaPulseSrc_91b7');
  if (src) src.textContent = GLA_PULSE_91b7_mode;

  GLA_PULSE_91b7_refresh(true);
}

function GLA_PULSE_91b7_setText(id, text){
  const el = document.getElementById(id);
  if(el) el.textContent = text;
}

function GLA_PULSE_91b7_setBadgeText(id, val){
  const el = document.getElementById(id);
  if(!el) return;
  el.textContent = GLA_PULSE_91b7_fmt(val);
}

function GLA_PULSE_91b7_setTopBadge(val){
  const b = document.getElementById('glaPulseBadge_91b7');
  if(!b) return;
  const n = Number(val || 0);
  if(n > 0){
    b.classList.remove('hidden');
    b.textContent = n > 99 ? '99+' : String(n);
  } else {
    b.classList.add('hidden');
  }
}

function GLA_PULSE_91b7_progress(pct){
  const bar = document.getElementById('glaPulseProg_91b7');
  if(!bar) return;
  bar.style.width = Math.max(0, Math.min(100, pct)) + '%';
}

function GLA_PULSE_91b7_ajax(url, onOk, onErr){
  const xhr = new XMLHttpRequest();
  xhr.open('GET', url, true);
  xhr.setRequestHeader('Accept', 'application/json');
  xhr.withCredentials = true;

  xhr.onreadystatechange = function(){
    if(xhr.readyState !== 4) return;

    if(xhr.status >= 200 && xhr.status < 300){
      try {
        const data = JSON.parse(xhr.responseText || '{}');
        onOk && onOk(data);
      } catch(e){
        onErr && onErr(e);
      }
    } else {
      onErr && onErr(new Error('HTTP '+xhr.status));
    }
  };

  xhr.onerror = function(){
    onErr && onErr(new Error('Network error'));
  };

  xhr.send(null);
}

function GLA_PULSE_91b7_refresh(force){
  if (GLA_PULSE_91b7_loading) return;
  GLA_PULSE_91b7_loading = true;

  GLA_PULSE_91b7_setText('glaPulseStatus_91b7', 'جاري جلب البيانات…');
  GLA_PULSE_91b7_progress(15);

  const url = new URL(@json(route('superadmin.pulse.gla')), window.location.origin);
  url.searchParams.set('mode', GLA_PULSE_91b7_mode || 'day');

  // since للـ ProActive changes_since (اختياري)
  try {
    const since = window.GLA_PULSE_91b7_lastChangeTs || '';
    if (since) url.searchParams.set('since', since);
  } catch(e){}

  GLA_PULSE_91b7_ajax(url.toString(), function(j){
    if(!j || !j.ok) throw new Error('bad');

    GLA_PULSE_91b7_progress(60);

    // Lives
    const L = j.lives || {};
    GLA_PULSE_91b7_setBadgeText('glaPulseLivesTotalBadge_91b7', L.total || 0);
    GLA_PULSE_91b7_setText('glaPulseLivesPending_91b7', GLA_PULSE_91b7_fmt(L.pending_review || 0));
    GLA_PULSE_91b7_setText('glaPulseLivesNoExcuse_91b7', GLA_PULSE_91b7_fmt(L.missed_no_excuse || 0));

    // Guests (guests + guest_submissions)
    const G  = j.guests || {};
    const GS = j.guest_submissions || {};

    const guestsTotal = Number(G.total || 0) + Number(GS.total || 0);
    const guestsPending = Number(G.pending || 0) + Number(GS.pending || 0);
    const guestsApproved = Number(G.confirmed || 0) + Number(GS.approved || 0);

    GLA_PULSE_91b7_setBadgeText('glaPulseGuestsTotalBadge_91b7', guestsTotal);
    GLA_PULSE_91b7_setText('glaPulseGuestsPending_91b7', GLA_PULSE_91b7_fmt(guestsPending));
    GLA_PULSE_91b7_setText('glaPulseGuestsApproved_91b7', GLA_PULSE_91b7_fmt(guestsApproved));

    // Members
    const M = j.members || {};
    GLA_PULSE_91b7_setBadgeText('glaPulseMembersTotalBadge_91b7', M.total || 0);
    GLA_PULSE_91b7_setText('glaPulseMembersNew_91b7', GLA_PULSE_91b7_fmt(M.new || 0));
    GLA_PULSE_91b7_setText('glaPulseMembersActive_91b7', GLA_PULSE_91b7_fmt(M.active || 0));
    GLA_PULSE_91b7_setText('glaPulseMembersLeft_91b7', GLA_PULSE_91b7_fmt(M.left || 0));

    // ProActive
    const P = j.proactive || {};
    GLA_PULSE_91b7_setBadgeText('glaPulseProBadge_91b7', (P.counts && P.counts.pending) ? P.counts.pending : 0);
    GLA_PULSE_91b7_setText('glaPulseProActive_91b7', GLA_PULSE_91b7_fmt(P.active_now || 0));
    GLA_PULSE_91b7_setText('glaPulseProPending_91b7', GLA_PULSE_91b7_fmt((P.counts && P.counts.pending) ? P.counts.pending : 0));

    // حفظ آخر change timestamp للـ since
    try {
      if (P.latest_change_ts) window.GLA_PULSE_91b7_lastChangeTs = P.latest_change_ts;
    } catch(e){}

    // Top Badge من السيرفر (الأصح)
    const top = Number(j.badges?.top || 0);
    GLA_PULSE_91b7_setTopBadge(top);

    const now = new Date();
    const t = now.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'});
    GLA_PULSE_91b7_setText('glaPulseLast_91b7', t);

    const att = Number(j.badges?.attention || 0);
    GLA_PULSE_91b7_setText('glaPulseStatus_91b7', 'جاهز • متابعة: ' + GLA_PULSE_91b7_fmt(att));

    GLA_PULSE_91b7_progress(100);
    setTimeout(()=>GLA_PULSE_91b7_progress(0), 450);

    GLA_PULSE_91b7_loading = false;

  }, function(){
    GLA_PULSE_91b7_setText('glaPulseStatus_91b7', 'فشل التحميل');
    GLA_PULSE_91b7_progress(0);
    GLA_PULSE_91b7_loading = false;
  });
}

// افتراضي: يوم
setTimeout(()=>GLA_PULSE_91b7_setMode('day'), 50);
</script>



<div class="relative">
    <button id="messages-toggle-btn"
            onclick="toggleMessagesDropdown(event)"
            class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                   rounded-full text-emerald-700 hover:text-emerald-950
                   dark:text-emerald-200 dark:hover:text-emerald-100
                   hover:bg-emerald-50/70 dark:hover:bg-emerald-500/10
                   transition-all
                   ring-1 ring-transparent hover:ring-emerald-200/60 dark:hover:ring-emerald-400/15
                   focus:outline-none focus:ring-2 focus:ring-emerald-300/60 dark:focus:ring-emerald-400/30"
            aria-label="الرسائل الخاصة"
            aria-haspopup="true"
            aria-expanded="false">
        <i class="fa-regular fa-envelope text-[14px] sm:text-[15px]"></i>

        @php
            $unreadMessagesCount = auth()->user()->unreadMessagesCount ?? 0;
        @endphp
        @if($unreadMessagesCount > 0)
            <span class="absolute top-0 right-2 flex items-center justify-center
                         h-3 w-3 sm:h-4 sm:w-4
                         rounded-full bg-red-500 text-white text-[7px] sm:text-[8px] font-extrabold
                         ring-2 ring-white dark:ring-black
                         -translate-x-1/6 -translate-y-1/6 z-10
                         shadow-[0_10px_30px_rgba(244,63,94,0.35)]">
                {{ $unreadMessagesCount > 9 ? '9+' : $unreadMessagesCount }}
            </span>
        @endif
    </button>

    {{-- ✅ Wrapper واحد فقط (مركز بالنص) --}}
    <div class="fixed inset-0 z-[999] hidden" id="messages-center-wrap" aria-hidden="true">
        {{-- Backdrop clickable --}}
        <button type="button"
                class="absolute inset-0 bg-black/30 backdrop-blur-[2px]"
                onclick="closeMessagesDropdown()"
                aria-label="إغلاق"></button>

        {{-- Panel --}}
        <div class="absolute top-16 left-1/2 -translate-x-1/2 w-[min(560px,calc(100vw-24px))] sm:w-96"
             onclick="event.stopPropagation()">
            @include('member.messages.partials.messages-dropdown')
        </div>
    </div>
</div>

<script>
let isMessagesDropdownOpen = false;
let closeMessagesDropdownListener = null;

function getMessagesElements() {
    const wrap = document.getElementById('messages-center-wrap');
    const btn  = document.getElementById('messages-toggle-btn');
    // داخل الـ include لازم يكون فيه id="messages-dropdown"
    const dropdown = document.getElementById('messages-dropdown');
    return { wrap, btn, dropdown };
}

function toggleMessagesDropdown(event) {
    event.stopPropagation();
    event.preventDefault();

    const { wrap, btn, dropdown } = getMessagesElements();
    if (!wrap || !btn) return;

    const isHidden = wrap.classList.contains('hidden');

    closeAllOtherDropdowns('messages-dropdown');

    if (isHidden) {
        // فتح
        wrap.classList.remove('hidden');
        wrap.setAttribute('aria-hidden', 'false');
        btn.setAttribute('aria-expanded', 'true');
        isMessagesDropdownOpen = true;

        // إذا الـ include نفسه حاطط hidden على messages-dropdown نخليه يظهر
        if (dropdown && dropdown.classList.contains('hidden')) {
            dropdown.classList.remove('hidden');
            dropdown.setAttribute('aria-hidden', 'false');
        }

        // تحميل الرسائل
        if (typeof loadMessages === 'function') loadMessages();

        // إغلاق بالنقر خارج الصندوق
        closeMessagesDropdownListener = function(e) {
            const { wrap, btn, dropdown } = getMessagesElements();
            if (!wrap) return;

            const panel = wrap.querySelector('div[onclick="event.stopPropagation()"]') || wrap;
            if (panel && !panel.contains(e.target) && !btn.contains(e.target)) {
                closeMessagesDropdown();
            }
        };

        setTimeout(() => {
            document.addEventListener('click', closeMessagesDropdownListener);
            document.addEventListener('touchstart', closeMessagesDropdownListener, { passive: true });
        }, 10);

        document.addEventListener('keydown', handleEscapeKey);
    } else {
        closeMessagesDropdown();
    }
}

function closeMessagesDropdown() {
    const { wrap, btn, dropdown } = getMessagesElements();

    if (wrap && !wrap.classList.contains('hidden')) {
        wrap.classList.add('hidden');
        wrap.setAttribute('aria-hidden', 'true');
    }

    // (اختياري) نخلي dropdown hidden كمان إذا بدك
    if (dropdown && !dropdown.classList.contains('hidden')) {
        dropdown.classList.add('hidden');
        dropdown.setAttribute('aria-hidden', 'true');
    }

    if (btn) btn.setAttribute('aria-expanded', 'false');

    isMessagesDropdownOpen = false;

    if (closeMessagesDropdownListener) {
        document.removeEventListener('click', closeMessagesDropdownListener);
        document.removeEventListener('touchstart', closeMessagesDropdownListener);
        closeMessagesDropdownListener = null;
    }

    document.removeEventListener('keydown', handleEscapeKey);
}

function closeAllOtherDropdowns(exceptId) {
    const allDropdowns = ['top-notifications-dropdown']; // رسائل رح تنغلق لحالها
    allDropdowns.forEach(id => {
        if (id !== exceptId) {
            const el = document.getElementById(id);
            if (el && !el.classList.contains('hidden')) el.classList.add('hidden');
        }
    });
}

function handleEscapeKey(e) {
    if (e.key === 'Escape' && isMessagesDropdownOpen) closeMessagesDropdown();
}

document.addEventListener('DOMContentLoaded', function() {
    // إغلاق على scroll
    window.addEventListener('scroll', function() {
        if (isMessagesDropdownOpen) closeMessagesDropdown();
    }, { passive: true });
});

// منع الإغلاق عند النقر داخل dropdown نفسه
document.addEventListener('click', function(e){
    const dd = document.getElementById('messages-dropdown');
    if (dd && dd.contains(e.target)) e.stopPropagation();
}, true);
</script>


<!-- hahaha-->
{{-- مركز النشاط (Tabbed Dropdown) --}}
{{-- مركز النشاط (Small Card + Tabs + Scroll) --}}
<div class="relative">
    <button id="hub-toggle-btn"
            onclick="toggleHubDropdown(event)"
            class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                   rounded-full text-indigo-700 hover:text-indigo-950
                   dark:text-indigo-200 dark:hover:text-indigo-100
                   hover:bg-indigo-50/70 dark:hover:bg-indigo-500/10
                   transition-all
                   ring-1 ring-transparent hover:ring-indigo-200/60 dark:hover:ring-indigo-400/15
                   focus:outline-none focus:ring-2 focus:ring-indigo-300/60 dark:focus:ring-indigo-400/30"
            aria-label="مركز النشاط">
        <i class="fa-solid fa-layer-group text-[14px] sm:text-[15px]"></i>

        {{-- total = internal(عام) + violations + requests + absences + honors + competitions + (marks dot => +1)
             ✅ presence badge لا يُحسب بالـ total
             ✅ maintenance لا badges ولا يُحسب --}}
        <span id="hub-total-badge"
              class="hidden absolute top-0 right-2 flex items-center justify-center
                         h-3 w-3 sm:h-4 sm:w-4 rounded-full bg-rose-500 text-white text-[9px] sm:text-[10px] font-extrabold
                     ring-2 ring-white dark:ring-black
                     shadow-[0_10px_30px_rgba(244,63,94,0.30)]">
            0
        </span>

    </button>

<div id="hub-dropdown"
     onclick="event.stopPropagation()"
     class="hidden
            fixed top-16 left-[50vw] -translate-x-1/2
            w-[min(560px,calc(100vw-24px))]
            rounded-[28px] overflow-hidden
            bg-white dark:bg-slate-950
            border border-slate-200/80 dark:border-white/10
            ring-1 ring-slate-900/5 dark:ring-white/10
            shadow-[0_30px_120px_rgba(2,6,23,0.28)]
            dark:shadow-[0_40px_140px_rgba(0,0,0,0.75)]
            z-50
            backdrop-blur-2xl">

    {{-- Enterprise Header (Clean + Solid) --}}
    <div class="px-4 py-3 border-b border-slate-200/80 dark:border-white/10
                bg-gradient-to-b from-slate-50 to-white
                dark:from-slate-950 dark:to-slate-950">
        <div class="flex items-center justify-between">
            <div class="min-w-0">
                <h3 class="text-sm font-extrabold text-slate-950 dark:text-white truncate">مركز النشاط</h3>
                <p id="hub-subtitle" class="text-[10px] text-slate-600 dark:text-white/55 truncate">
                    كل سجلات الإدارة داخل النظام.
                </p>
            </div>
                <button id="hub-mark-read-btn" type="button" onclick="hubMarkRead(event)"
                        class="text-[11px] text-sky-700 hover:text-sky-900
                               dark:text-sky-200 dark:hover:text-white font-extrabold
                               px-2 py-1 rounded-full hover:bg-sky-50 dark:hover:bg-white/5 transition">
                    كمقروء
                </button>
            </div>

            {{-- Main Tabs: أيقونة فوق + عنوان تحت --}}
            <div class="mt-3 grid grid-cols-5 gap-2">
                {{-- داخلي --}}
                <button type="button" id="hub-tab-internal" onclick="hubSwitchMain(event,'internal')"
                        class="relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10
                               bg-white dark:bg-black/40 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-bell text-[15px]"></i>
                        <span class="text-[11px] font-extrabold">داخلي</span>
                    </div>
                    <span id="hub-badge-internal0"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- علاماتي --}}
                <button type="button" id="hub-tab-marks" onclick="hubSwitchMain(event,'marks')"
                        class="relative rounded-xl px-2 py-2.5  rounded-full border border-slate-200/70 dark:border-white/10
                               bg-slate-50/70 dark:bg-white/5 text-slate-700 dark:text-white/70 transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-star text-[15px]"></i>
                        <span class="text-[11px] font-extrabold">علاماتي</span>
                    </div>
                    <span id="hub-badge-marks"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 w-2.5 h-2.5 rounded-full bg-rose-500 ring-2 ring-white/70 dark:ring-black/50"></span>
                </button>


                {{-- حضور اليوم --}}
                <button type="button" id="hub-tab-presence" onclick="hubSwitchMain(event,'presence')"
                        class="relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10
                               bg-slate-50/70 dark:bg-white/5 text-slate-700 dark:text-white/70 transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-users text-[15px]"></i>
                        <span class="text-[11px] font-extrabold">حضور</span>
                    </div>
                    <span id="hub-badge-presence"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- طلبات + تغيبات --}}
                <button type="button" id="hub-tab-requests" onclick="hubSwitchMain(event,'requests')"
                        class="relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10
                               bg-slate-50/70 dark:bg-white/5 text-slate-700 dark:text-white/70 transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-list-check text-[15px]"></i>
                        <span class="text-[11px] font-extrabold">طلبات</span>
                    </div>
                    <span id="hub-badge-requests"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- تكريم + مسابقات --}}
                <button type="button" id="hub-tab-honors" onclick="hubSwitchMain(event,'honors')"
                        class="relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10
                               bg-slate-50/70 dark:bg-white/5 text-slate-700 dark:text-white/70 transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-trophy text-[15px]"></i>
                        <span class="text-[11px] font-extrabold">تكريم</span>
                    </div>
                    <span id="hub-badge-honors"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>
            </div>

            {{-- Sub Tabs: داخلي (3 فقط) --}}
            <div id="hub-subtabs-internal" class="hidden mt-3 grid grid-cols-3 gap-2">
                {{-- عام (نفس بياناتك الحالية) --}}
                <button type="button" id="hub-sub-internal-general" onclick="hubSwitchSub(event,'internal','general')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-layer-group text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">عام</span>
                    </div>
                    <span id="hub-badge-internal-general"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- مخالفات (للجميع) --}}
                <button type="button" id="hub-sub-internal-violations" onclick="hubSwitchSub(event,'internal','violations')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-triangle-exclamation text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">مخالفات</span>
                    </div>
                    <span id="hub-badge-violations"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- صيانة (بدون بادجات) --}}
                <button type="button" id="hub-sub-internal-maintenance" onclick="hubSwitchSub(event,'internal','maintenance')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-screwdriver-wrench text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">صيانة</span>
                    </div>
                    {{-- ✅ متعمد: لا يوجد badge للصيانة --}}
                </button>
            </div>

            {{-- Sub Tabs: طلبات --}}
            <div id="hub-subtabs-requests" class="hidden mt-3 grid grid-cols-2 gap-2">
                {{-- طلبات القيادة العليا --}}
                <button type="button" id="hub-sub-requests-high" onclick="hubSwitchSub(event,'requests','requests')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-list-check text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">الطلبات</span>
                    </div>
                    <span id="hub-badge-high-requests"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- التغيبات --}}
                <button type="button" id="hub-sub-requests-absences" onclick="hubSwitchSub(event,'requests','absences')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-calendar-xmark text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">تغيبات</span>
                    </div>
                    <span id="hub-badge-absences"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>
            </div>

            {{-- Sub Tabs: تكريم --}}
            <div id="hub-subtabs-honors" class="hidden mt-3 grid grid-cols-2 gap-2">
                {{-- تكريمات/مكافآت --}}
                <button type="button" id="hub-sub-honors-rewards" onclick="hubSwitchSub(event,'honors','honors')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-award text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">تكريمات</span>
                    </div>
                    <span id="hub-badge-honor-rewards"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>

                {{-- مسابقات --}}
                <button type="button" id="hub-sub-honors-competitions" onclick="hubSwitchSub(event,'honors','competitions')"
                        class="relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10
                               bg-white/80 dark:bg-black/35 text-slate-900 dark:text-white transition-all
                               hover:shadow-[0_16px_60px_rgba(2,6,23,0.10)]">
                    <div class="flex flex-col items-center gap-1">
                        <i class="fa-solid fa-trophy text-[14px]"></i>
                        <span class="text-[10px] font-extrabold">مسابقات</span>
                    </div>
                    <span id="hub-badge-competitions"
                          class="hidden absolute -top-1 -right-1 inline-flex items-center justify-center
                                 min-w-[18px] h-5 px-1.5 rounded-full bg-rose-500 text-white text-[10px] font-extrabold
                                 ring-2 ring-white/70 dark:ring-black/50">0</span>
                </button>
            </div>

            {{-- Marks Summary (يظهر فقط بتاب علاماتي) --}}
            <div id="hub-marks-summary" class="hidden mt-3">
                <div class="grid grid-cols-2 gap-2">
                    <div class="rounded-xl border border-slate-200/70 dark:border-white/10 bg-white/80 dark:bg-black/35 px-3 py-2">
                        <div class="text-[10px] text-slate-600 dark:text-white/50 font-bold">العلامة الكليّة</div>
                        <div id="marks-total" class="text-sm font-extrabold text-slate-900 dark:text-white mt-0.5">—</div>
                    </div>
                    <div class="rounded-xl border border-slate-200/70 dark:border-white/10 bg-white/80 dark:bg-black/35 px-3 py-2">
                        <div class="text-[10px] text-slate-600 dark:text-white/50 font-bold">علامة الشهر</div>
                        <div id="marks-month" class="text-sm font-extrabold text-slate-900 dark:text-white mt-0.5">—</div>
                    </div>
                </div>

                <div class="mt-2 flex items-center gap-2 text-[10px]">
                    <span id="marks-month-hours"
                          class="px-2 py-0.5 rounded-full bg-sky-50 text-sky-700 border border-sky-200/70
                                 dark:bg-white/5 dark:text-white/70 dark:border-white/10">—</span>
                    <span id="marks-month-records"
                          class="px-2 py-0.5 rounded-full bg-slate-100 text-slate-700 border border-slate-200/70
                                 dark:bg-white/5 dark:text-white/70 dark:border-white/10">—</span>
                </div>
            </div>
        </div>

        {{-- Body --}}
        <div id="hub-body"
             class="h-[320px] sm:h-[360px] overflow-y-auto overscroll-contain scroll-smooth
                    [scrollbar-width:thin] [scrollbar-color:rgba(100,116,139,.45)_transparent]
                    dark:[scrollbar-color:rgba(255,255,255,.18)_transparent]">
            <div class="px-4 py-8 text-center text-slate-600 dark:text-white/55 text-sm">جاري التحميل...</div>
        </div>

        {{-- Footer --}}
        <div class="border-t border-slate-200/70 dark:border-white/10 px-3.5 py-2.5 text-center">
            <a href="{{ route('superadmin.internal-activities.index') }}"
               class="text-[11px] text-indigo-700 hover:text-indigo-900 dark:text-indigo-200 dark:hover:text-white font-extrabold">
                صفحة النشاطات
            </a>

            @if(\Illuminate\Support\Facades\Route::has('superadmin.violations.index'))
                <span class="mx-2 text-slate-400">•</span>
                <a href="{{ route('superadmin.violations.index') }}"
                   class="text-[11px] text-rose-700 hover:text-rose-900 dark:text-rose-200 dark:hover:text-white font-extrabold">
                    صفحة المخالفات
                </a>
            @endif

            <span class="mx-2 text-slate-400">•</span>

            @if(\Illuminate\Support\Facades\Route::has('general.marks.my-marks'))
                <a href="{{ route('general.marks.my-marks') }}"
                   class="text-[11px] text-sky-700 hover:text-sky-900 dark:text-sky-200 dark:hover:text-white font-extrabold">
                    صفحة علاماتي
                </a>
            @else
                <span class="text-[11px] text-slate-500 dark:text-white/40 font-bold">علامة غير مفعّلة</span>
            @endif
        </div>
    </div>
</div>


                    {{-- النصائح المستلمة --}}
                    <a href="{{ route('received-tips.index') }}"
                       class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                              rounded-full text-slate-600 hover:text-slate-950
                              dark:text-white/70 dark:hover:text-white
                              hover:bg-white/70 dark:hover:bg-white/10
                              transition-all
                              ring-1 ring-transparent hover:ring-slate-200/70 dark:hover:ring-white/10
                              focus:outline-none focus:ring-2 focus:ring-slate-300/70 dark:focus:ring-white/20"
                       aria-label="النصائح المقدمة لي">
                        <svg class="w-5 h-5 sm:w-5 sm:h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                  d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"/>
                        </svg>
                        @if($unreadTipsCount > 0)
                            <span
                                class="absolute -top-0.5 -right-0.5 flex h-4 w-4 sm:h-5 sm:w-5 items-center justify-center
                                       rounded-full bg-rose-500 text-white text-[9px] sm:text-[10px] font-extrabold
                                       ring-2 ring-white dark:ring-black animate-pulse-scale
                                       shadow-[0_10px_30px_rgba(244,63,94,0.30)]">
                                {{ $unreadTipsCount > 9 ? '9+' : $unreadTipsCount }}
                            </span>
                        @endif
                    </a>

                    {{-- الإشعارات اليدوية --}}
                    {{-- (تركتها زي ما هي عندك: ما أضفت زر جديد عشان ما نغامر بروت/صفحة مش موجودة) --}}

                    {{-- المتواجدون الآن (Dropdown) --}}
                    <div class="relative">
                        <button onclick="toggleOnlineDropdown(event)"
                                class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                                       rounded-full text-emerald-700 hover:text-emerald-950
                                       dark:text-emerald-200 dark:hover:text-emerald-100
                                       hover:bg-emerald-50/70 dark:hover:bg-emerald-500/10
                                       transition-all
                                       ring-1 ring-transparent hover:ring-emerald-200/60 dark:hover:ring-emerald-400/15
                                       focus:outline-none focus:ring-2 focus:ring-emerald-300/60 dark:focus:ring-emerald-400/30"
                                aria-label="الأعضاء المتواجدون الآن">
                            <div class="relative flex items-center justify-center w-5 h-5 sm:w-5 sm:h-5">
                                <span id="online-users-pulse"
                                      class="absolute inline-flex h-full w-full rounded-full opacity-50
                                             bg-emerald-400 animate-ping"></span>

                                <span
                                    class="relative inline-flex h-5 w-5 sm:h-5 sm:w-5 items-center justify-center
                                           rounded-full bg-gradient-to-br from-emerald-500 via-cyan-500 to-sky-500
                                           text-white shadow-sm">
                                    <i class="fa-solid fa-user-group text-[11px]"></i>
                                </span>
                            </div>


                            <span id="online-users-badge"
                                  class="absolute top-0.5 right-2 flex items-center justify-center
           h-3 w-3 sm:h-3.5 sm:w-3.5
                                         rounded-full bg-white text-[9px] font-extrabold text-emerald-700
                                         ring-2 ring-emerald-500 dark:bg-black/60 dark:text-emerald-200 dark:ring-emerald-400/50
                                         shadow-[0_10px_30px_rgba(16,185,129,0.18)]">
                                0
                            </span>                        </button>

                        {{-- لازم يبقى مباشرة بعد الزر (عشان JS) --}}
<div id="online-users-dropdown"
     class="hidden
            fixed top-16 left-[50vw] -translate-x-1/2
            w-[min(560px,calc(100vw-24px))] sm:w-96
            origin-top
            rounded-[28px] overflow-hidden
            bg-white
            dark:bg-slate-950
            border border-slate-200/80 dark:border-white/10
            ring-1 ring-slate-900/5 dark:ring-white/10
            shadow-[0_32px_140px_rgba(2,6,23,0.26)]
            dark:shadow-[0_40px_160px_rgba(0,0,0,0.78)]
            z-50 max-h-[80vh]
            backdrop-blur-2xl">

                            <div class="relative px-4 py-3 border-b border-slate-200/70 dark:border-white/10">
                                <div class="pointer-events-none absolute -top-20 -right-16 w-56 h-56 rounded-full bg-emerald-500/10 blur-3xl"></div>

                                <div class="relative flex items-center justify-between">
                                    <div>
                                        <h3 class="text-sm sm:text-base font-extrabold text-slate-950 dark:text-white">
                                            المتواجدون الآن
                                        </h3>
                                        <p class="text-[10px] text-slate-600 dark:text-white/55">
                                            محسوب على خوارزمية <span class="font-extrabold">زمن الفوزي</span> ⏱
                                        </p>
                                    </div>

                                    <span
                                          class="top-0 right-2 flex items-center justify-center
                       				  h-3 w-3 sm:h-3.5 sm:w-3.5  rounded-full text-[11px] font-extrabold
                                                 bg-emerald-50 text-emerald-700 border border-emerald-200/70
                                                 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20">
                                        0
                                    </span>
                                </div>
                            </div>

                            <div id="online-users-list" class="max-h-80 overflow-y-auto">
                                <div class="px-4 py-6 text-center text-slate-600 dark:text-white/55 text-sm">
                                    جاري تحميل قائمة المتواجدين...
                                </div>
                            </div>

                            <div class="border-t border-slate-200/70 dark:border-white/10 px-4 py-3 text-center">
                                <a href="{{ route('superadmin.falcon-room.online-members') }}"
                                   class="inline-flex items-center justify-center gap-2 text-xs sm:text-sm
                                          text-emerald-700 hover:text-emerald-900
                                          dark:text-emerald-200 dark:hover:text-emerald-100 font-extrabold">
                                    <i class="fa-solid fa-arrow-up-right-from-square text-[11px]"></i>
                                    فتح مركز الحضور المباشر
                                </a>
                            </div>
                        </div>
                    </div>

                    {{-- الإشعارات الأوتوماتيكية (Dropdown) --}}
                    <div class="relative">
                        <button onclick="toggleNotificationsDropdown(event)"
                                class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                                       rounded-full text-slate-600 hover:text-slate-950
                                       dark:text-white/70 dark:hover:text-white
                                       hover:bg-white/70 dark:hover:bg-white/10
                                       transition-all
                                       ring-1 ring-transparent hover:ring-slate-200/70 dark:hover:ring-white/10
                                       focus:outline-none focus:ring-2 focus:ring-slate-300/70 dark:focus:ring-white/20">
                            <svg class="w-5 h-5 sm:w-5 sm:h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                      d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
                            </svg>

                            @if (isset($unreadNotificationsCount) && $unreadNotificationsCount > 0)
                                <span class="absolute top-0 right-2 flex items-center justify-center
                         h-3 w-3 sm:h-3.5 sm:w-3.5 rounded-full bg-rose-500 text-[9px] sm:text-[10px] font-extrabold text-white
                                             ring-2 ring-white dark:ring-black
                                             shadow-[0_10px_30px_rgba(244,63,94,0.30)]">
                                    {{ $unreadNotificationsCount > 9 ? '9+' : $unreadNotificationsCount }}
                                </span>
                            @endif
                        </button>

                        {{-- لازم يبقى مباشرة بعد الزر (عشان JS) --}}
<div id="top-notifications-dropdown"
     class="hidden
            fixed top-16 left-[50vw] -translate-x-1/2
            w-[min(560px,calc(100vw-24px))] sm:w-96
            origin-top
            rounded-[28px] overflow-hidden
            bg-white
            dark:bg-slate-950
            border border-slate-200/80 dark:border-white/10
            ring-1 ring-slate-900/5 dark:ring-white/10
            shadow-[0_32px_140px_rgba(2,6,23,0.26)]
            dark:shadow-[0_40px_160px_rgba(0,0,0,0.78)]
            z-50 max-h-[80vh]
            backdrop-blur-2xl">

                            <div class="flex items-center justify-between border-b border-slate-200/70 dark:border-white/10 px-4 py-3">
                                <h3 class="text-sm sm:text-base font-extrabold text-slate-950 dark:text-white">
                                    الإشعارات
                                </h3>
                                @if (isset($unreadNotificationsCount) && $unreadNotificationsCount > 0)
                                    <button onclick="markAllAsRead()"
                                            class="text-xs sm:text-sm text-sky-700 hover:text-sky-900
                                                   dark:text-sky-200 dark:hover:text-white font-extrabold
                                                   px-2 py-1 rounded-full hover:bg-sky-50 dark:hover:bg-white/5 transition">
                                        وضع الكل كمقروء
                                    </button>
                                @endif
                            </div>

                            <div class="max-h-96 overflow-y-auto">
                                @if(isset($recentNotifications))
                                    @forelse($recentNotifications as $notification)
                                        <div
                                            class="border-b border-slate-100 dark:border-white/10 px-4 py-3
                                                   hover:bg-slate-50 dark:hover:bg-white/5 transition-colors
                                                   {{ !$notification->isReadBy(auth()->id()) ? 'bg-sky-50/80 dark:bg-sky-500/10' : '' }}">
                                            <div class="flex items-start gap-2.5 sm:gap-3">
                                                <div class="flex-shrink-0 mt-0.5">
                                                    <div
                                                        class="w-8 h-8 sm:w-9 sm:h-9 rounded-2xl flex items-center justify-center border
                                                               @if($notification->type === 'success') bg-emerald-100 text-emerald-700 border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20 @endif
                                                               @if($notification->type === 'info') bg-sky-100 text-sky-700 border-sky-200 dark:bg-sky-500/10 dark:text-sky-200 dark:border-sky-400/20 @endif
                                                               @if($notification->type === 'warning') bg-amber-100 text-amber-700 border-amber-200 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20 @endif
                                                               @if($notification->type === 'danger') bg-rose-100 text-rose-700 border-rose-200 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20 @endif">
                                                        <svg class="w-4 h-4 sm:w-5 sm:h-5" fill="currentColor" viewBox="0 0 20 20">
                                                            <path d="M10 2a8 8 0 100 16 8 8 0 000-16zM9 9a1 1 0 012 0v4a1 1 0 11-2 0V9zm1-4a1 1 0 100 2 1 1 0 000-2z"/>
                                                        </svg>
                                                    </div>
                                                </div>

                                                <div class="flex-1 min-w-0">
                                                    <p class="text-xs sm:text-sm text-slate-900 dark:text-white {{ !$notification->isReadBy(auth()->id()) ? 'font-extrabold' : 'font-medium' }}">
                                                        {{ $notification->message }}
                                                    </p>
                                                    <p class="text-xs text-slate-600 dark:text-white/55 mt-1">
                                                        {{ $notification->created_at->diffForHumans() }}
                                                    </p>

                                                    <div class="flex items-center gap-3 mt-2">
                                                        @if ($notification->action_url)
                                                            <a href="{{ $notification->action_url }}"
                                                               onclick="markAsRead({{ $notification->id }})"
                                                               class="text-xs text-sky-700 hover:text-sky-900 dark:text-sky-200 dark:hover:text-white font-extrabold">
                                                                عرض التفاصيل
                                                            </a>
                                                        @endif
                                                        @if (!$notification->isReadBy(auth()->id()))
                                                            <button onclick="markAsRead({{ $notification->id }})"
                                                                    class="text-xs text-slate-600 hover:text-slate-900 dark:text-white/60 dark:hover:text-white font-bold">
                                                                وضع كمقروء
                                                            </button>
                                                        @endif
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    @empty
                                        <div class="px-4 py-8 text-center text-slate-600 dark:text-white/55">
                                            <svg class="mx-auto h-10 w-10 sm:h-12 sm:w-12 text-slate-400 dark:text-white/30"
                                                 fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                                      d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/>
                                            </svg>
                                            <p class="mt-2 text-sm font-bold">لا توجد إشعارات جديدة</p>
                                        </div>
                                    @endforelse
                                @endif
                            </div>

                            @if (isset($unreadNotificationsCount) && $unreadNotificationsCount > 0)
                                <div class="border-t border-slate-200/70 dark:border-white/10 px-4 py-3 text-center">
                                    <a href="{{ route('general-notifications.index') }}"
                                       class="text-xs sm:text-sm text-sky-700 hover:text-sky-900 dark:text-sky-200 dark:hover:text-white font-extrabold">
                                        عرض جميع الإشعارات
                                    </a>
                                </div>
                            @endif
                        </div>
                    </div>

                    {{-- الاختبارات المتاحة --}}
                    <a href="{{ route('tests.weekly.index') }}"
                       class="relative flex items-center justify-center h-8 w-8 sm:h-9 sm:w-9
                              rounded-full text-slate-600 hover:text-slate-950
                              dark:text-white/70 dark:hover:text-white
                              hover:bg-white/70 dark:hover:bg-white/10
                              transition-all
                              ring-1 ring-transparent hover:ring-slate-200/70 dark:hover:ring-white/10
                              focus:outline-none focus:ring-2 focus:ring-slate-300/70 dark:focus:ring-white/20"
                       aria-label="الاختبارات المتاحة">
                        <i class="fa-solid fa-clipboard-question text-[15px] sm:text-[16px]"></i>
                        @if($testsCount > 0)
                            <span
                                class="absolute -top-0.5 -right-0.5 flex h-4 w-4 items-center justify-center
                                       rounded-full bg-emerald-500 text-white text-[9px] font-extrabold
                                       ring-2 ring-white dark:ring-black animate-pulse
                                       shadow-[0_10px_30px_rgba(16,185,129,0.20)]">
                                {{ $testsCount }}
                            </span>
                        @endif
                    </a>
                </div>

            </div>

        </div>
    </div>
</header>

@push('scripts')


<script>
(() => {
    const widgetUrl = @json(route('top-hub.widget'));
    const markUrl   = @json(route('top-hub.mark-read'));

    // ✅ NEW (كنترول ثاني موحد للجديد)
    const widgetExtraUrl = @json(\Illuminate\Support\Facades\Route::has('top-hub.widget-extra') ? route('top-hub.widget-extra') : null);
    const markExtraUrl   = @json(\Illuminate\Support\Facades\Route::has('top-hub.mark-read-extra') ? route('top-hub.mark-read-extra') : null);

    const csrf      = @json(csrf_token());

    // ✅ tabKey الحقيقي اللي بنرسل للـ backend
    let hubTab  = 'internal';

    // ✅ main tabs
    let hubMain = 'internal'; // internal | marks | presence | requests | honors

    // ✅ subtabs
    let internalSub = 'general';     // general | violations | maintenance (3 فقط)
    let requestsSub = 'requests';    // requests | absences
    let honorsSub   = 'honors';      // honors | competitions

    let hubOpen = false;

    // paging
    let pageCursor = 1, hasMore = true, loading = false;
    const per = 30;

    // ✅ keep last counts merged (old + extra)
    let lastCounts = {};

    const dd  = () => document.getElementById('hub-dropdown');
    const btn = () => document.getElementById('hub-toggle-btn');

    function isExtraTab(tab){
        return ['violations','high_requests','absences','honor_rewards','competitions','counts'].includes(tab);
    }

    function activeTabKey(){
        if (hubMain === 'internal') {
            if (internalSub === 'violations') return 'violations';
            if (internalSub === 'maintenance') return 'maintenance';
            return 'internal'; // general
        }
        if (hubMain === 'marks') return 'marks';
        if (hubMain === 'presence') return 'presence';
        if (hubMain === 'requests') return (requestsSub === 'absences') ? 'absences' : 'high_requests';
        if (hubMain === 'honors') return (honorsSub === 'competitions') ? 'competitions' : 'honor_rewards';
        return 'internal';
    }

    function syncHubTab(){
        hubTab = activeTabKey();
    }

    function canMarkRead(tab){
        // ✅ ما بنخليها للحضور ولا للصيانة
        return !['presence','maintenance'].includes(tab);
    }

    function updateMarkReadBtn(){
        const b = document.getElementById('hub-mark-read-btn');
        if(!b) return;
        const ok = canMarkRead(hubTab);

        b.disabled = !ok;
        b.classList.toggle('opacity-40', !ok);
        b.classList.toggle('pointer-events-none', !ok);
    }

    // ✅ NEW: تحويل الدقائق لساعات (بدون ما نلمس باقي الكود)
    function fmtMinsToHM(mins){
        mins = parseInt(mins, 10) || 0;
        if (mins < 60) return `${mins} د`;
        const h = Math.floor(mins / 60);
        const m = mins % 60;
        return m ? `${h} س ${m} د` : `${h} س`;
    }

    // ✅ أيقونات السجلات (زي ما كانت: مربّع + أيقونة)
    function iconForType(type){
        switch((type||'').toLowerCase()){
            case 'marks': return {wrap:'bg-violet-50 text-violet-700 border-violet-200/70 dark:bg-violet-500/10 dark:text-violet-200 dark:border-violet-400/20', icon:'fa-star'};
            case 'presence': return {wrap:'bg-emerald-50 text-emerald-700 border-emerald-200/70 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20', icon:'fa-users'};

            case 'evaluation': return {wrap:'bg-sky-50 text-sky-700 border-sky-200/70 dark:bg-sky-500/10 dark:text-sky-200 dark:border-sky-400/20', icon:'fa-clipboard-check'};
            case 'excuse': return {wrap:'bg-amber-50 text-amber-700 border-amber-200/70 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20', icon:'fa-circle-info'};

            case 'user_joined': return {wrap:'bg-emerald-50 text-emerald-700 border-emerald-200/70 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20', icon:'fa-user-plus'};
            case 'user_left':
            case 'user-left': return {wrap:'bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20', icon:'fa-user-minus'};
            case 'user': return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-user'};

            case 'violation':
            case 'warning': return {wrap:'bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20', icon:'fa-triangle-exclamation'};
            case 'violation_resolved':
            case 'check': return {wrap:'bg-emerald-50 text-emerald-700 border-emerald-200/70 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20', icon:'fa-circle-check'};

            case 'tip': return {wrap:'bg-indigo-50 text-indigo-700 border-indigo-200/70 dark:bg-indigo-500/10 dark:text-indigo-200 dark:border-indigo-400/20', icon:'fa-lightbulb'};
            case 'tip_reply':
            case 'reply': return {wrap:'bg-indigo-50 text-indigo-700 border-indigo-200/70 dark:bg-indigo-500/10 dark:text-indigo-200 dark:border-indigo-400/20', icon:'fa-reply'};

            case 'member_care':
            case 'member-care': return {wrap:'bg-fuchsia-50 text-fuchsia-700 border-fuchsia-200/70 dark:bg-fuchsia-500/10 dark:text-fuchsia-200 dark:border-fuchsia-400/20', icon:'fa-heart'};

            case 'proactive':
            case 'proactive-plus': return {wrap:'bg-cyan-50 text-cyan-700 border-cyan-200/70 dark:bg-cyan-500/10 dark:text-cyan-200 dark:border-cyan-400/20', icon:'fa-bolt'};

            case 'competition':
            case 'trophy': return {wrap:'bg-amber-50 text-amber-700 border-amber-200/70 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20', icon:'fa-trophy'};

            // ✅ سجلات TopHub الجديدة (أيقونات + ألوان) — بدون تابات
            case 'alerts':
            case 'alert': return {wrap:'bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20', icon:'fa-bell'};

            case 'updates':
            case 'update': return {wrap:'bg-indigo-50 text-indigo-700 border-indigo-200/70 dark:bg-indigo-500/10 dark:text-indigo-200 dark:border-indigo-400/20', icon:'fa-rotate'};

            case 'support': return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-headset'};

            case 'social':
            case 'post':
            case 'posts': return {wrap:'bg-sky-50 text-sky-700 border-sky-200/70 dark:bg-sky-500/10 dark:text-sky-200 dark:border-sky-400/20', icon:'fa-newspaper'};

            case 'reports':
            case 'report': return {wrap:'bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20', icon:'fa-flag'};

            case 'lives_logs':
            case 'live_log':
            case 'live_logs':
            case 'live_action': return {wrap:'bg-purple-50 text-purple-700 border-purple-200/70 dark:bg-purple-500/10 dark:text-purple-200 dark:border-purple-400/20', icon:'fa-tower-broadcast'};

            case 'taateer':
            case 'effect':
            case 'effects': return {wrap:'bg-amber-50 text-amber-700 border-amber-200/70 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20', icon:'fa-wand-magic-sparkles'};

            case 'proactive_logs':
            case 'proactive_log': return {wrap:'bg-cyan-50 text-cyan-700 border-cyan-200/70 dark:bg-cyan-500/10 dark:text-cyan-200 dark:border-cyan-400/20', icon:'fa-bolt'};

            case 'invites':
            case 'invite':
            case 'invitation': return {wrap:'bg-emerald-50 text-emerald-700 border-emerald-200/70 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20', icon:'fa-user-plus'};

            case 'status':
            case 'status_change':
            case 'account_status': return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-user-gear'};

            case 'absence':
            case 'excused_absence':
            case 'absence_warning': return {wrap:'bg-amber-50 text-amber-700 border-amber-200/70 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20', icon:'fa-calendar-xmark'};

            case 'tests':
            case 'test':
            case 'weekly_test': return {wrap:'bg-sky-50 text-sky-700 border-sky-200/70 dark:bg-sky-500/10 dark:text-sky-200 dark:border-sky-400/20', icon:'fa-clipboard-list'};

            case 'broadcast':
            case 'notification':
            case 'manual_notification': return {wrap:'bg-indigo-50 text-indigo-700 border-indigo-200/70 dark:bg-indigo-500/10 dark:text-indigo-200 dark:border-indigo-400/20', icon:'fa-bullhorn'};

            case 'requests':
            case 'request': return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-list-check'};

            case 'errors':
            case 'error':
            case 'failed_job': return {wrap:'bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20', icon:'fa-bug'};

            case 'support': return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-headset'};
            case 'live': return {wrap:'bg-purple-50 text-purple-700 border-purple-200/70 dark:bg-purple-500/10 dark:text-purple-200 dark:border-purple-400/20', icon:'fa-tower-broadcast'};
            case 'maintenance': return {wrap:'bg-amber-50 text-amber-700 border-amber-200/70 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20', icon:'fa-screwdriver-wrench'};

            default: return {wrap:'bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10', icon:'fa-bell'};
        }
    }

    // ✅ تبديل ستايل أزرار الـ main tabs
    function setActiveMain(main){
        const active = "relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10 bg-white dark:bg-black/40 text-slate-900 dark:text-white transition-all";
        const idle   = "relative rounded-xl px-2 py-2.5 border border-slate-200/70 dark:border-white/10 bg-slate-50/70 dark:bg-white/5 text-slate-700 dark:text-white/70 transition-all";

        const ids = ['internal','marks','presence','requests','honors'];
        ids.forEach(k => {
            const el = document.getElementById('hub-tab-' + k);
            if (!el) return;
            el.className = (k === main) ? active : idle;
        });

        // show/hide subtabs blocks
        document.getElementById('hub-subtabs-internal')?.classList.toggle('hidden', main !== 'internal');
        document.getElementById('hub-subtabs-requests')?.classList.toggle('hidden', main !== 'requests');
        document.getElementById('hub-subtabs-honors')?.classList.toggle('hidden', main !== 'honors');
    }

    // ✅ subtabs active styles
    function setActiveInternalSub(sub){
        const active = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white dark:bg-black/40 text-slate-900 dark:text-white transition-all";
        const idle   = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white/80 dark:bg-black/35 text-slate-700 dark:text-white/70 transition-all";

        ['general','violations','maintenance'].forEach(k => {
            const el = document.getElementById('hub-sub-internal-' + k);
            if(!el) return;
            el.className = (k === sub) ? active : idle;
        });
    }

    function setActiveRequestsSub(sub){
        const active = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white dark:bg-black/40 text-slate-900 dark:text-white transition-all";
        const idle   = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white/80 dark:bg-black/35 text-slate-700 dark:text-white/70 transition-all";

        const a = document.getElementById('hub-sub-requests-high');
        const b = document.getElementById('hub-sub-requests-absences');
        if(a) a.className = (sub === 'requests') ? active : idle;
        if(b) b.className = (sub === 'absences') ? active : idle;
    }

    function setActiveHonorsSub(sub){
        const active = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white dark:bg-black/40 text-slate-900 dark:text-white transition-all";
        const idle   = "relative rounded-xl px-2 py-2 border border-slate-200/70 dark:border-white/10 bg-white/80 dark:bg-black/35 text-slate-700 dark:text-white/70 transition-all";

        const a = document.getElementById('hub-sub-honors-rewards');
        const b = document.getElementById('hub-sub-honors-competitions');
        if(a) a.className = (sub === 'honors') ? active : idle;
        if(b) b.className = (sub === 'competitions') ? active : idle;
    }

    function updateSubtitle(){
        const sub = document.getElementById('hub-subtitle');
        if(!sub) return;

        if (hubTab === 'presence') sub.textContent = 'المتواجدون اليوم داخل البرنامج (Online + Tracking).';
        else if (hubTab === 'marks') sub.textContent = 'سجل نقاطك وملخص الشهر/الإجمالي.';
        else if (hubTab === 'maintenance') sub.textContent = 'آخر صيانة + فحص سريع.';
        else if (hubTab === 'violations') sub.textContent = 'المخالفات والإنذارات (للجميع).';
        else if (hubTab === 'high_requests') sub.textContent = 'طلبات القيادة العليا (High Level Requests).';
        else if (hubTab === 'absences') sub.textContent = 'طلبات الغياب + التغيبات.';
        else if (hubTab === 'honor_rewards') sub.textContent = 'التكريمات والمكافآت.';
        else if (hubTab === 'competitions') sub.textContent = 'المسابقات (جديد + نشاط).';
        else sub.textContent = 'كل سجلات الإدارة داخل النظام.';
    }

    function updateMarksSummaryVisibility(){
        document.getElementById('hub-marks-summary')?.classList.toggle('hidden', hubTab !== 'marks');
    }

    window.toggleHubDropdown = function(e){
        e.preventDefault(); e.stopPropagation();
        const el = dd(); if (!el) return;

        el.classList.toggle('hidden');
        hubOpen = !el.classList.contains('hidden');

        if (hubOpen) {
            syncHubTab();

            setActiveMain(hubMain);
            setActiveInternalSub(internalSub);
            setActiveRequestsSub(requestsSub);
            setActiveHonorsSub(honorsSub);

            updateMarksSummaryVisibility();
            updateSubtitle();
            updateMarkReadBtn();

            resetList();
            hubLoad(hubTab);
        }
    };

    document.addEventListener('click', (e) => {
        const el = dd(), b = btn();
        if (!el || !b) return;
        if (!el.contains(e.target) && !b.contains(e.target)) { el.classList.add('hidden'); hubOpen = false; }
    });

    // ✅ main switch
    window.hubSwitchMain = function(e, main){
        e.preventDefault(); e.stopPropagation();
        hubMain = main;

        syncHubTab();

        setActiveMain(main);
        setActiveInternalSub(internalSub);
        setActiveRequestsSub(requestsSub);
        setActiveHonorsSub(honorsSub);

        updateMarksSummaryVisibility();
        updateSubtitle();
        updateMarkReadBtn();

        resetList();
        hubLoad(hubTab);

        // نفس سلوكك: تبويب علاماتي يعلّم مقروء مباشرة
        if (hubTab === 'marks') hubMarkRead();
    };

    // ✅ sub switch
    window.hubSwitchSub = function(e, main, sub){
        e.preventDefault(); e.stopPropagation();

        if(main === 'internal') internalSub = sub;
        if(main === 'requests') requestsSub = sub;
        if(main === 'honors') honorsSub = sub;

        hubMain = main;

        syncHubTab();

        setActiveMain(main);
        setActiveInternalSub(internalSub);
        setActiveRequestsSub(requestsSub);
        setActiveHonorsSub(honorsSub);

        updateMarksSummaryVisibility();
        updateSubtitle();
        updateMarkReadBtn();

        resetList();
        hubLoad(hubTab);

        if (hubTab === 'marks') hubMarkRead();
    };

    function optimisticMarkRead(tab){
        // ✅ تحديث البادجات مباشرة بدون ريفرش صفحة
        switch(tab){
            case 'internal': lastCounts.internal = 0; break;
            case 'marks': lastCounts.marks = 0; break;
            case 'violations': lastCounts.violations = 0; break;
            case 'high_requests': lastCounts.high_requests = 0; break;
            case 'absences': lastCounts.absences = 0; break;
            case 'honor_rewards': lastCounts.honor_rewards = 0; break;
            case 'competitions': lastCounts.competitions = 0; break;
        }
        applyCounts(); // يعيد حساب الكل من lastCounts
    }

    window.hubMarkRead = async function(e){
        if (e) { e.preventDefault(); e.stopPropagation(); }

        if(!canMarkRead(hubTab)) return;

        const url = isExtraTab(hubTab) ? markExtraUrl : markUrl;

        // لو التبويب جديد وما تم إضافة الكنترول/الراوت — لا نكسر الواجهة
        if (isExtraTab(hubTab) && !url) return;

        try{
            await fetch(url, {
                method:'POST',
                headers:{'Content-Type':'application/json','X-CSRF-TOKEN':csrf,'Accept':'application/json'},
                body: JSON.stringify({ tab: hubTab })
            });

            optimisticMarkRead(hubTab);

            // تحديث العدّادات من السيرفر (بدون تحديث صفحة)
            refreshBadgesOnly();

            // إعادة تحميل نفس التبويب حتى ينعكس “لا يوجد شيء جديد” لو السيرفر صار يرجع unread فقط
            resetList();
            hubLoad(hubTab);

        }catch(err){}
    };

    function resetList(){
        pageCursor = 1;
        hasMore = true;
        loading = false;
        const b = document.getElementById('hub-body');
        if (b) b.scrollTop = 0;
    }

    // ✅ badges auto refresh (old + extra)
    async function refreshBadgesOnly(){
        try{
            // old counts
            const resOld = await fetch(`${widgetUrl}?tab=presence&page=1&per=1`, { headers:{'Accept':'application/json'} });
            if(resOld.ok){
                const dataOld = await resOld.json();
                applyCounts(dataOld.counts || {});
            }

            // extra counts
            if(widgetExtraUrl){
                const resExtra = await fetch(`${widgetExtraUrl}?tab=counts`, { headers:{'Accept':'application/json'} });
                if(resExtra.ok){
                    const dataExtra = await resExtra.json();
                    applyCounts(dataExtra.counts || {});
                }
            }

        }catch(e){}
    }

    refreshBadgesOnly();
    setInterval(refreshBadgesOnly, 20000);

    function applyCounts(newCounts){
        // merge
        if(newCounts && typeof newCounts === 'object'){
            lastCounts = Object.assign({}, lastCounts, newCounts);
        }

        const internal = Number(lastCounts.internal || 0);
        const maint    = Number(lastCounts.maintenance || 0); // ✅ لا نستخدمه للبادجات/التوتال
        const marks    = Number(lastCounts.marks || 0);
        const presence = Number(lastCounts.presence || 0);

        const violations    = Number(lastCounts.violations || 0);
        const highRequests  = Number(lastCounts.high_requests || 0);
        const absences      = Number(lastCounts.absences || 0);
        const honorRewards  = Number(lastCounts.honor_rewards || 0);
        const competitions  = Number(lastCounts.competitions || 0);

        // ✅ داخلي: بادج main = (عام + مخالفات)
      //  setBadge('hub-badge-internal', internal + violations);

        // ✅ بادجات subtabs
       // setBadge('hub-badge-internal-general', internal);
        setBadge('hub-badge-violations', violations);

        // ✅ حضور: يظهر بادجه لكن لا يدخل بالـ total
        setBadge('hub-badge-presence', presence);

        // ✅ طلبات: main = (طلبات + تغيبات)
        setBadge('hub-badge-requests', highRequests + absences);
        setBadge('hub-badge-high-requests', highRequests);
        setBadge('hub-badge-absences', absences);

        // ✅ تكريم: main = (تكريمات + مسابقات)
        setBadge('hub-badge-honors', honorRewards + competitions);
        setBadge('hub-badge-honor-rewards', honorRewards);
        setBadge('hub-badge-competitions', competitions);

        // ✅ علامة: نقطة فقط
        setDot('hub-badge-marks', marks > 0);

        // ✅ total (بدون presence وبدون maintenance)
        const total =
            
            violations +
            highRequests +
            absences +
            honorRewards +
            competitions +
            (marks > 0 ? 1 : 0);

        setBadge('hub-total-badge', total);
    }

    function baseUrlForTab(tab){
        if(isExtraTab(tab)) return widgetExtraUrl;
        return widgetUrl;
    }

    async function hubLoad(tab){
        const body = document.getElementById('hub-body');
        if (!body) return;

        body.innerHTML = `<div class="px-4 py-8 text-center text-slate-600 dark:text-white/55 text-sm">جاري التحميل...</div>`;

        try{
            const base = baseUrlForTab(tab);

            if(!base){
                body.innerHTML = `<div class="px-4 py-8 text-center text-slate-600 dark:text-white/55 text-sm font-bold">التبويب غير مفعّل (راوت/كنترول غير موجود)</div>`;
                return;
            }

            if (tab === 'maintenance') {
                const res = await fetch(`${base}?tab=maintenance&page=1&per=1`, { headers:{'Accept':'application/json'} });
                if(!res.ok) throw new Error('bad');
                const data = await res.json();
                applyCounts(data.counts || {});
                body.innerHTML = renderMaintenanceCard(data.maintenance_status || {}, data.maintenance_url, data.maintenance_logs_url);
                return;
            }

            const res = await fetch(`${base}?tab=${encodeURIComponent(tab)}&page=${pageCursor}&per=${per}`, { headers:{'Accept':'application/json'} });
            if(!res.ok) throw new Error('bad');
            const data = await res.json();

            applyCounts(data.counts || {});

            if (tab === 'marks' && data.marksSummary){
                const s = data.marksSummary;
                document.getElementById('marks-total').textContent = `${formatNum(s.total_points||0)} نقطة`;
                document.getElementById('marks-month').textContent = `${formatNum(s.month_points||0)} نقطة`;
                document.getElementById('marks-month-hours').textContent = `${formatNum(s.month_hours||0)} س`;
                document.getElementById('marks-month-records').textContent = `${formatNum(s.month_records||0)} سجّل`;
            }

            body.innerHTML = renderItemsHtml(tab, data.items || []);

            hasMore = !!data.has_more;
            pageCursor++;

        }catch(e){
            body.innerHTML = `<div class="px-4 py-8 text-center text-rose-600 dark:text-rose-300 text-sm font-bold">تعذر تحميل البيانات</div>`;
        }
    }

    // scroll load more (للداخلي + الحضور + التابات الجديدة القائمة)
    document.addEventListener('DOMContentLoaded', () => {
        const body = document.getElementById('hub-body');
        if (!body) return;

        body.addEventListener('scroll', () => {
            if (!hubOpen) return;

            // ✅ نفس خوارزمية السكّرول مع توسيع بسيط للتابات الجديدة
            const scrollTabs = ['internal','presence','violations','high_requests','absences','honor_rewards','competitions'];
            if (!scrollTabs.includes(hubTab)) return;

            if (!hasMore || loading) return;

            const nearBottom = (body.scrollTop + body.clientHeight) >= (body.scrollHeight - 90);
            if (!nearBottom) return;

            loading = true;
            hubLoad(hubTab).finally(() => loading = false);
        });
    });

    function renderMaintenanceCard(s, maintenanceUrl, logsUrl){
        const warn = !!s.warn;
        const box = warn
          ? "border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-400/20 dark:bg-rose-500/10 dark:text-rose-200"
          : "border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-400/20 dark:bg-emerald-500/10 dark:text-emerald-200";

        const lastHuman = esc(s.last_human || '—');
        const admin = esc(s.admin || '');
        const action = esc(s.action || '');
        const status = esc(s.status || '');

        return `
          <div class="px-3 py-3">
            <div class="rounded-2xl border ${box} px-3 py-3">
              <div class="flex items-start justify-between gap-3">
                <div class="min-w-0">
                  <div class="text-xs font-extrabold">آخر صيانة</div>
                  <div class="text-[11px] mt-0.5 opacity-90">${lastHuman}</div>
                </div>
                <i class="fa-solid fa-screwdriver-wrench text-sm"></i>
              </div>

              <div class="mt-2 text-[10px] opacity-90">
                ${admin ? `• المنفّذ: ${admin}<br>` : ``}
                ${action ? `• action: ${action}<br>` : ``}
                ${status ? `• status: ${status}` : ``}
              </div>

              <div class="mt-3 flex items-center justify-center gap-3 text-[11px] font-extrabold">
                ${maintenanceUrl ? `<a href="${esc(maintenanceUrl)}" class="text-sky-700 hover:text-sky-900 dark:text-sky-200 dark:hover:text-white">🔍 فحص الآن</a>` : ``}
                ${logsUrl ? `<span class="text-slate-400">•</span><a href="${esc(logsUrl)}" class="text-indigo-700 hover:text-indigo-900 dark:text-indigo-200 dark:hover:text-white">📜 سجل الصيانة</a>` : ``}
              </div>
            </div>
          </div>`;
    }

    function renderItemsHtml(tab, items){
        if(!items || items.length === 0){
            return `<div class="px-4 py-10 text-center text-slate-600 dark:text-white/55"><div class="text-sm font-bold">لا يوجد شيء جديد</div></div>`;
        }

        /* =========================================================
           ✅ حضور اليوم (بطاقات — اقتراحك)
           ========================================================= */
        if (tab === 'presence') {
            const cards = items.map(it => {
                const msg = (it.message || '').toString();
                const name = msg.split('•')[0].trim();

                // محاولة استخراج "مدة: XXX د"
                const m = msg.match(/مدة:\s*([0-9]+)\s*د/);
                const mins = m ? m[1] : '';

                return `
                    <div class="flex items-center justify-between gap-3 py-2 px-3 rounded-xl
                                border border-slate-200/70 dark:border-white/10
                                bg-white/70 dark:bg-black/25">
                        <div class="flex items-center gap-2 min-w-0">
                            <span class="w-2 h-2 rounded-full bg-emerald-500"></span>
                            <span class="font-extrabold text-slate-900 dark:text-white truncate">${esc(name || 'عضو')}</span>
                        </div>
                        ${mins ? `<span class="text-[11px] font-extrabold text-emerald-700 dark:text-emerald-200 whitespace-nowrap">${fmtMinsToHM(mins)}</span>` : ``}
                    </div>
                `;
            }).join('');

            return `
                <div class="px-4 py-4">
                    <div class="flex items-center gap-2 mb-2">
                        <i class="fa-solid fa-users text-emerald-600 dark:text-emerald-300"></i>
                        <div class="text-sm font-extrabold text-slate-900 dark:text-white">المتواجدون اليوم داخل البرنامج</div>
                    </div>
                    <div class="text-[11px] text-slate-600 dark:text-white/55 mb-3">
                        يعني: تم رصد وجودهم عبر (Online + Tracking) اليوم.
                    </div>
                    <div class="space-y-2">${cards}</div>
                </div>
            `;
        }

        /* =========================================================
           ✅ باقي التابات (مع إضافات العلامات)
           ========================================================= */
        return items.map(it => {
            const title = esc(it.title || '');
            const msg   = esc(it.message || '');
            const time  = esc(it.time || '');
            const ic    = iconForType(it.type || (tab === 'marks' ? 'marks' : tab));

            // ✅ إضافات العلامات: + / - و “إضافة / خصم” + ألوان
            let marksMeta = '';
            if (tab === 'marks' && it.meta) {
                const p   = Number(it.meta.points || 0);
                const h   = Number(it.meta.hours || 0);
                const src = esc(it.meta.source_type || '');

                const isPos = p > 0;
                const isNeg = p < 0;

                const pillClass = isPos
                    ? "bg-emerald-50 text-emerald-700 border-emerald-200/70 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20"
                    : isNeg
                        ? "bg-rose-50 text-rose-700 border-rose-200/70 dark:bg-rose-500/10 dark:text-rose-200 dark:border-rose-400/20"
                        : "bg-slate-100 text-slate-700 border-slate-200/70 dark:bg-white/5 dark:text-white/70 dark:border-white/10";

                const sign  = (p > 0 ? '+' : '');
                const label = isPos ? 'إضافة' : (isNeg ? 'خصم' : '0');

                marksMeta = `
                    <div class="mt-2 flex flex-wrap items-center gap-2 text-[10px]">
                        <span class="px-2 py-0.5 rounded-full border ${pillClass} font-extrabold">
                            ${label}: ${sign}${p} نقطة
                        </span>

                        ${h ? `
                            <span class="px-2 py-0.5 rounded-full border
                                         bg-sky-50 text-sky-700 border-sky-200/70
                                         dark:bg-white/5 dark:text-white/70 dark:border-white/10 font-extrabold">
                                ${h} س
                            </span>
                        ` : ''}

                        ${src ? `
                            <span class="px-2 py-0.5 rounded-full border
                                         bg-white/80 text-slate-700 border-slate-200/70
                                         dark:bg-black/25 dark:text-white/70 dark:border-white/10 font-bold">
                                ${src}
                            </span>
                        ` : ''}
                    </div>
                `;
            }

            return `
            <div class="border-b border-slate-100 dark:border-white/10 px-3 py-2 hover:bg-slate-50 dark:hover:bg-white/5 transition-colors">
                <div class="flex items-start gap-2.5">
                    <div class="w-8 h-8 rounded-xl flex items-center justify-center border ${ic.wrap} flex-shrink-0">
                        <i class="fa-solid ${ic.icon} text-[12px]"></i>
                    </div>
                    <div class="flex-1 min-w-0">
                        <div class="text-[12px] font-extrabold text-slate-900 dark:text-white truncate">${title}</div>
                        <div class="text-[11px] text-slate-600 dark:text-white/60 mt-0.5 leading-snug">${msg}</div>
                        ${marksMeta}
                        <div class="text-[10px] text-slate-500 dark:text-white/45 mt-1">${time}</div>
                    </div>
                </div>
            </div>`;
        }).join('');
    }

    function setBadge(id, n){
        const el = document.getElementById(id);
        if(!el) return;
        n = Number(n||0);
        if(n <= 0){ el.classList.add('hidden'); el.textContent = '0'; return; }
        el.classList.remove('hidden');
        el.textContent = (n > 99 ? '99+' : String(n));
    }
    function setDot(id, on){
        const el = document.getElementById(id);
        if(!el) return;
        if(on) el.classList.remove('hidden'); else el.classList.add('hidden');
    }
    function esc(s){
        return (s||'').toString()
            .replaceAll('&','&amp;').replaceAll('<','&lt;')
            .replaceAll('>','&gt;')
            .replaceAll('"','&quot;')
            .replaceAll("'","&#039;");
    }
    function formatNum(n){
        n = Number(n||0);
        return (Math.round(n*100)/100).toString();
    }

    // default
    syncHubTab();
    setActiveMain('internal');
    setActiveInternalSub(internalSub);
    setActiveRequestsSub(requestsSub);
    setActiveHonorsSub(honorsSub);

    updateMarksSummaryVisibility();
    updateSubtitle();
    updateMarkReadBtn();
})();
</script>

<script>
    // ================== المتواجدون الآن (Dropdown) فقط ==================
    const onlineDataUrl = "{{ route('superadmin.falcon-room.online-members.data') }}";

    let onlineDropdown     = null;
    let onlineButton       = null;
    let onlineDropdownOpen = false;

    function onlineEscapeHtml(str) {
        if (!str) return '';
        return str.replace(/[&<>"'`=\/]/g, function (s) {
            return ({
                '&': '&amp;',
                '<': '&lt;',
                '>': '&gt;',
                '"': '&quot;',
                "'": '&#39;',
                '/': '&#x2F;',
                '`': '&#x60;',
                '=': '&#x3D;'
            })[s];
        });
    }

    // ✅ نفس الخوارزمية — فقط ستايل أشيك + يدعم دارك
    function onlineMinutesState(mins) {
        if (mins <= 5)  return {label: 'متصل الآن', class: 'bg-emerald-50 text-emerald-700 border border-emerald-200 dark:bg-emerald-500/10 dark:text-emerald-200 dark:border-emerald-400/20'};
        if (mins <= 10) return {label: 'مشغول', class: 'bg-yellow-50 text-yellow-700 border border-yellow-200 dark:bg-yellow-500/10 dark:text-yellow-200 dark:border-yellow-400/20'};
        if (mins <= 30) return {label: 'على وشك الانقطاع', class: 'bg-amber-50 text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-200 dark:border-amber-400/20'};
        return {label: 'غير متصل', class: 'bg-gray-100 text-gray-600 border border-gray-200 dark:bg-white/5 dark:text-white/60 dark:border-white/10'};
    }

    function onlineHumanTime(d) {
        const diffMin = Math.floor((Date.now() - d.getTime()) / 60000);
        if (diffMin < 1)  return 'قبل لحظات';
        if (diffMin < 60) return 'منذ ' + diffMin + ' دقيقة';
        const h = Math.floor(diffMin / 60);
        if (h === 1)  return 'منذ ساعة تقريبًا';
        if (h < 5)    return 'منذ ' + h + ' ساعات';
        return 'منذ أكثر من ' + h + ' ساعة';
    }

    function toggleOnlineDropdown(event) {
        if (event) event.stopPropagation();

        if (!onlineDropdown) {
            onlineDropdown = document.getElementById('online-users-dropdown');
            onlineButton   = onlineDropdown ? onlineDropdown.previousElementSibling : null;
        }
        if (!onlineDropdown) return;

        onlineDropdownOpen = !onlineDropdownOpen;
        onlineDropdown.classList.toggle('hidden', !onlineDropdownOpen);

        if (onlineDropdownOpen) {
            refreshOnlineUsers(true);
        }
    }

    // إغلاق الدروبداون عند الضغط خارج
    document.addEventListener('click', function (event) {
        if (!onlineDropdown) {
            onlineDropdown = document.getElementById('online-users-dropdown');
            onlineButton   = onlineDropdown ? onlineDropdown.previousElementSibling : null;
        }
        if (onlineDropdown && !onlineDropdown.classList.contains('hidden')) {
            if (!onlineButton?.contains(event.target) && !onlineDropdown.contains(event.target)) {
                onlineDropdown.classList.add('hidden');
                onlineDropdownOpen = false;
            }
        }
    });

    function refreshOnlineUsers(force = false) {
        fetch(onlineDataUrl, {
            headers: { 'Accept': 'application/json' }
        })
        .then(r => r.json())
        .then(d => {
            if (!d || !d.users) return;
            updateOnlineBadge(d.users);
            if (onlineDropdownOpen || force) {
                renderOnlineDropdown(d.users);
            }
        })
        .catch(err => console.error('خطأ في جلب المتواجدين الآن:', err));
    }

    function updateOnlineBadge(list) {
        const badge = document.getElementById('online-users-badge');
        const pulse = document.getElementById('online-users-pulse');
        if (!badge) return;

        const now = Date.now();
        let onlineNow = 0, busy = 0, almost = 0;

        (list || []).forEach(u => {
            if (!u.last_visit_iso) return;
            const dt   = new Date(u.last_visit_iso);
            const mins = Math.floor((now - dt.getTime()) / 60000);

            if (mins <= 5)       onlineNow++;
            else if (mins <= 10) busy++;
            else if (mins <= 30) almost++;
        });

        const total = onlineNow + busy + almost;
        badge.textContent = total > 99 ? '99+' : total;

        if (pulse) {
            pulse.classList.remove('bg-emerald-400', 'bg-amber-400', 'bg-slate-400');
            if (onlineNow > 0) {
                pulse.classList.add('bg-emerald-400');
            } else if (busy > 0 || almost > 0) {
                pulse.classList.add('bg-amber-400');
            } else {
                pulse.classList.add('bg-slate-400');
            }
        }
    }

    function renderOnlineDropdown(list) {
        const container = document.getElementById('online-users-list');
        const totalEl   = document.getElementById('online-users-header-count');
        if (!container) return;

        const now = Date.now();

        // نفس منطق صفحة الحضور: نشط لو آخر نشاط خلال 30 دقيقة
        const active = (list || []).filter(u => {
            if (!u.last_visit_iso) return false;
            const dt   = new Date(u.last_visit_iso);
            const mins = Math.floor((now - dt.getTime()) / 60000);
            return mins <= 30;
        });

        if (totalEl) totalEl.textContent = active.length;

        if (!active.length) {
            container.innerHTML = `
                <div class="px-4 py-8 text-center text-slate-600 dark:text-white/55 text-sm font-bold">
                    لا يوجد أعضاء نشطين حاليًا في زمن الفوزي ✨
                </div>
            `;
            return;
        }

        const top = active.slice(0, 10); // أول 10 فقط
        container.innerHTML = top.map(u => renderOnlineItem(u, now)).join('');
    }

    function renderOnlineItem(u, nowTs) {
        const d    = u.last_visit_iso ? new Date(u.last_visit_iso) : null;
        const mins = d ? Math.floor((nowTs - d.getTime()) / 60000) : 9999;
        const st   = onlineMinutesState(mins);
        const ht   = d ? onlineHumanTime(d) : 'غير معروف';

        const avatar = u.avatar_url
            ? u.avatar_url
            : 'https://ui-avatars.com/api/?background=0D9488&color=fff&name=' + encodeURIComponent(u.name || 'عضو');

        const place    = u.current_place || 'غير محدد';
        const username = u.username || '';
        const id       = u.id || '';

        return `
            <div class="px-4 py-3 border-b border-slate-100/80 dark:border-white/10 last:border-0">
                <div class="flex items-start gap-3">
                    <img src="${avatar}"
                         class="w-8 h-8 rounded-2xl object-cover flex-shrink-0 ring-1 ring-slate-200 dark:ring-white/10"
                         alt="${onlineEscapeHtml(u.name ?? '')}">
                    <div class="flex-1 min-w-0">
                        <div class="flex items-center justify-between gap-2">
                            <p class="text-xs sm:text-sm font-extrabold text-slate-950 dark:text-white truncate">
                                ${onlineEscapeHtml(u.name ?? '')}
                            </p>
                            <span class="px-2 py-0.5 rounded-full text-[10px] font-bold ${st.class} whitespace-nowrap">
                                ${st.label}
                            </span>
                        </div>
                        <p class="text-[10px] text-slate-600 dark:text-white/55 mt-0.5 truncate">
                            @${onlineEscapeHtml(username)} • #${id}
                        </p>
                        <p class="mt-1 text-[11px] text-slate-700 dark:text-white/70 line-clamp-1">
                            <span class="font-extrabold">المكان:</span> ${onlineEscapeHtml(place)}
                        </p>
                        <p class="mt-0.5 text-[10px] text-slate-500 dark:text-white/45">
                            آخر ظهور (زمن الفوزي): ${ht}
                        </p>
                    </div>
                </div>
            </div>
        `;
    }

    document.addEventListener('DOMContentLoaded', function () {
        refreshOnlineUsers(true);
        setInterval(refreshOnlineUsers, 20000); // كل 20 ثانية
    });
</script>
@endpush

@push('scripts')
<script>
// Use window to avoid redeclaration errors if scripts are re-run
window.notificationsDropdown = window.notificationsDropdown || null;
window.notificationsButton   = window.notificationsButton   || null;

// عداد + مؤقت
window.notificationsCountEl  = window.notificationsCountEl  || null;
window.notificationsPollerId = window.notificationsPollerId || null;

function getCsrf() {
    return document.querySelector('meta[name="csrf-token"]')?.content || '';
}

function toggleNotificationsDropdown(event) {
    if (event) event.stopPropagation();

    if (!window.notificationsDropdown) {
        window.notificationsDropdown = document.getElementById('top-notifications-dropdown');
        window.notificationsButton   = window.notificationsDropdown?.previousElementSibling;
    }

    if (window.notificationsDropdown) {
        window.notificationsDropdown.classList.toggle('hidden');
    }
}

// إغلاق القائمة عند الضغط خارجها
document.addEventListener('click', function(event) {
    if (!window.notificationsDropdown) {
        window.notificationsDropdown = document.getElementById('top-notifications-dropdown');
        window.notificationsButton   = window.notificationsDropdown?.previousElementSibling;
    }

    if (window.notificationsDropdown && !window.notificationsDropdown.classList.contains('hidden')) {
        if (!window.notificationsButton?.contains(event.target) && !window.notificationsDropdown.contains(event.target)) {
            window.notificationsDropdown.classList.add('hidden');
        }
    }
});

/**
 * ✅ تحديث العداد فقط (AJAX)
 * لازم endpoint يرجع JSON مثل: { unread_count: 5 }
 */
function refreshNotificationsCount() {
    // ما تحدّث والتاب مخفي (يوفّر موارد)
    if (document.hidden) return;

    fetch('/superadmin/notifications/poll-count', {
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'X-Requested-With': 'XMLHttpRequest'
        },
        cache: 'no-store'
    })
    .then(r => r.ok ? r.json() : Promise.reject(r.status))
    .then(data => {
        // بدك تحط ID لعنصر العداد بالـ Blade: id="top-notifications-count"
        if (!window.notificationsCountEl) {
            window.notificationsCountEl = document.getElementById('top-notifications-count');
        }

        if (window.notificationsCountEl && typeof data.unread_count !== 'undefined') {
            const n = Number(data.unread_count) || 0;
            window.notificationsCountEl.textContent = String(n);
            window.notificationsCountEl.classList.toggle('hidden', n <= 0);
        }
    })
    .catch(() => {});
}

function markAsRead(notificationId) {
    fetch(`/superadmin/notifications/${notificationId}/read`, {
        method: 'POST',
        headers: {
            'X-CSRF-TOKEN': getCsrf(),
            'Accept': 'application/json',
            'X-Requested-With': 'XMLHttpRequest'
        }
    })
    .then(r => r.ok ? r.json() : Promise.reject(r.status))
    .then(() => {
        // بدل reload
        refreshNotificationsCount();
    })
    .catch(error => console.error('خطأ في وضع الإشعار كمقروء:', error));
}

function markAllAsRead() {
    fetch('/superadmin/notifications/mark-all-read', {
        method: 'POST',
        headers: {
            'X-CSRF-TOKEN': getCsrf(),
            'Accept': 'application/json',
            'X-Requested-With': 'XMLHttpRequest'
        }
    })
    .then(r => r.ok ? r.json() : Promise.reject(r.status))
    .then(() => {
        // بدل reload
        refreshNotificationsCount();
    })
    .catch(error => console.error('خطأ في وضع جميع الإشعارات كمقروءة:', error));
}

// تشغيل التحديث كل ثانية
document.addEventListener('DOMContentLoaded', function() {
    window.notificationsDropdown = document.getElementById('top-notifications-dropdown');
    window.notificationsButton   = window.notificationsDropdown?.previousElementSibling;
    window.notificationsCountEl  = document.getElementById('top-notifications-count');

    // تحديث أول ما تفتح الصفحة
    refreshNotificationsCount();

    // امنع تكرار setInterval إذا السكربت انحقن أكثر من مرة
    if (window.notificationsPollerId) clearInterval(window.notificationsPollerId);
    window.notificationsPollerId = setInterval(refreshNotificationsCount, 1000);
});

// تحديث فوري لما يرجع التاب
document.addEventListener('visibilitychange', function() {
    if (!document.hidden) refreshNotificationsCount();
});
</script>


@endpush

<!-- Page Content -->
<main class="relative p-4 sm:p-6 lg:p-8 min-h-screen">
    @if (session('success'))
      <div class="mb-4 sm:mb-6 rounded-3xl border border-emerald-200/70 dark:border-emerald-400/20
                  bg-gradient-to-br from-emerald-50 via-white to-white
                  dark:from-emerald-500/10 dark:via-black/40 dark:to-black/40
                  text-emerald-800 dark:text-emerald-100 shadow-lg">
        <div class="p-4 sm:p-5 flex items-start gap-3">
          <div class="w-10 h-10 rounded-2xl bg-emerald-500/10 border border-emerald-400/20 grid place-items-center text-emerald-700 dark:text-emerald-200 flex-shrink-0">
            <i class="fa-solid fa-circle-check"></i>
          </div>
          <div class="min-w-0">
            <div class="text-sm sm:text-base font-extrabold">تم بنجاح</div>
            <div class="text-sm sm:text-base mt-0.5 break-words">{{ session('success') }}</div>
          </div>
        </div>
      </div>
    @endif

    @if (session('error'))
      <div class="mb-4 sm:mb-6 rounded-3xl border border-rose-200/70 dark:border-rose-400/20
                  bg-gradient-to-br from-rose-50 via-white to-white
                  dark:from-rose-500/10 dark:via-black/40 dark:to-black/40
                  text-rose-800 dark:text-rose-100 shadow-lg">
        <div class="p-4 sm:p-5 flex items-start gap-3">
          <div class="w-10 h-10 rounded-2xl bg-rose-500/10 border border-rose-400/20 grid place-items-center text-rose-700 dark:text-rose-200 flex-shrink-0">
            <i class="fa-solid fa-triangle-exclamation"></i>
          </div>
          <div class="min-w-0">
            <div class="text-sm sm:text-base font-extrabold">حدث خطأ</div>
            <div class="text-sm sm:text-base mt-0.5 break-words">{{ session('error') }}</div>
          </div>
        </div>
      </div>
    @endif

    @yield('content')
</main>

</div>


    <!-- Mobile Sidebar Overlay -->
    <div id="sidebar-overlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden lg:hidden backdrop-blur-sm"></div>

    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
    <script>
        // Current Time Display
        function updateTime() {
            const now = new Date();
            const timeString = now.toLocaleString('ar-EG', {
                weekday: 'short',
                hour: '2-digit',
                minute: '2-digit'
            });
            const timeElement = document.getElementById('current-time');
            if (timeElement) {
                timeElement.textContent = timeString;
            }
        }
        updateTime();
        setInterval(updateTime, 60000);

        // Sidebar Dropdowns
        function toggleDropdown(dropdownId) {
            const dropdown = document.getElementById(dropdownId);
            if (!dropdown) return;

            const button = dropdown.previousElementSibling;
            const arrow = button?.querySelector('svg:last-child');

            dropdown.classList.toggle('active');
            if (arrow) {
                arrow.style.transform = dropdown.classList.contains('active') ? 'rotate(180deg)' : 'rotate(0deg)';
            }
        }

        // Notifications Dropdown
// notificationsDropdown and notificationsButton are now managed via window object above

        function toggleNotificationsDropdown(event) {
            if (event) event.stopPropagation();

            if (!notificationsDropdown) {
                notificationsDropdown = document.getElementById('top-notifications-dropdown');
                notificationsButton = notificationsDropdown?.previousElementSibling;
            }

            if (notificationsDropdown) {
                notificationsDropdown.classList.toggle('hidden');
            }
        }

        // Close notifications dropdown when clicking outside
        document.addEventListener('click', function(event) {
            if (!notificationsDropdown) {
                notificationsDropdown = document.getElementById('top-notifications-dropdown');
                notificationsButton = notificationsDropdown?.previousElementSibling;
            }

            if (notificationsDropdown && !notificationsDropdown.classList.contains('hidden')) {
                if (!notificationsButton?.contains(event.target) && !notificationsDropdown.contains(event.target)) {
                    notificationsDropdown.classList.add('hidden');
                }
            }
        });

        // Mark notifications as read
        function markAsRead(notificationId) {
            fetch(`/superadmin/notifications/${notificationId}/read`, {
                method: 'POST',
                headers: {
                    'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                    'Accept': 'application/json'
                }
            })
            .then(response => response.json())
            .then(() => location.reload())
            .catch(error => console.error('خطأ في وضع الإشعار كمقروء:', error));
        }

        function markAllAsRead() {
            fetch('/superadmin/notifications/mark-all-read', {
                method: 'POST',
                headers: {
                    'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                    'Accept': 'application/json'
                }
            })
            .then(response => response.json())
            .then(() => location.reload())
            .catch(error => console.error('خطأ في وضع جميع الإشعارات كمقروءة:', error));
        }

        // Auto-open active dropdowns on page load
        document.addEventListener('DOMContentLoaded', function() {
            notificationsDropdown = document.getElementById('top-notifications-dropdown');
            notificationsButton = notificationsDropdown?.previousElementSibling;

            const activeDropdowns = document.querySelectorAll('.dropdown-menu');
            activeDropdowns.forEach(dropdown => {
                const hasActiveLink = dropdown.querySelector('a[class*="bg-white/20"]');
                if (hasActiveLink) {
                    dropdown.classList.add('active');
                    const arrow = dropdown.previousElementSibling?.querySelector('svg:last-child');
                    if (arrow) arrow.style.transform = 'rotate(180deg)';
                }
            });

            updateNotificationsBadge();
        });

        // Sidebar Toggle (Mobile)
        const sidebarToggle = document.getElementById('sidebar-toggle');
        const sidebar = document.getElementById('sidebar');
        const sidebarOverlay = document.getElementById('sidebar-overlay');

        sidebarToggle?.addEventListener('click', () => {
            sidebar.classList.toggle('open');
            sidebarOverlay.classList.toggle('hidden');
            document.body.style.overflow = sidebar.classList.contains('open') ? 'hidden' : '';
        });

        function closeSidebar() {
            sidebar.classList.remove('open');
            sidebarOverlay.classList.add('hidden');
            document.body.style.overflow = '';
        }

        sidebarOverlay?.addEventListener('click', closeSidebar);

        document.addEventListener('keydown', (e) => {
            if (e.key === 'Escape' && sidebar.classList.contains('open')) {
                closeSidebar();
            }
        });

        window.addEventListener('resize', () => {
            if (window.innerWidth >= 1024) {
                sidebar.classList.remove('open');
                sidebarOverlay.classList.add('hidden');
                document.body.style.overflow = '';
            }
        });

        // Update Notifications Badge
        function updateNotificationsBadge() {
            fetch('/api/notifications/unread-count')
                .then(response => response.json())
                .then(data => {
                    const badge = document.getElementById('sidebar-notification-badge');
                    const count = document.getElementById('sidebar-notification-count');

                    if (badge && count) {
                        if (data.unread_count > 0) {
                            badge.classList.remove('hidden');
                            count.textContent = data.unread_count > 99 ? '99+' : data.unread_count;
                        } else {
                            badge.classList.add('hidden');
                        }
                    }
                })
                .catch(error => console.error('خطأ في تحديث عداد الإشعارات:', error));
        }

        setInterval(updateNotificationsBadge, 30000);
    </script>
    
     <script>
        // دالة للتحكم في مؤشر السكرول
        function updateScrollIndicator() {
            const scrollContainer = document.querySelector('.sidebar-scroll');
            const indicator = document.getElementById('scroll-indicator');
            
            if (!scrollContainer || !indicator) return;
            
            const hasScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;
            const isAtBottom = Math.abs(scrollContainer.scrollHeight - scrollContainer.clientHeight - scrollContainer.scrollTop) < 5;
            
            if (hasScroll && !isAtBottom) {
                indicator.classList.add('visible');
            } else {
                indicator.classList.remove('visible');
            }
        }

        // استدعاء الدالة عند التحميل والسكرول
        document.addEventListener('DOMContentLoaded', function() {
            const scrollContainer = document.querySelector('.sidebar-scroll');
            if (scrollContainer) {
                scrollContainer.addEventListener('scroll', updateScrollIndicator);
                updateScrollIndicator();
            }
        });

        // باقي السكريبتات كما هي...
        function toggleDropdown(dropdownId) {
            const dropdown = document.getElementById(dropdownId);
            if (!dropdown) return;

            const button = dropdown.previousElementSibling;
            const arrow = button?.querySelector('svg:last-child');

            dropdown.classList.toggle('active');
            if (arrow) {
                arrow.style.transform = dropdown.classList.contains('active') ? 'rotate(180deg)' : 'rotate(0deg)';
            }
            
            // تحديث مؤشر السكرول بعد فتح/إغلاق القائمة
            setTimeout(updateScrollIndicator, 300);
        }
    </script>
    @stack('scripts')

@php
    // 🔥 تحكم رئيسي — غلّق النظام كامل
    $MAINTENANCE = false; // ← غيّرها إلى false لإلغاء الصيانة

    $tz = config('app.timezone','Asia/Jerusalem');
    $until = \Carbon\Carbon::today($tz)->setTime(15,0,0);
@endphp

@if($MAINTENANCE)
<style>
    body { overflow: hidden !important; }
</style>
{{-- Messenger Chat Widget --}}

<div id="maint"
     class="fixed inset-0 z-[999999] flex items-center justify-center bg-slate-950/90 backdrop-blur-2xl">

    <div class="max-w-md w-full mx-6 bg-slate-900/80 border border-emerald-500/30 rounded-3xl shadow-2xl p-6 text-center text-white relative overflow-hidden">

        {{-- تأثيرات --}}
        <div class="absolute -top-20 -left-20 w-60 h-60 bg-emerald-500/20 blur-3xl rounded-full"></div>
        <div class="absolute -bottom-20 -right-10 w-60 h-60 bg-cyan-500/20 blur-3xl rounded-full"></div>

        <div class="relative space-y-4">

            <h1 class="text-xl font-bold">
                ⚙️ جاري تحديث قواعد البيانات والسيرفر
            </h1>

            <p class="text-sm text-gray-300 leading-relaxed">
                يتم الآن <span class="text-emerald-300 font-semibold">تجديد الذكاء الاصطناعي</span>  
                وتحسين نظام فريق الوفاء الذهبي. الرجاء الانتظار حتى انتهاء الصيانة.
            </p>

            <div class="mt-4">
                <div class="text-xs text-gray-400 mb-1">الوقت المتبقي:</div>

                <div id="countdown"
                     class="px-4 py-2 rounded-2xl bg-black/40 border border-emerald-400/40 text-lg font-mono inline-flex gap-2">
                    <span id="h">00</span>:<span id="m">00</span>:<span id="s">00</span>
                </div>

                <div class="mt-1 text-[11px] text-gray-400">
                    حتى الساعة <b>{{ $until->format('H:i') }}</b>
                </div>
            </div>

            <p class="text-[11px] text-gray-500">
                سيتم إعادة فتح النظام تلقائيًا فور انتهاء العد التنازلي.
            </p>

        </div>

    </div>
</div>
{{-- 🌟 Dock نقاطك - ثابت أسفل الشاشة --}}
<div class="fixed inset-x-0 bottom-3 z-40 pointer-events-none">
    <div class="flex justify-center">
        <div class="pointer-events-auto">
            <div class="flex items-center gap-2
                        rounded-full
                        bg-white/90 dark:bg-slate-900/95
                        border border-indigo-100/80 dark:border-indigo-800/70
                        px-4 py-2
                        shadow-lg shadow-slate-900/15">

                {{-- النص --}}
                <span class="text-xs sm:text-sm font-semibold
                             text-indigo-700 dark:text-indigo-200">
                    نقاطك: {{ number_format(auth()->user()->total_points) }}
                </span>

                {{-- أيقونة النجمة --}}
                <span class="inline-flex items-center justify-center
                             w-5 h-5 rounded-full
                             bg-indigo-100 dark:bg-indigo-800
                             text-indigo-600 dark:text-indigo-100">
                    <i class="fa-solid fa-star text-[11px]"></i>
                </span>
            </div>
        </div>
    </div>
</div>
@include('partials.falcon-i18n')
<script>
(function(){
    const end = new Date(@json($until->format('Y-m-d\\TH:i:sP')));
    const h = document.getElementById('h');
    const m = document.getElementById('m');
    const s = document.getElementById('s');
    const box = document.getElementById('maint');

    function pad(n){ return n<10?"0"+n:n; }

    function tick(){
        const now = new Date();
        let diff = Math.floor((end - now) / 1000);

        if(diff <= 0){
            box.remove();
            return;
        }

        const H = Math.floor(diff/3600);
        diff -= H*3600;
        const M = Math.floor(diff/60);
        const S = diff % 60;

        h.textContent = pad(H);
        m.textContent = pad(M);
        s.textContent = pad(S);
    }

    tick();
    setInterval(tick, 1000);
})();
</script>
@endif

@auth
    @php
        $title = trim($__env->yieldContent('title','غير محدد'));

        if ($title) {
            \Illuminate\Support\Facades\DB::table('user_live_sessions')
                ->where('user_id', auth()->id())
                ->where('is_active', 1)
                ->update([
                    'current_page' => mb_substr($title, 0, 191),
                    'last_seen_at' => now(),
                ]);
        }
    @endphp
@endauth


</body>
</html>
