/* Debug Data Viewer Styles */

.debug-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

.debug-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.debug-container {
  max-width: 95%;
  width: 100%;
  margin: 20px auto;
  background: #ffffff;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid #e0e0e0;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.debug-title {
  font-size: 24px;
  font-weight: 600;
  color: #333333;
  margin: 0;
}

.debug-close {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.debug-close:hover {
  background: #c82333;
}

.debug-summary {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
  border: 1px solid #e9ecef;
}

.debug-summary-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-summary-label {
  font-size: 13px;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.debug-summary-value {
  font-size: 20px;
  font-weight: 600;
  color: #333333;
}

.debug-summary-value.cost {
  color: #28a745;
}

.debug-controls {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid #e9ecef;
}

.debug-search {
  flex: 1;
  min-width: 300px;
  padding: 10px 15px;
  background: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  color: #333333;
  font-size: 14px;
}

.debug-search:focus {
  outline: none;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.debug-search::placeholder {
  color: #999999;
}

.debug-filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

.debug-filter-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.debug-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.debug-section {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
}

.debug-section-header {
  background: #f8f9fa;
  padding: 15px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #dee2e6;
  transition: background 0.2s;
}

.debug-section-header:hover {
  background: #e9ecef;
}

.debug-section-title {
  font-size: 18px;
  font-weight: 600;
  color: #333333;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.debug-section-badge {
  background: #007bff;
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.debug-section-type {
  font-size: 14px;
  font-weight: 400;
  color: #6c757d;
  font-style: italic;
}

.debug-section-count {
  font-size: 14px;
  color: #6c757d;
  background: #ffffff;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid #dee2e6;
}

.debug-section-toggle {
  font-size: 18px;
  color: #6c757d;
  transition: transform 0.2s;
}

.debug-section-content {
  max-height: 800px;
  overflow: auto;
}

.debug-section.collapsed .debug-section-content {
  display: none;
}

.debug-section.collapsed .debug-section-toggle {
  transform: rotate(-90deg);
}

.debug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.debug-table thead {
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 10;
}

.debug-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

.debug-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.debug-table th.sortable:hover {
  background: #e9ecef;
}

.debug-table th.sorted-asc::after {
  content: ' ▲';
  color: #007bff;
}

.debug-table th.sorted-desc::after {
  content: ' ▼';
  color: #007bff;
}

.debug-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.debug-table tbody tr:hover {
  background: #f8f9fa;
}

.debug-table tbody tr:last-child {
  border-bottom: none;
}

.debug-table td {
  padding: 10px;
  color: #333333;
  border-right: 1px solid #e9ecef;
}

.debug-table td:last-child {
  border-right: none;
}

.debug-table th {
  border-right: 1px solid #dee2e6;
}

.debug-table th:last-child {
  border-right: none;
}

.debug-url {
  color: #007bff;
  text-decoration: none;
  display: inline-block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-url:hover {
  text-decoration: underline;
}

.debug-query {
  display: inline-block;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: #e9ecef;
  color: #495057;
}

.debug-badge.serper {
  background: #d1ecf1;
  color: #0c5460;
}

.debug-badge.exa {
  background: #d4edda;
  color: #155724;
}

.debug-badge.jina {
  background: #fff3cd;
  color: #856404;
}

.debug-score {
  font-weight: 600;
  color: #495057;
}

.debug-status-icon {
  font-size: 16px;
  font-weight: bold;
}

.debug-status-icon.success {
  color: #28a745;
}

.debug-status-icon.failure {
  color: #dc3545;
}

.debug-status-icon.neutral {
  color: #6c757d;
}

.debug-error {
  color: #dc3545;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-rejection {
  color: #dc3545;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-loading {
  text-align: center;
  padding: 60px 20px;
  color: #6c757d;
  font-size: 16px;
}

.debug-no-results {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
  font-style: italic;
}

.debug-button {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin: 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
}

.debug-button:hover:not(:disabled) {
  background: #0056b3;
  transform: translateY(-1px);
}

.debug-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.debug-icon {
  font-size: 18px;
}

/* Cell with copy button */
.cell-with-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.copy-cell-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.copy-cell-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.copy-cell-btn:active {
  transform: scale(0.95);
}


/* View facts button */
.view-facts-btn {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.view-facts-btn:hover:not(:disabled) {
  background: #0056b3;
  transform: scale(1.05);
}

.view-facts-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.view-facts-btn:disabled {
  background: #e9ecef;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Facts Modal */
.facts-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10001;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.facts-modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.2s ease-out;
}

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

.facts-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 2px solid #e9ecef;
}

.facts-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #333333;
}

.facts-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.facts-modal-close:hover {
  background: #f8f9fa;
  color: #dc3545;
}

.facts-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.facts-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.facts-modal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.facts-modal-meta-item strong {
  color: #495057;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.facts-modal-meta-item span {
  color: #333333;
  font-size: 14px;
  word-break: break-all;
}

.facts-modal-divider {
  height: 2px;
  background: #e9ecef;
  margin: 16px 0;
}

.facts-modal-facts {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e9ecef;
}

.facts-modal-facts pre {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333333;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Adjust column widths */
.debug-table th:nth-child(1), /* URL */
.debug-table td:nth-child(1) {
  min-width: 180px;
  max-width: 250px;
}

.debug-table th:nth-child(2), /* Query Text */
.debug-table td:nth-child(2) {
  min-width: 150px;
  max-width: 220px;
}

.debug-table th:nth-child(4), /* Selected For Load */
.debug-table td:nth-child(4),
.debug-table th:nth-child(6), /* Loaded */
.debug-table td:nth-child(6),
.debug-table th:nth-child(9), /* Extracted */
.debug-table td:nth-child(9),
.debug-table th:nth-child(10), /* Passed To Writer */
.debug-table td:nth-child(10) {
  width: 80px;
  text-align: center;
}

.debug-table th:nth-child(12), /* Extracted Facts */
.debug-table td:nth-child(12) {
  width: 70px;
  text-align: center;
}
