<?php
session_start();

/* ✅ DB CONNECTION (THIS WAS MISSING) */
require_once __DIR__ . '/config/db.php'; 
// OR (if student_dashboard.php is inside a folder)
// require_once __DIR__ . '/../config/db.php';

/* ✅ TEACHER SECURITY CHECK */
if (!isset($_SESSION['teacher_id'])) {
    header("Location: /rs_lab/teacher/login.php");
    exit;
}
/* OPTIONAL: get teacher name safely */
$teacherName = $_SESSION['teacher_username'] ?? 'Teacher';

// 🔹 FETCH INSTITUTION DETAILS
$stmt = $pdo->prepare("
    SELECT institution_name 
    FROM institutions 
    WHERE id = ?
    LIMIT 1
");
$institutionId = $_SESSION['institution_id'] ?? null;
$institution = $stmt->fetch(PDO::FETCH_ASSOC);

// Fallback (safety)
$institutionName = $institution['institution_name'] ?? 'School';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>School Dashboard | RS Learning Lab</title>

    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            background: radial-gradient(circle at top, #0f172a, #020617);
            color: #e5e7eb;
        }

        header {
            padding: 30px 40px;
            border-bottom: 1px solid #1e293b;
        }

        header h1 {
            margin: 0;
            font-size: 26px;
            color: #ffffff;
        }

        header p {
            margin-top: 8px;
            color: #94a3b8;
        }

        .container {
            padding: 40px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 30px;
        }

        .card {
            background: rgba(15, 23, 42, 0.9);
            border-radius: 18px;
            padding: 28px;
            box-shadow: 0 0 30px rgba(11, 140, 159, 0.15);
        }

        .card h3 {
            margin-top: 0;
            color: #ffffff;
        }

        .card p {
            color: #cbd5f5;
            font-size: 14px;
            line-height: 1.6;
        }

        .card button {
            margin-top: 20px;
            padding: 12px 18px;
            border: none;
            border-radius: 12px;
            background: linear-gradient(135deg, #0b8c9f, #14b8a6);
            color: #ffffff;
            font-size: 15px;
            cursor: pointer;
        }

        .card button:hover {
            opacity: 0.9;
        }

        footer {
            text-align: center;
            padding: 20px;
            color: #64748b;
            font-size: 13px;
            border-top: 1px solid #1e293b;
            margin-top: 40px;
        }
    </style>
</head>

<body>

<header>
    <h1>🏫 <?= htmlspecialchars($institutionName) ?> — School Dashboard</h1>
    <p>Manage learning style assessments, coding practice, and reports.</p>
</header>

<div class="container">

    <!-- Learning Style Assessment -->
    <div class="card">
        <h3>🧠 Learning Style Assessment</h3>
        <p>
            Understand how students learn using facilitated and self-assessment
            modes. No marks. No ranks.
        </p>
       <button onclick="location.href='/rs_lab/choose_assessment_mode.php'">
    Start Assessment
</button>

    </div>

    <!-- Coding Challenges -->
    <div class="card">
        <h3>💻 Coding Challenges</h3>
        <p>
            Practice-based coding tracks to improve confidence, logic,
            and application skills.
        </p>
        <button onclick="location.href='/rs_lab/school/coding_tracks.php'">
            Open Coding Tracks
        </button>
    </div>

    <!-- Reports -->
    <div class="card">
        <h3>📊 Reports & Insights</h3>
        <p>
            View class-wise learning patterns, momentum signals,
            and learning passports.
        </p>
        <button type="button" onclick="window.location.href='class_report.php'">
View Reports
</button>
    </div>

</div>

<footer>
    © RS Learning Lab — School Learning Behaviour Platform
</footer>

</body>
</html>
