/* --- List View Container Adjustment --- */
#list-view-container {
  position: absolute;
  top: 70px; /* Push down to start below the 70px header */
  left: 0;
  width: 66%; /* Match the map width */
  height: calc(100% - 70px); /* Fill remaining height */
  background-color: #f0f2f5;
  z-index: 1000; /* Above map (z-index 400) but below header (z-index 1002) */
  display: none; /* Hidden by default */
  overflow-y: auto;
  box-sizing: border-box;
  border-right: 1px solid #555;
}

.project-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  background-color: #fff;
  table-layout: fixed; /* Forces columns to respect set widths */
}

.project-list-table thead {
  position: sticky;
  top: 0;
  background-color: #25385b;
  color: #fff;
  z-index: 10; /* Increased to sit above the tfoot (which is z-index: 2) */
}

.list-view-title-row th {
  font-size: 1.1em;
  padding: 24px 15px !important; /* Taller */
  text-align: left;
  background-color: #ffffff; /* White background */
  color: #25385b;
  border-bottom: none !important; /* Removes the tiny gap */
  overflow: visible !important; /* Lets the dropdown break out of the header */
  white-space: normal; /* Resets the text wrap behavior for the top bar */
}

.project-list-table tfoot {
  position: sticky;
  bottom: 0;
  background-color: #f8f9fa;
  border-top: 2px solid #25385b;
  z-index: 2;
}

.list-view-footer-row td {
  padding: 12px 15px;
}

.project-list-table th,
.project-list-table td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  /* Add truncation logic */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* Standard fallback */
}

@supports (text-overflow: " .") {
  .project-list-table th,
  .project-list-table td {
    text-overflow: " ."; /* Applies single dot if supported */
  }
}

.project-list-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0; /* CRITICAL: Forces the cell to respect the colgroup width */
}

.project-list-table tr.expanded-row td {
  white-space: normal; /* Allows text to wrap when expanded */
  word-wrap: break-word;
}

.list-chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid #595959;
  border-bottom: 2px solid #595959;
  transform: rotate(45deg);
  transition: transform 0.3s ease;
  cursor: pointer;
}

.project-list-table tr.expanded-row .list-chevron {
  transform: translateY(4px) rotate(-135deg); /* Point chevron up */
}

.chevron-cell {
  width: 40px;
  text-align: center !important;
  padding: 12px 10px !important;
}

.list-method-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  color: #fff;
  font-weight: bold;
  font-size: 0.8em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  box-sizing: border-box;
}

.project-list-table tr.expanded-row .list-method-pill {
  white-space: normal;
  word-wrap: break-word;
  overflow: visible;
}

.project-list-table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s;
}

.project-list-table tbody tr:hover {
  background-color: #e9ecef;
}

.project-list-table tbody tr.selected-row {
  background-color: #dbeafe;
}

/* Draw an inner blue line on ALL visible cells in the selected row */
.project-list-table tbody tr.selected-row td:not(.hidden-column) {
  box-shadow: inset 4px 0 0 0 #0984e3;
}

/* Instantly wipe the line from any cell that comes AFTER another visible cell.
   This guarantees only the absolute far-left column keeps the blue line! */
.project-list-table
  tbody
  tr.selected-row
  td:not(.hidden-column)
  ~ td:not(.hidden-column) {
  box-shadow: none;
}

/* Mobile adjustments for list view */
.is-mobile #list-view-container {
  width: 100%;
  height: 80vh; /* Matches mobile map height */
  position: relative;
}

/* Style for the toggle buttons in the header */
.view-toggle-group {
  display: flex;
  margin-right: 15px;
  gap: 0; /* Buttons touch each other */
}

.view-toggle-btn,
#header .view-toggle-btn {
  padding: 5px 16px !important;
  border: 1px solid #25385b !important;
  background-color: #fff !important;
  color: #25385b !important;
  cursor: pointer;
  font-weight: bold !important;
  font-size: 0.9em !important; /* Matched to filter pills */
  transition: all 0.2s ease;
  height: 38px !important; /* Matched to filter pills */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.view-toggle-btn:first-child,
#header .view-toggle-btn:first-child {
  border-radius: 25px 0 0 25px !important; /* Matched curve to filter pills */
  border-right: none !important;
}

.view-toggle-btn:last-child,
#header .view-toggle-btn:last-child {
  border-radius: 0 25px 25px 0 !important; /* Matched curve to filter pills */
}

.list-total-pill {
  background-color: #f8f9fa;
  color: #25385b;
  border: 1px solid #25385b;
  padding: 7px 15px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.85em;
  margin-right: 5px;
  display: inline-flex;
  align-items: center;
}

.view-toggle-btn.active,
#header .view-toggle-btn.active {
  background-color: #25385b !important;
  color: #fff !important;
}

.view-toggle-btn:hover:not(.active),
#header .view-toggle-btn:hover:not(.active) {
  background-color: #e9ecef !important;
}

#list-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 2000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

/* ADD: Nicer pagination buttons */
.pagination-btn {
  background-color: #fff;
  border: 1px solid #25385b;
  padding: 7px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  color: #25385b;
  font-size: 0.85em;
  transition: all 0.2s ease;
}
.pagination-btn:hover:not(:disabled) {
  background-color: #e9ecef;
}
.pagination-btn:disabled {
  background-color: #f8f9fa;
  border-color: #dee2e6;
  color: #adb5bd;
  cursor: not-allowed;
}

/* Sorting indicators for list view headers */
.project-list-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease-in-out;
  position: relative;
  background-color: #25385b; /* Explicitly define to prevent composite flashing */
  color: #fff;
  padding-right: 18px; /* Leave room for the arrow */
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -2px;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
}

.col-resizer:hover,
.col-resizer.resizing {
  background-color: #0984e3;
}

.project-list-table th {
  /* Stops fast-clicking from highlighting text blue/white */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: element;
}

.dragging-col {
  /* Removed opacity so it doesn't blend with white background */
  background-color: #1a2841 !important; /* Slightly darker than the header */
  color: #8fa5c7 !important; /* Dim the text slightly */
}

.drag-over-col {
  border-left: 4px solid #0984e3 !important; /* Solid looks cleaner than dashed */
}

.project-list-table th.sortable:hover {
  background-color: #3f5a8a; /* Slightly lighter shade of the #25385B header */
}
.project-list-table th.sortable.alt-header {
  background-color: #324872; /* Slightly lighter alternate column header color */
}
.project-list-table th.sortable.alt-header:hover {
  background-color: #3f5a8a; /* Even lighter hover for the alt header */
}
col.alt-col {
  background-color: rgba(9, 132, 227, 0.03); /* Faint blue tint for the whole column */
}
.project-list-table th.sortable::after {
  content: " \2195"; /* Up/Down arrow */
  opacity: 0.3;
  font-size: 0.85em;
}
.project-list-table th.sortable.asc::after {
  content: " \2191"; /* Up arrow */
  opacity: 1;
}
.project-list-table th.sortable.desc::after {
  content: " \2193"; /* Down arrow */
  opacity: 1;
}
.hidden-column {
  display: none !important;
}
.search-highlight {
  background-color: rgba(241, 196, 15, 0.5); /* Soft yellow highlight */
  color: #000;
  border-radius: 2px;
}

.list-pill-btn {
  background-color: #fff !important;
  border: 1px solid #25385b !important;
  color: #25385b !important;
  padding: 6px 14px !important;
  border-radius: 20px !important;
  font-weight: bold !important;
  font-size: 0.85em !important;
  box-shadow: none !important;
  height: auto !important;
  margin: 0 !important;
  gap: 5px !important;
}

.list-pill-btn:hover {
  background-color: #e9ecef !important;
}

.list-pill-btn .chevron {
  border-right-color: #25385b !important;
  border-bottom-color: #25385b !important;
  width: 6px;
  height: 6px;
  margin-top: -2px;
}

.tall-pill-row {
  flex-direction: column !important;
  align-items: stretch !important;
  border-radius: 25px !important;
  padding: 10px 12px 15px 12px !important;
  cursor: default !important;
}

.tall-pill-header {
  cursor: pointer;
}

#tree-height-slider {
  margin-top: 10px;
  margin-bottom: 25px; /* space for pips */
}

#tree-height-slider .noUi-value {
  font-size: 10px;
  margin-top: 6px;
}

.layer-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background-color: #fff;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
  margin-left: auto; /* Pushes it to the far right of the flex container */
  cursor: pointer;
  flex-shrink: 0;
}

.layer-info-btn:hover {
  transform: scale(1.2);
}

.layer-info-btn img {
  width: 75%;
  height: 75%;
  object-fit: cover;
}
