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

{% block title %}{% trans "My Profile" %} | EduPlatform{% endblock %}

{% block content %}
<section class="hero-section text-center pt-5 pb-5">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="glass-card text-start">
                    <div class="d-flex align-items-center mb-4">
                        {% if student_profile and student_profile.avatar %}
                            <img src="{{ student_profile.avatar.url }}" alt="Profile" class="rounded-circle me-3" width="100" height="100" style="object-fit: cover; border: 3px solid var(--primary-color);">
                        {% else %}
                            <div class="rounded-circle bg-secondary d-flex align-items-center justify-content-center me-3" style="width: 100px; height: 100px; color: white; font-size: 2rem;">
                                {{ user.username|make_list|first|upper }}
                            </div>
                        {% endif %}
                        <div>
                            <h2 class="mb-1">{{ user.get_full_name|default:user.username }}</h2>
                            <p class="text-muted mb-0">{{ user.email }}</p>
                            {% if student_profile and student_profile.classroom %}
                                <span class="badge bg-primary">{{ student_profile.classroom.name_en }}</span>
                            {% elif user.is_staff %}
                                <span class="badge bg-success">{% trans "Staff / Admin" %}</span>
                            {% endif %}
                        </div>
                    </div>

                    <hr class="my-4">

                    {% if student_profile %}
                        <h4 class="mb-3">{% trans "Student Details" %}</h4>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label text-muted">{% trans "Username" %}</label>
                                <p class="fw-bold">{{ user.username }}</p>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label text-muted">{% trans "City" %}</label>
                                <p class="fw-bold">{{ student_profile.city|default:"-" }}</p>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label text-muted">{% trans "Governorate" %}</label>
                                <p class="fw-bold">{{ student_profile.governorate|default:"-" }}</p>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label text-muted">{% trans "Mobile Number" %}</label>
                                <p class="fw-bold">{{ student_profile.mobile_number|default:"-" }}</p>
                            </div>
                        </div>

                        <h4 class="mb-3 mt-4">{% trans "My Subjects" %}</h4>
                        {% if student_profile.subscribed_subjects.all %}
                            <div class="list-group">
                                {% for subject in student_profile.subscribed_subjects.all %}
                                    <a href="{% url 'subject_detail' subject.pk %}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                                        {{ subject.name_en }}
                                        <span class="badge bg-secondary rounded-pill">{% trans "View" %}</span>
                                    </a>
                                {% endfor %}
                            </div>
                        {% else %}
                            <p class="text-muted">{% trans "No subjects subscribed yet." %}</p>
                        {% endif %}
                    {% else %}
                        <div class="alert alert-info">
                            {% trans "You are logged in as a staff member or user without a student profile." %}
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}
