<?php
// includes/sidebar.php
$nav = $nav ?? 'dashboard';
$sidebar_logo_cache = file_exists(__DIR__ . '/../assets/upload/logo.png') ? filemtime(__DIR__ . '/../assets/upload/logo.png') : time();
$panel_logo_size = 42;
if (isset($conn)) {
    $resSide = $conn->query("SELECT panel_logo_size FROM config WHERE theme_id = 1 LIMIT 1");
    if ($resSide && $rowSide = $resSide->fetch_assoc()) {
        if (!empty($rowSide['panel_logo_size'])) {
            $panel_logo_size = (int)$rowSide['panel_logo_size'];
        }
    }
}
?>
<div class="sidebar">
    <div class="logo">
        <img src="assets/upload/logo.png?v=<?php echo $sidebar_logo_cache; ?>" alt="Logo" style="max-height: <?php echo $panel_logo_size; ?>px !important;">
    </div>
    
    <ul class="list-unstyled">
        <li class="menu-title">Menu Principal</li>
        <li>
            <a class="menu-link<?php echo $nav === 'dashboard' ? ' active' : ''; ?>" href="dashboard.php">
     <img width="25" height="25" src="https://img.icons8.com/fluency/48/control-panel.png" alt="control-panel" style="margin-right: 8px;" /> Dashboard
            </a>
        </li>

        <li class="menu-title">Launcher</li>
        <li>
            <a href="branding.php" class="menu-link <?php echo $nav == 'branding' ? 'active' : ''; ?>">
     <img width="25" height="25" src="https://img.icons8.com/arcade/64/exhibition.png" alt="exhibition" style="margin-right: 8px;"/> Fundo-Logo-Nome
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'propaganda' ? ' active' : ''; ?>" href="propaganda.php">
     <img width="25" height="25" src="https://img.icons8.com/external-smashingstocks-flat-smashing-stocks/66/external-Image-music-and-multimedia-smashingstocks-flat-smashing-stocks.png" alt="external-Image-music-and-multimedia-smashingstocks-flat-smashing-stocks" style="margin-right: 8px;" /> Banners
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'buttons' ? ' active' : ''; ?>" href="buttons.php">
     <img width="24" height="24" src="https://img.icons8.com/external-tal-revivo-filled-tal-revivo/24/external-nintendo-switch-system-a-gaming-console-you-can-play-both-at-home-and-on-the-go-logo-filled-tal-revivo.png" alt="external-nintendo-switch-system-a-gaming-console-you-can-play-both-at-home-and-on-the-go-logo-filled-tal-revivo" style="margin-right: 8px;" /> Botões Principais
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'grid' ? ' active' : ''; ?>" href="grid.php">
     <img width="25" height="25" src="https://img.icons8.com/emoji/48/mobile-phone.png" alt="mobile-phone" style="margin-right: 8px;" /> Aplicativos
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'apps' ? ' active' : ''; ?>" href="apps.php">
     <img width="25" height="25" src="https://img.icons8.com/fluency/48/device-shop.png" alt="device-shop" style="margin-right: 8px;" /> Loja de Apps (Store)
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'devices' ? ' active' : ''; ?>" href="devices.php">
     <img width="25" height="25" src="https://img.icons8.com/external-flaticons-flat-flat-icons/64/external-hard-code-web-development-flaticons-flat-flat-icons.png" alt="external-hard-code-web-development-flaticons-flat-flat-icons" style="margin-right: 8px;" /> Gestão de Dispositivos
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'plans' ? ' active' : ''; ?>" href="plans.php">
     <img width="25" height="25" src="https://img.icons8.com/external-vectorslab-outline-color-vectorslab/53/external-giving-money-business-and-finance-vectorslab-outline-color-vectorslab-2.png" alt="external-giving-money-business-and-finance-vectorslab-outline-color-vectorslab-2" style="margin-right: 8px;" /> Planos e Preços
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'configuracoes' ? ' active' : ''; ?>" href="configuracoes.php">
     <img width="25" height="25" src="https://img.icons8.com/fluency/48/administrative-tools.png" alt="administrative-tools" style="margin-right: 8px;" /> Configurações      
            </a>
        </li>
        <li>
            <a class="menu-link<?php echo $nav === 'themes' ? ' active' : ''; ?>" href="themes.php">
    <img width="25" height="25" src="https://img.icons8.com/fluency/48/themes.png" alt="themes"style="margin-right: 8px;" /> Gerenciar Temas
            </a>
        </li>

        <li class="menu-title">Acesso</li>
        <li>
            <a class="menu-link" href="logout.php">
    <img width="25" height="25" src="https://img.icons8.com/stencil/32/exit.png" alt="exit" style="margin-right: 8px;" /> Sair
</a>

            </a>
        </li>
    </ul>
    
    <div class="text-center py-3" style="font-size: 11px; opacity: 0.25; transition: opacity 0.3s; margin-top: 20px;" onmouseover="this.style.opacity='0.85'" onmouseout="this.style.opacity='0.25'">
        <a href="<?php echo htmlspecialchars(base64_decode('aHR0cHM6Ly90Lm1lL3N0b3JlYXJ0X2RpZ2l0YWw=')); ?>" target="_blank" style="color: #fff; text-decoration: none; font-weight: bold; letter-spacing: 0.5px;">
            <i class="bi bi-code-slash me-1"></i><?php echo htmlspecialchars(base64_decode('U3RvcmVBcnQ=')); ?>
        </a>
    </div>
</div>
<div class="sidebar-overlay" id="sidebarOverlay"></div>

