/* ============================================
   FocusAgent AI伙伴悬浮窗样式
   儿童友好 · 太空主题 · 玻璃拟态
   ============================================ */

/* ===== 悬浮按钮 ===== */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4), 0 0 0 0 rgba(59, 130, 246, 0.3);
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  border: none;
  outline: none;
}

.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.5), 0 0 0 0 rgba(59, 130, 246, 0.3);
}

.ai-fab:active {
  transform: scale(0.95);
}

.ai-fab.ai-fab-active {
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  transform: scale(0.95);
}

.ai-fab-icon {
  font-size: 26px;
  color: white;
  font-weight: 800;
  animation: aiFabIconPulse 2s ease-in-out infinite;
}

@keyframes aiFabIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.ai-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.4);
  animation: aiFabPulse 2.5s ease-out infinite;
}

@keyframes aiFabPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.ai-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #EF4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--space-950, #030712);
  animation: aiBadgeBounce 0.5s ease;
}

@keyframes aiBadgeBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== 对话面板 ===== */
.ai-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  height: 540px;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  z-index: 9997;
  background: rgba(10, 15, 30, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(59, 130, 246, 0.1);
  animation: aiPanelSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes aiPanelSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== 面板头部 ===== */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
}

.ai-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-panel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.ai-panel-name {
  font-family: 'Outfit', 'Noto Sans SC', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #E2E8F0;
}

.ai-panel-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #4ADE80;
}

.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ADE80;
  animation: aiStatusPulse 2s ease-in-out infinite;
}

@keyframes aiStatusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-panel-header-right {
  display: flex;
  gap: 6px;
}

.ai-panel-btn {
  width: 30px;
  height: 30px;
  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-panel-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border-color: rgba(59, 130, 246, 0.3);
}

/* ===== 消息区域 ===== */
.ai-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ai-panel-messages::-webkit-scrollbar {
  width: 4px;
}

.ai-panel-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-panel-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 2px;
}

/* ===== 欢迎消息 ===== */
.ai-welcome-msg {
  text-align: center;
  padding: 20px 16px;
}

.ai-welcome-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.ai-welcome-text {
  font-size: 16px;
  font-weight: 700;
  color: #E2E8F0;
  margin-bottom: 6px;
}

.ai-welcome-desc {
  font-size: 12px;
  color: #94A3B8;
  line-height: 1.5;
}

/* ===== 快捷操作 ===== */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 4px 0 8px;
}

.ai-quick-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.08);
  color: #93C5FD;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-quick-btn:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

/* ===== 消息气泡 ===== */
.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: aiMsgFadeIn 0.3s ease;
}

@keyframes aiMsgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg-ai {
  align-self: flex-start;
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: white;
  font-weight: 800;
  flex-shrink: 0;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.ai-msg-bubble-user {
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-msg-bubble-ai {
  background: rgba(30, 41, 59, 0.7);
  color: #E2E8F0;
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-bottom-left-radius: 4px;
}

/* ===== AI消息内容样式 ===== */
.ai-msg-text .ai-paragraph {
  margin-bottom: 6px;
}

.ai-msg-text .ai-paragraph:last-child {
  margin-bottom: 0;
}

.ai-msg-text .ai-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
  padding-left: 4px;
}

.ai-msg-text .ai-list-dot {
  color: #60A5FA;
  font-size: 14px;
  line-height: 1.5;
  flex-shrink: 0;
}

.ai-msg-text .ai-list-ordered {
  gap: 6px;
}

.ai-msg-text .ai-list-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: #60A5FA;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== 消息操作按钮 ===== */
.ai-msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(100, 116, 139, 0.1);
}

.ai-msg-action {
  padding: 3px 8px;
  border-radius: 6px;
  border: none;
  background: rgba(100, 116, 139, 0.1);
  color: #94A3B8;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-msg-action:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

/* ===== 输入指示器 ===== */
.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #60A5FA;
  animation: aiTypingBounce 1.4s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes aiTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ===== 输入区域 ===== */
.ai-panel-input {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-top: 1px solid rgba(59, 130, 246, 0.08);
}

.ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ai-voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(100, 116, 139, 0.2);
  background: rgba(30, 41, 59, 0.5);
  color: #94A3B8;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-voice-btn:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

.ai-voice-btn.ai-voice-active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #F87171;
  animation: aiVoicePulse 1s ease-in-out infinite;
}

@keyframes aiVoicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.ai-input-text {
  flex: 1;
  min-height: 36px;
  max-height: 80px;
  padding: 8px 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;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.ai-input-text:focus {
  border-color: rgba(59, 130, 246, 0.5);
}

.ai-input-text::placeholder {
  color: #64748B;
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.ai-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.ai-send-btn:active {
  transform: scale(0.95);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .ai-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    bottom: 8px;
    right: 8px;
    border-radius: 16px;
  }

  .ai-fab {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .ai-fab-icon {
    font-size: 22px;
  }
}

/* ===== Landing Page AI Panel Extensions ===== */
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', 'Noto Sans SC', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #E2E8F0;
}

.ai-panel-title i {
  color: #60A5FA;
  font-size: 18px;
}

.ai-panel-close {
  width: 30px;
  height: 30px;
  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-panel-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.ai-panel-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  max-width: 88%;
  animation: aiMsgFadeIn 0.3s ease;
}

.ai-panel-msg.bot {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.7);
  color: #E2E8F0;
  border: 1px solid rgba(59, 130, 246, 0.08);
  border-bottom-left-radius: 4px;
}

.ai-panel-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-panel-msg.typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.7);
}

.ai-panel-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-top: 1px solid rgba(59, 130, 246, 0.08);
}

.ai-panel-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-panel-input:focus {
  border-color: rgba(59, 130, 246, 0.5);
}

.ai-panel-input::placeholder {
  color: #64748B;
}

.ai-panel-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  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(59, 130, 246, 0.3);
}

.ai-panel-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.ai-panel-send:active {
  transform: scale(0.95);
}

/* ===== Typing Dots (shared) ===== */
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #60A5FA;
  animation: aiTypingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ===== AI Panel open state ===== */
.ai-panel:not(.open) {
  display: none;
}
