<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Logs for Device: {{ nume_masa }}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: Arial, sans-serif;
        }
        h1 {
            text-align: center;
            color: #343a40;
        }
        .table-container {
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
        .table {
            margin-bottom: 0;
            table-layout: fixed; /* Ensures consistent column widths */
            width: 100%; /* Makes the table take up the full container width */
        }
        .table th, .table td {
            text-align: center;
            word-wrap: break-word; /* Ensures long text wraps within the cell */
        }
        .table th:nth-child(1), .table td:nth-child(1) {
            width: 20%; /* Device ID column */
        }
        .table th:nth-child(2), .table td:nth-child(2) {
            width: 20%; /* Nume Masa column */
        }
        .table th:nth-child(3), .table td:nth-child(3) {
            width: 30%; /* Timestamp column */
        }
        .table th:nth-child(4), .table td:nth-child(4) {
            width: 30%; /* Event Description column */
        }
        .back-button {
            margin-bottom: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container mt-5">
        <h1 class="mb-4">Logs for Device: {{ nume_masa }}</h1>
        <div class="back-button">
            <a href="/dashboard" class="btn btn-primary">Back to Dashboard</a>
        </div>
        <div class="table-container">
            <table class="table table-striped table-bordered">
                <thead class="table-dark">
                    <tr>
                        <th>Device ID</th>
                        <th>Work Place</th>
                        <th>Timestamp</th>
                        <th>Event Description</th>
                    </tr>
                </thead>
                <tbody>
                    {% if logs %}
                        {% for log in logs %}
                        <tr>
                            <td>{{ log[0] }}</td>
                            <td>{{ log[1] }}</td>
                            <td>{{ log[2] }}</td>
                            <td>{{ log[3] }}</td>
                        </tr>
                        {% endfor %}
                    {% else %}
                        <tr>
                            <td colspan="4">No logs found for this device.</td>
                        </tr>
                    {% endif %}
                </tbody>
            </table>
        </div>
    </div>
    <footer>
        <p class="text-center mt-4">&copy; 2023 Device Logs Dashboard. All rights reserved.</p>
    </footer>
</body>
</html>