/* ============================================================
   羡曦吾语AI · 学习功能组件样式
   仪表盘 / 进度 / 笔记 / 收藏 / 成就 / 目标 / 热力图 / 报告 / 每日一题 /
   路径推荐 / 学习助手 / 番茄钟 / 知识图谱 / 专注统计 / 排行榜
   ============================================================ */

/* ---------- 通用 ---------- */
.qh-dashboard, .qh-report, .qh-daily-q, .qh-path-rec, .qh-advisor,
.qh-pomodoro, .qh-kg, .qh-focus, .qh-leader, .qh-goals, .qh-notes-section {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2937;
}
.qh-empty {
  text-align: center;
  color: #9ca3af;
  padding: 24px 12px;
  font-size: 14px;
}

/* ---------- 仪表盘统计卡片 ---------- */
.qh-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.qh-stat-card {
  background: var(--grad-main);
  color: #fff;
  border-radius: var(--r-m);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-glow);
  transition: transform .2s;
}
.qh-stat-card:hover { transform: translateY(-3px); }
.qh-stat-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}
.qh-stat-label {
  font-size: 12px;
  opacity: .9;
  margin-top: 4px;
}

/* ---------- 成就徽章 ---------- */
.qh-achievements-head {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: #4b5563;
}
.qh-badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.qh-badge {
  border-radius: var(--r-m);
  padding: 12px 8px;
  text-align: center;
  border: 2px solid transparent;
  transition: all .2s;
}
.qh-badge-on {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #f59e0b;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}
.qh-badge-off {
  background: #f3f4f6;
  border-color: #e5e7eb;
  opacity: .7;
}
.qh-badge-emoji {
  font-size: 28px;
  margin-bottom: 4px;
}
.qh-badge-name {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
}
.qh-badge-desc {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.3;
}

/* ---------- 收藏列表 ---------- */
.qh-fav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qh-fav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-s);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .2s;
}
.qh-fav-item:hover { border-color: var(--lake); }
.qh-fav-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  flex: 1;
}
.qh-fav-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-right: 10px;
}
.qh-fav-del {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.qh-fav-del:hover { background: #fecaca; }

/* ---------- 目标 ---------- */
.qh-goal-add {
  background: var(--grad-main);
  color: #fff;
  border: none;
  border-radius: var(--r-s);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.qh-goal-list { display: flex; flex-direction: column; gap: 10px; }
.qh-goal-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-m);
  padding: 12px;
}
.qh-goal-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  justify-content: space-between;
}
.qh-goal-num { font-weight: 400; color: var(--lake); font-size: 12px; }
.qh-goal-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  margin: 8px 0;
  overflow: hidden;
}
.qh-goal-bar-fill {
  height: 100%;
  background: var(--grad-main);
  border-radius: 4px;
  transition: width .3s;
}
.qh-goal-deadline {
  font-size: 11px;
  color: #9ca3af;
}
.qh-goal-del {
  margin-top: 6px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}

/* ---------- 热力图 ---------- */
.qh-heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 12px 0;
}
.qh-heat-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #ebedf0;
}
.qh-heat-l1 { background: #ebedf0; }
.qh-heat-l2 { background: #9be9a8; }
.qh-heat-l3 { background: #40c463; }
.qh-heat-l4 { background: #216e39; }
.qh-heat-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #6b7280;
  margin-top: 6px;
}

/* ---------- 笔记面板 ---------- */
.qh-note-panel {
  position: fixed;
  right: 16px;
  bottom: 80px;
  width: 320px;
  max-height: 70vh;
  background: #fff;
  border-radius: var(--r-m);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}
.qh-note-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--grad-main);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.qh-note-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.qh-note-input {
  margin: 12px;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: var(--r-s);
  min-height: 60px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}
.qh-note-actions { padding: 0 12px 8px; }
.qh-note-save {
  background: var(--lake);
  color: #fff;
  border: none;
  border-radius: var(--r-s);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}
.qh-note-save:hover { background: var(--lake-deep); }
.qh-note-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}
.qh-note-item {
  background: #f9fafb;
  border-radius: var(--r-s);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.qh-note-text { font-size: 13px; color: #1f2937; line-height: 1.5; }
.qh-note-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.qh-note-del {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11px;
  cursor: pointer;
}

/* ---------- 课程卡片装饰 ---------- */
.qh-lesson-done {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important;
  border-color: #10b981 !important;
}
.qh-done-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #10b981;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.qh-fav-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qh-fav-btn.qh-fav-on { color: #f59e0b; }

/* ---------- 浮动工具栏 ---------- */
.qh-float-bar {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9998;
}
.qh-fb-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--grad-main);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transition: transform .2s;
}
.qh-fb-btn:hover { transform: scale(1.1); }

/* ---------- 学习报告 ---------- */
.qh-report { padding: 8px 0; }
.qh-report-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  margin: 8px 0 12px;
}
.qh-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}
.qh-report-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-m);
  padding: 12px;
  text-align: center;
}
.qh-r-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--lake);
}
.qh-r-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.qh-report-insight {
  margin-top: 12px;
  background: #fef3c7;
  border-radius: var(--r-s);
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
}

/* ---------- 每日一题 ---------- */
.qh-daily-q {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-radius: var(--r-m);
  padding: 16px;
  margin: 12px 0;
}
.qh-daily-q h4 { margin: 0 0 10px; color: #5b21b6; }
.qh-dq-text {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
  line-height: 1.5;
}
.qh-dq-opts { display: flex; flex-direction: column; gap: 6px; }
.qh-dq-opt {
  text-align: left;
  background: #fff;
  border: 1px solid #c4b5fd;
  border-radius: var(--r-s);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #1f2937;
  transition: all .15s;
}
.qh-dq-opt:hover:not(:disabled) {
  background: #f5f3ff;
  border-color: #8b5cf6;
}
.qh-dq-opt.qh-dq-right {
  background: #d1fae5 !important;
  border-color: #10b981 !important;
  color: #065f46;
}
.qh-dq-opt.qh-dq-wrong {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #991b1b;
}
.qh-dq-exp {
  margin-top: 12px;
  background: #fff;
  border-radius: var(--r-s);
  padding: 10px 12px;
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
}

/* ---------- 路径推荐 ---------- */
.qh-path-rec {
  background: #f0f9ff;
  border-radius: var(--r-m);
  padding: 14px;
  margin: 12px 0;
}
.qh-path-rec h4 { margin: 0 0 6px; color: #0369a1; }
.qh-path-reason { font-size: 13px; color: #075985; margin-bottom: 10px; }
.qh-path-next {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.qh-path-node {
  background: #fff;
  border: 1px solid #7dd3fc;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: #0369a1;
}

/* ---------- 学习助手 ---------- */
.qh-advisor {
  background: #fef2f2;
  border-radius: var(--r-m);
  padding: 14px;
  margin: 12px 0;
}
.qh-advisor h4 { margin: 0 0 8px; color: #b91c1c; }
.qh-advisor-tip {
  font-size: 13px;
  color: #7f1d1d;
  padding: 6px 0;
  border-bottom: 1px solid #fecaca;
}
.qh-advisor-tip:last-child { border-bottom: none; }

/* ---------- 番茄钟 ---------- */
.qh-pomodoro {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border-radius: var(--r-m);
  padding: 16px;
  margin: 12px 0;
  text-align: center;
}
.qh-pomodoro h4 { margin: 0 0 8px; color: #c2410c; }
.qh-pomo-mode { font-size: 13px; color: #9a3412; margin-bottom: 6px; }
.qh-pomo-time {
  font-size: 42px;
  font-weight: 800;
  color: #ea580c;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}
.qh-pomo-cycles { font-size: 12px; color: #9a3412; margin: 6px 0 12px; }
.qh-pomo-btns { display: flex; gap: 8px; justify-content: center; }
.qh-pomo-btn {
  background: #ea580c;
  color: #fff;
  border: none;
  border-radius: var(--r-s);
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
}
.qh-pomo-btn:hover { background: #c2410c; }

/* ---------- 知识图谱 ---------- */
.qh-kg {
  background: #f8fafc;
  border-radius: var(--r-m);
  padding: 14px;
  margin: 12px 0;
}
.qh-kg h4 { margin: 0 0 8px; color: #334155; }
.qh-kg-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
}
.qh-kg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
}
.qh-kg-dot.qh-kg-visited { background: #10b981; }
.qh-kg-svg { width: 100%; height: auto; }
.qh-kg-edge { stroke: #cbd5e1; stroke-width: 1; }
.qh-kg-node circle { fill: #e2e8f0; stroke: #94a3b8; stroke-width: 1.5; }
.qh-kg-node.qh-kg-visited circle { fill: #10b981; stroke: #059669; }
.qh-kg-node text { pointer-events: none; }

/* ---------- 专注统计 ---------- */
.qh-focus {
  background: #f8fafc;
  border-radius: var(--r-m);
  padding: 14px;
  margin: 12px 0;
}
.qh-focus h4 { margin: 0 0 10px; color: #334155; }
.qh-focus-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 80px;
}
.qh-focus-bar {
  flex: 1;
  background: linear-gradient(180deg, #22d3ee, #0891b2);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height .3s;
}
.qh-focus-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ---------- 排行榜 ---------- */
.qh-leader {
  background: #fffbeb;
  border-radius: var(--r-m);
  padding: 14px;
  margin: 12px 0;
}
.qh-leader h4 { margin: 0 0 10px; color: #b45309; }
.qh-leader-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-s);
  margin-bottom: 4px;
}
.qh-leader-me { background: #fef3c7; }
.qh-leader-rank { font-size: 16px; width: 28px; text-align: center; }
.qh-leader-name { flex: 1; font-size: 13px; color: #1f2937; }
.qh-leader-min { font-size: 12px; color: #6b7280; font-weight: 600; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .qh-note-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 70px;
  }
  .qh-stat-num { font-size: 22px; }
  .qh-pomo-time { font-size: 32px; }
  .qh-dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 动画 ---------- */
@keyframes qhPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.qh-badge-on, .qh-stat-card, .qh-done-tag {
  animation: qhPop .3s ease;
}
@keyframes qhSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.qh-note-panel { animation: qhSlideIn .25s ease; }

/* ---------- 滚动出现动画 ---------- */
@keyframes qhFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.qh-sc-section { animation: qhFadeUp .4s ease both; }

/* ---------- 按钮通用交互 ---------- */
.qh-fc-btn, .qh-goal-add, .qh-note-save, .qh-chat-send,
.qh-pomo-btn, .qh-fb-btn, .qh-fav-del, .qh-goal-del {
  transition: all .2s ease;
}
.qh-fc-btn:active, .qh-goal-add:active, .qh-note-save:active {
  transform: scale(0.96);
}

/* ---------- 卡片悬浮效果 ---------- */
.qh-stat-card, .qh-report-card, .qh-badge, .qh-medal,
.qh-fav-item, .qh-goal-item, .qh-post {
  transition: transform .2s ease, box-shadow .2s ease;
}
.qh-stat-card:hover, .qh-report-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* ---------- 进度条动画 ---------- */
@keyframes qhBarGrow {
  from { width: 0; }
}
.qh-goal-bar-fill { animation: qhBarGrow .6s ease; }

/* ---------- 热力图格子悬浮 ---------- */
.qh-heat-cell {
  transition: transform .15s ease;
}
.qh-heat-cell:hover {
  transform: scale(1.3);
  z-index: 1;
}

/* ---------- 徽章解锁闪光 ---------- */
@keyframes qhShine {
  0%, 100% { box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 2px 20px rgba(245, 158, 11, 0.6); }
}
.qh-badge-on { animation: qhPop .3s ease, qhShine 2s ease infinite; }

/* ---------- 番茄钟脉冲 ---------- */
@keyframes qhPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.qh-pomo-time { animation: qhPulse 2s ease infinite; }

/* ---------- 滚动条美化 ---------- */
.qh-note-list::-webkit-scrollbar,
.qh-chat-messages::-webkit-scrollbar,
.qh-qs-results::-webkit-scrollbar {
  width: 6px;
}
.qh-note-list::-webkit-scrollbar-thumb,
.qh-chat-messages::-webkit-scrollbar-thumb,
.qh-qs-results::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}
.qh-note-list::-webkit-scrollbar-track,
.qh-chat-messages::-webkit-scrollbar-track,
.qh-qs-results::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 无数据占位图标 ---------- */
.qh-empty::before {
  content: '📭';
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
}

/* ---------- 打印样式 ---------- */
@media print {
  .qh-float-bar, .qh-note-panel, .qh-goal-del,
  .qh-fav-del, .qh-note-del, .qh-m-del { display: none !important; }
  .qh-sc-section { break-inside: avoid; box-shadow: none; border: 1px solid #e5e7eb; }
}
