/* ==========================================================================
   VIETBCC - PANDA AI TUTOR WIDGET (ai_tutor.css)
   Interactive floating AI Math Tutor powered by AI Box Unified API.
   ========================================================================== */

/* Floating Button (FAB) */
.ai-tutor-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
  color: #FFFFFF;
  border: 3px solid #FFFFFF;
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4);
  cursor: pointer;
  transition: transform var(--duration-fast, 0.2s) ease, box-shadow var(--duration-fast, 0.2s) ease;
}

.ai-tutor-fab:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 28px rgba(108, 92, 231, 0.5);
}

.ai-tutor-fab-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #FFFFFF;
  border: 2px solid #FFC857;
  flex-shrink: 0;
}

.ai-tutor-fab-text {
  font-family: var(--font-family-display, 'Baloo 2', sans-serif);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

/* Chat Drawer / Modal */
.ai-tutor-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background-color: #FFFFFF;
  border-radius: 20px;
  border: 1px solid var(--color-border, #E7E8F0);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1060;
  animation: aiPanelSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-tutor-panel.is-open {
  display: flex;
}

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

/* Header */
.ai-tutor-header {
  background: linear-gradient(135deg, #6C5CE7 0%, #5545C7 100%);
  color: #FFFFFF;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-tutor-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-tutor-avatar-header {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #FFC857;
  object-fit: cover;
  background-color: #FFFFFF;
}

.ai-tutor-name {
  font-family: var(--font-family-display, 'Baloo 2', sans-serif);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}

.ai-tutor-badge-live {
  font-size: 11px;
  color: #E4FBFA;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  margin-top: 2px;
}

.ai-tutor-badge-live::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #16B879;
  border-radius: 50%;
  box-shadow: 0 0 6px #16B879;
}

.ai-tutor-btn-close {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.ai-tutor-btn-close:hover {
  opacity: 1;
}

/* Chat Messages */
.ai-tutor-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #F8F9FD;
}

.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  align-items: flex-start;
}

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

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

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #E7E8F0;
  background-color: #FFFFFF;
}

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

.ai-msg-tutor .ai-msg-bubble {
  background-color: #FFFFFF;
  color: var(--color-text, #292A3A);
  border: 1px solid #E7E8F0;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ai-msg-user .ai-msg-bubble {
  background-color: var(--color-primary, #6C5CE7);
  color: #FFFFFF;
  border-top-right-radius: 4px;
}

/* Quick Chips */
.ai-tutor-chips {
  padding: 8px 12px;
  background-color: #FFFFFF;
  border-top: 1px solid var(--color-border, #E7E8F0);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-chip {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary, #6C5CE7);
  background-color: #EEEAFE;
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-chip:hover {
  background-color: var(--color-primary, #6C5CE7);
  color: #FFFFFF;
}

/* Input Bar */
.ai-tutor-input-bar {
  padding: 10px 14px;
  background-color: #FFFFFF;
  border-top: 1px solid var(--color-border, #E7E8F0);
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-tutor-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border, #CBD5E1);
  border-radius: 20px;
  outline: none;
  background-color: #F8F9FD;
  transition: border-color 0.15s ease;
}

.ai-tutor-input:focus {
  border-color: var(--color-primary, #6C5CE7);
  background-color: #FFFFFF;
}

.ai-tutor-btn-send {
  background: var(--color-primary, #6C5CE7);
  color: #FFFFFF;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 14px;
  transition: transform 0.12s ease;
}

.ai-tutor-btn-send:hover {
  transform: scale(1.08);
}

/* Typing indicator */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1px solid #E7E8F0;
  border-radius: 14px;
  width: fit-content;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94A3B8;
  border-radius: 50%;
  animation: aiTypingBounce 1.4s infinite both;
}

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

@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Mobile Placement */
@media (max-width: 768px) {
  .ai-tutor-fab {
    bottom: 76px; /* Above mobile bottom nav */
    right: 16px;
    padding: 4px 12px 4px 4px;
  }
  .ai-tutor-fab-img {
    width: 38px;
    height: 38px;
  }
  .ai-tutor-fab-text {
    font-size: 12px;
  }
  .ai-tutor-panel {
    bottom: 128px;
    right: 16px;
    height: 460px;
  }
}
