<?php
session_start();

/* ✅ SESSION CHECK */
if (!isset($_SESSION['institution_id'])) {
    header("Location: /rs_lab/institution/login.php");
    exit;
}

/* ✅ SAFE VARIABLES */
$institutionName = $_SESSION['institution_name'] ?? 'Institution';
$type = $_SESSION['institution_type'] ?? 'school';
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($institutionName) ?> | Dashboard</title>

<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">

<style>
*{margin:0;padding:0;box-sizing:border-box;font-family:'Inter',sans-serif;}

body{
    background:radial-gradient(circle at top,#0b1220,#020617);
    color:#eaf2ff;

    display:flex;
    flex-direction:column;
    min-height:100vh;
    overflow:hidden;
}

/* 🔥 RS WATERMARK */
body::before{
    content:"RS";
    position:fixed;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
    font-size:300px;
    font-weight:900;
    background:linear-gradient(135deg,#0b8c9f,#38bdf8);
    -webkit-background-clip:text;
    -webkit-text-fill-color:transparent;
    opacity:0.05;
    z-index:0;
    pointer-events:none;
}

/* MAIN CENTER */
.main{
    flex:1;
    display:flex;
    justify-content:center;
    align-items:center;
    flex-direction:column;
    position:relative;
    z-index:1;
}

/* GLASS BOX */
.glass-box{
    padding:50px;
    border-radius:25px;

    /* 🔥 reduce brightness */
    background:rgba(15,23,42,0.4);

    border:1px solid rgba(255,255,255,0.05);
    backdrop-filter:blur(12px);

    box-shadow:0 10px 40px rgba(0,0,0,0.5);

    text-align:center;
}
/* HEADER */
header{
    margin-bottom:40px;
}
header h1{
    font-size:42px;
    font-weight:800;
    background:linear-gradient(135deg,#ffffff,#38bdf8,#0ea5e9);
    -webkit-background-clip:text;
    -webkit-text-fill-color:transparent;
    text-shadow:0 0 20px rgba(56,189,248,0.3);
}
header p{
    color:#94a3b8;
    margin-top:6px;
}

/* ACTION CARDS */
.dashboard-actions{
    display:flex;
    gap:30px;
    justify-content:center;
    flex-wrap:wrap;
}
.action-card{
    padding:25px 45px;
    border-radius:18px;

    /* 🔥 less contrast */
    background:rgba(15,23,42,0.85);

    border:1px solid #1e293b;
    color:#38bdf8;
    font-size:18px;
    text-decoration:none;
    transition:0.25s;
    min-width:230px;

    box-shadow:0 2px 8px rgba(0,0,0,0.3);
}
.action-card:hover{
    transform:translateY(-3px);

    /* 🔥 LESS BRIGHT COLOR */
    background:#38bdf8;
    color:#020617;

    box-shadow:0 2px 10px rgba(56,189,248,0.15);
}/* COLLEGE GRID */
.container{
    max-width:1100px;
    width:100%;
    padding:0 20px;
}

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

.card{
    background:rgba(15,23,42,0.7);
    border:1px solid #1e293b;
    border-radius:18px;
    padding:25px;
    transition:.3s;
}

.card:hover{
    transform:translateY(-6px);
    box-shadow:0 10px 40px rgba(0,0,0,0.6);
}

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

.card p{
    color:#94a3b8;
    margin-bottom:15px;
}

.card a{
    display:inline-block;
    padding:10px 18px;
    border-radius:10px;
    background:#38bdf8;
    color:#020617;
    font-weight:600;
    text-decoration:none;
}

/* DERIS SPECIAL */
.deris{
    background:linear-gradient(135deg,#ff8a00,#ffb347);
    color:#1a0e00;
}
.deris a{
    background:#1a0e00;
    color:#ffb347;
}

/* FOOTER */
.footer{
    text-align:center;
    padding:15px;
    font-size:13px;
    color:#94a3b8;
    border-top:1px solid #1e293b;
    position:relative;
    z-index:1;
}

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

<body>

<div class="main">

<div class="glass-box">

<header>
    <h1><?= htmlspecialchars($institutionName) ?></h1>
    <p><?= strtoupper($type) ?> Dashboard</p>
</header>

<?php if ($type === 'school'): ?>

<div class="dashboard-actions">

    <a href="/rs_lab/institution/add_teacher.php" class="action-card">
        ➕ Add Teacher
    </a>

    <a href="/rs_lab/teacher/login.php" class="action-card">
        👨‍🏫 Teacher Login
    </a>

</div>

<?php else: ?>

<div class="container">

<div class="grid">

    <div class="card">
        <h3>💻 Coding Challenges</h3>
        <p>Practice → Reinforcement → Final Track.</p>
        <a href="../practice_track.php">Start Coding</a>
    </div>

    <div class="card">
        <h3>📜 Certificates</h3>
        <p>View certificates and achievements.</p>
        <a href="../my_certificates.php">View Certificates</a>
    </div>

    <div class="card deris">
        <h3>🤖 DERIS AI</h3>
        <p>AI-based resume & skill analysis.</p>
        <a href="../deris_ai/index.php">Launch</a>
    </div>

</div>

</div>

<?php endif; ?>

</div>

</div>

<div class="footer">
    © 2026 RS Learning Lab • Built with ❤️ by Gokula Krishnan
</div>

</body>
</html>