<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <title><?php echo $__env->yieldContent('title', 'Dashboard'); ?> - <?php echo e(setting('site_name', config('app.name'))); ?></title>

    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">

    <style>
        :root {
            --sidebar-width: 260px;
            --sidebar-collapsed-width: 64px;
            --topbar-height: 60px;
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f8f9fa;
        }

        /* Sidebar */
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            width: var(--sidebar-width);
            background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
            color: white;
            overflow-y: auto;
            z-index: 1000;
            box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        }
        .sidebar.collapsed {
            width: var(--sidebar-collapsed-width);
        }
        body.sidebar-collapsed .sidebar {
            width: var(--sidebar-collapsed-width);
        }

        .sidebar-header {
            padding: 20px;
            background: rgba(0,0,0,0.2);
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }

        .sidebar-header h4 {
            margin: 0;
            font-weight: 600;
            font-size: 20px;
        }

        .sidebar-menu {
            padding: 20px 0;
        }

        .menu-item {
            display: block;
            padding: 12px 20px;
            color: rgba(255,255,255,0.8);
            text-decoration: none;
            transition: all 0.3s;
            border-left: 3px solid transparent;
            position: relative;
        }

        .menu-item:hover {
            background: rgba(255,255,255,0.1);
            color: white;
            border-left-color: #667eea;
        }

        .menu-item.active {
            background: rgba(102, 126, 234, 0.2);
            color: white;
            border-left-color: #667eea;
        }

        .menu-item i {
            width: 20px;
            margin-right: 10px;
        }
        .menu-label {
            display: inline-block;
            vertical-align: middle;
        }

        .menu-section,
        .menu-section-toggle {
            padding: 10px 20px 6px;
            font-size: 12.5px;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            color: rgba(255,255,255,0.5);
        }
        .menu-section-toggle {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: transparent;
            border: 0;
            text-align: left;
            cursor: pointer;
        }
        .menu-section-label {
            display: inline-block;
            vertical-align: middle;
        }
        .menu-section i,
        .menu-section-toggle i {
            margin-right: 8px;
            font-size: 13px;
            vertical-align: -1px;
        }
        .menu-section-toggle-main {
            display: inline-flex;
            align-items: center;
            min-width: 0;
        }
        .menu-section-chevron {
            margin-right: 0 !important;
            font-size: 12px !important;
            transition: transform 0.2s ease, opacity 0.2s ease;
        }
        .menu-group:not(.is-open) .menu-section-chevron {
            transform: rotate(-90deg);
        }
        .menu-group-items {
            display: none;
        }
        .menu-group.is-open .menu-group-items {
            display: block;
        }
        .menu-site-heading {
            margin: 10px 14px 6px;
            padding: 10px 12px;
            border-top: none;
            border-radius: 8px;
            background: #f8fafc;
            border: 1px solid rgba(15, 23, 42, 0.12);
            font-size: 16px;
            text-transform: none;
            letter-spacing: 0;
            color: #0f172a;
            font-weight: 700;
        }
        .menu-site-heading i {
            color: #334155;
        }
        .site-menu-block {
            margin: 10px 12px 14px;
            padding: 8px;
            border-radius: 12px;
            border: 1px solid rgba(255,255,255,0.16);
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
        }
        .site-menu-block .menu-site-heading {
            margin: 0 0 6px;
            padding: 10px 12px;
        }
        .site-menu-block .menu-item {
            padding: 10px 12px;
            margin: 3px 0 0;
            border-left-width: 2px;
            border-radius: 8px;
        }
        .site-menu-block .menu-item i {
            margin-right: 9px;
        }
        .site-menu-block.site-theme-red {
            background: linear-gradient(180deg, #3b1313 0%, #250d0d 100%);
            border-color: rgba(227, 32, 20, 0.45);
            box-shadow: inset 0 0 0 1px rgba(227, 32, 20, 0.18);
        }
        .site-menu-block.site-theme-red .menu-site-heading {
            background: #f8fafc;
            border-color: rgba(120, 25, 25, 0.35);
            color: #3c1111;
        }
        .site-menu-block.site-theme-red .menu-site-heading i {
            color: #6f1d1d;
        }
        .site-menu-block.site-theme-red .menu-item:hover {
            background: rgba(227, 32, 20, 0.28);
            border-left-color: #f87171;
        }
        .site-menu-block.site-theme-red .menu-item.active {
            background: rgba(239, 68, 68, 0.36);
            border-left-color: #fecaca;
        }
        .site-menu-block.site-theme-gold {
            background: linear-gradient(180deg, #322214 0%, #21160f 100%);
            border-color: rgba(224, 131, 47, 0.48);
            box-shadow: inset 0 0 0 1px rgba(224, 131, 47, 0.2);
        }
        .site-menu-block.site-theme-gold .menu-site-heading {
            background: #f8fafc;
            border-color: rgba(121, 74, 22, 0.35);
            color: #3c2511;
        }
        .site-menu-block.site-theme-gold .menu-site-heading i {
            color: #8a5218;
        }
        .site-menu-block.site-theme-gold .menu-item:hover {
            background: rgba(224, 131, 47, 0.24);
            border-left-color: #facc15;
        }
        .site-menu-block.site-theme-gold .menu-item.active {
            background: rgba(217, 119, 6, 0.34);
            border-left-color: #fde68a;
        }

        /* Topbar */
        .topbar {
            position: fixed;
            top: 0;
            left: var(--sidebar-width);
            right: 0;
            height: var(--topbar-height);
            background: white;
            border-bottom: 1px solid #e0e0e0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 30px;
            z-index: 999;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        }
        body.sidebar-collapsed .topbar {
            left: var(--sidebar-collapsed-width);
        }

        .topbar-left h5 {
            margin: 0;
            font-weight: 600;
            color: #333;
        }

        .topbar-right {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .notification-btn {
            position: relative;
            background: none;
            border: none;
            font-size: 20px;
            color: #666;
            cursor: pointer;
            transition: color 0.3s;
        }

        .notification-btn:hover {
            color: #667eea;
        }

        .notification-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background: #dc3545;
            color: white;
            border-radius: 10px;
            padding: 2px 6px;
            font-size: 10px;
            font-weight: bold;
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
        }

        .user-avatar i {
            font-size: 18px;
        }

        .dropdown-icon {
            font-size: 12px;
            color: #888;
        }

        /* Main Content */
        .main-content {
            margin-left: var(--sidebar-width);
            margin-top: var(--topbar-height);
            padding: 30px;
            min-height: calc(100vh - var(--topbar-height));
        }
        body.sidebar-collapsed .main-content {
            margin-left: var(--sidebar-collapsed-width);
        }

        .sidebar-toggle {
            background: none;
            border: none;
            color: #4b5563;
            font-size: 20px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            transition: background 0.2s, color 0.2s;
            cursor: pointer;
            margin-right: 10px;
        }
        .sidebar-toggle:hover {
            background: #f1f5f9;
            color: #1f2937;
        }

        body.sidebar-collapsed .sidebar-header h4,
        body.sidebar-collapsed .sidebar-header small,
        body.sidebar-collapsed .menu-label,
        body.sidebar-collapsed .menu-section-label {
            display: none;
        }
        body.sidebar-collapsed .sidebar-header {
            text-align: center;
        }
        body.sidebar-collapsed .sidebar-header i {
            margin-bottom: 0;
        }
        body.sidebar-collapsed .menu-item {
            padding: 12px 16px;
        }
        body.sidebar-collapsed .menu-item i {
            margin-right: 0;
        }
        body.sidebar-collapsed .menu-section,
        body.sidebar-collapsed .menu-section-toggle {
            padding: 10px 16px 6px;
        }
        body.sidebar-collapsed .menu-section-toggle {
            justify-content: center;
        }
        body.sidebar-collapsed .menu-section-chevron,
        body.sidebar-collapsed .menu-group-items {
            display: none !important;
        }
        body.sidebar-collapsed .menu-site-heading {
            margin: 10px 8px 6px;
            padding: 10px 8px;
            text-align: center;
        }
        body.sidebar-collapsed .menu-site-heading i {
            margin-right: 0;
        }
        body.sidebar-collapsed .site-menu-block {
            margin: 10px 6px 12px;
            padding: 6px;
        }
        body.sidebar-collapsed .site-menu-block .menu-item {
            padding: 10px 8px;
        }
        body.sidebar-collapsed .site-menu-block .menu-item i {
            margin-right: 0;
        }
        body.sidebar-collapsed .site-menu-block .menu-site-heading {
            margin: 0 0 6px;
            padding: 10px 8px;
        }
        .sidebar-hover-label {
            position: fixed;
            left: 0;
            top: 0;
            transform: translateY(-50%);
            background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
            color: #ffffff;
            border: 1px solid rgba(102, 126, 234, 0.8);
            border-radius: 8px;
            padding: 7px 11px;
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;
            box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
            z-index: 3000;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.12s ease-in-out;
        }
        .sidebar-hover-label.is-visible {
            opacity: 1;
        }

        /* Cards */
        .card {
            border: none;
            border-radius: 10px;
        }

        .card-header {
            background: white;
            border-bottom: 1px solid #e0e0e0;
            padding: 15px 20px;
            font-weight: 600;
        }

        /* Action buttons in tables */
        .table .btn-group.btn-group-sm {
            display: inline-flex;
            flex-wrap: nowrap;
        }

        .table .btn-group.btn-group-sm .btn {
            min-width: 38px;
            padding: 0.35rem 0.55rem;
        }

        /* Scrollbar */
        .sidebar::-webkit-scrollbar {
            width: 6px;
        }

        .sidebar::-webkit-scrollbar-track {
            background: rgba(0,0,0,0.1);
        }

        .sidebar::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.2);
            border-radius: 3px;
        }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.3);
        }
    </style>

    <?php echo $__env->yieldPushContent('styles'); ?>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar">
        <div class="sidebar-header">
            <i class="bi bi-shield-lock fs-3 mb-2"></i>
            <h4><?php echo e(setting('site_name', 'Finance Panel')); ?></h4>
            <small class="text-light">Backoffice</small>
        </div>

        <div class="sidebar-menu">
            <?php
                $sidebarSites = \App\Models\Site::orderBy('name')->get();
                $activeSiteRouteValue = request()->route('site');
                $activeSiteId = $activeSiteRouteValue instanceof \App\Models\Site
                    ? (int) $activeSiteRouteValue->id
                    : (is_numeric($activeSiteRouteValue) ? (int) $activeSiteRouteValue : null);

                $canDashboard = can_access('dashboard');
                $canCrm = can_access('crm');
                $canDeposits = can_access('deposits');
                $canWithdrawals = can_access('withdrawals');
                $canTransactionLogs = can_access('transaction_logs');
                $canFinanceGroups = can_access('finance_groups');
                $canBankAccounts = can_access('bank_accounts');
                $canCryptoAccounts = can_access('crypto_accounts');
                $canFinanceUsers = can_access('finance_users');
                $canPermissions = can_access('permissions');
                $canUsers = can_access('users');
                $canCannedResponses = can_access('canned_responses');
                $canBlacklist = can_access('blacklist');
                $canSites = can_access('sites');
                $canPaymentPopups = can_access('payment_popups');
                $canSettings = can_access('settings');
                $canReports = can_access('reports');
                $canActivityLogs = can_access('activity_logs');

                $showGeneralSection = $canDashboard || $canCrm;
                $showTransactionsSection = $canDeposits || $canWithdrawals || $canTransactionLogs;
                $showFinanceSection = $canFinanceGroups || $canBankAccounts || $canCryptoAccounts || $canFinanceUsers;
                $showAccessSection = $canPermissions || $canUsers;
                $showSystemSection = $canCannedResponses || $canBlacklist || $canSites || $canPaymentPopups || $canSettings || $canReports || $canActivityLogs;

                $generalOpen = request()->routeIs('backoffice.dashboard')
                    || request()->routeIs('backoffice.crm.*');
                $transactionsOpen = request()->routeIs('backoffice.sites.deposits.*')
                    || request()->routeIs('backoffice.sites.withdrawals.*')
                    || request()->routeIs('backoffice.transaction-logs.*');
                $financeOpen = request()->routeIs('backoffice.finance-groups.*')
                    || request()->routeIs('backoffice.bank-accounts.*')
                    || request()->routeIs('backoffice.crypto-accounts.*')
                    || request()->routeIs('backoffice.finance-users.*');
                $accessOpen = request()->routeIs('backoffice.permissions.*')
                    || request()->routeIs('backoffice.users.*');
                $systemOpen = request()->routeIs('backoffice.canned-responses.*')
                    || request()->routeIs('backoffice.blacklist.*')
                    || request()->routeIs('backoffice.sites.index')
                    || request()->routeIs('backoffice.sites.show')
                    || request()->routeIs('backoffice.sites.update')
                    || request()->routeIs('backoffice.sites.toggle-status')
                    || request()->routeIs('backoffice.sites.destroy')
                    || request()->routeIs('backoffice.payment-popups.*')
                    || request()->routeIs('backoffice.settings*')
                    || request()->routeIs('backoffice.reports*')
                    || request()->routeIs('backoffice.activity-logs.*');
            ?>

            <?php if($showGeneralSection): ?>
            <div class="menu-group <?php echo e($generalOpen ? 'is-open' : ''); ?>" data-menu-group="general">
                <button type="button" class="menu-section-toggle" data-label="Genel">
                    <span class="menu-section-toggle-main">
                        <i class="bi bi-grid"></i>
                        <span class="menu-section-label">Genel</span>
                    </span>
                    <i class="bi bi-chevron-down menu-section-chevron"></i>
                </button>
                <div class="menu-group-items">
                    <?php if($canDashboard): ?>
                    <a href="<?php echo e(route('backoffice.dashboard', ['fresh' => time()])); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.dashboard') ? 'active' : ''); ?>">
                        <i class="bi bi-speedometer2"></i>
                        Dashboard
                    </a>
                    <?php endif; ?>
                    <?php if($canCrm): ?>
                    <a href="<?php echo e(route('backoffice.crm.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.crm.*') ? 'active' : ''); ?>">
                        <i class="bi bi-person-lines-fill"></i>
                        Mini CRM
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; ?>

            <?php if($showTransactionsSection): ?>
            <div class="menu-group <?php echo e($transactionsOpen ? 'is-open' : ''); ?>" data-menu-group="transactions">
                <button type="button" class="menu-section-toggle" data-label="Islemler">
                    <span class="menu-section-toggle-main">
                        <i class="bi bi-arrow-left-right"></i>
                        <span class="menu-section-label">Islemler</span>
                    </span>
                    <i class="bi bi-chevron-down menu-section-chevron"></i>
                </button>
                <div class="menu-group-items">
                    <?php $__currentLoopData = $sidebarSites; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sidebarSite): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($canDeposits || $canWithdrawals): ?>
                    <?php
                        $siteSid = (string) ($sidebarSite->sid ?? '');
                        if ($siteSid === 'pg_sid_7qcu15y1ippvtsh1wv3cbc70cugxp1ci') {
                            $siteThemeClass = 'site-theme-red';
                        } elseif ($siteSid === 'pg_sid_8f3c1b2a4d5e6f708192a3b4c5d6e7f8') {
                            $siteThemeClass = 'site-theme-gold';
                        } else {
                            $siteThemeClass = ($loop->iteration % 2 === 1) ? 'site-theme-red' : 'site-theme-gold';
                        }
                    ?>
                    <div class="site-menu-block <?php echo e($siteThemeClass); ?>">
                        <div class="menu-section menu-site-heading">
                            <i class="bi bi-globe2"></i> <?php echo e($sidebarSite->name); ?>

                        </div>
                        <?php if($canDeposits): ?>
                        <a href="<?php echo e(route('backoffice.sites.deposits.index', $sidebarSite->id)); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.sites.deposits.*') && $activeSiteId === (int) $sidebarSite->id ? 'active' : ''); ?>">
                            <i class="bi bi-arrow-down-circle"></i>
                            Yatirimlar
                        </a>
                        <?php endif; ?>
                        <?php if($canWithdrawals): ?>
                        <a href="<?php echo e(route('backoffice.sites.withdrawals.index', $sidebarSite->id)); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.sites.withdrawals.*') && $activeSiteId === (int) $sidebarSite->id ? 'active' : ''); ?>">
                            <i class="bi bi-arrow-up-circle"></i>
                            Cekimler
                        </a>
                        <?php endif; ?>
                    </div>
                    <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php if($canTransactionLogs): ?>
                    <a href="<?php echo e(route('backoffice.transaction-logs.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.transaction-logs.*') ? 'active' : ''); ?>">
                        <i class="bi bi-list-check"></i>
                        Islem Loglari
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; ?>

            <?php if($showFinanceSection): ?>
            <div class="menu-group <?php echo e($financeOpen ? 'is-open' : ''); ?>" data-menu-group="finance">
                <button type="button" class="menu-section-toggle" data-label="Finans">
                    <span class="menu-section-toggle-main">
                        <i class="bi bi-bank"></i>
                        <span class="menu-section-label">Finans</span>
                    </span>
                    <i class="bi bi-chevron-down menu-section-chevron"></i>
                </button>
                <div class="menu-group-items">
                    <?php if($canFinanceGroups): ?>
                    <a href="<?php echo e(route('backoffice.finance-groups.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.finance-groups.*') ? 'active' : ''); ?>">
                        <i class="bi bi-diagram-3"></i>
                        Finans Gruplari
                    </a>
                    <?php endif; ?>
                    <?php if($canBankAccounts): ?>
                    <a href="<?php echo e(route('backoffice.bank-accounts.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.bank-accounts.*') ? 'active' : ''); ?>">
                        <i class="bi bi-bank"></i>
                        Banka Hesaplari
                    </a>
                    <?php endif; ?>
                    <?php if($canCryptoAccounts): ?>
                    <a href="<?php echo e(route('backoffice.crypto-accounts.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.crypto-accounts.*') ? 'active' : ''); ?>">
                        <i class="bi bi-currency-bitcoin"></i>
                        Kripto Hesablari
                    </a>
                    <?php endif; ?>
                    <?php if($canFinanceUsers): ?>
                    <a href="<?php echo e(route('backoffice.finance-users.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.finance-users.*') ? 'active' : ''); ?>">
                        <i class="bi bi-person-badge"></i>
                        Finans Kullanicilar
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; ?>

            <?php if($showAccessSection): ?>
            <div class="menu-group <?php echo e($accessOpen ? 'is-open' : ''); ?>" data-menu-group="access">
                <button type="button" class="menu-section-toggle" data-label="Erisim">
                    <span class="menu-section-toggle-main">
                        <i class="bi bi-shield-check"></i>
                        <span class="menu-section-label">Erisim</span>
                    </span>
                    <i class="bi bi-chevron-down menu-section-chevron"></i>
                </button>
                <div class="menu-group-items">
                    <?php if($canPermissions): ?>
                    <a href="<?php echo e(route('backoffice.permissions.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.permissions.*') ? 'active' : ''); ?>">
                        <i class="bi bi-shield-check"></i>
                        Backoffice Yetkileri
                    </a>
                    <?php endif; ?>
                    <?php if($canUsers): ?>
                    <a href="<?php echo e(route('backoffice.users.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.users.*') ? 'active' : ''); ?>">
                        <i class="bi bi-people"></i>
                        Backoffice Kullanicilar
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; ?>

            <?php if($showSystemSection): ?>
            <div class="menu-group <?php echo e($systemOpen ? 'is-open' : ''); ?>" data-menu-group="system">
                <button type="button" class="menu-section-toggle" data-label="Sistem">
                    <span class="menu-section-toggle-main">
                        <i class="bi bi-gear"></i>
                        <span class="menu-section-label">Sistem</span>
                    </span>
                    <i class="bi bi-chevron-down menu-section-chevron"></i>
                </button>
                <div class="menu-group-items">
                    <?php if($canCannedResponses): ?>
                    <a href="<?php echo e(route('backoffice.canned-responses.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.canned-responses.*') ? 'active' : ''); ?>">
                        <i class="bi bi-chat-left-text"></i>
                        Hazir Cevaplar
                    </a>
                    <?php endif; ?>
                    <?php if($canBlacklist): ?>
                    <a href="<?php echo e(route('backoffice.blacklist.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.blacklist.*') ? 'active' : ''); ?>">
                        <i class="bi bi-slash-circle"></i>
                        Blacklist
                    </a>
                    <?php endif; ?>
                    <?php if($canSites): ?>
                    <a href="<?php echo e(route('backoffice.sites.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.sites.index') || request()->routeIs('backoffice.sites.show') || request()->routeIs('backoffice.sites.update') || request()->routeIs('backoffice.sites.toggle-status') || request()->routeIs('backoffice.sites.destroy') ? 'active' : ''); ?>">
                        <i class="bi bi-globe2"></i>
                        Siteler
                    </a>
                    <?php endif; ?>
                    <?php if($canPaymentPopups): ?>
                    <a href="<?php echo e(route('backoffice.payment-popups.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.payment-popups.*') ? 'active' : ''); ?>">
                        <i class="bi bi-images"></i>
                        Payment Popups
                    </a>
                    <?php endif; ?>
                    <?php if($canSettings): ?>
                    <a href="<?php echo e(route('backoffice.settings')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.settings*') ? 'active' : ''); ?>">
                        <i class="bi bi-gear"></i>
                        Sistem Ayarlari
                    </a>
                    <?php endif; ?>
                    <?php if($canReports): ?>
                    <a href="<?php echo e(route('backoffice.reports')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.reports*') ? 'active' : ''); ?>">
                        <i class="bi bi-graph-up"></i>
                        Raporlar
                    </a>
                    <?php endif; ?>
                    <?php if($canActivityLogs): ?>
                    <a href="<?php echo e(route('backoffice.activity-logs.index')); ?>" class="menu-item <?php echo e(request()->routeIs('backoffice.activity-logs.*') ? 'active' : ''); ?>">
                        <i class="bi bi-activity"></i>
                        Aktivite Loglari
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; ?>
        </div>
        </div>
    </div>

    <!-- Topbar -->
    <div class="topbar">
        <div class="topbar-left">
            <button type="button" class="sidebar-toggle" id="sidebarToggle" aria-label="Toggle sidebar">
                <i class="bi bi-list"></i>
            </button>
            
        </div>

        <div class="topbar-right">
            <?php ($currentUser = auth()->user()); ?>
            <?php if($currentUser): ?>
            <div class="dropdown">
                <div class="user-menu" data-bs-toggle="dropdown" aria-expanded="false">
                    <div class="user-avatar">
                        <i class="bi bi-person"></i>
                    </div>
                    <div class="d-none d-md-block">
                        <div class="fw-semibold"><?php echo e($currentUser->full_name); ?></div>
                        <small class="text-muted"><?php echo e(optional($currentUser->permissionGroup)->name ?? 'KullanÄ±cÄ±'); ?></small>
                    </div>
                    <i class="bi bi-chevron-down dropdown-icon"></i>
                </div>

                <div class="dropdown-menu dropdown-menu-end">
                    <a class="dropdown-item" href="<?php echo e(route('backoffice.2fa')); ?>">
                        <i class="bi bi-shield-lock me-1"></i>2FA Ayarlari
                    </a>
                    <form action="<?php echo e(route('backoffice.logout')); ?>" method="POST" class="px-3 py-1">
                        <?php echo csrf_field(); ?>
                        <button type="submit" class="btn btn-link p-0 text-danger">
                            <i class="bi bi-box-arrow-right me-1"></i>Cikis Yap
                        </button>
                    </form>
                </div>

            </div>
            <?php endif; ?>
        </div>
    </div>

    <!-- Main Content -->
    <div class="main-content">
        <?php echo $__env->yieldContent('content'); ?>
    </div>

    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- DataTables -->
    <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
    <!-- SweetAlert2 -->
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <!-- Number Formatter -->
    <script src="<?php echo e(asset('js/number-formatter.js')); ?>"></script>

    <?php echo $__env->yieldPushContent('scripts'); ?>

    <script>
        (function () {
            const sidebar = document.querySelector('.sidebar');
            const toggle = document.getElementById('sidebarToggle');
            if (!sidebar || !toggle) return;

            function setCollapsed(isCollapsed) {
                document.body.classList.toggle('sidebar-collapsed', isCollapsed);
                sidebar.classList.toggle('collapsed', isCollapsed);
                localStorage.setItem('boSidebarCollapsed', isCollapsed ? '1' : '0');
            }

            const saved = localStorage.getItem('boSidebarCollapsed');
            if (saved === '1') {
                setCollapsed(true);
            }

            toggle.addEventListener('click', function () {
                const isCollapsed = document.body.classList.contains('sidebar-collapsed');
                setCollapsed(!isCollapsed);
            });

            document.querySelectorAll('.menu-item').forEach(function (item) {
                if (!item.dataset.label) {
                    const label = item.textContent.trim();
                    if (label) {
                        item.dataset.label = label;
                    }
                }
                if (!item.querySelector('.menu-label')) {
                    const nodes = Array.from(item.childNodes).filter(function (n) {
                        return n.nodeType === Node.TEXT_NODE && n.textContent.trim().length;
                    });
                    if (nodes.length) {
                        const span = document.createElement('span');
                        span.className = 'menu-label';
                        span.textContent = nodes.map(n => n.textContent).join(' ').trim();
                        nodes.forEach(n => n.parentNode.removeChild(n));
                        item.appendChild(span);
                    }
                }
                const menuLabel = item.querySelector('.menu-label');
                const cleanLabel = menuLabel ? menuLabel.textContent.trim() : '';
                if (cleanLabel) {
                    item.dataset.label = cleanLabel;
                }
            });

            document.querySelectorAll('.menu-section-toggle').forEach(function (toggleButton) {
                const sectionLabel = toggleButton.querySelector('.menu-section-label');
                if (sectionLabel && !toggleButton.dataset.label) {
                    toggleButton.dataset.label = sectionLabel.textContent.trim();
                }
            });

            let hoverLabel = null;
            function removeHoverLabel() {
                if (!hoverLabel) {
                    return;
                }
                hoverLabel.remove();
                hoverLabel = null;
            }

            function showHoverLabel(item) {
                const labelText = (item.dataset.label || '').trim();
                const isCollapsed = document.body.classList.contains('sidebar-collapsed');
                if (!labelText || !isCollapsed) {
                    return;
                }

                removeHoverLabel();
                hoverLabel = document.createElement('div');
                hoverLabel.className = 'sidebar-hover-label';
                hoverLabel.textContent = labelText;
                document.body.appendChild(hoverLabel);

                const rect = item.getBoundingClientRect();
                hoverLabel.style.left = `${Math.round(rect.right + 10)}px`;
                hoverLabel.style.top = `${Math.round(rect.top + rect.height / 2)}px`;
                requestAnimationFrame(function () {
                    if (hoverLabel) {
                        hoverLabel.classList.add('is-visible');
                    }
                });
            }

            document.querySelectorAll('.menu-item, .menu-section-toggle').forEach(function (item) {
                item.addEventListener('mouseenter', function () {
                    showHoverLabel(item);
                });
                item.addEventListener('mouseleave', removeHoverLabel);
                item.addEventListener('focus', function () {
                    showHoverLabel(item);
                });
                item.addEventListener('blur', removeHoverLabel);
            });

            const sectionStateKey = 'boSidebarSectionState';

            function readSectionState() {
                try {
                    return JSON.parse(localStorage.getItem(sectionStateKey) || '{}');
                } catch (e) {
                    return {};
                }
            }

            function writeSectionState(state) {
                localStorage.setItem(sectionStateKey, JSON.stringify(state));
            }

            const savedSectionState = readSectionState();
            document.querySelectorAll('.menu-group[data-menu-group]').forEach(function (group) {
                const key = group.getAttribute('data-menu-group');
                if (Object.prototype.hasOwnProperty.call(savedSectionState, key)) {
                    group.classList.toggle('is-open', !!savedSectionState[key]);
                }

                const toggleButton = group.querySelector('.menu-section-toggle');
                if (!toggleButton) {
                    return;
                }

                toggleButton.addEventListener('click', function () {
                    if (document.body.classList.contains('sidebar-collapsed')) {
                        return;
                    }

                    group.classList.toggle('is-open');
                    const nextState = readSectionState();
                    nextState[key] = group.classList.contains('is-open');
                    writeSectionState(nextState);
                    removeHoverLabel();
                });
            });

            window.addEventListener('scroll', removeHoverLabel, { passive: true });
            window.addEventListener('resize', removeHoverLabel);
            toggle.addEventListener('click', removeHoverLabel);
        })();
    </script>

    <script>
        (function () {
            const dueDate = new Date(2026, 5, 10);
            const today = new Date();
            const startOfToday = new Date(today.getFullYear(), today.getMonth(), today.getDate());
            const diffMs = dueDate.getTime() - startOfToday.getTime();
            const diffDays = Math.ceil(diffMs / 86400000);
            if (diffDays >= 0 && diffDays < 10) {
                Swal.fire(
                    'Uyari!',
                    'Server Yenileme Tarihiniz Yaklasiyor. Lutfen Sistem Yazilimciniza Iletisime Geciniz',
                    'error'
                );
            }
        })();
    </script>

    <?php if(
        !request()->routeIs('backoffice.deposits.*')
        && !request()->routeIs('backoffice.withdrawals.*')
        && !request()->routeIs('backoffice.sites.deposits.*')
        && !request()->routeIs('backoffice.sites.withdrawals.*')
    ): ?>
    <script>
        $(document).ready(function() {
            const soundEnabled = '<?php echo e(setting('notification_sound', 'enabled')); ?>' !== 'disabled';
            const canCheckDeposits = <?php echo can_access('deposits') ? 'true' : 'false'; ?>;
            const canCheckWithdrawals = <?php echo can_access('withdrawals') ? 'true' : 'false'; ?>;

            if (!soundEnabled || (!canCheckDeposits && !canCheckWithdrawals)) {
                return;
            }

            let lastDepositTimestamp = Math.floor(Date.now() / 1000);
            let lastWithdrawalTimestamp = Math.floor(Date.now() / 1000);
            let pollingInterval = null;
            const autoRefreshEnabled = false;

            const depositSound = new Audio('<?php echo e(asset('audio/deposit.mp3')); ?>');
            depositSound.preload = 'auto';
            depositSound.volume = 0.7;

            const withdrawalSound = new Audio('<?php echo e(asset('audio/withdrawal.mp3')); ?>');
            withdrawalSound.preload = 'auto';
            withdrawalSound.volume = 0.7;

            let soundUnlocked = false;

            function unlockSound() {
                if (soundUnlocked) return;
                depositSound.play().then(function() {
                    depositSound.pause();
                    depositSound.currentTime = 0;
                    soundUnlocked = true;
                }).catch(function() {});
            }

            document.addEventListener('click', unlockSound, { once: true });
            document.addEventListener('keydown', unlockSound, { once: true });
            document.addEventListener('touchstart', unlockSound, { once: true });

            function playSound(type) {
                if (!soundUnlocked) {
                    unlockSound();
                }
                const audio = type === 'withdrawal' ? withdrawalSound : depositSound;
                audio.currentTime = 0;
                audio.play().catch(() => {});
            }

            const notificationToast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000,
                timerProgressBar: true,
                didOpen: (toast) => {
                    toast.addEventListener('mouseenter', Swal.stopTimer);
                    toast.addEventListener('mouseleave', Swal.resumeTimer);
                }
            });

            function showNotificationToast(options) {
                const fire = () => notificationToast.fire(options);
                if (Swal.isVisible()) {
                    const interval = setInterval(function() {
                        if (!Swal.isVisible()) {
                            clearInterval(interval);
                            fire();
                        }
                    }, 250);
                    return;
                }
                fire();
            }

            let latestDepositCount = 0;
            let latestWithdrawalCount = 0;

            function updateBadge() {
                const total = latestDepositCount + latestWithdrawalCount;
                const badge = document.querySelector('.notification-badge');
                if (badge) {
                    badge.textContent = total;
                }
            }

            function checkNewDeposits() {
                if (!canCheckDeposits) return;
                $.ajax({
                    url: '<?php echo e(route("backoffice.deposits.check-new")); ?>',
                    method: 'GET',
                    data: { since: lastDepositTimestamp },
                    success: function(response) {
                        if (response && response.success) {
                            const latestFromServer = response.latest_timestamp ? Number(response.latest_timestamp) : lastDepositTimestamp;
                            if (response.data && response.data.length > 0) {
                                const latestCreated = Math.max(...response.data.map(d => d.created_at_timestamp));
                                lastDepositTimestamp = Math.max(lastDepositTimestamp, latestFromServer, latestCreated);
                            } else {
                                lastDepositTimestamp = Math.max(lastDepositTimestamp, latestFromServer);
                            }

                            if (response.count > 0) {
                                playSound('deposit');
                                showNotificationToast({
                                    title: 'Yeni YatÄ±rÄ±m!',
                                    html: `<strong>${response.count}</strong> yeni yatÄ±rÄ±m iÅŸlemi alÄ±ndÄ±.`,
                                    icon: 'info'
                                });
                            }
                            latestDepositCount = response.count || 0;
                            updateBadge();
                        }
                    }
                });
            }

            function checkNewWithdrawals() {
                if (!canCheckWithdrawals) return;
                $.ajax({
                    url: '<?php echo e(route("backoffice.withdrawals.check-new")); ?>',
                    method: 'GET',
                    data: { since: lastWithdrawalTimestamp },
                    success: function(response) {
                        if (response && response.success) {
                            const latestFromServer = response.latest_timestamp ? Number(response.latest_timestamp) : lastWithdrawalTimestamp;
                            if (response.data && response.data.length > 0) {
                                const latestCreated = Math.max(...response.data.map(d => d.created_at_timestamp));
                                lastWithdrawalTimestamp = Math.max(lastWithdrawalTimestamp, latestFromServer, latestCreated);
                            } else {
                                lastWithdrawalTimestamp = Math.max(lastWithdrawalTimestamp, latestFromServer);
                            }

                            if (response.count > 0) {
                                playSound('withdrawal');
                                showNotificationToast({
                                    title: 'Yeni Ã‡ekim!',
                                    html: `<strong>${response.count}</strong> yeni Ã§ekim iÅŸlemi alÄ±ndÄ±.`,
                                    icon: 'info'
                                });
                            }
                            latestWithdrawalCount = response.count || 0;
                            updateBadge();
                        }
                    }
                });
            }

            function startPolling() {
                pollingInterval = setInterval(function() {
                    checkNewDeposits();
                    checkNewWithdrawals();
                }, 5000);
            }

            if (autoRefreshEnabled) {
                startPolling();
            }
        });
    </script>
    <?php endif; ?>
</body>
</html>





<?php /**PATH /home/cmummhol/public_html/zoom/resources/views/backoffice/layouts/app.blade.php ENDPATH**/ ?>