/* Results Table Styles */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: visible;
  flex: 1;
}

.results-filter {
  flex-shrink: 0;
}

.query-embedding-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #f9fbfa 0%, #eef3f2 100%);
  padding: 10px 12px;
}

.query-embedding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.inspect-query-embedding-button {
  width: auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: #e6eeec;
  color: var(--accent);
  border: 1px solid #bfd1cd;
  border-radius: 8px;
}

.inspect-query-embedding-button:hover {
  filter: brightness(1.04);
}

.results-filter input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.9rem;
  background: #fff;
}

.results-filter input:focus {
  outline: 2px solid rgba(24, 78, 90, 0.18);
  outline-offset: 2px;
}

.results-table-wrapper {
  min-height: 0;
  overflow: visible;
  flex: 0 0 auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.results-table thead {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #f9fbfa 0%, #eef2ef 100%);
  z-index: 10;
}

.results-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  border-bottom: 2px solid var(--line);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.results-table th:first-child {
  width: 50px;
  text-align: center;
}

.results-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.results-table tbody tr:hover {
  background-color: rgba(24, 78, 90, 0.03);
}

.results-table tbody tr.is-primary {
  background: linear-gradient(90deg, rgba(216, 233, 231, 0.4) 0%, transparent 40%);
  font-weight: 600;
}

.results-table tbody tr.is-primary td {
  border-top: 2px solid var(--accent-soft);
  border-bottom: 2px solid var(--accent-soft);
  padding: 14px;
}

.results-table tbody tr.is-primary:hover {
  background: linear-gradient(90deg, rgba(24, 78, 90, 0.08) 0%, rgba(24, 78, 90, 0.03) 40%);
}

.results-table td {
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--ink);
}

.results-table td.rank {
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  font-family: "Courier New", monospace;
  width: 50px;
}

.results-table td.title {
  font-weight: 600;
  max-width: 280px;
  word-break: break-word;
}

.results-table td.source {
  color: var(--muted);
  font-size: 0.85rem;
  width: 120px;
}

.results-table td.scores {
  text-align: right;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--accent);
  width: 110px;
}

.results-table td.actions {
  text-align: center;
  width: 110px;
}

.results-table td.cosine-cell {
  width: 84px;
  text-align: center;
}

.cosine-eye-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}

.cosine-eye-button:hover {
  transform: translateY(-1px);
}

.cosine-modal-card {
  max-width: min(860px, 92vw);
}

.cosine-summary-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cosine-modal-chart {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
}

.cosine-modal-chart svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.cosine-modal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.cosine-modal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot-query {
  background: #1e7f8f;
}

.legend-dot-chunk {
  background: #995f22;
}

@media (max-width: 760px) {
  .cosine-summary-grid {
    grid-template-columns: 1fr;
  }
}

.results-table button {
  width: auto;
  padding: 8px 12px;
  font-size: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.16s ease;
}

.results-table button:hover {
  filter: brightness(1.08);
}

.lexical-highlight {
  background: rgba(153, 95, 34, 0.2);
  color: #713d14;
  border-radius: 4px;
  padding: 0 2px;
}

.results-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.pager-button {
  width: auto;
  min-width: 36px;
  padding: 6px 10px;
  border: 1px solid #bfd1cd;
  border-radius: 10px;
  background: #edf3f1;
  color: var(--accent);
  font-size: 0.84rem;
}

.pager-button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pager-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Result Detail Modal */
.result-detail-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(24, 33, 39, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.result-detail-modal.is-open {
  display: flex;
}

.result-detail-modal-content {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(24, 33, 39, 0.24);
  animation: slideUp 0.24s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--ink);
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: auto;
  flex-shrink: 0;
  margin-left: 16px;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.modal-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.modal-detail-row:last-child {
  border-bottom: none;
}

.modal-detail-label {
  font-weight: 600;
  color: var(--muted);
}

.modal-detail-value {
  color: var(--ink);
  font-family: "Courier New", monospace;
  text-align: right;
}

.modal-explanation {
  background: rgba(24, 78, 90, 0.05);
  border-left: 3px solid var(--accent-soft);
  padding: 12px;
  border-radius: 8px;
  margin: 10px 0;
  line-height: 1.5;
}

.modal-explanation p {
  margin: 0;
}

.modal-explanation p + p {
  margin-top: 8px;
}

.modal-text-content {
  background: #f9fbfa;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.6;
  font-size: 0.9rem;
  max-height: 300px;
  overflow-y: auto;
}
