{% extends 'base.html' %}

{% block title %}Профиль{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-12 col-lg-8">
            <!-- Карточка профиля -->
            <div class="card shadow-sm">
                <div class="card-body p-4">
                    <!-- Заголовок -->
                    <div class="d-flex align-items-center mb-4">
                        <div class="bg-primary bg-opacity-10 rounded-circle d-flex align-items-center justify-content-center me-3" 
                             style="width: 64px; height: 64px;">
                            <i class="bi bi-person-fill text-primary" style="font-size: 2rem;"></i>
                        </div>
                        <div>
                            <h4 class="mb-0 fw-bold">{{ user.name }}</h4>
                            <p class="text-muted mb-0">{{ user.email }}</p>
                        </div>
                    </div>

                    <hr class="my-4">

                    <!-- Информация -->
                    <div class="row g-3">
                        <!-- Роль -->
                        <div class="col-md-6">
                            <div class="d-flex align-items-start">
                                <i class="bi bi-person-badge text-primary me-3 mt-1"></i>
                                <div class="flex-grow-1">
                                    <small class="text-muted d-block">Роль</small>
                                    {% if user.get_tenant_role %}
                                        <span class="badge bg-primary">{{ user.get_tenant_role.name }}</span>
                                    {% else %}
                                        <span class="text-muted">Не назначена</span>
                                    {% endif %}
                                </div>
                            </div>
                        </div>

                        <!-- Статус email -->
                        <div class="col-md-6">
                            <div class="d-flex align-items-start">
                                <i class="bi bi-shield-check text-primary me-3 mt-1"></i>
                                <div class="flex-grow-1">
                                    <small class="text-muted d-block">Статус email</small>
                                    {% if user.is_email_confirmed %}
                                        <span class="badge bg-success">
                                            <i class="bi bi-check-circle me-1"></i>Подтвержден
                                        </span>
                                    {% else %}
                                        <span class="badge bg-warning text-dark">
                                            <i class="bi bi-exclamation-circle me-1"></i>Не подтвержден
                                        </span>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    </div>

                    <hr class="my-4">

                    <!-- Действия -->
                    <div class="d-flex flex-wrap gap-2">
                        <a href="{% url 'accounts:change_password' %}" class="btn btn-primary">
                            <i class="bi bi-key me-1"></i>Сменить пароль
                        </a>
                        {% if not user.is_email_confirmed %}
                            <button class="btn btn-outline-warning" type="button" onclick="resendConfirmation()">
                                <i class="bi bi-envelope me-1"></i>Повторить письмо
                            </button>
                        {% endif %}
                        {% if user.is_owner or user.is_superuser %}
                            <a href="{% url 'system_settings:settings' %}" class="btn btn-outline-primary">
                                <i class="bi bi-gear me-1"></i>Настройки
                            </a>
                        {% endif %}
                        <a href="{% url 'index' %}" class="btn btn-outline-secondary ms-auto">
                            <i class="bi bi-arrow-left me-1"></i>Назад
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
function resendConfirmation() {
    alert('Письмо для подтверждения отправлено на ваш email!');
}
</script>
{% endblock %}