{% extends "layout.html.tera" %}
{% block title %}Admin Login{% endblock title %}
{% block content %}
<div class="flex items-center justify-center min-h-[70vh] px-4">
<div class="bg-white dark:bg-gray-800 p-8 rounded-xl shadow-lg w-full max-w-md border border-gray-200 dark:border-gray-700">
<!-- Header -->
<div class="text-center mb-8">
<div class="mx-auto w-16 h-16 bg-gradient-to-r from-indigo-600 to-fuchsia-600 rounded-full flex items-center justify-center mb-4">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
</svg>
</div>
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Admin Login</h2>
<p class="text-gray-600 dark:text-gray-400 mt-2">Sign in to access the admin panel</p>
</div>
<!-- Error Message -->
{% if error %}
<div class="mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg">
<div class="flex items-center">
<svg class="w-5 h-5 text-red-500 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span class="text-red-700 dark:text-red-400 text-sm font-medium">{{ error }}</span>
</div>
</div>
{% endif %}
<!-- Success Message (for redirects from logout, etc.) -->
{% if success %}
<div class="mb-6 p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg">
<div class="flex items-center">
<svg class="w-5 h-5 text-green-500 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>
<span class="text-green-700 dark:text-green-400 text-sm font-medium">{{ success }}</span>
</div>
</div>
{% endif %}
<!-- Login Form -->
<form method="post" action="/adminx/login" class="space-y-6">
<!-- Email Field -->
<div>
<label for="email" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Email Address
</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"/>
</svg>
</div>
<input type="email"
id="email"
name="email"
placeholder="Enter your email address"
value="{{ form_data.email | default(value="") }}"
class="w-full pl-10 pr-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 placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-colors"
required
autocomplete="email">
</div>
</div>
<!-- Password Field -->
<div>
<label for="password" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Password
</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
</svg>
</div>
<input type="password"
id="password"
name="password"
placeholder="Enter your password"
class="w-full pl-10 pr-12 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 placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-colors"
required
autocomplete="current-password">
<!-- Password visibility toggle -->
<button type="button"
class="absolute inset-y-0 right-0 pr-3 flex items-center"
onclick="togglePasswordVisibility()">
<svg id="eye-open" class="w-5 h-5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
<svg id="eye-closed" class="hidden w-5 h-5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L6.636 6.636m7.07 7.07l2.828 2.828m0 0L21 21"/>
</svg>
</button>
</div>
</div>
<!-- Remember Me Checkbox (Optional) -->
<div class="flex items-center justify-between">
<div class="flex items-center">
<input type="checkbox"
id="remember_me"
name="remember_me"
class="w-4 h-4 text-indigo-600 bg-gray-100 border-gray-300 rounded focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
<label for="remember_me" class="ml-2 text-sm text-gray-600 dark:text-gray-400">
Remember me
</label>
</div>
<div class="text-sm">
<a href="#" class="text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300">
Forgot password?
</a>
</div>
</div>
<!-- Submit Button -->
<div>
<button type="submit"
class="w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-gradient-to-r from-indigo-600 to-fuchsia-600 hover:from-indigo-700 hover:to-fuchsia-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
id="login-button">
<svg class="hidden animate-spin -ml-1 mr-2 h-4 w-4 text-white" id="loading-spinner" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span id="button-text">Sign In</span>
</button>
</div>
</form>
<!-- Footer Links -->
<div class="mt-6 text-center">
<p class="text-xs text-gray-500 dark:text-gray-400">
Protected by AdminX Security
</p>
</div>
</div>
</div>
<!-- JavaScript for enhanced functionality -->
<script>
// Password visibility toggle
function togglePasswordVisibility() {
const passwordInput = document.getElementById('password');
const eyeOpen = document.getElementById('eye-open');
const eyeClosed = document.getElementById('eye-closed');
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeOpen.classList.add('hidden');
eyeClosed.classList.remove('hidden');
} else {
passwordInput.type = 'password';
eyeOpen.classList.remove('hidden');
eyeClosed.classList.add('hidden');
}
}
// Form submission with loading state
document.querySelector('form').addEventListener('submit', function(e) {
const button = document.getElementById('login-button');
const buttonText = document.getElementById('button-text');
const spinner = document.getElementById('loading-spinner');
// Show loading state
button.disabled = true;
buttonText.textContent = 'Signing In...';
spinner.classList.remove('hidden');
// Re-enable after 10 seconds in case of network issues
setTimeout(() => {
button.disabled = false;
buttonText.textContent = 'Sign In';
spinner.classList.add('hidden');
}, 10000);
});
// Auto-focus email field
document.addEventListener('DOMContentLoaded', function() {
const emailInput = document.getElementById('email');
if (emailInput && !emailInput.value) {
emailInput.focus();
}
});
// Handle form validation
document.getElementById('email').addEventListener('input', function(e) {
const email = e.target.value;
const isValid = email.includes('@') && email.includes('.');
if (email && !isValid) {
e.target.setCustomValidity('Please enter a valid email address');
} else {
e.target.setCustomValidity('');
}
});
</script>
{% endblock content %}