/* AI 助教辅导抽屉样式与主题适配 */

#ai-tutor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg, #ffffff);
  color: var(--text-main, #1e293b);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--border, #e2e8f0);
}

#ai-tutor-drawer.open {
  transform: translateX(0);
}

#ai-tutor-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#ai-tutor-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* 顶部导航与操作条 */
.ai-drawer-header {
  padding: 14px 18px;
  background: var(--card-bg, #f8fafc);
  border-bottom: 1px solid var(--border, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-drawer-settings-btn {
  margin-left: auto;
  margin-right: 8px;
  font-size: 0.8rem;
  color: var(--text-muted, #64748b);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  transition: all 0.2s ease;
}
.ai-drawer-settings-btn:hover {
  color: var(--brand, #0f6e62);
  border-color: var(--brand, #0f6e62);
  background: rgba(15, 110, 98, 0.05);
}

.ai-drawer-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  padding: 4px 8px;
  border-radius: 6px;
}
.ai-drawer-close:hover {
  background: rgba(0,0,0,0.06);
}

/* 标签切换栏 */
.ai-drawer-tabs {
  display: flex;
  background: var(--bg-subtle, #f1f5f9);
  padding: 6px 12px;
  gap: 6px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.ai-tab-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  transition: all 0.2s;
  text-align: center;
}

.ai-tab-btn.active {
  background: #ffffff;
  color: var(--node-primary, #2563eb);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* 内容展示区域 */
.ai-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.ai-tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
}

.ai-tab-panel.active {
  display: flex;
}

/* Markdown 排版与打字机效果 */
.ai-markdown-content {
  line-height: 1.7;
  font-size: 0.95rem;
  color: var(--text-main, #334155);
}

.ai-markdown-content h1,
.ai-markdown-content h2,
.ai-markdown-content h3 {
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  font-weight: 700;
  color: var(--text-heading, #0f172a);
}

.ai-markdown-content ul,
.ai-markdown-content ol {
  padding-left: 1.4em;
  margin-bottom: 1em;
}

.ai-markdown-content p {
  margin-bottom: 0.8em;
}

.ai-markdown-content strong {
  color: var(--node-primary, #2563eb);
}

.ai-markdown-content code {
  background: rgba(0,0,0,0.05);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
}

.cursor-blink {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--node-primary, #2563eb);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 苏格拉底互动聊天窗口 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}

.ai-chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.ai-chat-bubble.tutor {
  align-self: flex-start;
  background: var(--card-bg, #f1f5f9);
  color: var(--text-main, #1e293b);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border, #e2e8f0);
}

.ai-chat-bubble.user {
  align-self: flex-end;
  background: var(--node-primary, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.ai-chat-input-bar {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, #cbd5e1);
  background: var(--bg, #ffffff);
  color: var(--text-main, #0f172a);
  font-size: 0.92rem;
}
.ai-chat-input:focus {
  outline: 2px solid var(--node-primary, #2563eb);
}

/* 靶向练习卡片 */
.quiz-card {
  background: var(--card-bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.quiz-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.quiz-badge.basic { background: #dcfce7; color: #166534; }
.quiz-badge.standard { background: #e0f2fe; color: #0369a1; }
.quiz-badge.challenge { background: #fef3c7; color: #92400e; }

.quiz-prompt {
  font-size: 0.98rem;
  font-weight: 500;
  margin-bottom: 14px;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-opt-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 14px;
  min-height: 44px;
  border: 1px solid var(--border, #cbd5e1);
  background: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.92rem;
  color: var(--text-main, #1e293b);
}
.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--node-primary, #2563eb);
  background: var(--bg-hover, #f8fafc);
}
.quiz-opt-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
  font-weight: 600;
}
.quiz-opt-btn.wrong {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.quiz-explanation-box {
  margin-top: 12px;
  padding: 12px;
  background: #ffffff;
  border-radius: 6px;
  border-left: 4px solid var(--node-primary, #2563eb);
  font-size: 0.88rem;
  display: none;
}
.quiz-explanation-box.show {
  display: block;
}

/* 设置表单 */
.ai-settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted, #475569);
}

.ai-form-group select,
.ai-form-group input {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #cbd5e1);
  background: var(--bg, #ffffff);
  color: var(--text-main, #0f172a);
}

.ai-btn-primary {
  background: var(--node-primary, #2563eb);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ai-btn-primary:hover {
  opacity: 0.9;
}
.ai-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 移动端适配 */
@media (max-width: 600px) {
  #ai-tutor-drawer {
    width: 100vw;
    height: 90vh;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    border-radius: 16px 16px 0 0;
  }
  #ai-tutor-drawer.open {
    transform: translateY(0);
  }
}
