{% extends "base.html" %}

{% block title %}Consultant Profile{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h3><i class="fas fa-user-cog mr-2"></i>Consultant Profile</h3>
                </div>
                <div class="card-body">
                    <form method="POST" enctype="multipart/form-data">
                        {{ form.hidden_tag() }}
                        
                        <div class="form-group">
                            {{ form.registration_number.label(class="form-label") }}
                            {{ form.registration_number(class="form-control") }}
                            {% if form.registration_number.errors %}
                                <div class="text-danger">
                                    {% for error in form.registration_number.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>

                        <div class="form-group">
                            {{ form.contact_details.label(class="form-label") }}
                            {{ form.contact_details(class="form-control", rows="3") }}
                            {% if form.contact_details.errors %}
                                <div class="text-danger">
                                    {% for error in form.contact_details.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>

                        <div class="form-group">
                            {{ form.logo.label(class="form-label") }}
                            {{ form.logo(class="form-control-file") }}
                            {% if form.logo.errors %}
                                <div class="text-danger">
                                    {% for error in form.logo.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <small class="form-text text-muted">Upload a logo for your reports (JPG, PNG, GIF - max 2MB)</small>
                        </div>

                        {% if current_user.logo_filename %}
                        <div class="form-group">
                            <label class="form-label">Current Logo:</label>
                            <div>
                                <img src="{{ url_for('static', filename='uploads/' + current_user.logo_filename) }}" 
                                     alt="Current Logo" class="img-thumbnail" style="max-width: 200px; max-height: 150px;">
                            </div>
                        </div>
                        {% endif %}

                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save mr-2"></i>Update Profile
                            </button>
                            <a href="{{ url_for('consultant.dashboard') }}" class="btn btn-secondary ml-2">
                                <i class="fas fa-arrow-left mr-2"></i>Back to Dashboard
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}