/* frontend/css/ai-diagnosis.css */
/* AI 助学模块样式 — 手机优先 · 大厂风 · 适合孩子 */
/* v3.3 | 2026-07-19 — 颜色统一走 CSS 变量 */

/* ═══════════════════════════════════════
   1. AI Shell 外壳页
   ═══════════════════════════════════════ */

.ai-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ai-bg-start) 0%, var(--ai-bg-end) 100%);
}

/* 顶部栏 */
.ai-shell-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--ai-bubble-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  gap: 8px;
}

.ai-shell-back {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--ai-button-bg);
  border: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.ai-shell-back:active {
  background: var(--ai-button-active-bg);
}

/* 学科标签栏 */
.ai-shell-title {
  display: none; /* v3.3 弃用，改用 tabs */
}

.ai-shell-tabs {
  flex: 1;
  display: flex;
  gap: 4px;
  background: var(--ai-button-bg);
  border-radius: 10px;
  padding: 3px;
}

.ai-shell-tab {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-desc-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.ai-shell-tab--active {
  background: var(--ai-card-bg);
  color: var(--ai-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 进度条 */
.ai-shell-progress {
  margin: 0 16px;
  padding: 8px 0;
}

.ai-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--ai-border-light);
  border-radius: 3px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ai-primary), var(--ai-primary-light));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-progress-label {
  font-size: 12px;
  color: var(--ai-desc-color);
  text-align: right;
  margin-top: 4px;
}

/* 内容滚动区 */
.ai-shell-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 40px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════
   2. 对话气泡
   ═══════════════════════════════════════ */

.ai-bubble {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  animation: aiBubbleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aiBubbleIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* AI 气泡 — 左侧，浅色背景 */
.ai-bubble--ai {
  align-items: flex-start;
}

.ai-bubble--ai .ai-bubble-body {
  background: var(--ai-card-bg);
  border-radius: 0 16px 16px 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  max-width: 88%;
}

/* 用户气泡 — 右侧，品牌色 */
.ai-bubble--user {
  align-items: flex-end;
}

.ai-bubble--user .ai-bubble-body {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
  color: var(--color-white);
  border-radius: 16px 0 16px 16px;
  max-width: 88%;
}

.ai-bubble-body {
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.6;
}

.ai-bubble-text {
  word-break: break-word;
}

/* 气泡顶部标签 */
.ai-bubble-label {
  font-size: 11px;
  color: var(--ai-desc-color);
  font-weight: 600;
  margin-bottom: 4px;
  padding-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 气泡内配图 */
.ai-bubble-media {
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
}
.ai-bubble-media img {
  width: 100%;
  display: block;
  border-radius: 10px;
}

/* 气泡状态色 */
.ai-bubble--correct .ai-bubble-body {
  border: 2px solid var(--color-success);
}
.ai-bubble--wrong .ai-bubble-body {
  border: 2px solid var(--color-warning);
}

/* 错误气泡 */
.ai-bubble-body--error {
  background: var(--ai-danger-bg) !important;
  border: 1px solid var(--ai-danger-border) !important;
}

.ai-bubble-text--error {
  color: var(--color-danger);
}

/* Loading 气泡 */
.ai-bubble--loading .ai-bubble-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-loading-dots {
  display: flex;
  gap: 4px;
}
.ai-loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--ai-dot-color);
  animation: aiDotPulse 1.4s infinite;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiDotPulse {
  0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
  40% { transform: scale(1.3); opacity: 1; }
}

.ai-loading-text {
  font-size: 13px;
  color: var(--ai-desc-color);
}

/* ═══════════════════════════════════════
   3. 交互区 (action-bar)
   ═══════════════════════════════════════ */

.ai-action-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 20px;
}

/* 选择题按钮 — 大厂风卡片式 */
.ai-choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--ai-card-bg);
  border: 2px solid var(--ai-border-light);
  border-radius: 14px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  color: var(--ai-text-tertiary);
}
.ai-choice-btn:hover {
  border-color: var(--ai-primary-lighter);
  background: var(--ai-bg-start);
}
.ai-choice-btn:active {
  transform: scale(0.98);
}
.ai-choice-btn--selected {
  border-color: var(--ai-primary);
  background: var(--ai-primary-lightest);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
.ai-choice-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.ai-choice-marker {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
  color: var(--color-white);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-choice-label {
  flex: 1;
  line-height: 1.4;
}

/* 拍照按钮 */
.ai-photo-upload {
  position: relative;
}

.ai-photo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  background: var(--ai-card-bg);
  border: 2px dashed var(--ai-primary-lighter);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.ai-photo-btn:active {
  background: var(--ai-bg-start);
  border-color: var(--ai-primary);
}

.ai-photo-icon {
  font-size: 36px;
}

.ai-photo-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-primary);
}

.ai-photo-preview {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.ai-photo-preview img {
  width: 100%;
  display: block;
}

/* 跳过按钮 */
.ai-skip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1.5px solid var(--ai-skip-border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ai-desc-color);
  cursor: pointer;
  transition: all 0.2s;
}
.ai-skip-btn:active {
  background: var(--ai-kg-bg);
  color: var(--ai-text-secondary);
}

/* ─── 文本输入 ─── */
.ai-text-input {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}
.ai-text-field {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--ai-kg-border);
  border-radius: 14px;
  font-size: 15px;
  background: var(--ai-card-bg);
  color: var(--ai-text-primary);
  outline: none;
  transition: border-color 0.2s;
}
.ai-text-field:focus {
  border-color: var(--ai-primary);
}
.ai-text-field:disabled {
  opacity: 0.5;
}
.ai-text-submit {
  padding: 12px 20px;
  border: none;
  border-radius: 14px;
  background: var(--ai-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.ai-text-submit:hover {
  background: var(--ai-primary-dark, #2c2416);
}
.ai-text-submit:active {
  transform: scale(0.96);
}
.ai-text-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════
   4. 判题反馈
   ═══════════════════════════════════════ */

.ai-feedback {
  margin: 12px 0 20px;
  padding: 16px;
  border-radius: 16px;
  animation: aiFeedbackPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-feedback--correct {
  background: linear-gradient(135deg, var(--ai-success-bg), #dcfce7);
  border: 1.5px solid var(--ai-success-border);
}

.ai-feedback--wrong {
  background: linear-gradient(135deg, var(--ai-warning-bg), #fef3c7);
  border: 1.5px solid var(--ai-warning-border);
}

.ai-feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-feedback-emoji {
  font-size: 24px;
}

.ai-feedback-verdict {
  font-size: 16px;
  font-weight: 700;
  color: var(--ai-text-primary);
  flex: 1;
}

.ai-feedback-score {
  font-size: 16px;
  font-weight: 800;
  color: var(--ai-primary);
  background: var(--ai-primary-lightest);
  padding: 4px 12px;
  border-radius: 20px;
}

.ai-feedback-detail {
  font-size: 13px;
  color: var(--ai-text-secondary);
  line-height: 1.6;
  padding: 8px 12px;
  background: rgba(255,255,255,0.6);
  border-radius: 10px;
  margin-top: 8px;
}

.ai-feedback-kp {
  font-size: 12px;
  color: var(--ai-primary-light);
  margin-top: 8px;
  font-weight: 500;
}

/* ═══════════════════════════════════════
   5. 报告区域
   ═══════════════════════════════════════ */

.ai-report-section {
  background: var(--ai-card-bg);
  border-radius: 20px;
  padding: 20px 16px;
  margin: 16px 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
  border: 1px solid var(--ai-card-border);
}

.ai-report-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ai-text-primary);
  margin-bottom: 16px;
}

/* 雷达图 */
.ai-radar-container {
  display: flex;
  justify-content: center;
}

.ai-radar-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
}

.ai-radar-label {
  font-size: 12px;
  fill: var(--ai-text-secondary);
  font-weight: 500;
}

/* 知识网格 */
.ai-kg-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-kg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ai-kg-bg);
  border-radius: 12px;
  border-left: 4px solid var(--ai-skip-border);
}

.ai-kg-item.ai-kg--mastered { border-left-color: var(--color-success); background: var(--ai-success-bg); }
.ai-kg-item.ai-kg--learning  { border-left-color: var(--color-warning); background: var(--ai-warning-bg); }
.ai-kg-item.ai-kg--weak     { border-left-color: var(--color-danger); background: var(--ai-danger-bg); }

.ai-kg-emoji { font-size: 18px; flex-shrink: 0; }
.ai-kg-name  { font-size: 14px; font-weight: 600; color: var(--ai-text-tertiary); min-width: 64px; }

.ai-kg-bar {
  flex: 1;
  height: 8px;
  background: var(--ai-kg-bar-bg);
  border-radius: 4px;
  overflow: hidden;
}

.ai-kg-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ai-primary), var(--ai-primary-light));
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-kg-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--ai-text-secondary);
  min-width: 36px;
  text-align: right;
}

/* 建议列表 */
.ai-suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--ai-bg-start);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ai-text-tertiary);
  line-height: 1.5;
}

.ai-suggestion-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
  color: var(--color-white);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════
   6. 模块选择网格
   ═══════════════════════════════════════ */

.ai-module-grid {
  padding: 8px 0;
}

.ai-module-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ai-text-primary);
  margin-bottom: 20px;
  text-align: center;
}

.ai-module-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.ai-module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--ai-card-bg);
  border: 2px solid var(--ai-card-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ai-module-card:active {
  transform: scale(0.97);
  border-color: var(--ai-primary);
  background: var(--ai-bg-start);
  box-shadow: 0 4px 16px rgba(99,102,241,0.12);
}

.ai-module-icon {
  font-size: 44px;
}

.ai-module-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--ai-text-primary);
}

.ai-module-desc {
  font-size: 12px;
  color: var(--ai-desc-color);
  text-align: center;
  line-height: 1.4;
}

/* ═══════════════════════════════════════
   7. AI Hub 入口页
   ═══════════════════════════════════════ */

.ai-hub {
  padding: 24px 16px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ai-bg-start) 0%, var(--ai-bg-end) 100%);
}

.ai-hub-header {
  text-align: center;
  margin-bottom: 32px;
}

.ai-hub-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--ai-text-primary);
  margin-bottom: 6px;
}

.ai-hub-subtitle {
  font-size: 14px;
  color: var(--ai-desc-color);
}

.ai-hub-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ai-hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 12px;
  background: var(--ai-card-bg);
  border: 1.5px solid var(--ai-card-border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  text-align: center;
}
.ai-hub-card:active {
  transform: scale(0.96);
}

.ai-hub-card--active {
  border-color: var(--ai-primary-lighter);
  background: var(--ai-bg-start);
}

.ai-hub-card--coming {
  opacity: 0.5;
  cursor: default;
}
.ai-hub-card--coming:active {
  transform: none;
}

.ai-hub-card-icon {
  font-size: 36px;
}

.ai-hub-card-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ai-text-primary);
}

.ai-hub-card-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--ai-primary-lightest);
  color: var(--ai-primary);
}
.ai-hub-card-badge--soon {
  background: #fef3c7;
  color: #b45309;
}

/* ═══════════════════════════════════════
   8. 响应式增强
   ═══════════════════════════════════════ */

/* 平板及以上 — 模块网格两列 */
@media (min-width: 480px) {
  .ai-module-cards {
    grid-template-columns: 1fr 1fr;
  }
  .ai-hub-cards {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* 大屏 — 居中限制宽度 */
@media (min-width: 768px) {
  .ai-shell-content,
  .ai-hub {
    max-width: 520px;
    margin: 0 auto;
  }
}

/* ═══════════════════════════════════════
   9. 动画增强
   ═══════════════════════════════════════ */

/* 反馈弹入 */
@keyframes aiFeedbackPop {
  0%   { transform: scale(0.9); opacity: 0; }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

/* 雷达图旋转淡入 */
.ai-report--radar {
  animation: aiFadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ========== AI Hub 今日战绩 ========== */
.ai-hub-today {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 1px solid #d0d8f0;
}
.ai-hub-today-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ai-primary);
  margin-bottom: 10px;
}
.ai-hub-today-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed #c8d0e8;
  font-size: 14px;
}
.ai-hub-today-row:last-child { border-bottom: none; }
.ai-hub-today-subject { font-weight: 600; color: var(--ai-text-primary); }
.ai-hub-today-score  { color: #16a34a; font-weight: 700; }
.ai-hub-today-arrow { color: #94a3b8; font-size: 18px; margin-left: 4px; }
.ai-hub-today-row { cursor: pointer; transition: background 0.15s; }
.ai-hub-today-row:hover { background: rgba(99,102,241,0.06); border-radius: 8px; padding: 8px; margin: 0 -8px; }

/* 报告弹窗 */
.ai-hub-report {
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  animation: aiFadeSlideUp 0.25s ease;
}
.ai-hub-report-header { text-align: right; margin-bottom: 6px; }
.ai-hub-report-close {
  font-size: 18px;
  color: #94a3b8; cursor: pointer;
  display: inline-block; padding: 2px 6px; border-radius: 50%;
}
.ai-hub-report-close:hover { color: #ef4444; background: #fef2f2; }
.ai-hub-report-body { font-size: 14px; color: var(--ai-text-primary); line-height: 1.6; }
.ai-hub-report-summary { margin-bottom: 12px; font-weight: 600; color: var(--ai-primary); }
.ai-hub-report-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid #f1f5f9; }
