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

{% block title %}{{ parent.get_full_name }} - Parent/Guardian{% 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">{{ parent.get_full_name }}</h1>
            <p class="text-muted">{{ parent.get_relationship_display }} of {{ parent.student.get_full_name }}</p>
        </div>
        <div class="btn-group">
            <a href="{% url 'students:parent_list' %}" class="btn btn-outline-secondary">
                <i class="fas fa-arrow-left me-2"></i>Back
            </a>
            <a href="{% url 'students:parent_edit' parent.pk %}" class="btn btn-warning">
                <i class="fas fa-edit me-2"></i>Edit
            </a>
        </div>
    </div>

    <div class="row">
        <div class="col-md-8">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Contact Information</h6>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Full Name</label>
                            <p class="fw-bold mb-0">{{ parent.get_full_name }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Relationship</label>
                            <p class="fw-bold mb-0">{{ parent.get_relationship_display }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Primary Phone</label>
                            <p class="fw-bold mb-0"><i class="fas fa-phone text-success me-2"></i>{{ parent.phone }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Alternate Phone</label>
                            <p class="fw-bold mb-0">{{ parent.alternate_phone|default:"—" }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Email</label>
                            <p class="fw-bold mb-0">{{ parent.email|default:"—" }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Address</label>
                            <p class="fw-bold mb-0">{{ parent.address|default:"—" }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Occupation</label>
                            <p class="fw-bold mb-0">{{ parent.get_occupation_display|default:"—" }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Employer</label>
                            <p class="fw-bold mb-0">{{ parent.employer|default:"—" }}</p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Mobile Money</label>
                            <p class="fw-bold mb-0">
                                {% if parent.mobile_money_number %}
                                {{ parent.get_mobile_money_provider_display }}: {{ parent.mobile_money_number }}
                                {% else %}—{% endif %}
                            </p>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="text-muted small">Preferred Language</label>
                            <p class="fw-bold mb-0">{{ parent.get_preferred_language_display }}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Linked Student</h6>
                </div>
                <div class="card-body">
                    <div class="d-flex align-items-center mb-3">
                        <div class="rounded-circle bg-primary bg-opacity-10 d-flex align-items-center justify-content-center me-3" style="width:50px;height:50px;">
                            <i class="fas fa-user-graduate text-primary"></i>
                        </div>
                        <div>
                            <div class="fw-bold">{{ parent.student.get_full_name }}</div>
                            <small class="text-muted">{{ parent.student.student_id }}</small>
                        </div>
                    </div>
                    <p class="mb-1"><i class="fas fa-chalkboard text-info me-2"></i>{{ parent.student.current_class|default:"No class assigned" }}</p>
                    <p class="mb-1"><i class="fas fa-circle text-{% if parent.student.status == 'active' %}success{% else %}secondary{% endif %} me-2"></i>{{ parent.student.get_status_display }}</p>
                    <a href="{% url 'students:student_detail' parent.student.pk %}" class="btn btn-outline-primary btn-sm mt-2 w-100">
                        View Student Profile
                    </a>
                </div>
            </div>

            <div class="card shadow">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">Notifications</h6>
                </div>
                <div class="card-body">
                    <div class="d-flex justify-content-between mb-2">
                        <span>SMS Alerts</span>
                        <span class="badge bg-{% if parent.receive_sms %}success{% else %}secondary{% endif %}">{{ parent.receive_sms|yesno:"On,Off" }}</span>
                    </div>
                    <div class="d-flex justify-content-between mb-2">
                        <span>Email Alerts</span>
                        <span class="badge bg-{% if parent.receive_email %}success{% else %}secondary{% endif %}">{{ parent.receive_email|yesno:"On,Off" }}</span>
                    </div>
                    <div class="d-flex justify-content-between">
                        <span>WhatsApp</span>
                        <span class="badge bg-{% if parent.receive_whatsapp %}success{% else %}secondary{% endif %}">{{ parent.receive_whatsapp|yesno:"On,Off" }}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
