{% extends "base.html" %}

{% block title %}Change Email - AISBF{% endblock %}

{% block content %}
<div class="container">
    <h1 data-i18n="email_page.title">Change Email Address</h1>
    <p data-i18n="email_page.subtitle">Update your email address. You will need to verify the new email before it takes effect.</p>

    {% if success %}
    <div class="alert alert-success">{{ success }}</div>
    {% endif %}

    {% if error %}
    <div class="alert alert-error">{{ error }}</div>
    {% endif %}

    <div class="card">
        <h2 data-i18n="email_page.current">Current Email</h2>
        <p style="color: var(--color-muted); margin-bottom: 2rem;">{{ session.email }}</p>
        
        <form method="POST" action="{{ url_for(request, '/dashboard/change-email') }}">
            <div class="form-group">
                <label for="new_email" data-i18n="email_page.new">New Email Address</label>
                <input type="email" id="new_email" name="new_email" required>
            </div>

            <div class="form-group">
                <label for="password" data-i18n="email_page.password">Current Password</label>
                <input type="password" id="password" name="password" required>
                <small style="color: var(--color-muted); display: block; margin-top: 0.5rem;" data-i18n="email_page.password_hint">Confirm your password to proceed</small>
            </div>

            <div style="margin-top: 1.5rem; display: flex; gap: 1rem;">
                <button type="submit" class="btn btn-primary" data-i18n="email_page.submit">Send Verification Email</button>
                <a href="{{ url_for(request, '/dashboard/profile') }}" class="btn btn-secondary" data-i18n="email_page.cancel">Cancel</a>
            </div>
        </form>
    </div>
</div>

<style>
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.card {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.card h2 {
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--bg-page);
    color: var(--color-text);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-link);
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--alert-success-bg);
    color: var(--alert-success-fg);
    border: 1px solid var(--alert-success-border);
}

.alert-error {
    background: var(--alert-error-bg);
    color: var(--alert-error-fg);
    border: 1px solid var(--alert-error-border);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--bg-accent);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: var(--bg-panel);
}
</style>
{% endblock %}
