{% extends 'base.html' %}
{% load static %}

{% block title %}{{ subject.name }} - Rapha-Bethel BNPS{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-0">{{ subject.name }}</h1>
            <p class="text-muted">{{ subject.code }} &bull; {{ subject.get_category_display }}</p>
        </div>
        <a href="{% url 'academics:subject_list' %}" class="btn btn-outline-secondary">
            <i class="fas fa-arrow-left me-2"></i>Back to Subjects
        </a>
    </div>

    <div class="row">
        <div class="col-md-6">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Subject Details</h6>
                </div>
                <div class="card-body">
                    <table class="table table-borderless">
                        <tr><td class="text-muted fw-bold" width="40%">Subject Code</td><td>{{ subject.code }}</td></tr>
                        <tr><td class="text-muted fw-bold">Name (English)</td><td class="fw-bold">{{ subject.name }}</td></tr>
                        <tr><td class="text-muted fw-bold">Name (French)</td><td>{{ subject.name_fr|default:"—" }}</td></tr>
                        <tr><td class="text-muted fw-bold">Category</td><td><span class="badge bg-primary">{{ subject.get_category_display }}</span></td></tr>
                        <tr><td class="text-muted fw-bold">Description</td><td>{{ subject.description|default:"—" }}</td></tr>
                    </table>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Assigned Teachers</h6>
                </div>
                <div class="card-body p-0">
                    <table class="table table-hover mb-0">
                        <thead class="table-light">
                            <tr><th>Teacher</th><th>Class</th><th>Hrs/Week</th></tr>
                        </thead>
                        <tbody>
                            {% for ts in subject.class_subjects.select_related('teacher','school_class') %}
                            <tr>
                                <td>{{ ts.teacher.user.get_full_name|default:"Unassigned" }}</td>
                                <td>{{ ts.school_class }}</td>
                                <td>{{ ts.hours_per_week }}</td>
                            </tr>
                            {% empty %}
                            <tr><td colspan="3" class="text-center text-muted py-3">No teachers assigned</td></tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
