<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Employee Dashboard - Ticket Master</title>
    <%- include('partials/bootstrapcss') %> <%- include('partials/bootstrapcss')
    %>

    <style>
      /* Additional styles for the dashboard page */
      /* * {
        margin: 0;
        padding: 0;
      } */
      .dashboard-container {
        display: flex;
        min-height: 100vh;
      }

      .dashboard-nav {
        background-color: #333;
        /* color: #fff; */
        padding: 20px;
        flex: 0 0 250px;
      }

      .dashboard-content {
        flex: 1;
        padding: 50px;
        background-color: #f5f5f5;
      }

      .dashboard-nav ul {
        list-style: none;
        padding: 0;
      }

      .dashboard-nav li {
        margin-bottom: 15px;
      }

      .dashboard-nav a {
        text-decoration: none;
        color: #fff;
        font-size: 18px;
      }

      .dashboard-btn {
        padding: 10px 20px;
        background-color: #333;
        color: #fff;
        border: none;
        cursor: pointer;
      }

      /*form */
      .create-ticket-container {
        max-width: 600px;
        margin: 0 auto;
        padding: 50px;
        background-color: #f5f5f5;
      }

      .create-ticket-form label {
        display: block;
        margin-bottom: 10px;
      }
      .description {
        width: 100%;
      }
      .create-ticket-form select,
      .create-ticket-form input {
        width: 100%;
        padding: 10px;
        margin-bottom: 15px;
        border: 1px solid #ccc;
      }

      .create-ticket-btn {
        padding: 10px 20px;
        background-color: #333;
        color: #fff;
        border: none;
        cursor: pointer;
      }

      /* cards */
      .ticket-container {
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
      }

      .ticket-card {
        background-color: #fff;

        padding: 10px;
        width: 23rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      }

      .ticket-card-header {
        display: flex;
        justify-content: space-between;
      }

      .ticket-card-heading {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 10px;
      }

      .ticket-card-description {
        font-size: 16px;
        margin-bottom: 15px;
      }

      .ticket-card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .priority-label {
        font-weight: bold;
        padding: 3px 8px;
        border-radius: 3px;
        color: #fff;
      }

      .priority-low {
        background-color: green;
      }

      .priority-medium {
        background-color: orange;
      }

      .priority-high {
        background-color: red;
      }

      .chat-btn {
        padding: 5px 10px;
        background-color: #333;
        color: #fff;
        border: none;
        text-decoration: none;
        cursor: pointer;
      }
      @media (max-width: 767px) {
        .dashboard-container {
          display: flex;
          flex-direction: column;
        }
        .dashboard-nav {
          background-color: #333;
          padding: 20px;
          flex: 0 0 0;
        }
        .dashboard-content {
          padding: 1rem;
        }
      }
    </style>
  </head>
  <body>
    <%- include('partials/employeedashboardnav') %>

    <div class="dashboard-container">
      <!-- dashboard sidebar -->
      <%- include('partials/employeedashboardsidebar') %>

      <section class="dashboard-content">
        <% if (typeof employeeName!=='undefined') { %>
        <h2>Welcome <%= employeeName %></h2>
        <% } else{ %>
        <h2>Welcome</h2>
        <%}%>

        <p>
          Resove your department's tickets and manage your tasks efficiently.
        </p>
        <div class="ticket-container">
          <% if (typeof tickets!=='undefined') { %> <% tickets.forEach(ticket =>
          { %> <% if (ticket.status==='pending') { %>
          <div class="ticket-card">
            <div class="ticket-card-header">
              <h3 class="ticket-card-heading"><%= ticket.title %></h3>
              <% if (ticket.status==='pending') { %>
              <!-- Button trigger modal -->

              <button
                type="button"
                class="btn btn-danger btn-sm"
                data-bs-toggle="modal"
                data-bs-target="#exampleModal1"
              >
                Close
              </button>

              <!-- Modal -->
              <div
                class="modal fade"
                id="exampleModal1"
                tabindex="-1"
                aria-labelledby="exampleModal1Label"
                aria-hidden="true"
              >
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <h1 class="modal-title fs-5" id="exampleModal1Label">
                        Confirmation
                      </h1>
                      <button
                        type="button"
                        class="btn-close"
                        data-bs-dismiss="modal"
                        aria-label="Close"
                      ></button>
                    </div>
                    <div class="modal-body">
                      Are you sure you want to close the ticket?
                    </div>
                    <div class="modal-footer">
                      <button
                        type="button"
                        class="btn btn-secondary"
                        data-bs-dismiss="modal"
                      >
                        Cancel
                      </button>
                      <a
                        ticket-id="<%= ticket._id %>"
                        id="close-ticket-button"
                        class="btn btn-primary"
                      >
                        Confirm</a
                      >
                    </div>
                  </div>
                </div>
              </div>

              <% }else { } %>
            </div>
            <p class="ticket-card-description"><%= ticket.description %></p>
            <span class="ticket-card-description"
              ><strong>Status:</strong> <%= ticket.status %></span
            >
            <div class="ticket-card-footer">
              <span class="assignee"
                ><strong>Assignee:</strong> <%= ticket.assignedTo %></span
              >
              <div>
                <span
                  class="priority-label priority-<%= ticket.priorityLevel %>"
                  ><%= ticket.priorityLevel %></span
                >
                <a href="/chat?ticketId=<%= ticket._id %>" class="chat-btn"
                  >Chat</a
                >
              </div>
            </div>
          </div>
          <% } %> <% }); %> <% } %>
        </div>
      </section>
    </div>
    <script src="/scripts/employeetickets.js"></script>
    <%- include('partials/footer') %> <%- include('partials/bootstrapjs') %>
  </body>
</html>