<?php
// ===============================
// TEMPORARY LOGIN BYPASS
// ===============================
// This disables the login requirement so you can access desktop.php
// Remove the comments later to re‑enable authentication.

session_start();
require_once "config.php";

// if (!isset($_SESSION['user_id'])) {
//     header("Location: login.php");
//     exit;
// }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>iDONTByTE Desktop</title>
<link rel="stylesheet" href="assets/css/style.css">
<script src="assets/js/main.js" defer></script>

<style>
    body {
        margin: 0;
        overflow: hidden;
        background: url('assets/wallpapers/default.jpg') center/cover no-repeat fixed;
        font-family: <?= $THEME["font"] ?>;
    }

    /* Taskbar */
    #taskbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 42px;
        background: <?= $THEME["taskbar"] ?>;
        display: flex;
        align-items: center;
        padding: 0 10px;
        border-top: 2px solid <?= $THEME["accent"] ?>;
    }

    #start-btn {
        background: <?= $THEME["accent"] ?>;
        padding: 6px 12px;
        border-radius: 6px;
        font-weight: bold;
        cursor: pointer;
        margin-right: 10px;
    }

    #taskbar-apps {
        display: flex;
        gap: 8px;
        flex-grow: 1;
    }

    .taskbar-icon {
        width: 32px;
        height: 32px;
        cursor: pointer;
    }

    #taskbar-clock {
        color: white;
        font-size: 14px;
        margin-left: auto;
        padding-right: 10px;
    }

    /* Desktop icons */
    .desktop-icon {
        width: 80px;
        text-align: center;
        color: white;
        position: absolute;
        cursor: pointer;
        user-select: none;
    }

    .desktop-icon img {
        width: 64px;
        height: 64px;
    }

    /* Windows */
    .window {
        position: absolute;
        width: 600px;
        height: 400px;
        background: rgba(20,20,20,0.85);
        border: 2px solid <?= $THEME["window_border"] ?>;
        border-radius: 6px;
        box-shadow: 0 0 20px black;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .window-titlebar {
        background: <?= $THEME["accent"] ?>;
        padding: 6px;
        display: flex;
        justify-content: space-between;
        cursor: grab;
        color: black;
        font-weight: bold;
    }

    .window-controls span {
        margin-left: 10px;
        cursor: pointer;
        font-weight: bold;
    }

    .window-content {
        flex-grow: 1;
        background: #111;
        overflow: auto;
    }

    /* Notification shade */
    #notif-shade {
        position: fixed;
        top: -300px;
        left: 0;
        right: 0;
        height: 300px;
        background: rgba(0,0,0,0.85);
        border-bottom: 2px solid <?= $THEME["accent"] ?>;
        color: white;
        padding: 20px;
        transition: top 0.3s ease;
    }
</style>
</head>

<body>

<!-- Notification Shade -->
<div id="notif-shade">
    <h3>Notifications</h3>
    <div id="notif-list">Loading...</div>
</div>

<!-- Desktop Icons -->
<div class="desktop-icon" style="top: 40px; left: 40px;" onclick="openApp('filemanager')">
    <img src="assets/icons/folder.png">
    <div>My Docs</div>
</div>

<div class="desktop-icon" style="top: 140px; left: 40px;" onclick="openApp('games')">
    <img src="assets/icons/games.png">
    <div>Games</div>
</div>

<div class="desktop-icon" style="top: 240px; left: 40px;" onclick="openApp('notepad')">
    <img src="assets/icons/notepad.png">
    <div>Notepad</div>
</div>

<!-- Taskbar -->
<div id="taskbar">
    <div id="start-btn" onclick="toggleStartMenu()">iDONTByTE</div>
    <div id="taskbar-apps"></div>
    <div id="taskbar-clock"></div>
</div>

<!-- Start Menu -->
<div id="start-menu" style="
    position: fixed;
    bottom: 42px;
    left: 10px;
    width: 260px;
    background: rgba(0,0,0,0.85);
    border: 2px solid <?= $THEME["accent"] ?>;
    border-radius: 6px;
    padding: 10px;
    display: none;
">
    <div onclick="openApp('filemanager')" style="padding: 8px; cursor: pointer; color: white;">📁 File Manager</div>
    <div onclick="openApp('notepad')" style="padding: 8px; cursor: pointer; color: white;">📝 Notepad</div>
    <div onclick="openApp('calculator')" style="padding: 8px; cursor: pointer; color: white;">🧮 Calculator</div>
    <div onclick="openApp('games')" style="padding: 8px; cursor: pointer; color: white;">🎮 Games</div>
    <hr style="border-color: <?= $THEME["accent"] ?>;">
    <div onclick="location.href='logout.php'" style="padding: 8px; cursor: pointer; color: #ff4444;">⏻ Logout</div>
</div>

</body>
</html>