/* ==========================================
   RAG SEARCH PANEL STYLES
   ========================================== */

/* Overlay */
.rag-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}

/* Modal */
.rag-search-modal {
  background: var(--bp-surface);
  border-radius: 16px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Header */
.rag-search-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--bp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rag-search-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.rag-search-close {
  background: none;
  border: none;
  color: var(--bp-text-muted);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.rag-search-close:hover {
  color: var(--bp-text);
}

/* Search Input */
.rag-search-input-container {
  padding: 20px 24px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--bp-border);
}

.rag-search-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bp-bg);
  border: 1px solid var(--bp-border);
  border-radius: 8px;
  color: var(--bp-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
}

.rag-search-input:focus {
  border-color: var(--bp-primary);
}

.rag-search-input::placeholder {
  color: var(--bp-text-muted);
}

.rag-search-btn {
  padding: 12px 24px;
  background: var(--bp-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.rag-search-btn:hover:not(:disabled) {
  background: var(--bp-primary-hover);
}

.rag-search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Advanced Options Toggle */
.rag-advanced-toggle {
  padding: 12px 24px;
  border-bottom: 1px solid var(--bp-border);
}

.rag-toggle-btn {
  background: none;
  border: none;
  color: var(--bp-text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rag-toggle-btn:hover {
  color: var(--bp-text);
}

/* Advanced Options Panel */
.rag-advanced-options {
  padding: 16px 24px;
  background: var(--bp-bg);
  border-bottom: 1px solid var(--bp-border);
}

.rag-option-row {
  margin-bottom: 12px;
}

.rag-option-row:last-child {
  margin-bottom: 0;
}

.rag-option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--bp-text);
  cursor: pointer;
}

.rag-option-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--bp-primary);
}

.rag-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rag-option-hint {
  font-size: 12px;
  color: var(--bp-text-muted);
}

.rag-option-select {
  margin-left: 8px;
  padding: 6px 12px;
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: 6px;
  color: var(--bp-text);
  font-size: 13px;
}

/* Error Display */
.rag-error {
  margin: 16px 24px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--bp-danger);
  border-radius: 8px;
  color: var(--bp-danger);
  font-size: 14px;
}

/* Results Container */
.rag-results {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Search Info Badge */
.rag-search-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bp-bg);
  border-radius: 8px;
}

.rag-info-badge {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rag-info-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rag-info-rerank {
  background: rgba(59, 130, 246, 0.2);
  color: var(--bp-info);
}

.rag-info-hybrid {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.rag-info-model {
  background: var(--bp-surface-elevated);
  color: var(--bp-text-muted);
}

.rag-info-count {
  font-size: 12px;
  color: var(--bp-text-muted);
}

/* Context Summary */
.rag-context-summary {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bp-primary-soft);
  border-radius: 8px;
  border-left: 4px solid var(--bp-primary);
}

.rag-context-summary h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--bp-primary);
  margin-bottom: 8px;
}

.rag-context-summary p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--bp-text);
  margin: 0;
}

/* Source Results */
.rag-sources h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--bp-text);
}

.rag-source-item {
  background: var(--bp-bg);
  border: 1px solid var(--bp-border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.rag-source-item:hover {
  border-color: var(--bp-primary);
}

.rag-source-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bp-surface-elevated);
  border-bottom: 1px solid var(--bp-border);
}

.rag-source-rank {
  width: 28px;
  height: 28px;
  background: var(--bp-primary);
  color: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.rag-source-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--bp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rag-confidence-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rag-reranked-icon {
  font-size: 10px;
  margin-left: 2px;
}

.rag-source-text {
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--bp-text);
  white-space: pre-wrap;
}

.rag-source-meta {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bp-surface-elevated);
  border-top: 1px solid var(--bp-border);
  font-size: 12px;
  color: var(--bp-text-muted);
}

/* Empty State */
.rag-empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--bp-text-muted);
}

.rag-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.rag-empty-state p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.rag-empty-hint {
  font-size: 13px;
  color: var(--bp-text-muted);
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 640px) {
  .rag-search-modal {
    max-height: 95vh;
    border-radius: 12px;
  }

  .rag-search-input-container {
    flex-direction: column;
  }

  .rag-search-btn {
    width: 100%;
  }

  .rag-search-info {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}
