<!-- Sidebar -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <a href="dashboard.php" class="brand-link">
        <i class="fas fa-microchip brand-image"></i>
        <span class="brand-text font-weight-light">DMAppsESP</span>
    </a>

    <div class="sidebar">
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <img src="assets/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
            </div>
            <div class="info">
                <a href="#" class="d-block text-white"><?php echo htmlspecialchars($user['username']); ?></a>
                <small class="text-muted"><?php echo htmlspecialchars($user['role']); ?></small>
            </div>
        </div>
        
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu">
                <li class="nav-item">
                    <a href="dashboard.php" class="nav-link <?php echo $current_page == 'dashboard' ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>Dashboard</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="devices.php" class="nav-link <?php echo $current_page == 'devices' ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-microchip"></i>
                        <p>Cihazlar</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">
                        <i class="nav-icon fas fa-chart-line"></i>
                        <p>
                            Analitik
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="analytics.php" class="nav-link <?php echo $current_page == 'analytics' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Analitik</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="analytics_advanced.php" class="nav-link <?php echo $current_page == 'analytics_advanced' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Gelişmiş Analitik</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">
                        <i class="nav-icon fas fa-tools"></i>
                        <p>
                            Cihaz Yönetimi
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="add_device.php" class="nav-link <?php echo $current_page == 'add_device' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Cihaz Ekle</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="device_detail.php" class="nav-link <?php echo $current_page == 'device_detail' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Cihaz Detay</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="device_edit.php" class="nav-link <?php echo $current_page == 'device_edit' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Cihaz Düzenle</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="device_logs.php" class="nav-link <?php echo $current_page == 'device_logs' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Cihaz Logları</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="flasher.php" class="nav-link <?php echo $current_page == 'flasher' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Firmware Flash</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>
                            Dashboard'lar
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="dashboard.php" class="nav-link <?php echo $current_page == 'dashboard' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Ana Dashboard</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="dashboard_new.php" class="nav-link <?php echo $current_page == 'dashboard_new' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Yeni Dashboard</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="dashboard_realtime.php" class="nav-link <?php echo $current_page == 'dashboard_realtime' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Gerçek Zamanlı</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">
                        <i class="nav-icon fas fa-file-alt"></i>
                        <p>
                            Sistem
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="error_logs.php" class="nav-link <?php echo $current_page == 'error_logs' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Hata Logları</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="profile.php" class="nav-link <?php echo $current_page == 'profile' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Profil</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <?php if ($user['role'] === 'admin'): ?>
                <li class="nav-item">
                    <a href="#" class="nav-link <?php echo $current_page == 'users' ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-users"></i>
                        <p>
                            Kullanıcı Yönetimi
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="all_users.php" class="nav-link <?php echo $current_page == 'all_users' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Tüm Kullanıcılar</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="add_user.php" class="nav-link <?php echo $current_page == 'add_user' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Kullanıcı Ekle</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="delete_user.php" class="nav-link <?php echo $current_page == 'delete_user' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Kullanıcı Sil</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">
                        <i class="nav-icon fas fa-cogs"></i>
                        <p>
                            Admin Araçları
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="admin_settings.php" class="nav-link <?php echo $current_page == 'admin_settings' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Admin Ayarları</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="database_status.php" class="nav-link <?php echo $current_page == 'database_status' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Veritabanı Durumu</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="mobile_responsive.php" class="nav-link <?php echo $current_page == 'mobile_responsive' ? 'active' : ''; ?>">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Mobil Görünüm</p>
                            </a>
                        </li>
                    </ul>
                </li>
                <?php endif; ?>
                <li class="nav-item">
                    <a href="settings.php" class="nav-link <?php echo $current_page == 'settings' ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-cog"></i>
                        <p>Ayarlar</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="logout.php" class="nav-link">
                        <i class="nav-icon fas fa-sign-out-alt"></i>
                        <p>Çıkış</p>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</aside>
