/* ===== AI 智能搜索页 ===== */

/* 搜索框 */
.ai-search-box {
  background: linear-gradient(135deg, rgba(26, 77, 74, 0.06), rgba(184, 145, 70, 0.08));
  border: 1px solid rgba(184, 145, 70, 0.3);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  width: 100%;
  box-sizing: border-box;
}
.ai-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid rgba(26, 77, 74, 0.2);
  border-radius: 12px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}
.ai-search-input-wrap:focus-within {
  border-color: var(--gold);
}
.ai-search-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.ai-search-input-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 15px;
  padding: 10px 0;
  background: transparent;
  color: var(--text);
}
.ai-search-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.ai-search-btn:hover { background: var(--gold-light); }
.ai-search-btn:active { transform: scale(0.97); }
.ai-search-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 加载状态 */
.ai-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.ai-loading-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 4px solid rgba(26, 77, 74, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: ai-spin 0.9s linear infinite;
}
.ai-loading-hint {
  font-size: 12px;
  margin-top: 8px;
  opacity: 0.7;
}
.ai-loading-timer {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* 错误提示 */
.ai-error {
  background: rgba(199, 63, 63, 0.08);
  border: 1px solid rgba(199, 63, 63, 0.3);
  color: #c73f3f;
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}

/* 未配置 API Key */
.ai-noconfig {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.ai-noconfig-icon { font-size: 48px; margin-bottom: 16px; }
.ai-noconfig p { margin-bottom: 20px; }

/* 匹配病历列表 */
.ai-records-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 17px;
  font-family: var(--font-serif);
  color: var(--text);
}
.ai-record-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}
.ai-record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* 统一竖向卡片布局（PC + 移动端均美观、不因窄屏错乱） */
.ai-record-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(26, 77, 74, 0.12);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.ai-record-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 16px rgba(26, 77, 74, 0.1);
  transform: translateY(-1px);
}
/* 顶部信息条：日期 + 患者 */
.ai-record-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(26, 77, 74, 0.12);
}
.ai-record-date {
  font-size: 11px;
  color: #fff;
  background: var(--gold);
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-record-patient {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-record-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
  padding-right: 20px; /* 给右下箭头留空间 */
}
.ai-record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.ai-record-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-record-diag {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-top: 2px;
  padding-right: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;          /* 最多两行，超出省略 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-record-arrow {
  position: absolute;
  right: 14px;
  top: 14px;
  font-size: 20px;
  color: rgba(26, 77, 74, 0.35);
}

/* 匹配总结分组 */
#aiSummarySection { margin-top: 24px; }
.ai-summary-card { border-left-color: #1a4d4a; }
.ai-summary-card:hover { border-color: #1a4d4a; }
/* 「含解读」标记 */
.ai-badge-interp {
  color: #1a4d4a;
  background: rgba(26, 77, 74, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
}

/* 空状态 */
.ai-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.ai-empty-icon { font-size: 48px; margin-bottom: 16px; }

/* 响应式 */
@media (max-width: 640px) {
  .ai-search-box { padding: 16px; }
  .ai-search-input-wrap { flex-wrap: wrap; }
  .ai-search-btn { width: 100%; }

  /* 加载区移动端 */
  .ai-loading { padding: 40px 16px; }
  .ai-loading-spinner { width: 36px; height: 36px; border-width: 3px; }
  #aiLoadingText { font-size: 14px; }
  .ai-loading-timer { font-size: 12px; margin-top: 8px; }
  .ai-loading-hint { font-size: 11px; }

  /* 匹配病历卡片移动端：竖向卡片，紧凑整齐 */
  .ai-record-list { gap: 10px; }
  .ai-record-card {
    padding: 12px 14px;
    border-left-width: 3px;
    border-radius: 10px;
  }
  .ai-record-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(26, 77, 74, 0.08);
  }
  .ai-record-top { margin-bottom: 6px; padding-bottom: 6px; gap: 6px; }
  .ai-record-date { font-size: 10px; padding: 1px 7px; }
  .ai-record-patient { font-size: 11px; }
  .ai-record-title { font-size: 14px; line-height: 1.4; margin-bottom: 6px; }
  .ai-record-meta { gap: 4px 8px; font-size: 11px; margin-bottom: 4px; }
  .ai-record-diag { font-size: 12px; line-height: 1.5; -webkit-line-clamp: 2; }
  .ai-record-arrow { right: 12px; top: 12px; font-size: 18px; }

  .ai-records-header h3 { font-size: 15px; }
  .ai-record-count { font-size: 12px; }
  .ai-empty { padding: 40px 16px; }
  .ai-empty-icon { font-size: 40px; }
}
