<!DOCTYPE html>
<html lang="en">

<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'); ?> - AutoPromix</title>
    <link rel="icon" type="image/png" href="<?php echo e(asset('images/icon.png')); ?>">

    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <!-- Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
    <!-- SweetAlert2 -->
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

    <style>
        :root {
            --sidebar-width: 260px;
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --superadmin-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            --admin-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        * {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        body {
            background-color: #f0f2f5;
        }

        .sidebar {
            width: var(--sidebar-width);
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            background: var(--primary-gradient);
            padding-top: 0;
            z-index: 1000;
            overflow-y: auto;
        }

        .sidebar.superadmin {
            background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
        }

        .sidebar .brand {
            padding: 1.25rem 1.5rem;
            color: white;
            font-size: 1.25rem;
            font-weight: 700;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            gap: 0.75rem;
            background: rgba(0, 0, 0, 0.1);
        }

        .sidebar .brand .logo-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            overflow: hidden;
        }

        .sidebar .brand .logo-icon img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .sidebar .role-badge {
            padding: 0.5rem 1.5rem;
            background: rgba(0, 0, 0, 0.15);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .sidebar .role-badge .badge {
            font-size: 0.7rem;
            padding: 0.35rem 0.75rem;
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .sidebar .role-badge .badge.superadmin {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        }

        .sidebar .role-badge .badge.admin {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        }

        .sidebar .nav-section {
            padding: 0.75rem 1.5rem 0.5rem;
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: rgba(255, 255, 255, 0.5);
            font-weight: 600;
            margin-top: 0.5rem;
        }

        .sidebar .nav-link {
            color: rgba(255, 255, 255, 0.75);
            padding: 0.65rem 1.5rem;
            margin: 0.15rem 0.75rem;
            border-radius: 0.5rem;
            transition: all 0.2s ease;
            font-size: 0.875rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .sidebar .nav-link:hover,
        .sidebar .nav-link.active {
            background: rgba(255, 255, 255, 0.15);
            color: white;
            transform: translateX(4px);
        }

        .sidebar .nav-link i {
            width: 20px;
            font-size: 1rem;
        }

        .sidebar .nav-link .new-badge {
            margin-left: auto;
            font-size: 0.65rem;
            padding: 0.15rem 0.4rem;
            background: #f5576c;
            border-radius: 4px;
        }

        .main-content {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .footer a:hover {
            color: #764ba2 !important;
            text-decoration: underline !important;
        }

        .top-bar {
            background: white;
            padding: 1rem 2rem;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .top-bar .page-title {
            font-weight: 600;
            color: #1a1a2e;
        }

        .top-bar .admin-info {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .top-bar .admin-avatar {
            width: 38px;
            height: 38px;
            border-radius: 10px;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
            font-size: 0.875rem;
        }

        .content-wrapper {
            padding: 1.5rem 2rem;
        }

        .stat-card {
            background: white;
            border-radius: 1rem;
            padding: 1.5rem;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
            border: 1px solid rgba(0, 0, 0, 0.04);
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
        }

        .stat-card .icon {
            width: 56px;
            height: 56px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }

        .stat-card.calls .icon {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
            color: #667eea;
        }

        .stat-card.sms .icon {
            background: linear-gradient(135deg, rgba(40, 167, 69, 0.15) 0%, rgba(0, 200, 83, 0.15) 100%);
            color: #28a745;
        }

        .stat-card.users .icon {
            background: linear-gradient(135deg, rgba(253, 126, 20, 0.15) 0%, rgba(255, 165, 0, 0.15) 100%);
            color: #fd7e14;
        }

        .stat-card.success .icon {
            background: linear-gradient(135deg, rgba(23, 162, 184, 0.15) 0%, rgba(0, 210, 255, 0.15) 100%);
            color: #17a2b8;
        }

        .stat-card .value {
            font-size: 2rem;
            font-weight: 700;
            color: #1a1a2e;
            line-height: 1.2;
        }

        .stat-card .label {
            color: #6c757d;
            font-size: 0.8rem;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .chart-container {
            background: white;
            border-radius: 1rem;
            padding: 1.5rem;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
            border: 1px solid rgba(0, 0, 0, 0.04);
        }

        .table-container {
            background: white;
            border-radius: 1rem;
            padding: 1.5rem;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
            border: 1px solid rgba(0, 0, 0, 0.04);
            overflow: visible;
        }

        .table-container .table-responsive {
            overflow: visible;
        }

        .card .table-responsive {
            overflow: visible;
        }

        .dropdown-menu {
            z-index: 1050;
        }

        .badge {
            padding: 0.4rem 0.75rem;
            font-size: 0.75rem;
            font-weight: 600;
            border-radius: 6px;
        }

        .badge-incoming {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
            color: #ffffff !important;
        }

        .badge-outgoing {
            background: linear-gradient(135deg, #007bff 0%, #6610f2 100%) !important;
            color: #ffffff !important;
        }

        .badge-missed {
            background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%) !important;
            color: #ffffff !important;
        }

        .badge-sent {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
            color: #ffffff !important;
        }

        .badge-failed {
            background: linear-gradient(135deg, #dc3545 0%, #bd2130 100%) !important;
            color: #ffffff !important;
        }

        .badge-pending {
            background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
            color: #212529 !important;
        }

        .badge-superadmin {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
            color: #ffffff !important;
        }

        .badge-admin-role {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
            color: #ffffff !important;
        }

        .masked-data {
            font-family: 'Courier New', monospace;
            background: rgba(0, 0, 0, 0.05);
            padding: 0.15rem 0.4rem;
            border-radius: 4px;
            color: #6c757d;
        }

        .restricted-notice {
            background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(253, 126, 20, 0.1) 100%);
            border: 1px solid rgba(255, 193, 7, 0.3);
            border-radius: 8px;
            padding: 0.75rem 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: #856404;
            font-size: 0.875rem;
        }

        .btn {
            font-weight: 500;
            border-radius: 8px;
            padding: 0.5rem 1rem;
            transition: all 0.2s ease;
        }

        .btn-primary {
            background: var(--primary-gradient);
            border: none;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }

        .alert {
            border-radius: 10px;
            border: none;
        }

        .alert-success {
            background: linear-gradient(135deg, rgba(40, 167, 69, 0.1) 0%, rgba(0, 200, 83, 0.1) 100%);
            color: #155724;
        }

        .alert-danger {
            background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(189, 33, 48, 0.1) 100%);
            color: #721c24;
        }

        .table {
            font-size: 0.875rem;
        }

        .table th {
            font-weight: 600;
            color: #6c757d;
            text-transform: uppercase;
            font-size: 0.7rem;
            letter-spacing: 0.5px;
            border-bottom-width: 1px;
        }

        .table td {
            vertical-align: middle;
            color: #1a1a2e;
        }

        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                height: auto;
                position: relative;
            }

            .main-content {
                margin-left: 0;
            }

            .content-wrapper {
                padding: 1rem;
            }
        }

        /* Animation for restricted content */
        @keyframes pulse-border {

            0%,
            100% {
                border-color: rgba(255, 193, 7, 0.3);
            }

            50% {
                border-color: rgba(255, 193, 7, 0.6);
            }
        }

        .restricted-section {
            animation: pulse-border 2s infinite;
        }

        /* Pagination Styling */
        .pagination {
            gap: 0.25rem;
            flex-wrap: wrap;
            justify-content: center;
        }

        .pagination .page-item .page-link {
            border: none;
            border-radius: 8px;
            padding: 0.5rem 0.85rem;
            color: #667eea;
            font-weight: 500;
            background: #f8f9fa;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 38px;
            height: 38px;
        }

        .pagination .page-item .page-link:hover {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            transform: translateY(-1px);
        }

        .pagination .page-item.active .page-link {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
        }

        .pagination .page-item.disabled .page-link {
            background: #e9ecef;
            color: #adb5bd;
        }

        /* Fix SVG arrow size in pagination */
        .pagination .page-link svg {
            width: 14px !important;
            height: 14px !important;
            flex-shrink: 0;
        }

        /* Better pagination arrow buttons */
        .pagination .page-item:first-child .page-link,
        .pagination .page-item:last-child .page-link {
            padding: 0.5rem 0.75rem;
        }

        /* Ensure badge text is always visible */
        .badge-incoming,
        .badge-outgoing,
        .badge-missed,
        .badge-sent,
        .badge-failed {
            color: #ffffff !important;
        }

        .badge-pending {
            color: #212529 !important;
        }
    </style>

    <?php echo $__env->yieldPushContent('styles'); ?>
</head>

<body>
    <?php
    $currentAdmin = auth()->guard('admin')->user();
    $isSuperAdmin = $currentAdmin && $currentAdmin->isSuperAdmin();
    ?>

    <!-- Sidebar -->
    <nav class="sidebar d-none d-md-block <?php echo e($isSuperAdmin ? 'superadmin' : ''); ?>">
        <div class="brand">
            <div class="logo-icon">
                <img src="<?php echo e(asset('images/icon.png')); ?>" alt="AutoPromix Logo">
            </div>
            <span>AutoPromix</span>
        </div>


        <!-- Role Badge (SuperAdmin only) -->
        <?php if($isSuperAdmin): ?>
        <div class="role-badge">
            <span class="badge superadmin"><i class="bi bi-shield-check me-1"></i>SUPER ADMIN</span>
        </div>
        <?php endif; ?>

        <ul class="nav flex-column">
            <!-- Main Section -->
            <div class="nav-section">Main</div>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard')); ?>">
                    <i class="bi bi-speedometer2"></i>
                    Dashboard
                </a>
            </li>

            <!-- User Management -->
            <?php if($currentAdmin && $currentAdmin->hasPermission('users.view')): ?>
            <div class="nav-section">Users</div>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.users*') || request()->routeIs('dashboard.user-details') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.users')); ?>">
                    <i class="bi bi-people"></i>
                    Users
                </a>
            </li>
            <?php endif; ?>

            <!-- Templates -->
            <?php if($currentAdmin && $currentAdmin->hasPermission('templates.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.templates*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.templates')); ?>">
                    <i class="bi bi-file-text"></i>
                    Templates
                </a>
            </li>
            <?php endif; ?>

            <!-- Logs Section -->
            <?php if($currentAdmin && $currentAdmin->hasAnyPermission(['logs.call.view', 'logs.sms.view', 'logs.promotion.view', 'logs.session.view'])): ?>
            <div class="nav-section">Logs</div>

            <?php if($currentAdmin->hasPermission('logs.call.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.call-logs') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.call-logs')); ?>">
                    <i class="bi bi-telephone"></i>
                    Call Logs
                </a>
            </li>
            <?php endif; ?>

            <?php if($currentAdmin->hasPermission('logs.sms.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.sms-logs') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.sms-logs')); ?>">
                    <i class="bi bi-chat-dots"></i>
                    Message Logs
                </a>
            </li>
            <?php endif; ?>

            <?php if($currentAdmin->hasPermission('logs.promotion.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.promotion-logs') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.promotion-logs')); ?>">
                    <i class="bi bi-megaphone"></i>
                    Promotion Logs
                </a>
            </li>
            <?php endif; ?>

            <?php if($currentAdmin->hasPermission('logs.session.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.session-logs') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.session-logs')); ?>">
                    <i class="bi bi-clock-history"></i>
                    Session Logs
                </a>
            </li>
            <?php endif; ?>
            <?php endif; ?>

             <!-- Client Management - Permission Based -->
            <?php if($currentAdmin && $currentAdmin->hasAnyPermission(['clients.view', 'approvals.view', 'template_assignment.view'])): ?>
            <div class="nav-section">Client Management</div>
            <?php if($currentAdmin->hasPermission('clients.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.clients*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.clients')); ?>">
                    <i class="bi bi-building"></i>
                    Organizations
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('approvals.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.approvals*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.approvals')); ?>">
                    <i class="bi bi-person-check"></i>
                    Pending Approvals
                    <?php
                    $pendingCount = \App\Models\User::whereNotNull('client_id')->pending()->count();
                    ?>
                    <?php if($pendingCount > 0): ?>
                    <span class="badge bg-warning ms-auto"><?php echo e($pendingCount); ?></span>
                    <?php endif; ?>
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('template_assignment.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.template-assignment*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.template-assignment')); ?>">
                    <i class="bi bi-file-earmark-plus"></i>
                    Template Assignment
                </a>
            </li>
            <?php endif; ?>
            <?php endif; ?>


            <!-- Analytics -->
            <?php if($currentAdmin && $currentAdmin->hasPermission('analytics.view')): ?>
            <div class="nav-section">Analytics</div>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.analytics') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.analytics')); ?>">
                    <i class="bi bi-graph-up"></i>
                    Analytics
                </a>
            </li>
            <?php endif; ?>

            <!-- Reports -->
            <?php if($currentAdmin && $currentAdmin->hasPermission('reports.view')): ?>
            <div class="nav-section">Reports</div>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.reports') && !request()->routeIs('dashboard.reports.*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.reports')); ?>">
                    <i class="bi bi-file-earmark-bar-graph"></i>
                    Reports Dashboard
                </a>
            </li>
            <?php if($currentAdmin->hasPermission('reports.user_activity')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.reports.user-activity*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.reports.user-activity')); ?>">
                    <i class="bi bi-person-lines-fill"></i>
                    User Activity
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('reports.sms_summary')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.reports.sms-summary*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.reports.sms-summary')); ?>">
                    <i class="bi bi-chat-text-fill"></i>
                    SMS Summary
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('reports.call_summary')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.reports.call-summary*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.reports.call-summary')); ?>">
                    <i class="bi bi-telephone-fill"></i>
                    Call Summary
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('reports.daily_summary')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.reports.daily-summary*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.reports.daily-summary')); ?>">
                    <i class="bi bi-calendar-check-fill"></i>
                    Daily Summary
                </a>
            </li>
            <?php endif; ?>
            <?php endif; ?>

           
            <!-- Administration - Permission Based -->
            <?php if($currentAdmin && $currentAdmin->hasAnyPermission(['admins.view', 'audit_logs.view', 'settings.view'])): ?>
            <div class="nav-section">Administration</div>
            <?php if($currentAdmin->hasPermission('admins.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.admins*') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.admins')); ?>">
                    <i class="bi bi-person-gear"></i>
                    Admin Management
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('audit_logs.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.audit-logs') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.audit-logs')); ?>">
                    <i class="bi bi-journal-text"></i>
                    Audit Logs
                </a>
            </li>
            <?php endif; ?>
            <?php if($currentAdmin->hasPermission('settings.view')): ?>
            <li class="nav-item">
                <a class="nav-link <?php echo e(request()->routeIs('dashboard.settings') ? 'active' : ''); ?>" href="<?php echo e(route('dashboard.settings')); ?>">
                    <i class="bi bi-gear"></i>
                    Settings
                </a>
            </li>
            <?php endif; ?>
            <?php endif; ?>
        </ul>
    </nav>

    <!-- Main Content -->
    <div class="main-content">
        <!-- Top Bar -->
        <div class="top-bar">
            <div class="d-flex align-items-center">
                <button class="btn btn-link d-md-none me-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#mobileSidebar">
                    <i class="bi bi-list fs-4"></i>
                </button>
                <h4 class="mb-0 page-title"><?php echo $__env->yieldContent('page-title', 'Dashboard'); ?></h4>
            </div>

            <div class="admin-info">
                <div class="text-end d-none d-sm-block">
                    <div class="fw-semibold" style="font-size: 0.9rem;"><?php echo e($currentAdmin->name ?? 'Admin'); ?></div>
                    <div style="font-size: 0.75rem; color: #6c757d;">
                        <?php if($isSuperAdmin): ?>
                        <span class="text-danger">Super Administrator</span>
                        <?php else: ?>
                        <span>Administrator</span>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="admin-avatar">
                    <?php echo e(strtoupper(substr($currentAdmin->name ?? 'A', 0, 2))); ?>

                </div>
                <form action="<?php echo e(route('admin.logout')); ?>" method="POST" class="d-inline">
                    <?php echo csrf_field(); ?>
                    <button type="submit" class="btn btn-outline-secondary btn-sm">
                        <i class="bi bi-box-arrow-right"></i>
                    </button>
                </form>
            </div>
        </div>

        <!-- Content -->
        <div class="content-wrapper">

            <?php echo $__env->yieldContent('content'); ?>

            <!-- Footer -->
            <footer class="footer mt-auto py-3">
                <div class="container-fluid text-center">
                    <span class="text-muted small">
                        &copy; 2026 <strong>AutoPromix</strong>. All rights reserved. Made with <i class="bi bi-heart-fill text-danger mx-1"></i> by <a href="https://aviratmedia.com/" target="_blank" class="text-decoration-none text-primary fw-medium">Avirat Media</a>
                    </span>
                </div>
            </footer>
        </div>
    </div>

    <!-- Mobile Sidebar -->
    <div class="offcanvas offcanvas-start" tabindex="-1" id="mobileSidebar" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
        <div class="offcanvas-header">
            <h5 class="offcanvas-title text-white">
                <img src="<?php echo e(asset('images/icon.png')); ?>" alt="AutoPromix" style="width: 28px; height: 28px; margin-right: 8px;">AutoPromix
            </h5>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas"></button>
        </div>
        <div class="offcanvas-body">
            <ul class="nav flex-column">
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard')); ?>">
                        <i class="bi bi-speedometer2 me-2"></i> Dashboard
                    </a>
                </li>
                <?php if($currentAdmin && $currentAdmin->hasPermission('users.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.users')); ?>">
                        <i class="bi bi-people me-2"></i> Users
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('templates.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.templates')); ?>">
                        <i class="bi bi-file-text me-2"></i> Templates
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('logs.call.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.call-logs')); ?>">
                        <i class="bi bi-telephone me-2"></i> Call Logs
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('logs.sms.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.sms-logs')); ?>">
                        <i class="bi bi-chat-text me-2"></i> SMS Logs
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('logs.promotion.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.promotion-logs')); ?>">
                        <i class="bi bi-megaphone me-2"></i> Promotion Logs
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('logs.session.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.session-logs')); ?>">
                        <i class="bi bi-clock-history me-2"></i> Session Logs
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasPermission('analytics.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.analytics')); ?>">
                        <i class="bi bi-graph-up me-2"></i> Analytics
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasAnyPermission(['clients.view', 'approvals.view', 'template_assignment.view'])): ?>
                <li class="nav-item mt-3 pt-3 border-top border-secondary">
                    <span class="nav-link text-white-50 small text-uppercase">Client Management</span>
                </li>
                <?php if($currentAdmin->hasPermission('clients.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.clients')); ?>">
                        <i class="bi bi-building me-2"></i> Organizations
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin->hasPermission('approvals.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.approvals')); ?>">
                        <i class="bi bi-person-check me-2"></i> Pending Approvals
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin->hasPermission('template_assignment.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.template-assignment')); ?>">
                        <i class="bi bi-file-earmark-plus me-2"></i> Template Assignment
                    </a>
                </li>
                <?php endif; ?>
                <?php endif; ?>
                <?php if($currentAdmin && $currentAdmin->hasAnyPermission(['admins.view', 'audit_logs.view', 'settings.view'])): ?>
                <li class="nav-item mt-3 pt-3 border-top border-secondary">
                    <span class="nav-link text-white-50 small text-uppercase">Administration</span>
                </li>
                <?php if($currentAdmin->hasPermission('admins.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.admins')); ?>">
                        <i class="bi bi-person-gear me-2"></i> Admin Management
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin->hasPermission('audit_logs.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.audit-logs')); ?>">
                        <i class="bi bi-journal-text me-2"></i> Audit Logs
                    </a>
                </li>
                <?php endif; ?>
                <?php if($currentAdmin->hasPermission('settings.view')): ?>
                <li class="nav-item">
                    <a class="nav-link text-white" href="<?php echo e(route('dashboard.settings')); ?>">
                        <i class="bi bi-gear me-2"></i> Settings
                    </a>
                </li>
                <?php endif; ?>
                <?php endif; ?>
            </ul>
        </div>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

    <script>
        // SweetAlert2 Toast helper
        const SwalToast = Swal.mixin({
            toast: true,
            position: 'top-end',
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true,
            showCloseButton: true,
            didOpen: function(toast) {
                toast.addEventListener('mouseenter', Swal.stopTimer);
                toast.addEventListener('mouseleave', Swal.resumeTimer);
            }
        });

        function showToast(message, type) {
            type = type === 'error' ? 'error' : type;
            SwalToast.fire({
                icon: type || 'success',
                title: message
            });
        }

        // Confirmation popup using SweetAlert2
        function confirmAction(formOrCallback, title, message, btnText, btnClass) {
            var isDanger = (btnClass || '').indexOf('danger') !== -1;
            var isWarning = (btnClass || '').indexOf('warning') !== -1;
            Swal.fire({
                title: title || 'Confirm Action',
                text: message || 'Are you sure you want to proceed?',
                icon: isDanger ? 'warning' : (isWarning ? 'question' : 'question'),
                showCancelButton: true,
                confirmButtonColor: isDanger ? '#dc3545' : (isWarning ? '#fd7e14' : '#198754'),
                cancelButtonColor: '#6c757d',
                confirmButtonText: btnText || 'Confirm',
                reverseButtons: true
            }).then(function(result) {
                if (result.isConfirmed) {
                    if (typeof formOrCallback === 'function') {
                        formOrCallback();
                    } else if (formOrCallback && formOrCallback.submit) {
                        formOrCallback.submit();
                    }
                }
            });
        }

        // Auto-show session messages on page load
        document.addEventListener('DOMContentLoaded', function() {
            <?php if(session('success')): ?>
            Swal.fire({
                icon: 'success',
                title: 'Success',
                text: <?php echo json_encode(session('success'), 15, 512) ?>,
                timer: 3000,
                showConfirmButton: true,
                confirmButtonColor: '#198754'
            });
            <?php endif; ?>
            <?php if(session('error')): ?>
            Swal.fire({
                icon: 'error',
                title: 'Error',
                text: <?php echo json_encode(session('error'), 15, 512) ?>,
                confirmButtonColor: '#dc3545'
            });
            <?php endif; ?>
            <?php if(session('warning')): ?>
            showToast(<?php echo json_encode(session('warning'), 15, 512) ?>, 'warning');
            <?php endif; ?>
            <?php if(session('info')): ?>
            showToast(<?php echo json_encode(session('info'), 15, 512) ?>, 'info');
            <?php endif; ?>

            // Initialize popovers
            document.querySelectorAll('[data-bs-toggle="popover"]').forEach(function(el) {
                new bootstrap.Popover(el, {
                    trigger: 'hover focus'
                });
            });

            // Wire up all forms/buttons with data-confirm attribute
            document.querySelectorAll('[data-confirm]').forEach(function(el) {
                el.addEventListener('click', function(e) {
                    e.preventDefault();
                    e.stopPropagation();
                    var title = el.getAttribute('data-confirm-title') || 'Confirm Action';
                    var message = el.getAttribute('data-confirm') || 'Are you sure?';
                    var btnText = el.getAttribute('data-confirm-btn') || 'Confirm';
                    var btnClass = el.getAttribute('data-confirm-class') || 'btn-danger';
                    var form = el.closest('form');
                    if (form) {
                        confirmAction(form, title, message, btnText, btnClass);
                    }
                });
            });
        });
    </script>

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

</html><?php /**PATH /home/zwfgftjb/autopromix.byteengine.in/resources/views/layouts/dashboard.blade.php ENDPATH**/ ?>