/* Scoped Retrieval Debug Styles
   All rules are confined to the retrievalDebug output, which renderRetrievalDebug
   always wraps in `.debug-section-wrapper`. This prevents these styles from
   leaking onto the main debug table, config section, code tags, or other
   debug fields on the page. */

.debug-section-wrapper {
  margin: 15px 0;
  border: 1px solid #ccc;
  padding: 12px;
  background: #fafafa;
}

/* Retrieval summary body (replaces inline styles for CSP compliance) */
.debug-section-wrapper .retrieval-summary-body {
  line-height: 1.8;
  font-size: 0.95em;
}

.debug-section-wrapper .debug-view-controls {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
}

.debug-section-wrapper .debug-view-controls .debug-btn-default,
.debug-section-wrapper .debug-view-controls .debug-btn-expert {
  padding: 6px 12px;
  border: 1px solid #bbb;
  cursor: pointer;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
  background: #e8e8e8;
  color: #555;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  margin: 0;
}

.debug-section-wrapper .debug-view-controls .debug-btn-default:hover:not(.active),
.debug-section-wrapper .debug-view-controls .debug-btn-expert:hover:not(.active) {
  background: #d0d0d0;
  border-color: #999;
}

.debug-section-wrapper .debug-view-controls .debug-btn-default.active,
.debug-section-wrapper .debug-view-controls .debug-btn-expert.active {
  background: #555555 !important;
  color: #ffffff !important;
  border-color: #333333 !important;
  font-weight: bold;
}

.debug-section-wrapper .debug-view-controls .debug-btn-default.active:hover,
.debug-section-wrapper .debug-view-controls .debug-btn-expert.active:hover {
  background: #555555 !important;
}

/* View Sections */
.debug-section-wrapper .debug-view-default,
.debug-section-wrapper .debug-view-expert {
  display: none;
}

.debug-section-wrapper .debug-view-default.active,
.debug-section-wrapper .debug-view-expert.active {
  display: block;
}

/* Collapsible Sections */
.debug-section-wrapper .debug-section {
  margin-bottom: 12px;
}

.debug-section-wrapper .debug-section-title {
  font-weight: bold;
  margin-bottom: 8px;
}

.debug-section-wrapper .debug-toggle-link {
  color: #0066cc;
  text-decoration: underline;
  cursor: pointer;
  margin-left: 8px;
}

.debug-section-wrapper .debug-toggle-link:hover {
  text-decoration: none;
}

.debug-section-wrapper .debug-content {
  display: none;
  background: white;
  padding: 10px;
  border: 1px solid #ddd;
  margin-top: 8px;
  border-radius: 2px;
  font-size: 1em;
  line-height: 1.6;
  max-width: 100%;
  overflow-x: auto;
}

.debug-section-wrapper .debug-content.visible {
  display: block;
}

/* Tables */
.debug-section-wrapper .debug-table {
  display: table !important;
  width: 100%;
  border-collapse: collapse;
  font-size: 1em;
  margin: 10px 0;
}

.debug-section-wrapper .debug-table thead {
  background: #e8e8e8;
}

.debug-section-wrapper .debug-table th,
.debug-section-wrapper .debug-table td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  text-align: left;
}

.debug-section-wrapper .debug-table tbody tr {
  background: white;
}

.debug-section-wrapper .debug-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* Status Badge */
.debug-section-wrapper .status-badge {
  background: #e0e0e0;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 0.85em;
  font-weight: bold;
}

/* Score Breakdown */
.debug-section-wrapper .score-breakdown {
  display: none;
  margin-top: 6px;
  padding: 6px;
  background: #f5f5f5;
  border-left: 2px solid #000;
  font-family: monospace;
  font-size: 0.9em;
}

.debug-section-wrapper .score-breakdown.visible {
  display: block;
}

/* Score toggle text (looks like a link but does not open articles) */
.debug-section-wrapper .score-toggle-link {
  color: #0066cc;
  text-decoration: underline;
  cursor: pointer;
}

/* Expert Sections */
.debug-section-wrapper .expert-table-container {
  padding: 10px;
  background: white;
  border: 1px solid #ddd;
  margin-top: 8px;
  border-radius: 2px;
  font-size: 0.95em;
}

.debug-section-wrapper .expert-table {
  display: table !important;
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.debug-section-wrapper .expert-table th,
.debug-section-wrapper .expert-table td {
  border: 1px solid #ddd;
  padding: 4px 6px;
  text-align: left;
  white-space: nowrap;
}

/* Only the Reference (link) column wraps, and only when needed */
.debug-section-wrapper .expert-table td.expert-ref-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.debug-section-wrapper .expert-table thead {
  background: #f0f0f0;
}

.debug-section-wrapper .expert-table tbody tr {
  background: white;
}

.debug-section-wrapper .expert-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* Sample Evidence Row */
.debug-section-wrapper .sample-evidence-cell {
  border: 1px solid #ddd;
  padding: 8px;
  background: #f9f9f9;
}

.debug-section-wrapper .sample-evidence-details {
  display: none;
  margin-top: 8px;
  padding: 8px;
  background: white;
  border: 1px solid #ddd;
  border-left: 3px solid #000;
}

.debug-section-wrapper .sample-evidence-details.visible {
  display: block;
}

.debug-section-wrapper .sample-evidence-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  font-size: 0.9em;
  font-style: italic;
}

/* Scoring Disclaimer */
.debug-section-wrapper .scoring-disclaimer {
  margin-top: 12px;
  padding: 8px;
  background: #f5f5f5;
  border-left: 2px solid #999;
  font-size: 0.9em;
  font-style: italic;
  color: #333;
}

/* Configuration Display */
.debug-section-wrapper .config-line {
  margin: 4px 0;
  padding-left: 20px;
}

.debug-section-wrapper .config-label {
  font-weight: bold;
}

.debug-section-wrapper .config-value {
  font-family: monospace;
}

/* Search Details Display */
.debug-section-wrapper .search-detail {
  margin: 4px 0;
}

.debug-section-wrapper .search-detail-label {
  font-weight: bold;
}

.debug-section-wrapper .search-detail-value {
  display: inline;
  margin-left: 4px;
}

/* Info Box Style */
.debug-section-wrapper .info-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  font-size: 0.9em;
  font-style: italic;
}

/* Article Link */
.debug-section-wrapper .article-link {
  color: #0066cc;
  text-decoration: none;
  cursor: pointer;
}

.debug-section-wrapper .article-link:hover {
  text-decoration: underline;
}

/* Evidence Items */
.debug-section-wrapper .evidence-item {
  margin: 8px 0;
  padding: 8px;
  background: #fff;
  border: 1px solid #ffe0b2;
  border-radius: 3px;
  font-size: 0.95em;
}

.debug-section-wrapper .evidence-cell {
  border: 1px solid #ddd;
  padding: 8px;
  background: #f9f9f9;
}

/* Score Details */
.debug-section-wrapper .score-detail-item {
  margin: 8px 0;
  padding: 6px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-size: 0.95em;
  font-family: monospace;
}

/* Diagnostics Items */
.debug-section-wrapper .diag-item {
  margin-top: 4px;
}

.debug-section-wrapper .diag-content {
  font-size: 1em;
}

/* Decision Badges */
.debug-section-wrapper .decision-eligible {
  background: #e8f5e9;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: bold;
}

.debug-section-wrapper .decision-promoted {
  background: #fff3e0;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: bold;
}

/* Results Truncation Message */
.debug-section-wrapper .results-truncated {
  font-size: 0.9em;
  color: #666;
  font-style: italic;
  margin-top: 8px;
}

/* Sample Disclaimer */
.debug-section-wrapper .sample-disclaimer {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  font-size: 0.9em;
  font-style: italic;
  display: block;
  color: #666;
}

/* Final Score in Tables */
.debug-section-wrapper .final-score {
  font-weight: bold;
}

/* Code Tags Styling */
.debug-section-wrapper code {
  font-family: monospace;
  background: #f5f5f5;
  padding: 2px 4px;
  border-radius: 2px;
  font-size: 1.05em;
}

/* Debug Table Toggle Links */
.debug-section-wrapper .debug-table-toggle {
  color: #007bff;
  cursor: pointer;
  text-decoration: underline;
}

.debug-section-wrapper .debug-table-toggle:hover {
  text-decoration: none;
}

/* Collapsible Content in Debug Table */
.debug-section-wrapper .debug-table-content {
  display: none;
  margin-top: 8px;
}

.debug-section-wrapper .debug-table-content.visible {
  display: block;
}

/* Alert/Warning Values in Debug Table */
.debug-section-wrapper .debug-alert-value {
  color: red;
  font-weight: bold;
}

/* Format Debug Value Tables */
.debug-section-wrapper .debug-obj-table,
.debug-section-wrapper .debug-doc-table {
  display: table !important;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

.debug-section-wrapper .debug-obj-table thead tr,
.debug-section-wrapper .debug-doc-table thead tr {
  background: #f0f0f0;
}

.debug-section-wrapper .debug-obj-table th,
.debug-section-wrapper .debug-obj-table td,
.debug-section-wrapper .debug-doc-table th,
.debug-section-wrapper .debug-doc-table td {
  border: 1px solid #ddd;
  padding: 4px 8px;
  text-align: left;
}

.debug-section-wrapper .debug-list-item {
  margin: 4px 0;
}

.debug-section-wrapper .debug-list-item strong {
  font-weight: bold;
}
