/* ============================================
   FocusAgent 浮动AI人物组件
   可爱卡通形象 · 悬停交互 · 冒泡对话
   ============================================ */

/* ===== 浮动AI人物容器 ===== */
.float-ai-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

/* ===== AI人物本体 ===== */
.float-ai-character {
  width: 70px;
  height: 70px;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom center;
}

.float-ai-character:hover {
  transform: scale(1.15);
}

.float-ai-character:active {
  transform: scale(1.05);
}

/* ===== AI人物形象（可爱机器人） ===== */
.ai-avatar-body {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 机器人头部 */
.ai-avatar-head {
  width: 56px;
  height: 52px;
  background: linear-gradient(145deg, #4F46E5, #7C3AED);
  border-radius: 28px 28px 24px 24px;
  position: relative;
  box-shadow: 
    0 8px 24px rgba(79, 70, 229, 0.4),
    0 0 0 3px rgba(255, 255, 255, 0.1),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  animation: float-idle 3s ease-in-out infinite;
}

/* 天线 */
.ai-avatar-antenna {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 14px;
  background: linear-gradient(to top, #7C3AED, #A78BFA);
  border-radius: 2px;
}

.ai-avatar-antenna::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #FCD34D, #F59E0B);
  border-radius: 50%;
  box-shadow: 0 0 12px #FCD34D;
  animation: antenna-glow 2s ease-in-out infinite;
}

/* 眼睛 */
.ai-avatar-eyes {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.ai-eye {
  width: 14px;
  height: 16px;
  background: #1E1B4B;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}

.ai-eye::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  animation: eye-blink 4s ease-in-out infinite;
}

.ai-eye::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: #60A5FA;
  border-radius: 50%;
  top: 5px;
  left: 7px;
}

/* 嘴巴 */
.ai-avatar-mouth {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 6px;
  background: #1E1B4B;
  border-radius: 0 0 8px 8px;
  transition: all 0.2s;
}

.float-ai-character:hover .ai-avatar-mouth {
  width: 20px;
  height: 8px;
  border-radius: 0 0 10px 10px;
}

/* 腮红 */
.ai-avatar-blush {
  position: absolute;
  top: 22px;
  width: 8px;
  height: 5px;
  background: rgba(251, 113, 133, 0.6);
  border-radius: 50%;
}

.ai-avatar-blush.left { left: 6px; }
.ai-avatar-blush.right { right: 6px; }

/* 脉冲光环 */
.ai-pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(79, 70, 229, 0.3);
  animation: pulse-expand 2.5s ease-out infinite;
  pointer-events: none;
}

/* 状态指示器 */
.ai-status-indicator {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: #10B981;
  border-radius: 50%;
  border: 3px solid var(--space-950, #030712);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: status-pulse 2s ease-in-out infinite;
}

/* ===== 冒泡对话弹窗 ===== */
.ai-bubble-chat {
  position: absolute;
  bottom: 85px;
  right: 0;
  width: 340px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 20px;
  border: 1px solid rgba(79, 70, 229, 0.2);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(79, 70, 229, 0.15);
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  display: none;
}

.ai-bubble-chat.active {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* 弹窗小箭头 */
.ai-bubble-chat::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 28px;
  width: 20px;
  height: 20px;
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid rgba(79, 70, 229, 0.2);
  border-bottom: 1px solid rgba(79, 70, 229, 0.2);
  transform: rotate(45deg);
}

/* 弹窗头部 */
.ai-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid rgba(79, 70, 229, 0.1);
}

.ai-bubble-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-bubble-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(145deg, #4F46E5, #7C3AED);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.ai-bubble-name {
  font-family: 'Outfit', 'Noto Sans SC', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #E2E8F0;
}

.ai-bubble-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(100, 116, 139, 0.2);
  background: rgba(30, 41, 59, 0.5);
  color: #94A3B8;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-bubble-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* 弹窗消息区 */
.ai-bubble-messages {
  height: 280px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ai-bubble-messages::-webkit-scrollbar {
  width: 4px;
}

.ai-bubble-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-bubble-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 2px;
}

/* 欢迎消息 */
.ai-bubble-welcome {
  text-align: center;
  padding: 20px 16px;
}

.ai-bubble-welcome-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(145deg, #4F46E5, #7C3AED);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3);
}

.ai-bubble-welcome-text {
  font-size: 15px;
  font-weight: 700;
  color: #E2E8F0;
  margin-bottom: 6px;
}

.ai-bubble-welcome-desc {
  font-size: 12px;
  color: #94A3B8;
  line-height: 1.5;
}

/* 快捷按钮 */
.ai-bubble-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

.ai-quick-btn {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  background: rgba(79, 70, 229, 0.08);
  color: #A5B4FC;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-quick-btn:hover {
  background: rgba(79, 70, 229, 0.18);
  border-color: rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

/* 消息气泡 */
.ai-bubble-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msg-fade-in 0.3s ease;
}

@keyframes msg-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-bubble-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-bubble-msg.ai {
  align-self: flex-start;
}

.ai-msg-mini-avatar {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background: linear-gradient(145deg, #4F46E5, #7C3AED);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
}

.ai-bubble-msg.user .ai-msg-mini-avatar {
  background: linear-gradient(145deg, #06B6D4, #0891B2);
}

.ai-msg-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.ai-bubble-msg.user .ai-msg-content {
  background: linear-gradient(145deg, #4F46E5, #6366F1);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-bubble-msg.ai .ai-msg-content {
  background: rgba(30, 41, 59, 0.7);
  color: #E2E8F0;
  border: 1px solid rgba(79, 70, 229, 0.08);
  border-bottom-left-radius: 4px;
}

/* 打字指示器 */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.7);
  border-radius: 16px;
  border: 1px solid rgba(79, 70, 229, 0.08);
  border-bottom-left-radius: 4px;
}

.ai-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #818CF8;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* 弹窗输入区 */
.ai-bubble-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.6);
  border-top: 1px solid rgba(79, 70, 229, 0.08);
}

.ai-bubble-input input {
  flex: 1;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1.5px solid rgba(100, 116, 139, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #E2E8F0;
  font-size: 13px;
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.ai-bubble-input input:focus {
  border-color: rgba(79, 70, 229, 0.5);
}

.ai-bubble-input input::placeholder {
  color: #64748B;
}

.ai-bubble-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #4F46E5, #7C3AED);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.ai-bubble-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.ai-bubble-send:active {
  transform: scale(0.95);
}

.ai-bubble-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== 提示文字 ===== */
.ai-hint-text {
  position: absolute;
  bottom: 80px;
  right: 0;
  background: rgba(15, 23, 42, 0.9);
  color: #E2E8F0;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

.float-ai-character:hover .ai-hint-text {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 动画 ===== */
@keyframes float-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes antenna-glow {
  0%, 100% { opacity: 0.6; box-shadow: 0 0 8px #FCD34D; }
  50% { opacity: 1; box-shadow: 0 0 16px #FCD34D; }
}

@keyframes eye-blink {
  0%, 45%, 55%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.1); }
}

@keyframes pulse-expand {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== 角色颜色变体 ===== */
.float-ai-container[data-role="student"] .ai-avatar-head {
  background: linear-gradient(145deg, #0891B2, #06B6D4);
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.1), inset 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.float-ai-container[data-role="student"] .ai-pulse-ring {
  border-color: rgba(6, 182, 212, 0.3);
}

.float-ai-container[data-role="student"] .ai-bubble-chat {
  border-color: rgba(6, 182, 212, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(6, 182, 212, 0.15);
}

.float-ai-container[data-role="student"] .ai-quick-btn {
  border-color: rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.08);
  color: #67E8F9;
}

.float-ai-container[data-role="student"] .ai-quick-btn:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.4);
}

.float-ai-container[data-role="student"] .ai-bubble-send {
  background: linear-gradient(145deg, #0891B2, #06B6D4);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.float-ai-container[data-role="parent"] .ai-avatar-head {
  background: linear-gradient(145deg, #059669, #10B981);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.1), inset 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.float-ai-container[data-role="parent"] .ai-pulse-ring {
  border-color: rgba(16, 185, 129, 0.3);
}

.float-ai-container[data-role="parent"] .ai-bubble-chat {
  border-color: rgba(16, 185, 129, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(16, 185, 129, 0.15);
}

.float-ai-container[data-role="parent"] .ai-quick-btn {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
  color: #6EE7B7;
}

.float-ai-container[data-role="parent"] .ai-quick-btn:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.4);
}

.float-ai-container[data-role="parent"] .ai-bubble-send {
  background: linear-gradient(145deg, #059669, #10B981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.float-ai-container[data-role="teacher"] .ai-avatar-head {
  background: linear-gradient(145deg, #E11D48, #F43F5E);
  box-shadow: 0 8px 24px rgba(244, 63, 94, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.1), inset 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.float-ai-container[data-role="teacher"] .ai-pulse-ring {
  border-color: rgba(244, 63, 94, 0.3);
}

.float-ai-container[data-role="teacher"] .ai-bubble-chat {
  border-color: rgba(244, 63, 94, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(244, 63, 94, 0.15);
}

.float-ai-container[data-role="teacher"] .ai-quick-btn {
  border-color: rgba(244, 63, 94, 0.25);
  background: rgba(244, 63, 94, 0.08);
  color: #FDA4AF;
}

.float-ai-container[data-role="teacher"] .ai-quick-btn:hover {
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.4);
}

.float-ai-container[data-role="teacher"] .ai-bubble-send {
  background: linear-gradient(145deg, #E11D48, #F43F5E);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .float-ai-container {
    bottom: 16px;
    right: 16px;
  }

  .float-ai-character {
    width: 60px;
    height: 60px;
  }

  .ai-avatar-head {
    width: 48px;
    height: 44px;
  }

  .ai-bubble-chat {
    width: calc(100vw - 32px);
    right: -8px;
  }

  .ai-hint-text {
    display: none;
  }
}
