<?php
// --- TAMIM 1280 MASTER FIX START (অটোমেটিক ডিরেক্টরি ডিটেকশন) ---
$sessionPath = __DIR__ . '/sessions'; // এটি অটোমেটিক বর্তমান ফোল্ডার খুঁজে নিবে
if (!file_exists($sessionPath)) { 
    @mkdir($sessionPath, 0755, true); 
}
if (is_writable($sessionPath)) {
    ini_set('session.save_path', $sessionPath);
}
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
// --- TAMIM 1280 MASTER FIX END ---

if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

// Logo Logic
$logo_file = 'assets/logo.png';
if (file_exists('assets/logo.png')) $logo_file = 'assets/logo.png';
elseif (file_exists('assets/logo.jpg')) $logo_file = 'assets/logo.jpg';
elseif (file_exists('assets/logo.jpeg')) $logo_file = 'assets/logo.jpeg';
elseif (file_exists('logo.png')) $logo_file = 'logo.png';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Responsive Meta Tag -->
    <title>System Login | Squad Builder</title>
    <link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>

    <div class="container">
        
        <!-- Logout Button (Fixed Position inside container) -->
        <a href="logout.php" class="logout-btn" title="SHUTDOWN">
            <i class="fa-solid fa-power-off"></i>
        </a>

        <!-- Logo -->
        <div class="logo-area">
            <div class="logo-box">
                <img src="<?php echo $logo_file; ?>?v=<?php echo time(); ?>" alt="LOGO">
            </div>
        </div>

        <h1> 👑 TAMIM 1280 👑 </h1>
        
        <form action="form.php" method="POST">
            <label>Title</label>
            <input type="text" name="title" placeholder="Ƭᴇᴀᴍꜱ┊1280모" required autocomplete="off">

            <label>Select Mode</label>
            <select name="game_type" required>
                <option value="SOLO">SOLO [1 PLAYER]</option>
                <option value="DUO">DUO [2 PLAYERS]</option>
                <option value="SQUAD">SQUAD [4 PLAYERS]</option>
            </select>
            
            <label>Total Slots (Capacity)</label>
            <input type="number" name="total_players" min="2" max="100" placeholder="TOTAL PLAYERS" required>
            
            <button type="submit">NEXT 1280</button>
        </form>
    </div>

</body>
</html>