<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Toot Scheduler</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 20px;
            padding: 0;
            background-color: #f4f4f9;
            color: #333;
        }
        h1, h2 {
            color: #0056b3;
        }
        form {
            margin-bottom: 20px;
        }
        ul {
            list-style: none;
            padding: 0;
        }
        li {
            background: #fff;
            margin: 10px 0;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        button {
            background: #0056b3;
            color: #fff;
            border: none;
            padding: 5px 10px;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background: #003d80;
        }
        label {
            display: block;
            margin-top: 10px;
        }
        input, select {
            width: 100%;
            padding: 8px;
            margin-top: 5px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <h1>Toot Scheduler</h1>
    <h2>Welcome, {{ current_user.username }}</h2>

    <!-- Form to add a new toot -->
    <form action="{{ url_for('add_toot') }}" method="post">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
        <label for="message">Message:</label>
        <input type="text" id="message" name="message" required>
        <label for="toot_time">Time:</label>
        <input type="time" id="toot_time" name="toot_time" required>
        <label for="day">Day:</label>
        <select id="day" name="day" required>
            <option value="monday">Monday</option>
            <option value="tuesday">Tuesday</option>
            <option value="wednesday">Wednesday</option>
            <option value="thursday">Thursday</option>
            <option value="friday">Friday</option>
            <option value="saturday">Saturday</option>
            <option value="sunday">Sunday</option>
            <option value="everyday">Everyday</option>
        </select>
        <button type="submit">Add Toot</button>
    </form>

    <!-- List of scheduled toots -->
    <h2>Scheduled Toots</h2>
    <ul>
        {% for toot in toots %}
        <li>
            <strong>{{ toot.message }}</strong> at {{ toot.toot_time }} on {{ toot.day }}
            {% if toot.suspended %}
                <em>(Suspended)</em>
                <form action="{{ url_for('resume_toot', toot_id=toot.id) }}" method="post" style="display:inline;">
                    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                    <button type="submit">Resume</button>
                </form>
            {% else %}
                <form action="{{ url_for('suspend_toot', toot_id=toot.id) }}" method="post" style="display:inline;">
                    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                    <button type="submit">Suspend</button>
                </form>
            {% endif %}
            <form action="{{ url_for('delete_toot', toot_id=toot.id) }}" method="post" style="display:inline;">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                <button type="submit">Delete</button>
            </form>
        </li>
        {% endfor %}
    </ul>

    <!-- Logout form -->
    <form action="{{ url_for('logout') }}" method="post">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
        <button type="submit">Logout</button>
    </form>
</body>
</html>
