<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>New Ticket</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 0;
            background-color: #f9f9f9;
            text-align: center;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            color: #20336b;
        }
        p {
            color: #374a7a;
        }
        .btn {
            display: inline-block;
            padding: 10px 20px;
            background-color: #20336b;
            color: #ffffff;
            text-decoration: none;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }
        .btn:hover {
            background-color: #374a7a;
        }
    </style>
</head>
<body>
    <div class="container">
        {% if ticket.opened_by.id == user.id %}
            <h2>New Ticket Opened at Ositcom</h2>
        {% else %}
            <h2>New Ticket Opened by {{ticket.opened_by.user.first_name}} {{ticket.opened_by.user.last_name}}</h2>
        {% endif %}

        <p>Hello {{user.first_name}},</p>
        {% if ticket.opened_by.id == user.id %}
            <p>You opened a new ticket at Ositcom with the following details:</p>
        {% else %}
            <p>A new ticket was opened by {{ticket.opened_by.first_name}} {{ticket.opened_by.last_name}} with the following details:</p>
        {% endif %}
        <p><strong>Title:</strong> {{ ticket.title }}</p>
        <p><strong>Description:</strong> {{ ticket.description }}</p>
        <p><strong>Department:</strong> {{ ticket.department.name }}</p>
        <p><strong>Regarding:</strong> 
            {% if not ticket.project and not ticket.product %}
                {{ ticket.regarding }}
            {% elif ticket.product %}
                {{ ticket.product }}
            {% elif ticket.project %}
                {{ ticket.project }}
            {% endif %}</p>
        <p><strong>Opened By:</strong> {{ ticket.opened_by.first_name }} {{ ticket.opened_by.last_name }}</p>
        <p><strong>Opened Date:</strong> {{ ticket.opened_date }}</p>
        <p><a class="btn" href="https://osina.ositcom.com/tickets/{{ticket.ticket_number}}/">View Ticket</a></p>
        <p>Regards,<br>The Ositcom Team</p>
    </div>
</body>
</html>
