body {
    font-family: Arial, sans-serif;
    background: #f9f9f9;
    margin: 0;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 20px 30px 30px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

h1, h2 {
    color: #444;
}

/* --- Main Form Styling (Now similar to collapsible section's individual items) --- */
form {
    margin-bottom: 20px;
    display: flex; /* Makes the form a flex container */
    flex-direction: column; /* Stacks items vertically */
    gap: 15px; /* Provides vertical spacing between each label-input group */
}

/* General Input Styling applied to ALL relevant input types */
input[type="text"],
input[type="date"],
input[type="password"] {
    width: 100%; /* Take full width of their parent container (the form or flex-item) */
    max-width: none; /* IMPORTANT: Removes the fixed max-width from previous iteration, allowing them to stretch */
    padding: 10px 12px; /* Slightly more padding for better touch targets */
    margin: 0; /* Remove previous margins as flex gap and label margin handle spacing */
    border: 1px solid #ccc;
    border-radius: 6px; /* Slightly more rounded corners */
    box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
    font-size: 16px; /* Ensures text is readable and prevents iOS zoom */
    line-height: 1.5; /* Improves vertical alignment of text */
    -webkit-appearance: none; /* Removes default iOS/WebKit input styling for consistency */
}

/* Styling for labels in the main form */
form label {
    display: block; /* Ensures label takes its own line */
    text-align: left; /* Aligns label text to the left */
    padding-right: 0; /* Remove previous padding for right alignment */
    margin-bottom: 5px; /* Adds space between label and its input field */
    font-weight: bold;
    color: #555;
}

/* Adjust the submit button in the main form */
form button[type="submit"] {
    width: auto; /* Allow button to size based on content */
    min-width: 120px; /* Give it a minimum size */
    padding: 10px 20px;
    margin-top: 5px; /* Adjust vertical spacing as needed */
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    background-color: #4CAF50; /* Primary button color */
    color: white;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
    align-self: flex-start; /* Aligns the button to the left within the flex container */
}
form button[type="submit"]:hover {
    background-color: #45a049;
}

/* --- End Main Form Styling --- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table, th, td {
    border: 1px solid #ddd;
}

th, td {
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
}

.message {
    padding: 10px;
    background-color: #e7f3fe;
    border-left: 6px solid #2196F3;
    margin-bottom: 15px;
}

.error {
    padding: 10px;
    background-color: #f8d7da;
    border-left: 6px solid #f44336;
    margin-bottom: 15px;
}

.collapsible-section {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-bottom: 20px;
    background: #fafafa; /* Default light mode background */
}

.collapsible-header {
    background-color: #eee; /* Default light mode background */
    cursor: pointer;
    padding: 10px 15px;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
    user-select: none;
}

.collapsible-content {
    padding: 15px;
    display: none; /* Initially hidden by JS */
}

/* Styling for the form INSIDE the collapsible content */
.collapsible-content form {
    max-width: 100%; /* Ensure it takes available width */
    display: flex; /* Already flexbox */
    flex-direction: column; /* Stack items vertically */
    gap: 15px; /* Vertical gap between filter groups */
}

.collapsible-content .flex-row {
    display: flex;
    flex-wrap: wrap; /* Allows filter items to wrap onto the next line */
    gap: 15px; /* Space between filter items */
    justify-content: flex-start; /* Aligns filter inputs to the left */
}

.collapsible-content .flex-item {
    flex: 1 1 calc(50% - 15px); /* On larger screens, take about half width, accounting for gap */
    max-width: calc(50% - 15px); /* Ensure they don't grow too wide */
}

/* No change needed for filter labels; they already behave this way */
/* .collapsible-content .flex-item label {
    text-align: left;
    padding-right: 0;
    margin-bottom: 5px;
    display: block;
} */

/* No change needed for filter inputs; they already behave this way */
/* .collapsible-content .flex-item input[type="text"],
.collapsible-content .flex-item input[type="date"] {
    width: 100%;
    max-width: none;
    margin: 0;
} */


@media (max-width: 768px) { /* Adjust for typical tablet portrait width */
    .collapsible-content .flex-item {
        flex: 1 1 100%; /* Stack items on smaller screens */
        max-width: 100%;
    }
}

.export-btn {
    margin-top: 15px; /* Aligned with other buttons */
    width: auto;
    padding: 10px 20px;
    background-color: #2196F3;
    border: none;
    color: white;
    border-radius: 6px; /* Consistent border-radius */
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
}
.export-btn:hover {
    background-color: #1976d2;
}

.delete-form input[type="password"] {
    width: 150px; /* Fixed width for the password input in the table */
    max-width: 150px; /* Ensure it doesn't exceed this width */
    display: inline-block; /* Keep it next to the delete button */
    vertical-align: middle; /* Align vertically with the button */
    margin: 0 8px; /* Reduce horizontal margin */
}

.delete-form button {
    width: auto;
    padding: 6px 12px;
    background-color: #f44336;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}
.delete-form button:hover {
    background-color: #d32f2f;
}

/* --- Dark Mode Styles --- */
body.dark-mode {
    background: #121212;
    color: #e0e0e0;
}

body.dark-mode .container {
    background: #1e1e1e;
}

body.dark-mode table,
body.dark-mode th,
body.dark-mode td {
    border-color: #444;
}

body.dark-mode th {
    background-color: #2a2a2a;
}

body.dark-mode .message {
    background-color: #1e3a5f;
    border-left-color: #2196F3;
}

body.dark-mode .error {
    background-color: #5f1e1e;
    border-left-color: #f44336;
}

/* Dark mode styles for collapsible elements */
body.dark-mode .collapsible-section {
    background: #2a2a2a; /* Slightly darker than container */
    border-color: #444;
}

body.dark-mode .collapsible-header {
    background-color: #333; /* Darker header */
    color: #eee;
}

/* Dark Mode Input Styles */
body.dark-mode input[type="text"],
body.dark-mode input[type="date"],
body.dark-mode input[type="password"] {
    background-color: #333;
    color: #e0e0e0;
    border-color: #555;
}

#darkModeToggle {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    border-radius: 5px;
    border: none;
    background: #555;
    color: white;
    cursor: pointer;
    width: auto;      /* override button default */
    z-index: 1000;    /* ensure it’s above other elements */
}
body.dark-mode #darkModeToggle {
    background: #bbb;
    color: black;
}