{% extends 'layouts/portal.html.twig' %}
{% block title %}Class routine{% endblock %}
{% block content %}
<div class="page-head">
    <div>
        <h1 class="h3">Class routine</h1>
        <p class="text-muted mb-0">{{ student.class }} · {{ student.section }} · Saturday–Thursday</p>
    </div>
</div>
{% if slots == 0 %}
    <div class="card-soft p-4"><div class="empty-state">No weekly routine is published for this class yet.</div></div>
{% else %}
    <div class="card-soft student-list-card">
        <div class="table-scroll">
            <table class="table table-modern routine-grid">
                <thead>
                <tr>
                    <th>Period</th>
                    {% for day in days %}<th>{{ day }}</th>{% endfor %}
                </tr>
                </thead>
                <tbody>
                {% for period in periods %}
                    <tr>
                        <td class="fw-bold text-muted">{{ period }}</td>
                        {% for day in days %}
                            {% set slot = grid[period][day]|default(null) %}
                            <td>
                                {% if slot %}
                                    <div class="routine-slot">
                                        <div class="student-name">{{ slot.subject }}</div>
                                        <div class="student-subname">{{ slot.teacher }}{% if slot.roomNumber %} · {{ slot.roomNumber }}{% endif %}</div>
                                        <div class="student-subname">{{ slot.startTime|date('H:i') }}–{{ slot.endTime|date('H:i') }}</div>
                                    </div>
                                {% else %}
                                    <span class="text-muted">—</span>
                                {% endif %}
                            </td>
                        {% endfor %}
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endif %}
{% endblock %}
