/* --- Global Resets & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    /* Light grey background for the page */
    color: #333;
    /* Default text color */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-wrapper {
    flex: 1 0 auto;
    /* Allows footer to stick to bottom */
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1 0 auto;
    /* Allows main content to grow */
}


/* --- Container & Layout --- */
.container {
    width: 90%;
    max-width: 600px;
    /* Default max-width for general content */
    margin: 30px auto;
    padding: 25px 30px;
    /* Slightly more horizontal padding */
    background-color: #fff;
    /* White background for content boxes */
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    /* Softer shadow */
}

.dashboard-container {
    max-width: 900px;
    /* Wider for KADOE dashboard form */
}

.auth-container {
    max-width: 450px;
    /* Narrower for login/OTP forms */
}

.admin-container {
    /* For admin pages like manage_users, enquiry_log */
    max-width: 1100px;
    /* Wider to accommodate tables and more info */
}


/* --- Typography & Links --- */
h1,
h2,
h3 {
    margin-bottom: 0.75em;
    color: #2c3e50;
    /* Dark blue-grey for headings */
    line-height: 1.3;
}

h1 {
    font-size: 1.8em;
    font-weight: 300;
    /* Main page title */
    text-align: center;
    /* Default for H1 */
}

h2 {
    font-size: 1.5em;
    font-weight: 300;
    /* Section titles */
}

a {
    /* General links */
    color: #3498db;
    /* Standard link blue */
    text-decoration: none;
    /* No underline by default for general links */
    transition: color 0.2s ease-in-out;
}

a:hover {
    text-decoration: underline;
    /* Underline on hover for general links */
    color: #2980b9;
    /* Darker blue on hover */
}


/* --- Forms --- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    /* Adjusted padding */
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    background-color: #fff;
    /* Ensure inputs are white */
}

.form-group input:focus,
.form-group select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
    /* Softer focus ring */
}

.form-group input[readonly] {
    background-color: #e9ecef;
    /* Bootstrap-like readonly background */
    cursor: not-allowed;
}

/* --- Buttons --- */
button,
/* Targets <button> elements */
.button {
    /* Targets any element with class="button", like <a class="button"> */
    display: inline-block;
    color: #ffffff !important;
    /* Default button text to white */
    background-color: #3498db;
    /* Default Primary blue */
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    text-align: center;
    text-decoration: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    margin-top: 10px;
    line-height: 1.5;
}

/* Ensure hover states also maintain text color and no underline for <a> tags */
button:hover,
.button:hover {
    background-color: #2980b9;
    border-color: #206694;
    color: #ffffff !important;
    text-decoration: none !important;
}


button:active,
.button:active {
    background-color: #206694;
    /* Even darker for active/press state */
    transform: translateY(1px);
}

button:disabled,
.button:disabled,
button:disabled:hover,
/* Style disabled state hover too */
.button:disabled:hover {
    background-color: #bdc3c7;
    border-color: #adb5bd;
    color: #777777 !important;
    cursor: not-allowed;
    transform: none;
}

/* Helper Button Color Classes */
.button.primary {
    background-color: #007bff;
    border-color: #007bff;
    color: #ffffff !important;
    /* Explicitly white */
}

.button.primary:hover {
    background-color: #0069d9;
    border-color: #0062cc;
    color: #ffffff !important;
}

.button.secondary,
/* Target .secondary class */
button[type="reset"] {
    /* Also specifically target reset buttons without needing .secondary */
    background-color: #6c757d;
    /* Grey */
    border-color: #6c757d;
    color: #ffffff !important;
    /* <<< ENSURE TEXT IS WHITE */
}

.button.secondary:hover,
button[type="reset"]:not(:disabled):hover {
    /* Add :not(:disabled) for reset hover */
    background-color: #5a6268;
    /* Darker grey */
    border-color: #545b62;
    color: #ffffff !important;
    /* <<< ENSURE TEXT IS WHITE */
}

.button.success {
    background-color: #28a745;
    border-color: #28a745;
}

.button.success:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.button.danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

.button.danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.button.warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529 !important;
    /* Dark text for yellow background */
}

.button.warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529 !important;
}

.button.light {
    background-color: #f8f9fa;
    border-color: #f8f9fa;
    color: #212529 !important;
    /* Dark text for light background */
}

.button.light:hover {
    background-color: #e2e6ea;
    border-color: #dae0e5;
    color: #212529 !important;
}

.button.info {
    background-color: #17a2b8;
    border-color: #17a2b8;
}

.button.info:hover {
    background-color: #138496;
    border-color: #117a8b;
}

.button.dark {
    background-color: #343a40;
    border-color: #343a40;
}

.button.dark:hover {
    background-color: #23272b;
    border-color: #1d2124;
}

.button.small-button {
    /* For smaller utility buttons like 'Dismiss Password' */
    padding: 4px 8px;
    font-size: 0.8em;
    margin-top: 0;
}


.message {
    /* For AJAX success/error messages */
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 5px;
    font-size: 0.95em;
    text-align: center;
    display: none;
    /* Hidden by default, shown by JS */
}

.message.success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message:not(:empty) {
    /* Show if not empty, JS also controls display */
    display: block;
}


/* --- Dashboard Specific (KADOE Enquiry Page) --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.dashboard-header h1 {
    text-align: left;
    margin-bottom: 0;
    margin-right: 15px;
    font-size: 1.6em;
    font-weight: 300;
}

.dashboard-header nav {
    display: flex;
    gap: 10px;
}

.dashboard-header nav .button {
    margin-top: 0;
}

.logout-button {
    /* Used in dashboard and admin headers */
    background-color: #dc3545;
    /* Danger Red */
    border-color: #dc3545;
}

.logout-button:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.admin-link {
    /* Used in dashboard header */
    background-color: #ffc107;
    /* Warning Yellow */
    border-color: #ffc107;
    color: #212529 !important;
}

.admin-link:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529 !important;
}

/* KADOE Form Layout on Dashboard */
#kadoeForm .form-row {
    margin-bottom: 20px;
}

#kadoeForm .form-row:last-of-type {
    margin-bottom: 0;
}

#kadoeForm .grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#kadoeForm .form-group {
    margin-bottom: 0;
    /* Grid gap handles vertical spacing */
}

#kadoeForm input[type="text"],
#kadoeForm input[type="date"],
#kadoeForm select {
    width: 100%;
}

#kadoeForm input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.enquiry-summary-box {
    padding: 15px;
    background-color: #e9ecef;
    /* Light grey background to make it stand out */
    border: 1px solid #ced4da;
    border-radius: 5px;
    margin-bottom: 25px;
    /* Space between summary and main results */
}

.enquiry-summary-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #495057;
    /* Softer heading color for summary */
    border-bottom: 1px solid #ced4da;
    padding-bottom: 8px;
}

.enquiry-summary-box .summary-row {
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    /* Pushes label and value to opposite sides */
    flex-wrap: wrap;
    /* Allows wrapping on small screens */
}

.enquiry-summary-box .summary-row strong {
    color: #495057;
    margin-right: 10px;
    /* Space between label and value */
}

/* Results Area on Dashboard */
#resultsArea {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #f9f9f9;
}

#resultsArea h2 {
    margin-top: 0;
    text-align: left;
    font-size: 1.3em;
    font-weight: 300;
    /* Consistent with other section h2 */
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#resultsArea #printResultsBtn {
    background-color: #6c757d;
    /* Secondary/Grey */
    border-color: #6c757d;
    color: #ffffff !important;
    margin-bottom: 15px;
    /* <<< ADDED MARGIN BOTTOM FOR PRINT BUTTON */
}

#resultsArea #printResultsBtn:hover {
    background-color: #5a6268;
    border-color: #545b62;
}

#printableResults pre {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9em;
    border: 1px solid #ced4da;
    max-height: 400px;
    overflow-y: auto;
}

/* Styles for Formatted KADOE Results (used by formatKadoeResultsToHTML in JS) */
.kadoe-results-formatted {
    font-size: 0.95em;
}

.kadoe-results-formatted h3 {
    font-size: 1.15em;
    /* Slightly smaller than main section H2 */
    color: #2c3e50;
    /* Consistent heading color */
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dddddd;
}

.kadoe-results-formatted h3:first-of-type {
    margin-top: 0;
    /* No top margin for the very first h3 in results */
}

.kadoe-results-formatted .result-row {
    padding: 6px 0;
    border-bottom: 1px dotted #eaeaea;
    display: flex;
    /* For two-column layout of label/value */
    flex-wrap: wrap;
    /* Allow wrapping if content is long */
    line-height: 1.5;
}

.kadoe-results-formatted .result-row:last-child {
    border-bottom: none;
}

.kadoe-results-formatted .result-label {
    font-weight: 600;
    /* Bolder labels */
    color: #454d55;
    /* Darker grey for labels */
    min-width: 180px;
    /* Give labels a consistent minimum width */
    flex-shrink: 0;
    /* Prevent labels from shrinking too much */
    padding-right: 10px;
    /* Space between label and value */
}

.kadoe-results-formatted .result-value {
    flex-grow: 1;
    /* Allow value to take remaining space */
}

.kadoe-results-formatted .address-block {
    /* Specific for multi-line address */
    /* display: block; */
    /* Already block by default for div */
    padding-top: 2px;
    /* Align with label better if label is on its own line */
}

.kadoe-results-formatted .address-block br:first-child {
    display: none;
    /* Avoid leading <br> if addressParts.join makes one */
}


.kadoe-results-formatted .result-message.important .result-label,
.kadoe-results-formatted .result-message.important .result-value {
    color: #a94442;
    /* Dark red for important messages from DVLA */
    font-weight: bold;
}

/* Styling for DVLA API Error list (if result.data.errors exists) */
.kadoe-results-formatted .details-list.error-details {
    list-style-type: none;
    padding-left: 0;
    margin-top: 10px;
}

.kadoe-results-formatted .details-list.error-details li {
    color: #a94442;
    /* Bootstrap danger text color */
    background-color: #f2dede;
    /* Bootstrap danger background */
    border: 1px solid #ebccd1;
    /* Bootstrap danger border */
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
}

.kadoe-results-formatted .details-list.error-details li strong {
    color: #843534;
    /* Darker red for the code part */
}

.kadoe-disclaimer {
    margin-top: 25px;
    /* Adds space between the results box and the disclaimer text */
    font-size: 9px;
    /* Sets the font size to 9 pixels */
    color: #6c757d;
    /* A muted look */
    border-top: 1px solid #e0e0e0;
    /* Adds a separator line above the disclaimer */
    padding-top: 15px;
    /* Adds space between the separator line and the text */
}

/* --- Admin Page Specific Styles --- */
.admin-container h1 {
    font-size: 1.8em;
    font-weight: 300;
    /* text-align can be center or left based on preference */
}

.admin-container h2 {
    /* Section headers (e.g., "Add New User", "User List") */
    text-align: left;
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 1.5em;
    font-weight: 300;
    /* Slightly smaller than main H1 */
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

.admin-container h2:first-of-type {
    /* No top margin for the very first h2 */
    margin-top: 0;
}

.admin-section {
    /* Wrapper for distinct sections on admin pages */
    margin-bottom: 40px;
    padding-bottom: 20px;
}

.admin-section:last-of-type {
    /* No bottom margin/border for the last section */
    border-bottom: none;
    margin-bottom: 0;
}

/* Add User Form Grid on Manage Users Page */
#adminAddUserForm .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px 20px;
    margin-bottom: 20px;
}

#adminAddUserForm .form-grid .form-group {
    margin-bottom: 0;
}

/* Temporary Password Display Area */
#tempPasswordDisplay {
    display: none;
    margin-top: 15px;
    padding: 10px 15px;
    border: 1px solid #d1e7dd;
    background-color: #dff0d8;
    color: #0f5132;
    border-radius: 4px;
}

#tempPasswordDisplay strong {
    color: #0a3622;
}

#generatedTempPassword {
    font-weight: bold;
    color: #c7254e;
    background-color: #f9f2f4;
    padding: 2px 5px;
    border-radius: 3px;
    user-select: all;
}

#tempPasswordDisplay .button.small-button {
    margin-left: 15px;
    vertical-align: middle;
}


/* Filter Form on Manage Users/Log Pages */
.filter-form {
    margin-bottom: 25px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    /* Vertically align items if they wrap */
    gap: 10px;
    /* Space between all form elements */
    flex-wrap: wrap;
}

.filter-form label {
    font-weight: 600;
    margin-bottom: 0;
    /* Already have this */
    margin-right: 5px;
    /* Add a bit of space after labels if not wrapped by form-group */
}

.filter-form select,
.filter-form input[type="text"],
.filter-form input[type="date"] {
    padding: 8px 10px;
    min-width: 180px;
    /* Keep this or adjust */
    flex-grow: 1;
    /* Allow input fields to grow and take available space */
}

.filter-form button[type="submit"],
.filter-form button[type="reset"] {
    /* Target both buttons */
    margin-top: 0;
    /* Align with other filter elements if they are on the same line */
    padding: 8px 15px;
    min-width: 130px;
    /* <<< ADD OR ADJUST THIS: Give a minimum width */
    text-align: center;
    /* Ensure text is centered */
    flex-grow: 0;
    /* Don't let buttons grow disproportionately unless desired */
    flex-shrink: 0;
    /* Don't let buttons shrink disproportionately */
}

/* Table Styling for Admin Lists */
.table-responsive {
    overflow-x: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 15px;
}

.admin-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}

.admin-container th,
.admin-container td {
    border: 1px solid #dee2e6;
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}

.admin-container th {
    background-color: #e9ecef;
    font-weight: 600;
    white-space: nowrap;
}

/* Action Buttons in Admin Tables */
.admin-container td.actions {
    text-align: left;
    white-space: nowrap;
}

.admin-container td.actions .button {
    margin: 3px;
    padding: 5px 8px;
    /* Adjusted padding for smaller action buttons */
    font-size: 0.85em;
    /* Specific colors for action buttons will be applied by adding .primary, .danger etc. in HTML */
}

/* Status Badges in Admin Tables */
.status-badge {
    padding: .25em .6em;
    font-size: 85%;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .375rem;
    text-transform: capitalize;
    min-width: 85px;
    display: inline-block;
}

.status-badge.status-active {
    background-color: #28a745;
}

.status-badge.status-suspended {
    background-color: #dc3545;
}

.status-badge.status-archived {
    background-color: #6c757d;
}

.status-badge.status-pending_password_reset {
    background-color: #ffc107;
    color: #1f2937;
}


/* Modal Styles (for Edit User, Inactivity Warning etc.) */
.modal {
    /* The overlay */
    display: none;
    /* Hidden by default, JS toggles to 'flex' */
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    /* For vertical centering */
    justify-content: center;
    /* For horizontal centering */
}

.modal.show {
    /* Use this class via JS to show modal if preferred */
    display: flex;
}

.modal-content {
    /* The actual modal box */
    background-color: #fff;
    margin: auto;
    /* Part of flex centering, or for non-flex fallback */
    padding: 20px 30px 30px 30px;
    border: none;
    width: 90%;
    max-width: 500px;
    /* Default max width for modals */
    border-radius: .5rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    /* Modal Title */
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.4em;
    color: #333;
    font-weight: 300;
}

.close-button {
    /* The 'X' button to close modal */
    color: #6c757d;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    position: absolute;
    top: 15px;
    right: 15px;
    opacity: .75;
    text-shadow: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    opacity: 1;
    text-decoration: none;
}

/* Forms within Modals */
.modal-content .form-group {
    margin-bottom: 15px;
}

.modal-content .form-group:last-of-type {
    margin-bottom: 20px;
}

.modal-content button[type="submit"] {
    display: block;
    width: 100%;
    padding: 10px 15px;
}

.modal-content input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.modal-content label[for="edit_force_password_reset"] {
    /* Specific label for checkbox */
    display: inline-block;
    font-weight: normal;
    vertical-align: middle;
    margin-bottom: 0;
}

/* Inactivity Modal Specific Content Styling */
#inactivityModal .modal-content {
    /* Can target specific modal content if needed */
    max-width: 450px;
    /* Slightly smaller for inactivity warning */
}

#inactivityModal p {
    margin-bottom: 15px;
    font-size: 0.95em;
}

#inactivityModal #inactivityCountdown {
    font-weight: bold;
    font-size: 1.1em;
    color: #dc3545;
    /* Red for countdown */
}

#inactivityModal .button-group {
    /* If you wrap buttons */
    display: flex;
    justify-content: space-around;
    /* Or space-between */
    margin-top: 20px;
}


/* Admin Menu on Admin Index Page (admin/index.php) */
.admin-menu {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 25px;
}

.admin-menu-item {
    background-color: #fff;
    padding: 20px 25px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.admin-menu-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.admin-menu-item .large-button {
    /* Links styled as large buttons in admin menu */
    padding: 10px 20px;
    font-size: 1.05em;
    display: block;
    text-align: center;
    margin-bottom: 10px;
    /* Default button blue will be used unless a color class like .primary is added in HTML */
}

.admin-menu-item p {
    margin-top: 0;
    color: #495057;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Analytics Card Styles */
.analytics-card {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin: 25px 0;
}

.analytics-card h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
}

.analytics-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 15px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-number {
    font-size: 2.2em;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9em;
    color: #6c757d;
    font-weight: 500;
}

.success-stat .stat-number {
    color: #28a745;
}

.error-stat .stat-number {
    color: #dc3545;
}

.stat-divider {
    width: 1px;
    height: 50px;
    background-color: #e0e0e0;
    flex-shrink: 0;
}

.success-rate {
    text-align: center;
    font-size: 0.95em;
    color: #495057;
    font-weight: 500;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

/* Responsive adjustments for analytics */
@media (max-width: 480px) {
    .analytics-stats {
        flex-direction: column;
        gap: 20px;
    }
    
    .stat-divider {
        width: 60px;
        height: 1px;
    }
    
    .stat-number {
        font-size: 2em;
    }
}


/* Pagination Styles (for Enquiry Log, etc.) */
#logPagination {
    /* Container for pagination buttons */
    margin-top: 25px;
    text-align: center;
}

#logPagination .button {
    margin: 0 4px;
    /* Spacing between pagination buttons */
    padding: 6px 12px;
    font-size: 0.9em;
    margin-top: 0;
    /* Override default button top margin */
}

#logPagination .button.active {
    /* Style for the current page button */
    background-color: #0056b3;
    /* Darker blue for active page */
    border-color: #0056b3;
    cursor: default;
}

#logPagination .button:disabled {
    /* Style for disabled Prev/Next buttons */
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: #6c757d !important;
}

#logSummary {
    /* Text like "Displaying 1-10 of 100" */
    font-style: italic;
    color: #555;
    text-align: right;
    margin-bottom: 10px;
    /* Space below summary, above table/pagination */
    font-size: 0.9em;
}


/* --- Footer --- */
.site-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 25px 15px;
    background-color: #343a40;
    color: #adb5bd;
    font-size: 0.9em;
    margin-top: 40px;
}

.site-footer p {
    margin: 0;
}


/* --- Responsive Adjustments --- */
@media (min-width: 768px) {

    /* For tablets and larger */
    .admin-menu {
        grid-template-columns: 1fr 1fr;
        /* Two columns for admin menu */
    }
}

@media (max-width: 992px) {

    /* Breakpoint for user table to switch to cards (often tablets) */
    /* Responsive Card Layout for User Table */
    .user-cards-container .table-responsive {
        border: none;
        overflow-x: visible;
    }

    /* No scroll needed for cards */
    .user-cards-container table,
    .user-cards-container thead,
    .user-cards-container tbody,
    .user-cards-container th,
    .user-cards-container td,
    .user-cards-container tr {
        display: block;
    }

    .user-cards-container thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Hide headers */
    .user-cards-container tr {
        /* Style each row as a card */
        border: 1px solid #ddd;
        border-radius: 5px;
        margin-bottom: 15px;
        padding: 15px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .user-cards-container td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        border-bottom: 1px dotted #eee;
        /* Dotted line for softer separation */
        padding: 10px 0;
        /* Remove horizontal padding, rely on card padding */
        text-align: right;
        /* Align value to the right */
    }

    .user-cards-container td:last-child {
        border-bottom: none;
    }

    .user-cards-container td:before {
        /* Pseudo-element for labels */
        content: attr(data-label);
        font-weight: 600;
        /* Bolder labels */
        margin-right: 10px;
        text-align: left;
        color: #454d55;
        /* Darker label color */
        flex-basis: 40%;
        /* Give label some width */
        flex-shrink: 0;
        /* Prevent label from shrinking too much */
    }

    .user-cards-container td.actions {
        /* Actions cell in card view */
        flex-direction: column;
        align-items: stretch;
        padding-top: 15px;
    }

    .user-cards-container td.actions .button {
        width: 100%;
        margin-bottom: 8px;
        margin-left: 0;
        margin-right: 0;
    }

    .user-cards-container td.actions .button:last-child {
        margin-bottom: 0;
    }
}


@media (max-width: 768px) {

    /* For smaller tablets and mobile in portrait */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-header nav {
        margin-top: 15px;
        width: 100%;
        justify-content: flex-start;
    }

    .dashboard-header nav .button {
        flex-grow: 1;
        text-align: center;
    }

    #kadoeForm .grid-2-col {
        grid-template-columns: 1fr;
    }

    /* Stack KADOE form 2-col grid */
}

@media (max-width: 600px) {

    /* Further adjustments for very small screens (mobiles) */
    .container,
    .dashboard-container,
    .auth-container,
    .admin-container {
        width: 95%;
        margin: 20px auto;
        padding: 15px;
        /* Reduced padding */
    }

    h1 {
        font-size: 1.5em;
        font-weight: 300;
    }

    h2 {
        font-size: 1.25em;
        font-weight: 300;
    }

    .admin-menu {
        grid-template-columns: 1fr;
    }

    /* Ensure admin menu always stacks */

    .button,
    button {
        font-size: 0.9rem;
        padding: 10px 15px;
    }

    /* Slightly smaller buttons overall */
    .admin-container td.actions .button {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    /* Even smaller action buttons */

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* Stack filter items */
    .filter-form .form-group,
    .filter-form select,
    .filter-form input {
        width: 100%;
        min-width: 0;
    }

    .filter-form button {
        width: 100%;
        margin-top: 10px;
    }

    .modal-content {
        width: 95%;
        margin-top: 5%;
        margin-bottom: 5%;
        max-height: 85vh;
        padding: 15px 20px;
    }
}


/* --- Print Styles --- */
@media print {

    /* --- NEW @page rule to control browser-generated headers/footers --- */
    @page {
        size: auto;
        /* auto is the initial value */
        margin: 2cm;
        /* Set your desired page margins (e.g., 2cm, 0.5in) */
        /* Some browsers might require this to hide headers/footers */
        /* For some browsers, setting margin to 0 might be needed if they still show up */
        /* @page { margin: 0; } */
    }

    /* --- Existing print styles --- */
    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 11pt;
        /* Or your preferred print font size */
        line-height: 1.3;
    }

    /* Hide elements not relevant for printing */
    .dashboard-header,
    .kadoeForm,
    /* Note: Your form ID is #kadoeForm, this class selector might not be used */
    #kadoeForm,
    /* Correctly targeting the form by ID */
    #printResultsBtn,
    .site-footer,
    .admin-container header,
    /* For admin pages */
    .admin-container nav,
    .admin-container .filter-form,
    .admin-container #adminAddUserForm,
    .admin-container td.actions,
    .modal,
    .admin-menu,
    button,
    .button,
    /* Hides all buttons */
    .message,
    /* Hides success/error messages */
    .no-print

    /* General utility class to hide things */
        {
        display: none !important;
    }

    /* Reset styles for printable area to ensure it takes up the full page */
    .page-wrapper,
    .main-content,
    .container,
    .dashboard-container,
    .auth-container,
    .admin-container,
    #resultsArea {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        background-color: #fff !important;
    }

    /* Specifically show printable results and make sure they are visible */
    #printableResults,
    #printableResults * {
        /* Use universal selector to ensure all children are also visible */
        visibility: visible !important;
        color: #000 !important;
    }

    #printableResults {
        position: static !important;
        /* Reset any special positioning */
        background-color: #fff !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Style the formatted results for print */
    #printableResults .kadoe-results-formatted h3 {
        font-size: 14pt !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
        margin-top: 20px;
        page-break-after: avoid;
        /* Try not to have a page break right after a heading */
    }

    #printableResults .kadoe-results-formatted h3:first-of-type {
        margin-top: 0;
    }

    #printableResults .result-row {
        padding: 4px 0 !important;
        border: none !important;
        /* Remove dotted lines for cleaner print */
        page-break-inside: avoid;
        /* Try to keep a label and its value on the same page */
    }

    /* Style for raw JSON pre tag if it's used as a fallback */
    #printableResults pre {
        background-color: #fff !important;
        border: 1px solid #ccc !important;
        color: #000 !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        font-size: 9pt !important;
        page-break-inside: avoid;
    }

    /* Admin Table Print Styles (if you want to print them) */
    .admin-container .table-responsive,
    .admin-container table,
    .admin-container th,
    .admin-container td {
        visibility: visible !important;
        display: table-cell !important;
        border: 1px solid #999 !important;
        /* Darker border for print */
        padding: 6px 8px !important;
    }

    .admin-container th {
        background-color: #eee !important;
        /* Light grey for TH */
    }

    .admin-container table {
        font-size: 8pt !important;
        page-break-inside: auto;
    }

    .admin-container tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* Ensure links are plain text in print */
    a,
    a:visited {
        text-decoration: none !important;
        color: #000 !important;
    }

    /* Optional: Show full URL for external links after the link text */
    /* a[href^="http"]:after { content: " (" attr(href) ")"; font-size: 90%; } */
}

/* --- Credential rotation status -------------------------------------------
   Used by the admin dashboard tile (admin/index.php) and the countdown banner
   on both DVLA rotation pages. Band classes (.rotation-ok / .rotation-due_soon
   / .rotation-overdue) set only colours and are shared by the banner and the
   per-credential tile items. */

.admin-back-link {
    margin-bottom: 20px;
}

/* Status colour bands (shared) */
.rotation-ok {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.rotation-due_soon {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.rotation-overdue {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

/* Banner shown at the top of each rotation page */
.rotation-status-banner {
    padding: 14px 18px;
    margin: 16px 0 24px 0;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.4;
}

/* Dashboard tile grid */
.rotation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.rotation-item {
    padding: 16px;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: 8px;
    text-align: center;
}

.rotation-item-label {
    font-weight: 600;
    margin-bottom: 6px;
}

.rotation-item-days {
    font-size: 1.4em;
    font-weight: 700;
    margin-bottom: 4px;
}

.rotation-item-due {
    font-size: 0.85em;
    opacity: 0.85;
    margin-bottom: 10px;
}

.rotation-item-link {
    display: inline-block;
    font-size: 0.85em;
    font-weight: 600;
    text-decoration: underline;
    color: inherit;
}

.rotation-unavailable {
    color: #856404;
    font-size: 0.95em;
}