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

{% block title %}User Profile - RaktaPulse{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="glass-card">
                <div class="d-flex align-items-center mb-4">
                    {% if user.profile.profile_pic %}
                        <img src="{{ user.profile.profile_pic.url }}" alt="{{ user.username }}" class="rounded-circle me-3 object-fit-cover" style="width: 64px; height: 64px;">
                    {% else %}
                        <div class="bg-danger rounded-circle d-flex align-items-center justify-content-center me-3" style="width: 60px; height: 60px;">
                            <i class="bi bi-person-fill text-white fs-2"></i>
                        </div>
                    {% endif %}
                    <div>
                        <h2 class="mb-0 fw-bold">{{ user.username }}</h2>
                        <p class="text-secondary mb-0">Member since {{ user.date_joined|date:"M d, Y" }}</p>
                    </div>
                </div>

                <form method="POST" enctype="multipart/form-data">
                    {% csrf_token %}
                    <h5 class="fw-bold mb-3 border-bottom pb-2">Account Information</h5>
                    <div class="row g-3 mb-4">
                        <div class="col-md-6">
                            <label class="form-label small fw-bold">Username</label>
                            {{ u_form.username }}
                        </div>
                        <div class="col-md-6">
                            <label class="form-label small fw-bold">Email Address</label>
                            {{ u_form.email }}
                        </div>
                        <div class="col-md-6">
                            <label class="form-label small fw-bold">First Name</label>
                            {{ u_form.first_name }}
                        </div>
                        <div class="col-md-6">
                            <label class="form-label small fw-bold">Last Name</label>
                            {{ u_form.last_name }}
                        </div>
                    </div>

                    <h5 class="fw-bold mb-3 border-bottom pb-2">Profile Details</h5>
                    <div class="row g-3 mb-4">
                        <div class="col-12">
                            <label class="form-label small fw-bold">Bio</label>
                            {{ p_form.bio }}
                            <div class="form-text">Write a short bio about yourself.</div>
                        </div>
                        <div class="col-md-4">
                            <label class="form-label small fw-bold">Blood Group</label>
                            {{ p_form.blood_group }}
                        </div>
                        <div class="col-md-4">
                            <label class="form-label small fw-bold">Phone</label>
                            {{ p_form.phone }}
                        </div>
                        <div class="col-md-4">
                            <label class="form-label small fw-bold">Location</label>
                            {{ p_form.location }}
                        </div>
                        <div class="col-12">
                            <label class="form-label small fw-bold">Profile Picture</label>
                            {{ p_form.profile_pic }}
                        </div>
                    </div>

                    <div class="d-grid">
                        <button type="submit" class="btn btn-danger py-2 fw-bold">
                            <i class="bi bi-check-circle me-2"></i>Update Profile
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}
