/* --- General Page Styles --- */
body {
  font-family: Arial, sans-serif;
  margin: 20px;
}

h2 {
  margin-bottom: 15px;
}

/* --- Input styling --- */
.input-wrapper {
  position: relative;
  margin-bottom: 10px;
}

.input-wrapper input {
  padding: 8px;
  width: 300px;
  box-sizing: border-box;
}

/* --- Clear buttons inside inputs --- */
.input-with-clear {
  position: relative;
  display: inline-block;
}

.input-with-clear .clear-btn {
  position: absolute;
  right: 8px;       /* distance from right edge of input */
  top: 50%;         /* vertically center */
  transform: translateY(-50%);
  cursor: pointer;
  display: none;    /* shown only when input has value */
  font-size: 16px;
  color: #888;
  z-index: 2;       /* above input text */
}

/* --- Results Table --- */
#resultsTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* ensures columns align */
}

#resultsTable colgroup col {
  width: auto; /* can be overridden in index.html if needed */
}

#resultsTable th,
#resultsTable td {
  padding: 8px;
  border: 1px solid #ccc;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
}

#resultsTable th {
  background: #f4f4f4;
  cursor: pointer;
  position: relative; /* keep tooltip positioned relative to TH */
}

/* --- Allow Name column text to wrap --- */
#resultsTable td:nth-child(2),
#resultsTable th:nth-child(2) {
  white-space: normal;      /* allow wrapping */
  word-wrap: break-word;    /* break long words */
}

/* --- Structure column styling --- */
.structure-canvas {
  max-width: 120px;
  max-height: 100px;
  display: block;
  margin: 0 auto;
}

/* --- Header content (text + sort arrow inside the cell) --- */
.header-content {
  display: inline-flex; /* inline so tooltips don’t break alignment */
  justify-content: space-between; /* text left, arrow right */
  align-items: center;
  gap: 5px;
}

.sort-indicator {
  font-size: 12px;
  color: #555;
  flex-shrink: 0; /* prevent arrow shrinking */
  transition: transform 0.2s ease; /* smooth arrow toggle */
}

/* Column sorting visual feedback */
#resultsTable th.sorted-asc,
#resultsTable th.sorted-desc {
  background-color: #e0f0ff; /* subtle highlight for sorted column */
}

th.sorted-asc .sort-indicator {
  transform: rotate(0deg);
}

th.sorted-desc .sort-indicator {
  transform: rotate(180deg);
}

/* --- Tooltip Styling --- */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  width: max-content;
  max-width: 200px;
  background-color: #333;
  color: #fff;
  text-align: center;
  padding: 5px 8px;
  border-radius: 4px;
  position: absolute;
  z-index: 1;
  bottom: 125%; /* show above element */
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 12px;
  white-space: normal; /* allow wrapping */
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}