<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Set Timezone</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet" />
</head>
<body>
    <div class="container mt-5">
        <div class="row">
            <div class="col-md-6 offset-md-3">
                <div class="card">
                    <div class="card-header">
                        <h3>Select Timezone</h3>
                    </div>
                    <div class="card-body">
                        <form method="post">
                            {% csrf_token %}
                            <div class="form-group">
                                <label for="timezone">Select Timezone:</label>
                                <select id="timezone" name="timezone" class="form-control select2">
                                    {% for tz in timezones %}
                                        <option value="{{ tz }}" {% if tz == session.user_timezone %}selected{% endif %}>{{ tz }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                            <button type="submit" class="btn btn-primary">Set Timezone</button>
                        </form>
                    </div>
                </div>

                <div class="mt-4">
                    <div class="card">
                        <div class="card-header">
                            <h3>Current Time</h3>
                        </div>
                        <div class="card-body">
                            <p class="lead">{{ current_time }}</p>
                        </div>
                    </div>
                </div>

                <div class="mt-4">
                    <div class="card">
                        <div class="card-header">
                            <h3>Session Values</h3>
                        </div>
                        <div class="card-body">
                            <ul class="list-group">
                                {% for key, value in session_values %}
                                    <li class="list-group-item">
                                        <strong>{{ key }}:</strong> {{ value }}
                                    </li>
                                {% endfor %}
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
    <script>
        $(document).ready(function() {
            $('.select2').select2();
        });
    </script>
</body>
</html>
