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

{% block title %}Edit Profile{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h3 mb-0">
        <i class="bi bi-pencil me-2"></i>
        Edit Profile
    </h1>
    <a href="{% url 'users:profile' %}" class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-2"></i>
        Back to Profile
    </a>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">Edit Profile Information</h5>
            </div>
            <div class="card-body">
                <form method="post" enctype="multipart/form-data">
                    {% csrf_token %}
                    <div class="row">
                        <div class="col-md-6">
                            {{ form.first_name|as_crispy_field }}
                        </div>
                        <div class="col-md-6">
                            {{ form.last_name|as_crispy_field }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            {{ form.email|as_crispy_field }}
                        </div>
                        <div class="col-md-6">
                            {{ form.phone|as_crispy_field }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            {{ form.department|as_crispy_field }}
                        </div>
                        <div class="col-md-6">
                            {{ form.employee_id|as_crispy_field }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            {{ form.profile_picture|as_crispy_field }}
                        </div>
                        <div class="col-md-6">
                            <!-- user_type field removed as it's not in the form -->
                        </div>
                    </div>
                    
                    <div class="mt-3">
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-check-circle me-2"></i>
                            Save Changes
                        </button>
                        <a href="{% url 'users:profile' %}" class="btn btn-outline-secondary ms-2">
                            Cancel
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">Current Profile Picture</h5>
            </div>
            <div class="card-body text-center">
                {% if user.profile_picture %}
                    <img src="{{ user.profile_picture.url }}" alt="Current Profile Picture" class="img-fluid rounded mb-3" style="max-width: 200px;">
                {% else %}
                    <div class="bg-secondary rounded d-inline-flex align-items-center justify-content-center mb-3" style="width: 200px; height: 200px;">
                        <span class="text-white display-4">{{ user.first_name|first|upper }}{{ user.last_name|first|upper }}</span>
                    </div>
                {% endif %}
                <p class="text-muted small">Upload a new image to replace the current one</p>
            </div>
        </div>
        
        <div class="card mt-3">
            <div class="card-header">
                <h5 class="card-title mb-0">Profile Tips</h5>
            </div>
            <div class="card-body">
                <ul class="list-unstyled mb-0">
                    <li class="mb-2">
                        <i class="bi bi-info-circle text-primary me-2"></i>
                        Keep your information up to date
                    </li>
                    <li class="mb-2">
                        <i class="bi bi-shield-check text-success me-2"></i>
                        Profile picture should be professional
                    </li>
                    <li class="mb-2">
                        <i class="bi bi-telephone text-info me-2"></i>
                        Ensure contact details are current
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}
