<?php
if (session_status() === PHP_SESSION_NONE) { session_start(); }
// Finale Version für Sensor-Seiten-Fix
define('APP_VERSION', '18.3.0'); 
?>
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cazubu - Cannabis Zucht Buddy</title>
    
    <!-- Fonts & Icons -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Poppins:wght@500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css?v=<?php echo APP_VERSION; ?>">
</head>
<body>
    <div class="zoom-effect-container">
        <div class="zoom-effect-image"></div>
    </div>
    <div class="site-container">
        <nav class="side-menu d-flex flex-column p-3">
            <div class="text-center mb-4">
                <a href="index.php"><img src="logo.png" alt="Cazubu Logo" class="site-logo"></a>
                <h2 class="project-name">Cazubu</h2>
            </div>
            
            <div class="flex-grow-1 overflow-auto">
                <ul class="nav nav-pills flex-column gap-1">
                    <?php 
                    $current_page = basename($_SERVER['PHP_SELF']);
                    ?>
                    <?php if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true): ?>
                        <li><a href="index.php" class="nav-link <?php echo ($current_page == 'index.php') ? 'active' : ''; ?>"><i class="bi bi-grid-1x2-fill me-2"></i> Startseite</a></li>
                        <li><a href="plants.php" class="nav-link <?php echo ($current_page == 'plants.php' || $current_page == 'plant_detail.php') ? 'active' : ''; ?>"><i class="bi bi-flower2 me-2"></i> Pflanzen</a></li>
                        
                        <li class="nav-link-header">Aktionen</li>
                        <li><a href="sensors.php" class="nav-link <?php echo ($current_page == 'sensors.php') ? 'active' : ''; ?>"><i class="bi bi-activity me-2"></i> Sensoren</a></li>
                        <li><a href="#" class="nav-link" data-bs-toggle="modal" data-bs-target="#globalActivityModal"><i class="bi bi-lightning-charge-fill me-2"></i> Aktivität erfassen</a></li>
                        
                        <li class="nav-link-header">Verwaltung</li>
                        <li><a href="inventory.php" class="nav-link <?php echo ($current_page == 'inventory.php') ? 'active' : ''; ?>"><i class="bi bi-box2-fill me-2"></i> Inventar</a></li>
                        <li><a href="seeds.php" class="nav-link <?php echo ($current_page == 'seeds.php') ? 'active' : ''; ?>"><i class="bi bi-vinyl-fill me-2"></i> Samen</a></li>
                        
                        <li class="nav-link-header">System</li>
                        <li><a href="profile.php" class="nav-link <?php echo ($current_page == 'profile.php') ? 'active' : ''; ?>"><i class="bi bi-person-circle me-2"></i> Profil</a></li>
                    <?php else: ?>
                        <li><a href="login.php" class="nav-link <?php echo ($current_page == 'login.php') ? 'active' : ''; ?>">Login</a></li>
                        <li><a href="register.php" class="nav-link <?php echo ($current_page == 'register.php') ? 'active' : ''; ?>">Registrieren</a></li>
                    <?php endif; ?>
                </ul>
            </div>
            <?php if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true): ?>
            <div class="mt-auto">
                <hr>
                <div class="text-center text-white-50 small"><p class="mb-1">Angemeldet als:</p><strong class="text-white d-block"><?php echo htmlspecialchars($_SESSION['username']); ?></strong></div>
                <a href="logout.php" class="btn btn-outline-light w-100 mt-2">Abmelden</a>
            </div>
            <?php endif; ?>
        </nav>
        <main class="main-content">
