<?php
// admin/inc/header.php

// Verifica se há tentativa de acesso direto
if (!defined('BASE_PATH')) {
    exit('Acesso direto não permitido');
}

// Importações de arquivos necessários com verificação
$requiredFiles = ['config.php', 'auth.php'];
foreach ($requiredFiles as $file) {
    $path = BASE_PATH . '/includes/' . $file;
    if (!file_exists($path)) {
        file_put_contents(BASE_PATH . '/emergency.log', date('Y-m-d H:i:s') . " - Arquivo não encontrado: $path\n", FILE_APPEND);
        die("Erro crítico: Arquivo $file não encontrado.");
    }
    try {
        require_once $path;
    } catch (Throwable $e) {
        file_put_contents(BASE_PATH . '/emergency.log', date('Y-m-d H:i:s') . " - Erro ao incluir $file: " . $e->getMessage() . "\n", FILE_APPEND);
        die("Erro crítico ao incluir $file: " . $e->getMessage());
    }
}

// Verificar autenticação
try {
    if (!isset($auth) || !is_object($auth) || !method_exists($auth, 'isLoggedIn')) {
        throw new Exception("Objeto \$auth não está definido ou inválido.");
    }

    if (!$auth->isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php') {
        header('Location: login.php');
        exit;
    }
} catch (Exception $e) {
    file_put_contents(BASE_PATH . '/emergency.log', date('Y-m-d H:i:s') . " - Erro na verificação de autenticação: " . $e->getMessage() . "\n", FILE_APPEND);
    header('Location: login.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($pageTitle) ? htmlspecialchars($pageTitle) : 'Admin'; ?> - Painel Administrativo</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    <style>
        :root {
            --primary-color: #4F46E5;
            --primary-dark: #4338CA;
            --secondary-color: #7C3AED;
            --secondary-dark: #6D28D9;
            --accent-color: #EC4899;
            --dark-color: #1F2937;
            --light-color: #F9FAFB;
            --text-color: #1F2937;
            --text-light: #6B7280;
            --border-color: #E5E7EB;
            --success-color: #10B981;
            --warning-color: #F59E0B;
            --danger-color: #EF4444;
            --info-color: #3B82F6;
            --sidebar-width: 280px;
            --sidebar-collapse-width: 70px;
            --header-height: 65px;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            --gradient-success: linear-gradient(135deg, #10B981, #059669);
            --gradient-danger: linear-gradient(135deg, #EF4444, #DC2626);
            --gradient-warning: linear-gradient(135deg, #F59E0B, #D97706);
            --gradient-info: linear-gradient(135deg, #3B82F6, #2563EB);
            --transition-normal: all 0.3s ease;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            background-color: #F3F4F6;
            font-family: 'Poppins', sans-serif;
            color: var(--text-color);
            font-size: 0.95rem;
            line-height: 1.5;
            overflow-x: hidden;
        }
        
        a {
            text-decoration: none;
            color: inherit;
        }
        
        /* === SIDEBAR STYLES === */
        .sidebar {
            width: var(--sidebar-width);
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            background: white;
            box-shadow: var(--shadow-md);
            z-index: 1000;
            transition: var(--transition-normal);
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(0,0,0,0.2) transparent;
        }
        
        .sidebar::-webkit-scrollbar {
            width: 4px;
        }
        
        .sidebar::-webkit-scrollbar-track {
            background: transparent;
        }
        
        .sidebar::-webkit-scrollbar-thumb {
            background-color: rgba(0,0,0,0.2);
            border-radius: 10px;
        }
        
        .sidebar-collapsed {
            width: var(--sidebar-collapse-width);
        }
        
        .sidebar-logo {
            padding: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(0,0,0,0.05);
            height: var(--header-height);
        }
        
        .sidebar-logo img {
            height: 36px;
            transition: var(--transition-normal);
        }
        
        .sidebar-toggle {
            width: 30px;
            height: 30px;
            border-radius: 6px;
            background: var(--light-color);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--primary-color);
            transition: var(--transition-normal);
            border: none;
        }
        
        .sidebar-toggle:hover {
            background: rgba(79, 70, 229, 0.1);
            color: var(--primary-dark);
        }
        
        .sidebar-menu {
            padding: 1.5rem 0;
            flex: 1;
        }
        
        .sidebar-title {
            padding: 0 1.5rem;
            margin-bottom: 0.75rem;
            color: var(--text-light);
            font-size: 0.8rem;
            text-transform: uppercase;
            font-weight: 600;
            letter-spacing: 0.5px;
            transition: var(--transition-normal);
            white-space: nowrap;
            opacity: 1;
        }
        
        .sidebar-collapsed .sidebar-title {
            opacity: 0;
        }
        
        .nav-item {
            list-style: none;
            margin: 0.25rem 0.75rem;
            border-radius: 8px;
            transition: var(--transition-normal);
        }
        
        .nav-link {
            display: flex;
            align-items: center;
            padding: 0.75rem 0.75rem;
            color: var(--text-color);
            border-radius: 8px;
            transition: var(--transition-normal);
            position: relative;
            font-weight: 500;
        }
        
        .nav-link:hover {
            background: rgba(79, 70, 229, 0.05);
            color: var(--primary-color);
        }
        
        .nav-link.active {
            background: var(--gradient-primary);
            color: white;
            box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
        }
        
        .nav-link.active:hover {
            color: white;
        }
        
        .nav-icon {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
            font-size: 1.1rem;
            transition: var(--transition-normal);
            flex-shrink: 0;
        }
        
        .sidebar-collapsed .nav-icon {
            margin-right: 0;
        }
        
        .nav-text {
            transition: var(--transition-normal);
            white-space: nowrap;
            opacity: 1;
        }
        
        .sidebar-collapsed .nav-text {
            opacity: 0;
            width: 0;
        }
        
        .sidebar-divider {
            height: 1px;
            background: rgba(0,0,0,0.05);
            margin: 1rem 1.5rem;
        }
        
        .sidebar-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid rgba(0,0,0,0.05);
            display: flex;
            align-items: center;
            transition: var(--transition-normal);
        }
        
        .sidebar-user {
            display: flex;
            align-items: center;
            width: 100%;
        }
        
        .sidebar-user-img {
            width: 36px;
            height: 36px;
            border-radius: 8px;
            background: var(--gradient-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
            margin-right: 1rem;
            flex-shrink: 0;
            font-size: 1rem;
            transition: var(--transition-normal);
        }
        
        .sidebar-user-info {
            display: flex;
            flex-direction: column;
            transition: var(--transition-normal);
            overflow: hidden;
            white-space: nowrap;
            opacity: 1;
        }
        
        .sidebar-collapsed .sidebar-user-info {
            opacity: 0;
            width: 0;
        }
        
        .sidebar-user-name {
            font-weight: 600;
            font-size: 0.9rem;
        }
        
        .sidebar-user-role {
            font-size: 0.75rem;
            color: var(--text-light);
        }
        
        .sidebar-dropdown {
            margin-left: auto;
            cursor: pointer;
            color: var(--text-light);
            transition: var(--transition-normal);
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
        }
        
        .sidebar-dropdown:hover {
            background: rgba(79, 70, 229, 0.1);
            color: var(--primary-color);
        }
        
        .sidebar-collapsed .sidebar-dropdown {
            display: none;
        }
        
        /* === MAIN CONTENT === */
        .main-container {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            transition: var(--transition-normal);
            display: flex;
            flex-direction: column;
        }
        
        .sidebar-collapsed-main {
            margin-left: var(--sidebar-collapse-width);
        }
        
        /* === HEADER === */
        .header {
            height: var(--header-height);
            background: white;
            box-shadow: var(--shadow-sm);
            padding: 0 1.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 999;
        }
        
        .header-left {
            display: flex;
            align-items: center;
        }
        
        .menu-toggle {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background: var(--light-color);
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--primary-color);
            transition: var(--transition-normal);
            margin-right: 1rem;
            border: none;
        }
        
        .menu-toggle:hover {
            background: rgba(79, 70, 229, 0.1);
            color: var(--primary-dark);
        }
        
        .page-title {
            font-weight: 600;
            font-size: 1.25rem;
            color: var(--dark-color);
        }
        
        .header-right {
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        
        .header-icon {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-light);
            transition: var(--transition-normal);
            position: relative;
            background: var(--light-color);
        }
        
        .header-icon:hover {
            background: rgba(79, 70, 229, 0.1);
            color: var(--primary-color);
        }
        
        .header-icon .badge {
            position: absolute;
            top: -5px;
            right: -5px;
            width: 18px;
            height: 18px;
            background: var(--danger-color);
            color: white;
            border-radius: 50%;
            font-size: 0.7rem;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
        }
        
        .user-dropdown {
            position: relative;
        }
        
        .user-dropdown-toggle {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.5rem;
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition-normal);
        }
        
        .user-dropdown-toggle:hover {
            background: rgba(79, 70, 229, 0.05);
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background: var(--gradient-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 600;
            flex-shrink: 0;
            font-size: 1rem;
        }
        
        .user-avatar img {
            width: 100%;
            height: 100%;
            border-radius: 8px;
            object-fit: cover;
        }
        
        .user-info {
            display: flex;
            flex-direction: column;
        }
        
        .user-name {
            font-weight: 600;
            font-size: 0.9rem;
        }
        
        .user-role {
            font-size: 0.75rem;
            color: var(--text-light);
        }
        
        .user-dropdown-menu {
            position: absolute;
            top: calc(100% + 10px);
            right: 0;
            width: 260px;
            background: white;
            border-radius: 10px;
            box-shadow: var(--shadow-lg);
            padding: 1rem 0;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transform: translateY(10px);
            transition: var(--transition-normal);
        }
        
        .user-dropdown-menu.show {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        
        .user-dropdown-header {
            padding: 0 1.25rem 1rem;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 0.5rem;
        }
        
        .user-dropdown-header .user-info {
            margin-top: 0.75rem;
        }
        
        .user-dropdown-header .user-name {
            font-size: 1rem;
        }
        
        .user-dropdown-item {
            display: flex;
            align-items: center;
            padding: 0.75rem 1.25rem;
            color: var(--text-color);
            transition: var(--transition-normal);
        }
        
        .user-dropdown-item:hover {
            background: rgba(79, 70, 229, 0.05);
            color: var(--primary-color);
        }
        
        .user-dropdown-item i {
            width: 24px;
            margin-right: 0.75rem;
        }
        
        .user-dropdown-item.logout {
            color: var(--danger-color);
        }
        
        .user-dropdown-item.logout:hover {
            background: rgba(239, 68, 68, 0.05);
            color: var(--danger-color);
        }
        
        .user-dropdown-divider {
            height: 1px;
            background: var(--border-color);
            margin: 0.5rem 0;
        }
        
        /* === CONTENT === */
        .content {
            padding: 1.5rem;
            flex: 1;
        }
        
        /* === ALERTS === */
        .alert {
            border-radius: 10px;
            border: none;
            display: flex;
            align-items: flex-start;
            padding: 1rem 1.25rem;
            margin-bottom: 1.5rem;
        }
        
        .alert-icon {
            margin-right: 1rem;
            font-size: 1.25rem;
            display: flex;
        }
        
        .alert-content {
            flex: 1;
        }
        
        .alert-success {
            background-color: rgba(16, 185, 129, 0.1);
            color: var(--success-color);
        }
        
        .alert-warning {
            background-color: rgba(245, 158, 11, 0.1);
            color: var(--warning-color);
        }
        
        .alert-danger {
            background-color: rgba(239, 68, 68, 0.1);
            color: var(--danger-color);
        }
        
        .alert-info {
            background-color: rgba(59, 130, 246, 0.1);
            color: var(--info-color);
        }
        
        .btn-close {
            color: currentColor;
            font-size: 1rem;
            opacity: 0.5;
            padding: 0.75rem;
            transition: opacity 0.15s;
        }
        
        .btn-close:hover {
            opacity: 1;
        }
        
        /* === RESPONSIVE STYLES === */
        @media (max-width: 992px) {
            .sidebar {
                left: -280px;
                box-shadow: none;
            }
            
            .sidebar.show {
                left: 0;
                box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
            }
            
            .menu-toggle {
                display: flex;
            }
            
            .main-container {
                margin-left: 0 !important;
            }
            
            .user-info {
                display: none;
            }
            
            /* Always show user dropdown menu header info on mobile */
            .user-dropdown-header .user-info {
                display: flex;
            }
        }
        
        @media (max-width: 576px) {
            .header {
                padding: 0 1rem;
            }
            
            .content {
                padding: 1rem;
            }
            
            .page-title {
                font-size: 1.1rem;
            }
            
            .header-icon {
                width: 36px;
                height: 36px;
            }
            
            .user-avatar {
                width: 36px;
                height: 36px;
            }
            
            .user-dropdown-menu {
                width: 240px;
            }
        }
    </style>
    
    <?php if (isset($useRichEditor) && $useRichEditor): ?>
    <!-- Adiciona o CSS do CKEditor se a página usar o editor rich text -->
    <link rel="stylesheet" href="https://cdn.ckeditor.com/ckeditor5/35.1.0/classic/ckeditor.css">
    <?php endif; ?>
    
    <?php if (isset($useAjax) && $useAjax): ?>
    <!-- Adiciona jQuery se a página usar AJAX -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <?php endif; ?>
</head>
<body>
    <!-- Overlay para dispositivos móveis -->
    <div id="sidebarOverlay" class="sidebar-overlay"></div>
    
    <!-- Sidebar -->
    <div class="sidebar" id="sidebar">
        <div class="sidebar-logo">
            <img src="/assets/img/logo.png" alt="Logo" class="sidebar-logo-img">
            <button class="sidebar-toggle" id="sidebarCollapseToggle">
                <i class="fas fa-chevron-left"></i>
            </button>
        </div>
        
        <div class="sidebar-menu">
            <div class="sidebar-title">Menu Principal</div>
            <ul class="nav flex-column">
                <li class="nav-item">
                    <a href="/admin/index.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'dashboard') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-home"></i></span>
                        <span class="nav-text">Dashboard</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/page-list.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'pages') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-file-alt"></i></span>
                        <span class="nav-text">Páginas</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/page-create.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'create-page') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-plus-circle"></i></span>
                        <span class="nav-text">Nova Página</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/tracking-settings.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'tracking-settings') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-chart-line"></i></span>
                        <span class="nav-text">Rastreamento</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/newsletter-subscribers.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'newsletter-subscribers') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-users"></i></span>
                        <span class="nav-text">Inscritos</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/newsletter-campaigns.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'newsletter-campaigns') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-bullseye"></i></span>
                        <span class="nav-text">Campanhas</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/reports-unique-visits.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'reports-unique-visits') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-chart-pie"></i></span>
                        <span class="nav-text">Analytics</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/content-generator.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'generator') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-magic"></i></span>
                        <span class="nav-text">Gerador IA</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/reports.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'reporets') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-chart-bar"></i></span>
                        <span class="nav-text">Relatório</span>
                    </a>
                </li>
               
                <li class="nav-item">
                    <a href="/admin/whatsapp-settings.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'whatsapp-settings') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fab fa-whatsapp"></i></span>
                        <span class="nav-text">Whatsapp</span>
                    </a>
                </li>
            </ul>
            
            <div class="sidebar-divider"></div>
            <div class="sidebar-title">Sistema</div>
            
            <ul class="nav flex-column">
                <li class="nav-item">
                    <a href="/admin/profile.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'profile') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-user"></i></span>
                        <span class="nav-text">Meu Perfil</span>
                    </a>
                </li>
                <?php if (isset($_SESSION['admin_role']) && $_SESSION['admin_role'] === 'admin'): ?>
                <li class="nav-item">
                    <a href="/admin/settings.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'settings') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-cog"></i></span>
                        <span class="nav-text">Configurações</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/maintenance.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'maintenance') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-tools"></i></span>
                        <span class="nav-text">Manutenção</span>
                    </a>
                </li>
                <?php endif; ?>
                <li class="nav-item">
                    <a href="/admin/help.php" class="nav-link <?php echo (isset($currentPage) && $currentPage === 'help') ? 'active' : ''; ?>">
                        <span class="nav-icon"><i class="fas fa-question-circle"></i></span>
                        <span class="nav-text">Ajuda</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/logout.php" class="nav-link">
                        <span class="nav-icon"><i class="fas fa-sign-out-alt"></i></span>
                        <span class="nav-text">Sair</span>
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <!-- Main Container -->
    <div class="main-container" id="mainContainer">
        <!-- Header -->
        <div class="header">
            <div class="header-left">
                <button class="menu-toggle" id="mobileMenuToggle">
                    <i class="fas fa-bars"></i>
                </button>
                <h1 class="page-title"><?php echo isset($pageHeader) ? htmlspecialchars($pageHeader) : (isset($pageTitle) ? htmlspecialchars($pageTitle) : 'Dashboard'); ?></h1>
            </div>
            
            <div class="header-right">
                <a href="/admin/help.php" class="header-icon">
                    <i class="fas fa-question-circle"></i>
                </a>
                
                <div class="user-dropdown">
                    <div class="user-dropdown-toggle" id="userDropdownToggle">
                        <div class="user-avatar">
                            <?php 
                            $userName = isset($_SESSION['admin_name']) ? $_SESSION['admin_name'] : 'User';
                            $initials = '';
                            $nameParts = explode(' ', $userName);
                            if (count($nameParts) >= 2) {
                                $initials = mb_substr($nameParts[0], 0, 1) . mb_substr($nameParts[count($nameParts)-1], 0, 1);
                            } else {
                                $initials = mb_substr($userName, 0, 2);
                            }
                            echo htmlspecialchars(strtoupper($initials));
                            ?>
                        </div>
                        <div class="user-info">
                            <div class="user-name"><?php echo htmlspecialchars($_SESSION['admin_name'] ?? 'Usuário'); ?></div>
                            <div class="user-role"><?php echo ucfirst(htmlspecialchars($_SESSION['admin_role'] ?? 'admin')); ?></div>
                        </div>
                    </div>
                    
                    <div class="user-dropdown-menu" id="userDropdownMenu">
                        <div class="user-dropdown-header">
                            <div class="user-avatar">
                                <?php echo htmlspecialchars(strtoupper($initials)); ?>
                            </div>
                            <div class="user-info">
                                <div class="user-name"><?php echo htmlspecialchars($_SESSION['admin_name'] ?? 'Usuário'); ?></div>
                                <div class="user-role"><?php echo ucfirst(htmlspecialchars($_SESSION['admin_role'] ?? 'admin')); ?></div>
                            </div>
                        </div>
                        
                        <a href="/admin/profile.php" class="user-dropdown-item">
                            <i class="fas fa-user"></i>
                            <span>Meu Perfil</span>
                        </a>
                        
                        <?php if (isset($_SESSION['admin_role']) && $_SESSION['admin_role'] === 'admin'): ?>
                        <a href="/admin/settings.php" class="user-dropdown-item">
                            <i class="fas fa-cog"></i>
                            <span>Configurações</span>
                        </a>
                        <?php endif; ?>
                        
                        <div class="user-dropdown-divider"></div>
                        
                        <a href="/admin/help.php" class="user-dropdown-item">
                            <i class="fas fa-question-circle"></i>
                            <span>Ajuda & Suporte</span>
                        </a>
                        
                        <div class="user-dropdown-divider"></div>
                        
                        <a href="/admin/logout.php" class="user-dropdown-item logout">
                            <i class="fas fa-sign-out-alt"></i>
                            <span>Sair</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <!-- Content -->
        <div class="content">
            <?php if ($alert = getAlert()): ?>
                <div class="alert alert-<?php echo htmlspecialchars($alert['type']); ?>" role="alert">
                    <div class="alert-icon">
                        <?php if ($alert['type'] === ALERT_SUCCESS): ?>
                            <i class="fas fa-check-circle"></i>
                        <?php elseif ($alert['type'] === ALERT_WARNING): ?>
                            <i class="fas fa-exclamation-triangle"></i>
                        <?php elseif ($alert['type'] === ALERT_ERROR || $alert['type'] === 'danger'): ?>
                            <i class="fas fa-times-circle"></i>
                        <?php else: ?>
                            <i class="fas fa-info-circle"></i>
                        <?php endif; ?>
                    </div>
                    <div class="alert-content">
                        <?php echo htmlspecialchars($alert['message']); ?>
                    </div>
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
            <?php endif; ?>