/* --- Navigation Container --- */
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* The hamburger icon is hidden on wide screens by default */
.hamburger {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
}

/* The nav links container */
.nav-links {
    display: flex;
    gap: 1rem;
    flex-grow: 1;
}

/* Buttons inside nav-links (same style as your existing .nav-btn rules) */
.nav-btn {
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background-color: #6c757d;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    line-height: normal;
}

.nav-btn:hover {
    background-color: #5a6268;
}

/* --- Responsive (Below 600px) --- */
@media (max-width: 600px) {

    /* Show the hamburger icon and hide the nav links by default */
    .hamburger {
        display: block;
    }

    /* Hide nav links container by default (will show via JS) */
    .nav-links {
        display: none;
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-links a.nav-btn {
        width: 100%;
    }
}

/* === Global Styles === */
html {
    font-size: 16px;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

input,
button {
    font-size: var(--form-font, 0.875rem);
}

input:not([type="image"]) {
    border-style: inset;
}

h1,
h2,
h3 {
    text-align: center;
}

body,
h2,
label,
p,
div,
span,
td,
th {
    font-family: Arial, sans-serif;
    font-size: 0.875rem;
    color: #333;
}

h2 {
    font-size: 1.5rem;
    margin: 16px 0 8px;
}

h3 {
    font-size: 1.25rem;
    margin: 16px 0 8px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* === Base Layout === */
.container {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    text-align: center;
    margin: 0 auto;
}

.container-login {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 320px;
    text-align: center;
    margin: 0 auto;
}

/* === Navigation Buttons === */
button,
.nav-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    background-color: #6c757d;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 16px;
    min-height: 44px;
    line-height: 1;
}

button:hover,
.nav-btn:hover {
    background-color: #5a6268;
}

.nav-btn.disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
}

.nav-buttons .nav-btn {
    flex: 1;
    width: 0;
    margin-bottom: 0;
    text-align: center;
}

/* === Section Containers === */
.section {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 16px;
}

/* === Header Section === */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.time-display {
    font-size: 0.875rem;
    color: #333;
}

.logo-container {
    width: 80px;
    text-align: right;
}

.logo {
    max-width: 80px;
    height: auto;
}

/* === Shared Styles === */
.section-title {
    font-size: 1rem;
    margin: 5px 0 8px;
    font-weight: bold;
    color: #333;
}

select,
input[type="number"],
.section.login input[type="text"],
.section.login input[type="password"] {
    width: 100%;
    padding: 10px;
    margin: 8px 0 16px;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

hr {
    border: none;
    border-top: 1px solid #ccc;
    margin: 24px 0;
}

.footer {
    text-align: center;
    color: #555;
    padding: 8px;
    font-size: 0.625rem;
}

/* === Test-Devices Specific === */
.current-settings {
    font-size: 0.875rem;
    margin-bottom: 16px;
    text-align: center;
    font-weight: bold;
    padding: 8px;
    background-color: #f0f8ff;
    border-radius: 4px;
    border: 1px solid #cce5ff;
    width: 100%;
    box-sizing: border-box;
}

.current-settings-overlay {
    font-size: 0.875rem;
    margin-top: 5px;
    margin-bottom: -45px;
    text-align: center;
    font-weight: bold;
    padding: 8px;
    background-color: #f0f8ff;
    border-radius: 4px;
    border: 1px solid #cce5ff;
    width: 100%;
    box-sizing: border-box;
}

.current-settings-action {
    font-size: 0.875rem;
    margin-top: -45px;
    margin-bottom: 5px;
    text-align: center;
    font-weight: bold;
    padding: 8px;
    background-color: #f0f8ff;
    border-radius: 4px;
    border: 1px solid #cce5ff;
    width: 100%;
    box-sizing: border-box;
}

.ack-container {
    margin-bottom: 16px;
}

.ack-table {
    width: 100%;
    border-collapse: collapse;
}

.ack-checkbox {
    width: 100px;
    text-align: center;
    vertical-align: middle;
    min-height: 44px;
}

.ack-checkbox input[type="checkbox"] {
    width: 40px;
    height: 40px;
    vertical-align: middle;
}

.ack-label {
    text-align: left;
    vertical-align: middle;
    font-size: 0.875rem;
    color: #333;
}

/* === Table Styles (Updated for /users and /edit-test-devices Pages) === */
.table-container {
    width: 100%;
    max-width: 600px;
    /* Match the max-width of nav-container */
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: auto;
    /* Allow horizontal scrolling on small screens */
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border: none;
    table-layout: fixed;
    /* Ensure columns respect specified widths */
}

.table-container th,
.table-container td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid #ddd;
    word-wrap: break-word;
    /* Ensure long text wraps */
}

.table-container thead {
    background-color: #f2f2f2;
}

/* Specific column widths for the users table */
.table-container th:nth-child(1),
.table-container td:nth-child(1) {
    width: 40%;
    /* Username column in users.html, Device Name in edit-test-devices.html */
}

.table-container th:nth-child(2),
.table-container td:nth-child(2) {
    width: 20%;
    /* Signal Access column in users.html, Max uplinks in edit-test-devices.html */
}

.table-container th:nth-child(3),
.table-container td:nth-child(3) {
    width: 40%;
    /* Action column in both pages */
}

/* Style the delete icon (users.html) */
.table-container .delete-icon {
    width: 32px;
    height: 32px;
    cursor: pointer;
    vertical-align: middle;
}

/* Style the nav-btn in the table (users.html) */
.table-container .nav-btn {
    padding: 6px 12px;
    font-size: 0.875rem;
    background-color: #6c757d;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
}

.table-container .nav-btn:hover {
    background-color: #5a6268;
}

/* Style the max-uplinks input (edit-test-devices.html) */
.table-container .max-uplinks-input {
    width: 60px;
    /* Constrain the input width */
    padding: 5px;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}

/* Style the delete button in edit-test-devices.html */
.table-container .btn-danger {
    padding: 6px 12px;
    font-size: 0.875rem;
    background-color: #dc3545;
    /* Red background for delete */
    color: #fff;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table-container .btn-danger:hover {
    background-color: #c82333;
    /* Darker red on hover */
}

/* === Form Container (for user creation/edit form and add device form) === */
.form-container {
    width: 100%;
    max-width: 600px;
    /* Match the max-width of nav-container */
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

/* Style the form for better spacing */
.form-container .form-group {
    margin-bottom: 15px;
    text-align: left;
    /* Align labels and inputs to the left */
}

.form-container label {
    display: inline-block;
    margin-right: 10px;
}

.form-container input[type="text"],
.form-container input[type="password"],
.form-container input[type="number"] {
    padding: 5px;
    width: 100%;
    max-width: 200px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Style for full-width inputs (e.g., dev_eui in edit-test-devices.html) */
.form-container .full-width-input {
    width: 100%;
    max-width: none;
    /* Override the max-width constraint */
    padding: 10px;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* === Gauge Container & Value === */
#gauge-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

#gauge {
    display: block;
    width: 100%;
    height: 100%;
}

#gauge-value-display {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    font-weight: bold;
    pointer-events: none;
    text-align: center;
}

/* === Media Queries === */
@media (max-width: 600px) {

    .container,
    .container-login {
        padding: 16px;
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 0.9rem;
    }

    .current-settings {
        font-size: 0.75rem;
        padding: 6px;
    }

    label,
    .ack-label {
        font-size: 0.75rem;
    }

    select,
    input[type="number"],
    .section.login input[type="text"],
    .section.login input[type="password"] {
        padding: 8px;
        font-size: 0.75rem;
    }

    button,
    .nav-btn {
        padding: 12px;
        font-size: 1rem;
        min-height: 44px;
    }

    hr {
        margin: 16px 0;
    }

    .footer {
        font-size: 0.625rem;
    }

    .nav-buttons {
        gap: 8px;
    }

    .nav-buttons .nav-btn {
        min-width: 0;
    }

    .ack-checkbox {
        width: 80px;
        min-height: 44px;
    }

    /* Responsive adjustments for the table */
    .table-container table {
        table-layout: auto;
        /* Allow natural resizing on small screens */
    }

    .table-container th,
    .table-container td {
        font-size: 0.75rem;
        padding: 5px;
    }

    .table-container th:nth-child(1),
    .table-container td:nth-child(1) {
        width: 30%;
    }

    .table-container th:nth-child(2),
    .table-container td:nth-child(2) {
        width: 20%;
    }

    .table-container th:nth-child(3),
    .table-container td:nth-child(3) {
        width: 50%;
    }

    .table-container .nav-btn,
    .table-container .btn-danger {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .table-container .max-uplinks-input {
        width: 50px;
        font-size: 0.75rem;
    }

    .form-container input[type="text"],
    .form-container input[type="password"],
    .form-container input[type="number"] {
        width: 100%;
        max-width: 200px;
    }

    .form-container .full-width-input {
        padding: 8px;
        font-size: 0.75rem;
    }
}