<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Eversync</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    {% load static %}
    <link rel="icon" href="{% static 'favicon.ico' %}">
    <link rel="stylesheet" href="{% static 'index-style.css' %}">
    {% block scripts %}
        {% include "sentry_replay.html" %}
    {% endblock %}
    <style>
        .container {
            display: flex;
            gap: 30px;
            align-items: flex-start;
        }
        .welcome-box {
            flex: 0 0 250px;
            padding: 20px;
            border-radius: 8px;
            max-width: 250px; 
        }
        /* Center and widen welcome-box for the form */
        .welcome-box {
            max-width: 600px;
            margin: 60px auto 0 auto;
            width: 100%;
            background: #fff;
            box-shadow: 0 2px 16px rgba(0,0,0,0.08);
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .form-fields-group {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }
        .submit-btn-group {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 16px;
            width: 100%;
            align-items: stretch;
        }
        @media (max-width: 700px) {
            .container {
                flex-direction: column;
                align-items: center; 
            }
            .welcome-box {
                flex: none;
                width: auto;
                max-width: 95vw;
                margin: 0 0 20px 0; 
                padding: 16px 5vw;
            }
            .divider {
            border-top: 1px solid #dadde1;
            margin: 20px 0;
            }
            .login-button {
              width: 100%;
              padding: 12px;
              background-color: #1877f2;
              color: white;
              border: none;
              border-radius: 6px;
              font-size: 18px;
              font-weight: bold;
              cursor: pointer;
        }
        .login-button:hover {
            background-color: #166fe5;
        }
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="header-content">
            <a href="/"><img src="{% static 'eversync2.png' %}" alt="Eversync Logo" style="height: 80px; margin-right: 10px; display: flex; align-items: center; gap: 5px;"></a>
            <a href="/" class="logo" >eversync</a>
            <div class="nav-links" style="position: relative;">
                <div class="dropdown">
                    <button class="dropdown-toggle" style="background: none; border: none; color: white; font-size: 16px; cursor: pointer;">
                        Welcome, {{ user.username }} <i class="fas fa-caret-down"></i>
                    </button>
                    <div class="dropdown-menu" style="display: none; position: absolute; right: 0; background-color: #333; border: 1px solid #444; border-radius: 4px; padding: 10px; width: 184px;">
                        <form action="{% url 'manage' %}" method="post" style="margin: 0;">
                            {% csrf_token %}
                            <button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Manage Account</button>
                        </form>
                        <form action="{% url 'logoutz' %}" method="post" style="margin: 0;">
                            {% csrf_token %}
                            <button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Log Out</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="welcome-box">
            <h1 class="text-xl font-semibold mb-4">Add Your Email</h1>
            <p class="mb-4 text-gray-600">We need your email to continue. Please enter it below and we'll send a verification link.</p>
            <div class="divider"></div>

            <form method="post">
                {% csrf_token %}
                <div class="form-fields-group">
                    {{ form.as_p }}
                </div>
                <div class="submit-btn-group">
                    <button type="submit" class="login-button">
                        Submit Email
                    </button>
                </div>
            </form>
        </div>
    </div>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const toggle = document.querySelector('.dropdown-toggle');
            const menu = document.querySelector('.dropdown-menu');
            toggle.addEventListener('click', function () {
                menu.style.display = menu.style.display === 'block' ? 'none' : 'block';
            });
        });
    </script>
</body>
</html>