<?php
/**
 * NEPHRO ERP - SİDEBAR (AURA PRO v5 - TAM SÜRÜM)
 */
$current = $_GET['sayfa'] ?? 'dashboard';

// Aktif sayfa kontrol fonksiyonu
if (!function_exists('isActive')) {
    function isActive($p, $c) { return $p === $c ? 'is-active' : ''; }
}
?>

<div class="sidebar-overlay" onclick="toggleSidebar()"></div>

<aside class="main-sidebar">
    <div class="sidebar-brand">
        <a href="index.php" style="text-decoration: none; display: flex; align-items: center; gap: 12px;">
            <div class="brand-logo"><i class="fas fa-heartbeat"></i></div>
            <div class="brand-name">EGE<span>DESTEK</span></div>
        </a>
    </div>

    <nav class="sidebar-nav">
        <ul class="menu-list" style="list-style: none; padding: 0; margin: 0;">
            
            <li class="menu-item">
                <a href="index.php" class="menu-link <?php echo ($current == 'dashboard' || $current == '') ? 'is-active' : ''; ?>">
                    <i class="fas fa-chart-line"></i> <span>Genel Bakış (Dashboard)</span>
                </a>
            </li>

            <div class="menu-label">Operasyonel Süreçler</div>
            
            <li class="menu-item">
                <a href="?sayfa=hasta-ekle" class="menu-link <?php echo isActive('hasta-ekle', $current); ?>">
                    <i class="fas fa-user-plus"></i> <span>Yeni Hasta Kaydı</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=hasta-liste" class="menu-link <?php echo isActive('hasta-liste', $current); ?>">
                    <i class="fas fa-users"></i> <span>Hasta Listesi</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=hasta-onam" class="menu-link <?php echo isActive('hasta-onam', $current); ?>">
                    <i class="fas fa-file-signature"></i> <span>Onam & Arşiv</span>
                </a>
            </li>
			
			<li class="menu-item">
                <a href="?sayfa=dislab-gonder" class="menu-link <?php echo isActive('dislab-gonder', $current); ?>">
                    <i class="fas fa-file-export"></i> <span>Dışlab Hasta Gönderimi</span>
                </a>
            </li>
			
			<li class="menu-item">
                <a href="?sayfa=dislab-izle" class="menu-link <?php echo isActive('dislab-izle', $current); ?>">
                    <i class="fas fa-eye"></i> <span>Dışlab Hasta İzle</span>
                </a>
            </li>

            <div class="menu-label">Seans & Randevu</div>
            
			
			<li class="menu-item">
                <a href="?sayfa=seans-baslat" class="menu-link <?php echo isActive('seans-baslat', $current); ?>">
                    <i class="fas fa-stopwatch"></i> <span>Seans Başlat</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=aktif-seans-takip" class="menu-link <?php echo isActive('aktif-seans-takip', $current); ?>">
                    <i class="fas fa-broadcast-tower"></i> <span>Aktif Seans Takibi</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=seans-takvimi" class="menu-link <?php echo isActive('seans-takvimi', $current); ?>">
                    <i class="fas fa-calendar-alt"></i> <span>Haftalık Planlama</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=bugunku-seanslar" class="menu-link <?php echo isActive('bugunku-seanslar', $current); ?>">
                    <i class="fas fa-clock"></i> <span>Bugünkü Akış</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=yatak-doluluk" class="menu-link <?php echo isActive('yatak-doluluk', $current); ?>">
                    <i class="fas fa-bed"></i> <span>Cihaz/Yatak Durumu</span>
                </a>
            </li>

            <div class="menu-label">Klinik & Tıbbi</div>
            
            <li class="menu-item">
                <a href="?sayfa=vizit-notlari" class="menu-link <?php echo isActive('vizit-notlari', $current); ?>">
                    <i class="fas fa-user-md"></i> <span>Doktor Vizit Notları</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=hemsire-notlari" class="menu-link <?php echo isActive('hemsire-notlari', $current); ?>">
                    <i class="fas fa-notes-medical"></i> <span>Hemşire Gözlem</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=lab-sonuclari" class="menu-link <?php echo isActive('lab-sonuclari', $current); ?>">
                    <i class="fas fa-microscope"></i> <span>Laboratuvar Sonuçları</span>
                </a>
            </li>

            <div class="menu-label">Lojistik & Depo</div>
            
			<li class="menu-item">
                <a href="?sayfa=stok-takip" class="menu-link <?php echo isActive('stok-takip', $current); ?>">
                    <i class="fas fa-dolly"></i> <span>Sarf Malzeme Stok</span>
                </a>
            </li>
			
            <li class="menu-item">
                <a href="?sayfa=stok-liste" class="menu-link <?php echo isActive('stok-liste', $current); ?>">
                    <i class="fas fa-boxes-stacked"></i> <span>Malzeme Listesi</span>
                </a>
            </li>
            <li class="menu-item">
                <a href="?sayfa=stok-hareket" class="menu-link <?php echo isActive('stok-hareket', $current); ?>">
                    <i class="fas fa-exchange-alt"></i> <span>Depo Hareketleri</span>
                </a>
            </li>

            <div class="menu-label">Sistem</div>
			
            <li class="menu-item">
                <a href="?sayfa=test-tanimlari" class="menu-link <?php echo isActive('test-tanimlari', $current); ?>">
                    <i class="fas fa-vials"></i> <span>Test Tanımları</span>
                </a>
            </li>
			
			
			<li class="menu-item">
                <a href="?sayfa=cihazlar" class="menu-link <?php echo isActive('cihazlar', $current); ?>">
                    <i class="fas fa-microchip"></i> <span>Cihaz Tanımları</span>
                </a>
            </li>
			
			<li class="menu-item">
                <a href="?sayfa=cihaz-bakimlari" class="menu-link <?php echo isActive('cihaz-bakimlari', $current); ?>">
                    <i class="fas fa-screwdriver-wrench"></i> <span>Cihaz Bakımları</span>
                </a>
            </li>
			
            <li class="menu-item">
                <a href="?sayfa=ayarlar" class="menu-link <?php echo isActive('ayarlar', $current); ?>">
                    <i class="fas fa-cog"></i> <span>Sistem Ayarları</span>
                </a>
            </li>
			
			 <li class="menu-item">
                <a href="?sayfa=log-listesi" class="menu-link <?php echo isActive('log-listesi', $current); ?>">
                    <i class="fas fa-cog"></i> <span>Sistem Logları</span>
                </a>
            </li>
			
            <li class="menu-item">
                <a href="logout.php" class="menu-link" style="color:#ef4444;">
                    <i class="fas fa-power-off"></i> <span>Güvenli Çıkış</span>
                </a>
            </li>
        </ul>
    </nav>

    <div class="sidebar-footer">
        <div class="user-pill">
            <div class="u-avatar">AD</div>
            <div class="u-info"><strong>Dr. Admin</strong><span>Yönetici</span></div>
        </div>
    </div>
</aside>

<style>
/* SİDEBAR ANA TASARIM */
.main-sidebar { 
    width: var(--sb-w); height: 100vh; background: #fff; border-right: 1px solid var(--border); 
    position: fixed; left: 0; top: 0; display: flex; flex-direction: column; z-index: 1000; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-closed .main-sidebar { left: calc(var(--sb-w) * -1); }

.sidebar-brand { height: 70px; padding: 0 25px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 38px; height: 38px; background: var(--accent); color: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2); }
.brand-name { font-weight: 800; font-size: 1.1rem; color: #0f172a; letter-spacing: -0.5px; }
.brand-name span { color: var(--accent); font-weight: 300; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 15px; scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent; }

.menu-label { 
    padding: 25px 15px 12px; 
    font-size: 0.7rem; 
    font-weight: 800; 
    color: #334155; 
    text-transform: uppercase; 
    letter-spacing: 1.5px; 
    display: flex; 
    align-items: center;
    border-top: 1px solid #f8fafc;
    margin-top: 10px;
}
.menu-label:first-of-type { border-top: none; margin-top: 0; }

.menu-link { 
    display: flex; align-items: center; gap: 14px; padding: 12px 16px; color: #64748b; 
    text-decoration: none; font-weight: 600; font-size: 0.9rem; border-radius: 14px; 
    transition: 0.2s; margin-bottom: 4px;
}
.menu-link i { font-size: 1.1rem; width: 24px; text-align: center; color: #94a3b8; transition: 0.2s; }
.menu-link:hover { background: #f8fafc; color: var(--accent); }
.menu-link:hover i { color: var(--accent); }

.menu-link.is-active { background: #eff6ff; color: var(--accent); border-right: 3px solid var(--accent); border-radius: 14px 4px 4px 14px; }
.menu-link.is-active i { color: var(--accent); }

.sidebar-footer { padding: 15px; border-top: 1px solid var(--border); }
.user-pill { background: #f8fafc; padding: 12px; border-radius: 16px; display: flex; align-items: center; gap: 12px; border: 1px solid #f1f5f9; }
.u-avatar { width: 38px; height: 38px; background: #e2e8f0; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #475569; }
.u-info strong { display: block; font-size: 0.85rem; color: #0f172a; }
.u-info span { font-size: 0.7rem; color: #94a3b8; }

.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 999; backdrop-filter: blur(2px); }

@media (max-width: 992px) {
    .main-sidebar { left: calc(var(--sb-w) * -1); }
    body.sidebar-mobile-open .main-sidebar { left: 0; box-shadow: 20px 0 50px rgba(0,0,0,0.1); }
    body.sidebar-mobile-open .sidebar-overlay { display: block; }
}
</style>