{% extends "base.html" %}
{% from "components/forms.html" import text_input, button_primary, form_errors %}

{% block title %}Sign In - SmartTools{% endblock %}

{% block content %}
<div class="min-h-[70vh] flex items-center justify-center px-4 py-12">
    <div class="w-full max-w-md">
        <div class="text-center mb-8">
            <a href="{{ url_for('web.home') }}" class="inline-flex items-center justify-center">
                <svg class="w-10 h-10 text-indigo-600" fill="currentColor" viewBox="0 0 24 24">
                    <path d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                </svg>
            </a>
            <h1 class="mt-4 text-2xl font-bold text-gray-900">Sign in to SmartTools</h1>
            <p class="mt-2 text-gray-600">
                Access your dashboard and manage your tools
            </p>
        </div>

        <div class="bg-white rounded-lg border border-gray-200 p-8 shadow-sm">
            {{ form_errors(errors) }}

            <form action="{{ url_for('web.login') }}" method="POST">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                {% if next_url %}
                <input type="hidden" name="next" value="{{ next_url }}">
                {% endif %}

                {{ text_input(
                    name='email',
                    label='Email address',
                    type='email',
                    placeholder='you@example.com',
                    required=true,
                    value=email or ''
                ) }}

                {{ text_input(
                    name='password',
                    label='Password',
                    type='password',
                    placeholder='Your password',
                    required=true
                ) }}

                <div class="flex items-center justify-between mb-6">
                    <div class="flex items-center">
                        <input type="checkbox"
                               name="remember"
                               id="remember"
                               class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
                        <label for="remember" class="ml-2 text-sm text-gray-600">
                            Remember me
                        </label>
                    </div>
                    <a href="{{ url_for('web.forgot_password') }}" class="text-sm text-indigo-600 hover:text-indigo-800">
                        Forgot password?
                    </a>
                </div>

                {{ button_primary('Sign in', full_width=true) }}
            </form>
        </div>

        <p class="mt-6 text-center text-sm text-gray-600">
            Don't have an account?
            <a href="{{ url_for('web.register') }}" class="text-indigo-600 hover:text-indigo-800 font-medium">
                Create one
            </a>
        </p>
    </div>
</div>
{% endblock %}
