<?php
session_start();
require_once(__DIR__ . "/../config/db.php");

/* 🔒 Teacher-only guard */
if (!isset($_SESSION['teacher_id'])) {
    header("Location: /rs_lab/teacher/login.php");
    exit;
}

/* 🔹 Get teacher details */
$stmt = $pdo->prepare("
    SELECT username, class_handled
    FROM teachers
    WHERE id = ?
");
$stmt->execute([$_SESSION['teacher_id']]);
$teacher = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$teacher) {
    die("Invalid teacher session");
}
?>

<!DOCTYPE html>
<html>
<head>
<title>Teacher Dashboard</title>

<style>
body{
    margin:0;
    background:linear-gradient(135deg,#020617,#0f172a);
    font-family:Arial, sans-serif;
    color:white;
}

/* Container */
.container{
    padding:60px;
    display:flex;
    flex-direction:column;
    align-items:center;   /* 🔥 FULL CENTER */
}
/* Header */
.header{
    margin-bottom:50px;
    text-align:center;   /* 🔥 CENTER */
    animation:fadeIn 1s ease;
}
.header h1{
    font-size:32px;
}

.header span{
    color:#0b8c9f;
}

.sub{
    color:#94a3b8;
    margin-top:5px;
}

/* Cards */
.grid{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(250px,1fr));
    gap:25px;
}

/* Card */
.card{
    padding:25px;
    border-radius:15px;
    background:rgba(15,23,42,0.7);
    border:1px solid #1e293b;
    text-decoration:none;
    color:white;
    transition:0.3s;
    backdrop-filter:blur(10px);
    animation:fadeUp 0.8s ease;
}

.card h3{
    margin-bottom:10px;
}

.card p{
    color:#94a3b8;
    font-size:14px;
}

/* Hover */
.card:hover{
    transform:translateY(-5px) scale(1.03);
    border-color:#0b8c9f;
    box-shadow:0 10px 25px rgba(0,0,0,0.4);
}

/* Animations */
@keyframes fadeIn{
    from{opacity:0; transform:translateY(-20px);}
    to{opacity:1; transform:translateY(0);}
}

@keyframes fadeUp{
    from{opacity:0; transform:translateY(30px);}
    to{opacity:1; transform:translateY(0);}
}
</style>

</head>

<body>

<div class="container">

<!-- Header -->
<div class="header">
    <h1>
        Welcome, <span><?= htmlspecialchars($teacher['username']) ?></span>
    </h1>
    <p class="sub">
        Class Handled: <?= htmlspecialchars($teacher['class_handled']) ?>
    </p>
</div>

<!-- Cards -->
<div class="grid">

    <a href="/rs_lab/choose_assessment_mode.php" class="card">
        <h3>🧠 Learning Style Assessment</h3>
        <p>Analyze how students learn and adapt teaching methods</p>
    </a>

    <a href="http://localhost:5173/" target="_blank" class="card">
        <h3>💻 Coding Challenge</h3>
        <p>Evaluate student coding skills with real challenges</p>
    </a>

</div>

</div>
<?php include(__DIR__ . "/../includes/footer.php"); ?>
</body>
</html>