{% extends "admin/base.html" %}
{% load i18n static %}

{% block content_title %}
    {% trans "Change password" %}
{% endblock %}

{% block content %}
<div class="max-w-lg">
    <div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
        
        <!-- Header -->
        <div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-750">
            <div class="flex items-center">
                <svg class="w-6 h-6 text-gray-500 dark:text-gray-400 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/>
                </svg>
                <h2 class="text-lg font-semibold text-gray-900 dark:text-white">
                    {% trans "Change your password" %}
                </h2>
            </div>
        </div>
        
        {% if form.errors %}
        <div class="px-6 py-4 bg-red-50 dark:bg-red-900/20 border-b border-red-200 dark:border-red-800">
            <div class="flex items-start">
                <svg class="w-5 h-5 text-red-600 dark:text-red-400 mt-0.5 mr-3 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
                    <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
                </svg>
                <div>
                    <p class="text-sm text-red-800 dark:text-red-200">
                        {% trans "Please correct the errors below." %}
                    </p>
                </div>
            </div>
        </div>
        {% endif %}
        
        <form method="post" class="p-6">
            {% csrf_token %}
            
            <div class="space-y-6">
                <p class="text-sm text-gray-600 dark:text-gray-400">
                    {% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}
                </p>
                
                <!-- Old Password -->
                <div>
                    <label for="id_old_password" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                        {{ form.old_password.label }}
                        <span class="text-red-600 dark:text-red-400">*</span>
                    </label>
                    <input type="password" 
                           name="old_password" 
                           id="id_old_password"
                           autocomplete="current-password"
                           autofocus
                           required
                           class="w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors">
                    {% if form.old_password.errors %}
                    <div class="mt-2 text-sm text-red-600 dark:text-red-400">
                        {{ form.old_password.errors }}
                    </div>
                    {% endif %}
                </div>
                
                <!-- New Password -->
                <div>
                    <label for="id_new_password1" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                        {{ form.new_password1.label }}
                        <span class="text-red-600 dark:text-red-400">*</span>
                    </label>
                    <input type="password" 
                           name="new_password1" 
                           id="id_new_password1"
                           autocomplete="new-password"
                           required
                           class="w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors">
                    {% if form.new_password1.help_text %}
                    <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
                        {{ form.new_password1.help_text|safe }}
                    </p>
                    {% endif %}
                    {% if form.new_password1.errors %}
                    <div class="mt-2 text-sm text-red-600 dark:text-red-400">
                        {{ form.new_password1.errors }}
                    </div>
                    {% endif %}
                </div>
                
                <!-- Confirm New Password -->
                <div>
                    <label for="id_new_password2" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
                        {{ form.new_password2.label }}
                        <span class="text-red-600 dark:text-red-400">*</span>
                    </label>
                    <input type="password" 
                           name="new_password2" 
                           id="id_new_password2"
                           autocomplete="new-password"
                           required
                           class="w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors">
                    {% if form.new_password2.help_text %}
                    <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
                        {{ form.new_password2.help_text|safe }}
                    </p>
                    {% endif %}
                    {% if form.new_password2.errors %}
                    <div class="mt-2 text-sm text-red-600 dark:text-red-400">
                        {{ form.new_password2.errors }}
                    </div>
                    {% endif %}
                </div>
            </div>
            
            <div class="mt-8 flex items-center justify-end space-x-3">
                <a href="{% url 'admin:index' %}" class="inline-flex items-center px-4 py-2.5 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg font-medium transition-colors">
                    {% trans "Cancel" %}
                </a>
                <button type="submit" class="inline-flex items-center px-6 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors">
                    <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
                    </svg>
                    {% trans "Change my password" %}
                </button>
            </div>
        </form>
    </div>
</div>
{% endblock %}