.smartqa-root {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.smartqa-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.smartqa-health {
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef6ff;
  color: #1d4f8f;
  font-size: 13px;
  border: 1px solid #c8ddff;
}

.smartqa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.smartqa-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.smartqa-panel h2,
.smartqa-panel h3 {
  margin-top: 0;
}

.smartqa-field-stack {
  display: grid;
  gap: 10px;
}

.smartqa-field-stack label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
}

.smartqa-field-stack input,
.smartqa-field-stack textarea,
.smartqa-field-stack select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.smartqa-field-stack textarea {
  min-height: 92px;
  resize: vertical;
}

.smartqa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.smartqa-status {
  min-height: 20px;
  color: #64748b;
  font-size: 13px;
}

.smartqa-uploaded,
.smartqa-answer,
.smartqa-collections {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  min-height: 56px;
}

.smartqa-file-card,
.smartqa-collection-card,
.smartqa-document-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
  cursor: default;
}

.smartqa-collection-card {
  cursor: pointer;
}

.smartqa-document-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.smartqa-document-row small {
  display: block;
  color: #64748b;
}

.smartqa-manage-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
}

.smartqa-manage-box h3 {
  margin: 0 0 10px;
}

.smartqa-collection-card:hover {
  border-color: #2563eb;
}

.smartqa-file-card code,
.smartqa-collection-card code {
  color: #64748b;
  font-size: 12px;
  word-break: break-all;
}

.smartqa-answer-text {
  line-height: 1.65;
  color: #0f172a;
}

.smartqa-sources,
.smartqa-meta {
  margin-top: 12px;
  color: #475569;
  font-size: 13px;
}

.smartqa-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.smartqa-empty {
  color: #94a3b8;
}

.smartqa-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px;
}

.smartqa-manage-box h3 {
  margin: 0 0 10px;
}

.smartqa-manage-box h4 {
  margin: 16px 0 8px;
  font-size: 14px;
  color: #475569;
}

.smartqa-diagnostics {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  max-height: 400px;
  overflow-y: auto;
}

.smartqa-diagnostic-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fafbfc;
  margin-bottom: 8px;
}

.smartqa-diagnostic-row.is-warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.smartqa-diagnostic-row small {
  color: #64748b;
  font-size: 12px;
}

.smartqa-diagnostic-row details {
  margin-top: 8px;
}

.smartqa-diagnostic-row summary {
  color: #2563eb;
  cursor: pointer;
  font-size: 13px;
}

.smartqa-diagnostic-row pre {
  margin-top: 8px;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.smartqa-context-summary {
  padding: 10px;
  border-radius: 8px;
  background: #f0f9ff;
  border: 1px solid #bfdbfe;
  margin-bottom: 10px;
  font-size: 13px;
}

.smartqa-context-summary.is-warning {
  background: #fffbeb;
  border-color: #fcd34d;
}

.smartqa-warning {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
  font-size: 13px;
  margin-bottom: 8px;
}

.smartqa-warning {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
  font-size: 13px;
  margin-bottom: 8px;
}

/* 诊断中心布局 */
.smartqa-diagnostic-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.smartqa-diagnostic-toolbar {
  position: sticky;
  top: 80px;
  z-index: 9;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.smartqa-diagnostic-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.smartqa-diagnostic-toolbar select {
  min-width: 300px;
}

.smartqa-diagnostic-split {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  overflow: hidden;
}

.smartqa-diagnostic-pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px;
}

.smartqa-diagnostic-pane--top {
  border-bottom: 2px solid #cbd5e1;
}

.smartqa-section-header {
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 2;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

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

.smartqa-diagnostic-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.smartqa-diagnostic-controls input {
  flex: 1;
}

/* 折叠控件 */
.collapse-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  width: 100%;
  text-align: left;
  transition: color 0.2s ease;
}

.collapse-toggle:hover {
  color: #2563eb;
}

.collapse-icon {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.collapse-toggle[aria-expanded="false"] .collapse-icon {
  transform: rotate(-90deg);
}

.smartqa-collapsible-content {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.smartqa-collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
  margin: 0;
  padding: 0;
}

.smartqa-diagnostics-list {
  display: grid;
  gap: 16px;
}

.smartqa-diagnostic-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  background: #fff;
}

.smartqa-diagnostic-card.is-warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.smartqa-card-header {
  margin-bottom: 12px;
}

.smartqa-card-header .collapse-toggle {
  font-size: 15px;
  font-weight: 600;
}

.smartqa-card-header strong {
  font-weight: inherit;
  color: #1e293b;
}

.smartqa-diagnostic-header {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.smartqa-diagnostic-header strong {
  font-size: 15px;
  color: #1e293b;
}

.smartqa-diagnostic-header span {
  font-size: 14px;
  color: #475569;
}

.smartqa-diagnostic-header small {
  font-size: 13px;
  color: #64748b;
}

.smartqa-diagnostic-header .is-warning {
  color: #d97706;
  font-weight: 600;
}

.smartqa-preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.smartqa-preview-actions button.small {
  padding: 6px 12px;
  font-size: 13px;
}

.smartqa-preview-details {
  margin-top: 8px;
}

.smartqa-preview-details summary {
  color: #2563eb;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 0;
  user-select: none;
}

.smartqa-preview-details pre {
  margin-top: 8px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  line-height: 1.6;
  color: #1e293b;
  position: relative;
  z-index: 1;
}

/* 确保没有伪元素遮挡 */
.smartqa-preview-details pre::before,
.smartqa-preview-details pre::after {
  display: none;
}

/* 确保 details 展开时没有覆盖层 */
.smartqa-preview-details[open] {
  position: relative;
  z-index: auto;
}

.smartqa-preview-details[open] pre {
  opacity: 1;
  filter: none;
}

/* 进度面板 */
.smartqa-progress-panel {
  margin: 16px 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.smartqa-progress-panel.active {
  opacity: 1;
  transform: translateY(0);
}

.smartqa-progress-current {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
}

.smartqa-progress-current.processing {
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.smartqa-progress-current.complete {
  background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 100%);
}

.smartqa-progress-current.error {
  background: linear-gradient(135deg, #fef2f2 0%, #f8fafc 100%);
}

.smartqa-progress-current .progress-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.smartqa-progress-current .progress-icon.spinning {
  animation: spin 1s linear infinite;
}

.smartqa-progress-current .progress-icon.success {
  animation: scaleIn 0.3s ease;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes scaleIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.smartqa-progress-current .progress-content {
  flex: 1;
  min-width: 0;
}

.smartqa-progress-current .progress-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.smartqa-progress-current .progress-extra {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 4px;
}

.smartqa-progress-current .progress-tip {
  font-size: 13px;
  color: #3b82f6;
  margin-bottom: 4px;
  font-style: italic;
}

.smartqa-progress-current .progress-detail {
  font-size: 13px;
  color: #64748b;
  font-family: 'SF Mono', Monaco, monospace;
}

@media (max-width: 1100px) {
  .smartqa-grid,
  .smartqa-hero {
    grid-template-columns: 1fr;
  }
}

/* 文档查看模态框样式 */
.smartqa-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.smartqa-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.smartqa-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.smartqa-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.smartqa-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.smartqa-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  padding: 0;
  line-height: 1;
}

.smartqa-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.smartqa-modal-body {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: #f8f9fa;
}

.smartqa-modal-search {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.smartqa-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 14px;
}

.smartqa-search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.smartqa-search-result {
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
}

.smartqa-modal-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.8;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
  color: #2d3748;
  margin: 0;
}

.smartqa-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: #f8f9fa;
}

.smartqa-modal-footer button {
  padding: 8px 16px;
}

/* 新标签页打开按钮样式 */
.smartqa-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.smartqa-preview-actions button[data-action$="-new-tab"] {
  min-width: 32px;
  padding: 6px 8px;
  font-size: 16px;
}

@media (max-width: 768px) {
  .smartqa-modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .smartqa-modal-header,
  .smartqa-modal-body,
  .smartqa-modal-footer {
    padding: 16px;
  }

  .smartqa-modal-text {
    font-size: 13px;
    padding: 16px;
  }
}
