{% include 'header.twig' %}
<section>
    <div class="container">
        <div class="row ticket-form__alignment">
            <div class="col-lg-8 offset-lg-2">
                <div class="component_card">
                    <div>
                        {% if error %}
                            <div class="alert alert-dismissible alert-danger">
                                <button type="button" class="close" data-dismiss="alert">×</button>
                                {{ errorText }}
                            </div>
                        {% endif %}
                        {% if success %}
                            <div class="alert alert-dismissible alert-success">
                                <button type="button" class="close" data-dismiss="alert">×</button>
                                {{ successText }}
                            </div>
                        {% endif %}

                        <div class="ticket-dialog__title">
                            <h3>{{ messageList['ticket']['subject'] }}</h3>
                            {% if messageList["ticket"]["canmessage"] == 1 %}
                                <span class="badge"> This request has been closed by the administrator</span>
                            {% endif %}
                        </div>

                        {% if messageList %}
                            {% for message in messageList %}
                                {% if message["support"] == 1 %}
                                    <div class="ticket-dialog__body component_ticket_messages">
                                        <div class="message">
                                            <div class="ticket-dialog__row ticket-dialog__row-admin">
                                                <div class="message">{{ message["message"] }}</div>
                                                <div class="ticket-dialog__row-bottom">
                                                    <div class="info text-left">{{ user["username"] }}</div>
                                                    <span class="avatar"><i class="fa fa-user-circle"></i></span>
                                                    <div class="text-muted">{{ message["time"] }}</div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                {% elseif message["subject"] %}
                                {% else %}
                                    <div class="ticket-dialog__row ticket-dialog__row-user">
                                        <div class="message">{{ message["message"] }}</div>
                                        <div class="message">
                                            <div class="info text-left">Support</div>
                                            <span class="avatar"><i class="fa fa-user-circle"></i></span>
                                            <div class="text-muted">{{ message["time"] }}</div>
                                        </div>
                                    </div>
                                {% endif %}
                            {% endfor %}
                        {% endif %}
                        
                        {% if messageList['ticket']['canmessage'] == 2 %}
                            <div class="row">
                                <div class="col-md-12">
                                    <form method="post" action="tickets/{{ messageList['ticket']['ticket_id'] }}">
                                        <div class="form-group panel-border-top">
                                            <label for="message" class="control-label">Message</label>
                                            <textarea id="message" rows="5" class="form-control" name="message">{{ data["message"] }}</textarea>
                                        </div>
                                        <button type="submit" class="btn btn-block btn-big-primary">Submit</button>
                                    </form>
                                </div>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<style>
    /* Add your custom CSS styles here */

/* Adjustments for ticket dialog */
.ticket-form__alignment {
    margin-top: 30px;
}

.ticket-dialog__title {
    margin-bottom: 20px;
}

.ticket-dialog__body {
    margin-bottom: 20px;
}

.ticket-dialog__row {
    margin-bottom: 20px;
}

.ticket-dialog__row-bottom {
    display: flex;
    align-items: center;
}

.avatar {
    margin-right: 10px;
}

.message {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.panel-border-top {
    border-top: 1px solid #ccc;
    padding-top: 20px;
}

.btn-big-primary {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-big-primary:hover {
    background-color: #0056b3;
}

</style>
{% include 'footer.twig' %}
