<?php
// Include database connection
if (!isset($conn)) {
    include_once 'layouts/dbconn.php';
}

// Ensure session is started
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Get user information from session
$user_id = $_SESSION['user_id'] ?? 0;
$user_role_id = $_SESSION['role_id'] ?? 0;

// Get user details and role information
$user_role = 'guest';
$user_permissions = [];

if ($user_id > 0 && $user_role_id > 0) {
    try {
        // Get user role name
        $stmt = $conn->prepare("SELECT role_name FROM user_roles WHERE role_id = ?");
        $stmt->bind_param("i", $user_role_id);
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $user_role = $result['role_name'] ?? 'guest';
        $stmt->close();

        // Get user's permissions from database
        $stmt = $conn->prepare("
            SELECT p.name 
            FROM permissions p
            INNER JOIN role_permissions rp ON p.permission_id = rp.permission_id
            WHERE rp.role_id = ?
        ");
        $stmt->bind_param("i", $user_role_id);
        $stmt->execute();
        $result = $stmt->get_result();
        
        while ($row = $result->fetch_assoc()) {
            $user_permissions[] = $row['name'];
        }
        $stmt->close();
    } catch (Exception $e) {
        error_log("Error fetching user data: " . $e->getMessage());
    }
}

// Helper function to check if user has permission
function hasPermission($permission) {
    global $user_permissions;
    return in_array($permission, $user_permissions);
}

// Get unread notifications count
function getUnreadNotifications() {
    global $conn, $user_id;
    
    if ($user_id <= 0) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT COUNT(*) as count 
            FROM notifications 
            WHERE user_id = ? AND is_read = 0
        ");
        $stmt->bind_param("i", $user_id);
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching notifications: " . $e->getMessage());
        return 0;
    }
}

// Get open tickets count
function getOpenTickets() {
    global $conn, $user_id, $user_role;
    
    if ($user_id <= 0) return 0;
    
    try {
        if ($user_role === 'Customer') {
            // Count user's open tickets
            $stmt = $conn->prepare("
                SELECT COUNT(*) as count 
                FROM support_tickets 
                WHERE user_id = ? AND status IN ('OPEN', 'IN_PROGRESS')
            ");
            $stmt->bind_param("i", $user_id);
        } else {
            // Count all open tickets for support staff
            $stmt = $conn->prepare("
                SELECT COUNT(*) as count 
                FROM support_tickets 
                WHERE status IN ('OPEN', 'IN_PROGRESS')
            ");
        }
        
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching tickets: " . $e->getMessage());
        return 0;
    }
}

// Get pending license activations (admin only)
function getPendingActivations() {
    global $conn, $user_role;
    
    if (!in_array($user_role, ['Administrator', 'Support Agent'])) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT COUNT(*) as count 
            FROM license_checks 
            WHERE check_type = 'ACTIVATION' AND response_status = 'FAILED'
            AND checked_at >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
        ");
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching pending activations: " . $e->getMessage());
        return 0;
    }
}

// Get wallet balance for customers
function getWalletBalance() {
    global $conn, $user_id, $user_role;
    
    if ($user_role !== 'Customer' || $user_id <= 0) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT balance_usd 
            FROM wallets 
            WHERE user_id = ?
        ");
        $stmt->bind_param("i", $user_id);
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['balance_usd'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching wallet balance: " . $e->getMessage());
        return 0;
    }
}

// Get active licenses count for customers
function getActiveLicensesCount() {
    global $conn, $user_id, $user_role;
    
    if ($user_role !== 'Customer' || $user_id <= 0) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT COUNT(*) as count 
            FROM licenses 
            WHERE user_id = ? AND status = 'ACTIVE'
        ");
        $stmt->bind_param("i", $user_id);
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching active licenses: " . $e->getMessage());
        return 0;
    }
}

// Get piracy violations count (admin only)
function getPiracyViolations() {
    global $conn, $user_role;
    
    if (!in_array($user_role, ['Administrator', 'Support Agent'])) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT COUNT(*) as count 
            FROM piracy_violations 
            WHERE status = 'PENDING' AND severity IN ('HIGH', 'CRITICAL')
        ");
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching piracy violations: " . $e->getMessage());
        return 0;
    }
}

// Get pending orders count
function getPendingOrders() {
    global $conn, $user_role;
    
    if (!hasPermission('manage_payments')) return 0;
    
    try {
        $stmt = $conn->prepare("
            SELECT COUNT(*) as count 
            FROM orders 
            WHERE order_status = 'PENDING' AND created_at >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
        ");
        $stmt->execute();
        $result = $stmt->get_result()->fetch_assoc();
        $stmt->close();
        return $result['count'] ?? 0;
    } catch (Exception $e) {
        error_log("Error fetching pending orders: " . $e->getMessage());
        return 0;
    }
}
?>

<!-- Left Sidebar Start -->
<div class="app-sidebar-menu">
    <div class="h-100" data-simplebar>

        <!--- Sidemenu -->
        <div id="sidebar-menu">

            <div class="logo-box">
                <a href="<?php echo ($user_role === 'Customer') ? 'dashboard.php' : 'index.php'; ?>" class="logo logo-light">
                    <span class="logo-sm">
                        <img src="assets/images/momo-logo-sm.png" alt="MoMo Platform" height="22">
                    </span>
                    <span class="logo-lg">
                        <img src="assets/images/momo-logo-light.png" alt="MoMo Platform" height="24">
                    </span>
                </a>
                <a href="<?php echo ($user_role === 'Customer') ? 'dashboard.php' : 'index.php'; ?>" class="logo logo-dark">
                    <span class="logo-sm">
                        <img src="assets/images/momo-logo-sm.png" alt="MoMo Platform" height="22">
                    </span>
                    <span class="logo-lg">
                        <img src="assets/images/momo-logo-dark.png" alt="MoMo Platform" height="24">
                    </span>
                </a>
            </div>

            <ul id="side-menu">

                <li class="menu-title">Main</li>

                <!-- Dashboard -->
                <li>
                    <?php if ($user_role === 'Customer'): ?>
                    <a href="dashboard.php" class="tp-link">
                        <i data-feather="home"></i>
                        <span> Dashboard </span>
                    </a>
                    <?php else: ?>
                    <a href="#sidebarDashboards" data-bs-toggle="collapse">
                        <i data-feather="home"></i>
                        <span> Dashboard </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarDashboards">
                        <ul class="nav-second-level">
                            <li>
                                <a href="admin-dashboard.php" class="tp-link">Overview</a>
                            </li>
                            <?php if (hasPermission('view_analytics')): ?>
                            <li>
                                <a href="sales-dashboard.php" class="tp-link">Sales Analytics</a>
                            </li>
                            <li>
                                <a href="revenue-dashboard.php" class="tp-link">Revenue Reports</a>
                            </li>
                            <?php endif; ?>
                        </ul>
                    </div>
                    <?php endif; ?>
                </li>

                <?php if ($user_role === 'Customer'): ?>
                <!-- Customer Menu Items -->
                <li class="menu-title">My Account</li>

                <!-- Licenses & Downloads -->
                <li>
                    <a href="#sidebarLicenses" data-bs-toggle="collapse">
                        <i data-feather="key"></i>
                        <span> Licenses & Downloads </span>
                        <?php 
                        $activeLicenses = getActiveLicensesCount();
                        if ($activeLicenses > 0): 
                        ?>
                        <span class="badge bg-success ms-auto"><?php echo $activeLicenses; ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarLicenses">
                        <ul class="nav-second-level">
                            <li>
                                <a href="my-licenses.php" class="tp-link">My Licenses</a>
                            </li>
                            <li>
                                <a href="download-plugins.php" class="tp-link">Download Plugins</a>
                            </li>
                            <li>
                                <a href="license-activation.php" class="tp-link">Activate License</a>
                            </li>
                            <li>
                                <a href="customization-settings.php" class="tp-link">Plugin Customization</a>
                            </li>
                        </ul>
                    </div>
                </li>

                <!-- Wallet & Payments -->
                <li>
                    <a href="#sidebarWallet" data-bs-toggle="collapse">
                        <i data-feather="credit-card"></i>
                        <span> Wallet & Payments </span>
                        <?php 
                        $walletBalance = getWalletBalance();
                        if ($walletBalance > 0): 
                        ?>
                        <span class="badge bg-info ms-auto">$<?php echo number_format($walletBalance, 2); ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarWallet">
                        <ul class="nav-second-level">
                            <li>
                                <a href="wallet-overview.php" class="tp-link">Wallet Overview</a>
                            </li>
                            <li>
                                <a href="topup-wallet.php" class="tp-link">Top Up Wallet</a>
                            </li>
                            <li>
                                <a href="payment-history.php" class="tp-link">Payment History</a>
                            </li>
                            <li>
                                <a href="transaction-receipts.php" class="tp-link">Receipts</a>
                            </li>
                        </ul>
                    </div>
                </li>

                <!-- Plugin Store -->
                <li>
                    <a href="#sidebarStore" data-bs-toggle="collapse">
                        <i data-feather="shopping-cart"></i>
                        <span> Plugin Store </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarStore">
                        <ul class="nav-second-level">
                            <li>
                                <a href="browse-plugins.php" class="tp-link">Browse Plugins</a>
                            </li>
                            <li>
                                <a href="payment-gateways.php" class="tp-link">Payment Gateways</a>
                            </li>
                            <li>
                                <a href="custom-solutions.php" class="tp-link">Custom Solutions</a>
                            </li>
                            <li>
                                <a href="my-orders.php" class="tp-link">My Orders</a>
                            </li>
                        </ul>
                    </div>
                </li>

                <!-- Analytics -->
                <li>
                    <a href="customer-analytics.php" class="tp-link">
                        <i data-feather="bar-chart-2"></i>
                        <span> My Analytics </span>
                    </a>
                </li>

                <!-- Support -->
                <li>
                    <a href="#sidebarSupport" data-bs-toggle="collapse">
                        <i data-feather="help-circle"></i>
                        <span> Support </span>
                        <?php 
                        $openTickets = getOpenTickets();
                        if ($openTickets > 0): 
                        ?>
                        <span class="badge bg-danger ms-auto"><?php echo $openTickets; ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarSupport">
                        <ul class="nav-second-level">
                            <li>
                                <a href="my-tickets.php" class="tp-link">
                                    My Tickets
                                    <?php if ($openTickets > 0): ?>
                                    <span class="badge bg-warning ms-2"><?php echo $openTickets; ?></span>
                                    <?php endif; ?>
                                </a>
                            </li>
                            <li>
                                <a href="create-ticket.php" class="tp-link">Create Ticket</a>
                            </li>
                            <li>
                                <a href="documentation.php" class="tp-link">Documentation</a>
                            </li>
                            <li>
                                <a href="faqs.php" class="tp-link">FAQs</a>
                            </li>
                        </ul>
                    </div>
                </li>

                <?php else: ?>
                <!-- Admin/Staff Menu Items -->
                <li class="menu-title">Management</li>

                <!-- Users & Customers -->
                <?php if (hasPermission('manage_users')): ?>
                <li>
                    <a href="#sidebarUsers" data-bs-toggle="collapse">
                        <i data-feather="users"></i>
                        <span> Users & Customers </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarUsers">
                        <ul class="nav-second-level">
                            <li>
                                <a href="manage-customers.php" class="tp-link">Customers</a>
                            </li>
                            <li>
                                <a href="manage-staff.php" class="tp-link">Staff Users</a>
                            </li>
                            <li>
                                <a href="list_roles.php" class="tp-link">Roles & Permissions</a>
                            </li>
                            <li>
                                <a href="user-activity.php" class="tp-link">Activity Log</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <!-- Products & Plugins -->
                <?php if (hasPermission('manage_products')): ?>
                <li>
                    <a href="#sidebarProducts" data-bs-toggle="collapse">
                        <i data-feather="package"></i>
                        <span> Products & Plugins </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarProducts">
                        <ul class="nav-second-level">
                            <li>
                                <a href="manage-products.php" class="tp-link">All Products</a>
                            </li>
                            <li>
                                <a href="product-categories.php" class="tp-link">Categories</a>
                            </li>
                            <li>
                                <a href="plugin-templates.php" class="tp-link">Plugin Templates</a>
                            </li>
                            <li>
                                <a href="pricing-tiers.php" class="tp-link">Pricing Tiers</a>
                            </li>
                            <li>
                                <a href="product-files.php" class="tp-link">File Management</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <!-- Licenses & Activations -->
                <?php if (hasPermission('manage_licenses')): ?>
                <li>
                    <a href="#sidebarLicenseAdmin" data-bs-toggle="collapse">
                        <i data-feather="shield"></i>
                        <span> License Management </span>
                        <?php 
                        $pendingActivations = getPendingActivations();
                        $piracyViolations = getPiracyViolations();
                        $totalAlerts = $pendingActivations + $piracyViolations;
                        if ($totalAlerts > 0): 
                        ?>
                        <span class="badge bg-warning ms-auto"><?php echo $totalAlerts; ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarLicenseAdmin">
                        <ul class="nav-second-level">
                            <li>
                                <a href="all-licenses.php" class="tp-link">All Licenses</a>
                            </li>
                            <li>
                                <a href="license-activations.php" class="tp-link">
                                    Activations
                                    <?php if ($pendingActivations > 0): ?>
                                    <span class="badge bg-warning ms-2"><?php echo $pendingActivations; ?></span>
                                    <?php endif; ?>
                                </a>
                            </li>
                            <li>
                                <a href="piracy-violations.php" class="tp-link">
                                    Piracy Violations
                                    <?php if ($piracyViolations > 0): ?>
                                    <span class="badge bg-danger ms-2"><?php echo $piracyViolations; ?></span>
                                    <?php endif; ?>
                                </a>
                            </li>
                            <li>
                                <a href="license-analytics.php" class="tp-link">License Analytics</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <!-- Orders & Payments -->
                <?php if (hasPermission('manage_payments')): ?>
                <li>
                    <a href="#sidebarOrders" data-bs-toggle="collapse">
                        <i data-feather="shopping-bag"></i>
                        <span> Orders & Payments </span>
                        <?php 
                        $pendingOrders = getPendingOrders();
                        if ($pendingOrders > 0): 
                        ?>
                        <span class="badge bg-info ms-auto"><?php echo $pendingOrders; ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarOrders">
                        <ul class="nav-second-level">
                            <li>
                                <a href="all-orders.php" class="tp-link">All Orders</a>
                            </li>
                            <li>
                                <a href="payment-transactions.php" class="tp-link">Transactions</a>
                            </li>
                            <li>
                                <a href="wallet-management.php" class="tp-link">Wallet Management</a>
                            </li>
                            <li>
                                <a href="refunds.php" class="tp-link">Refunds</a>
                            </li>
                            <li>
                                <a href="discount-codes.php" class="tp-link">Discount Codes</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <!-- Support & Tickets -->
                <?php if (hasPermission('manage_support')): ?>
                <li>
                    <a href="#sidebarSupportAdmin" data-bs-toggle="collapse">
                        <i data-feather="headphones"></i>
                        <span> Support Center </span>
                        <?php 
                        $allTickets = getOpenTickets();
                        if ($allTickets > 0): 
                        ?>
                        <span class="badge bg-danger ms-auto"><?php echo $allTickets; ?></span>
                        <?php endif; ?>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarSupportAdmin">
                        <ul class="nav-second-level">
                            <li>
                                <a href="all-tickets.php" class="tp-link">
                                    All Tickets
                                    <?php if ($allTickets > 0): ?>
                                    <span class="badge bg-danger ms-2"><?php echo $allTickets; ?></span>
                                    <?php endif; ?>
                                </a>
                            </li>
                            <li>
                                <a href="ticket-queue.php" class="tp-link">Ticket Queue</a>
                            </li>
                            <li>
                                <a href="knowledge-base.php" class="tp-link">Knowledge Base</a>
                            </li>
                            <li>
                                <a href="canned-responses.php" class="tp-link">Canned Responses</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <li class="menu-title">Analytics & Reports</li>

                <!-- Business Analytics -->
                <?php if (hasPermission('view_analytics')): ?>
                <li>
                    <a href="#sidebarAnalytics" data-bs-toggle="collapse">
                        <i data-feather="trending-up"></i>
                        <span> Business Analytics </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarAnalytics">
                        <ul class="nav-second-level">
                            <li>
                                <a href="sales-analytics.php" class="tp-link">Sales Analytics</a>
                            </li>
                            <li>
                                <a href="revenue-reports.php" class="tp-link">Revenue Reports</a>
                            </li>
                            <li>
                                <a href="customer-analytics.php" class="tp-link">Customer Insights</a>
                            </li>
                            <li>
                                <a href="plugin-performance.php" class="tp-link">Plugin Performance</a>
                            </li>
                            <li>
                                <a href="market-analysis.php" class="tp-link">Market Analysis</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <!-- API Management -->
                <?php if (hasPermission('manage_api')): ?>
                <li>
                    <a href="#sidebarAPI" data-bs-toggle="collapse">
                        <i data-feather="settings"></i>
                        <span> API Management </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarAPI">
                        <ul class="nav-second-level">
                            <li>
                                <a href="api-keys.php" class="tp-link">API Keys</a>
                            </li>
                            <li>
                                <a href="api-logs.php" class="tp-link">API Logs</a>
                            </li>
                            <li>
                                <a href="api-documentation.php" class="tp-link">Documentation</a>
                            </li>
                            <li>
                                <a href="webhooks.php" class="tp-link">Webhooks</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <li class="menu-title">System</li>

                <!-- Settings -->
                <?php if (hasPermission('manage_settings')): ?>
                <li>
                    <a href="#sidebarSettings" data-bs-toggle="collapse">
                        <i data-feather="tool"></i>
                        <span> System Settings </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarSettings">
                        <ul class="nav-second-level">
                            <li>
                                <a href="general-settings.php" class="tp-link">General Settings</a>
                            </li>
                            <li>
                                <a href="payment-settings.php" class="tp-link">Payment Settings</a>
                            </li>
                            <li>
                                <a href="email-settings.php" class="tp-link">Email Settings</a>
                            </li>
                            <li>
                                <a href="security-settings.php" class="tp-link">Security Settings</a>
                            </li>
                            <li>
                                <a href="exchange-rates.php" class="tp-link">Exchange Rates</a>
                            </li>
                        </ul>
                    </div>
                </li>
                <?php endif; ?>

                <?php endif; ?>

                <!-- Profile & Account (All Users) -->
                <li class="menu-title">Account</li>

                <li>
                    <a href="#sidebarProfile" data-bs-toggle="collapse">
                        <i data-feather="user"></i>
                        <span> My Profile </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <div class="collapse" id="sidebarProfile">
                        <ul class="nav-second-level">
                            <li>
                                <a href="profile.php" class="tp-link">Profile Settings</a>
                            </li>
                            <li>
                                <a href="change-password.php" class="tp-link">Change Password</a>
                            </li>
                            <li>
                                <a href="notifications-settings.php" class="tp-link">
                                    Notifications
                                    <?php 
                                    $unreadNotifications = getUnreadNotifications();
                                    if ($unreadNotifications > 0): 
                                    ?>
                                    <span class="badge bg-info ms-2"><?php echo $unreadNotifications; ?></span>
                                    <?php endif; ?>
                                </a>
                            </li>
                            <?php if ($user_role === 'Customer'): ?>
                            <li>
                                <a href="billing-info.php" class="tp-link">Billing Information</a>
                            </li>
                            <li>
                                <a href="api-access.php" class="tp-link">API Access</a>
                            </li>
                            <?php endif; ?>
                        </ul>
                    </div>
                </li>

                <!-- Logout -->
                <li>
                    <a href="auth-logout.php" class="tp-link">
                        <i data-feather="log-out"></i>
                        <span> Logout </span>
                    </a>
                </li>

            </ul>
            
        </div>
        <!-- End Sidebar -->

        <div class="clearfix"></div>

    </div>
</div>
<!-- Left Sidebar End -->

<!-- Custom Styles for Platform -->
<style>
.badge {
    font-size: 0.65rem;
    padding: 0.25em 0.5em;
}

.menu-title {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.nav-second-level .badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

#side-menu > li > a {
    position: relative;
}

#side-menu .badge.ms-auto {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
}

/* Different colors for different user roles */
<?php if ($user_role === 'Customer'): ?>
.logo-box {
    border-bottom: 2px solid #28a745;
}
<?php elseif ($user_role === 'Administrator'): ?>
.logo-box {
    border-bottom: 2px solid #dc3545;
}
<?php elseif ($user_role === 'Support Agent'): ?>
.logo-box {
    border-bottom: 2px solid #17a2b8;
}
<?php elseif ($user_role === 'Sales Manager'): ?>
.logo-box {
    border-bottom: 2px solid #ffc107;
}
<?php elseif ($user_role === 'Developer'): ?>
.logo-box {
    border-bottom: 2px solid #6f42c1;
}
<?php endif; ?>

/* Sidebar hover effects */
.nav-second-level a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Badge animations */
.badge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Active menu item highlighting */
.nav-second-level .active {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .badge.ms-auto {
        right: 15px;
    }
    
    .nav-second-level .badge {
        right: 5px;
    }
}
</style>