/* Categories and expenses layout */
#data-container {
  display: flex; /* Enable flexbox for side-by-side layout */
  width: 100%; /* Ensure it takes full width of its parent */
  gap: 50px;
  overflow: hidden;
}

#categories-container {
  width: 25%; /* Takes 25% of the parent container's width */
  padding: 0px; /* Optional: Add some padding for spacing */
  margin-left: 20px;
  box-sizing: border-box; /* Ensures padding doesn't affect width */
  overflow-y: hidden;
}

#expenses-container {
  width: 75%; /* Takes 75% of the parent container's width */
  padding: 0px; /* Optional: Add some padding for spacing */
  margin-right: 40px;
  box-sizing: border-box; /* Ensures padding doesn't affect width */
  overflow-y: hidden;
}

#category-form-container {
  margin-bottom: 10px;
}

#category-form button {
  flex-shrink: 0; /* Prevent button from shrinking */
  float: right;
  white-space: nowrap; /* Keep button text on one line */
}

#categories-table-container {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}

#categories-full-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

#categories-full-table th,
#categories-full-table td {
  padding-top: 6px;
  padding-bottom: 6px;
  padding-right: 4px;
}

#categories-full-table th:nth-child(1),
#categories-full-table td:nth-child(1) {
  width: 50%;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#categories-full-table th:nth-child(2),
#categories-full-table td:nth-child(2) {
  width: 25%;
  text-align: right;
}

#categories-full-table th:nth-child(3),
#categories-full-table td:nth-child(3) {
  width: 25%;
  text-align: right;
}

#expense-form-container {
  margin-bottom: 30px;
}

#expense-form {
  display: flex; /* Use flexbox to align items horizontally */
  flex-wrap: nowrap; /* Prevent wrapping to the next line */
  gap: 10px; /* Space between elements */
  align-items: center; /* Vertically center items */
  width: 100%; /* Take full width of #expenses-container */
}

#category-name,
#category-form button.button.bluebutton,
#expense-name,
#expense-class,
#expense-category,
#expense-amount,
#expense-description,
#expense-date,
#expense-form button.button.bluebutton {
  height: 36px; /* Explicit height to match computed input height */
  box-sizing: border-box; /* Already set globally, reinforce here */
  margin: 0; /* Remove any default margins */
  padding: 6px; /* Match global padding */
  vertical-align: middle; /* Fallback for older browsers */
}

#expense-name {
  flex: 1 1 12.5%; /* 15% proportionate width, can shrink/grow */
  min-width: 100px; /* Minimum to ensure readability */
}

#expense-class {
  flex: 1 1 12.5%; /* Smaller width for select */
  min-width: 80px;
}

#expense-category {
  flex: 1 1 15%; /* Slightly wider for category names */
  min-width: 100px;
}

#expense-amount {
  flex: 1 1 10%; /* Smaller for numbers */
  min-width: 60px;
}

#expense-description {
  flex: 1 1 15%; /* Wider for longer text */
  min-width: 120px;
}

#expense-date {
  flex: 1 1 15%; /* Date needs enough space for YYYY-MM-DD */
  min-width: 100px;
}

#expense-form button {
  flex: 0 0 auto; /* Don’t grow or shrink, use natural width */
  white-space: nowrap; /* Keep button text on one line */
}

#expenses-table-container {
  max-height: 55vh; /* Set a maximum height (adjust as needed) */
  overflow-y: auto; /* Enable vertical scrollbar when content overflows */
  overflow-x: auto; /* Enable horizontal scrollbar when content overflows */
}

#expenses-full-table {
  width: 100%;
  min-width: 700px; /* Minimum width to force horizontal scrolling if needed */
  table-layout: fixed;
  border-collapse: collapse;
}

#expenses-full-table thead th {
  /* Ensure the header stays sticky */
  position: sticky;
  top: 0;
  background-color: #f9fafb; /* Match your header background */
  z-index: 1; /* Keep header above scrolling content */
}

#expenses-full-table th,
#expenses-full-table td {
  padding: 8px 5px; /* Consistent padding for all cells */
  border-bottom: 1px solid #e5e7eb; /* Light gray border for separation */
  text-align: left; /* Default left alignment */
  overflow: hidden; /* Prevent content overflow */
  white-space: nowrap; /* Keep content on one line */
}

#expenses-full-table th {
  /* Header-specific styling */
  background-color: #f9fafb; /* Light gray background for headers */
  font-weight: 600; /* Slightly bolder text */
  border-bottom: none; /* Remove original border */
  position: relative; /* Needed for pseudo-element positioning */
}

#expenses-full-table tbody tr:last-child td {
  /* Style for the last row only */
  border-bottom: 1.5px solid #5b5b5b; /* Matches header border for last row */
}

#expenses-full-table tbody tr:hover {
  /* Optional hover effect for rows */
  background-color: #f1f5f9; /* Light hover effect */
}

#expenses-full-table thead th::after {
  /* Add pseudo-element for sticky border */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px; /* Match your border thickness */
  background-color: #5b5b5b; /* Match your border color */
  z-index: 2; /* Ensure it’s above scrolling content */
}

/* Specific column widths */
#expenses-full-table th:nth-child(1),
#expenses-full-table td:nth-child(1) {
  width: 10%; /* Expense name */
  padding-left: 25px;
}

#expenses-full-table th:nth-child(2),
#expenses-full-table td:nth-child(2) {
  width: 10%; /* Class */
}

#expenses-full-table th:nth-child(3),
#expenses-full-table td:nth-child(3) {
  width: 10%; /* Category */
}

#expenses-full-table th:nth-child(4),
#expenses-full-table td:nth-child(4) {
  width: 10%; /* Amount */
  text-align: right; /* Right-align numbers for readability */
  padding-right: 30px;
}

#expenses-full-table th:nth-child(5),
#expenses-full-table td:nth-child(5) {
  width: 20%; /* Description (wider for longer text) */
}

#expenses-full-table th:nth-child(6),
#expenses-full-table td:nth-child(6) {
  width: 10%; /* Date */
}

#expenses-full-table th:nth-child(7),
#expenses-full-table td:nth-child(7) {
  width: 5%; /* Empty column (e.g., for edit button) */
}

#expenses-full-table th:nth-child(8),
#expenses-full-table td:nth-child(8) {
  width: 5%; /* Empty column (e.g., for delete button) */
  padding-right: 25px;
}
