/* ===== ROBOT TUTOR — Gyani 🤖 ===== */

.robot-wrapper {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.25rem;
  transition: transform 0.3s ease;
}

/* Animation container */
.robot-anim {
  width: 120px; height: 120px;
  border-radius: 50%;
  overflow: visible;
  transition: all 0.3s ease;
}

/* Name tag */
.robot-name-tag {
  font-size: 0.7rem; font-weight: 900;
  background: linear-gradient(135deg, #5b5ef4, #7209b7);
  color: white; padding: 0.15rem 0.6rem;
  border-radius: 50px; letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* State-based animations */
.robot-state-idle .robot-anim {
  animation: robotFloat 3s ease-in-out infinite;
}
.robot-state-talking .robot-anim {
  animation: robotBounce 0.6s ease-in-out infinite;
}
.robot-state-happy .robot-anim {
  animation: robotFloat 2s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(52, 211, 153, 0.4));
}
.robot-state-thinking .robot-anim {
  animation: robotTilt 2s ease-in-out infinite;
}
.robot-state-celebrate .robot-anim {
  animation: robotJump 0.5s ease-in-out 3;
  filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.5));
}
.robot-state-sad .robot-anim {
  animation: robotDroop 2s ease-in-out infinite;
}
.robot-state-wave .robot-anim {
  animation: robotWave 1s ease-in-out 2;
}
.robot-state-quiz .robot-anim {
  animation: robotBounce 0.4s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(91, 94, 244, 0.4));
}

@keyframes robotFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes robotBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.03); }
}
@keyframes robotTilt {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}
@keyframes robotJump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-20px) scale(1.1); }
  50% { transform: translateY(-20px) scale(1.1) rotate(5deg); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes robotDroop {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(3px) rotate(-3deg); }
}
@keyframes robotWave {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(10deg); }
  50% { transform: rotate(-5deg); }
  75% { transform: rotate(8deg); }
}

/* ===== SPEECH BUBBLE ===== */
.robot-speech-bubble {
  position: absolute; bottom: -10px;
  left: 50%; transform: translateX(-50%) translateY(100%);
  background: white; border-radius: 16px;
  padding: 0.6rem 1rem; font-size: 0.82rem;
  font-weight: 800; color: var(--text, #1e293b);
  box-shadow: 0 4px 16px rgba(91, 94, 244, 0.15);
  border: 2px solid #e8eaff;
  white-space: nowrap; max-width: 250px;
  white-space: normal; text-align: center;
  z-index: 10;
}
.robot-speech-bubble::before {
  content: ''; position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid white;
}
.speech-pop {
  animation: speechPop 0.3s ease;
}
@keyframes speechPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(100%) scale(0.8); }
  100% { opacity: 1; transform: translateX(-50%) translateY(100%) scale(1); }
}

/* ===== CSS FALLBACK ROBOT ===== */
.robot-css-fallback {
  width: 80px; height: 100px;
  display: flex; flex-direction: column;
  align-items: center; margin: 10px auto;
}
.robot-head {
  width: 60px; height: 50px;
  background: linear-gradient(135deg, #5b5ef4, #7209b7);
  border-radius: 16px; position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 12px; box-shadow: 0 4px 12px rgba(91, 94, 244, 0.3);
}
.robot-eye {
  width: 12px; height: 12px;
  background: white; border-radius: 50%;
  position: relative;
  animation: robotBlink 3s infinite;
}
.robot-eye::after {
  content: ''; position: absolute;
  width: 6px; height: 6px;
  background: #1e293b; border-radius: 50%;
  top: 3px; left: 3px;
  transition: all 0.3s;
}
.robot-mouth {
  position: absolute; bottom: 8px;
  width: 16px; height: 3px;
  background: white; border-radius: 2px;
  transition: all 0.3s;
}
.robot-body {
  width: 50px; height: 35px;
  background: linear-gradient(135deg, #7c7ff7, #9333ea);
  border-radius: 0 0 14px 14px;
  margin-top: -2px; position: relative;
}
.robot-arm {
  width: 10px; height: 25px;
  background: #5b5ef4; border-radius: 5px;
  position: absolute; top: 2px;
}
.robot-arm.left { left: -12px; transform: rotate(10deg); }
.robot-arm.right { right: -12px; transform: rotate(-10deg); }

/* CSS robot states */
.robot-css-idle .robot-head { animation: robotFloat 3s ease-in-out infinite; }
.robot-css-happy .robot-mouth { height: 8px; border-radius: 0 0 8px 8px; bottom: 6px; }
.robot-css-happy .robot-eye::after { top: 1px; }
.robot-css-sad .robot-mouth { border-radius: 8px 8px 0 0; bottom: 10px; }
.robot-css-thinking .robot-head { animation: robotTilt 2s ease-in-out infinite; }
.robot-css-talking .robot-mouth {
  height: 8px; width: 10px; border-radius: 50%;
  animation: robotTalk 0.5s ease-in-out infinite;
}
.robot-css-celebrate .robot-arm.left { animation: robotArmWave 0.4s ease-in-out infinite; }
.robot-css-celebrate .robot-arm.right { animation: robotArmWave 0.4s ease-in-out infinite 0.2s; }
.robot-css-wave .robot-arm.right { animation: robotArmWave 0.5s ease-in-out 3; }

@keyframes robotBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
@keyframes robotTalk {
  0%, 100% { height: 4px; }
  50% { height: 10px; }
}
@keyframes robotArmWave {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(-45deg); }
}

/* ===== ROBOT IN CHAT (AI Tutor page) ===== */
.chat-robot-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem; border-bottom: 2px solid #f0f2ff;
  background: linear-gradient(135deg, #fafbff, #f5f0ff);
}
.chat-robot-header .robot-wrapper { flex-direction: row; gap: 0.75rem; }
.chat-robot-header .robot-anim { width: 60px; height: 60px; }
.chat-robot-header .robot-name-tag { display: none; }
.chat-robot-header .robot-speech-bubble {
  position: static; transform: none;
  max-width: 300px;
}
.chat-robot-header .robot-speech-bubble::before { display: none; }
.chat-robot-info h3 {
  font-size: 1rem; font-weight: 900; margin-bottom: 0.1rem;
}
.chat-robot-info p {
  font-size: 0.78rem; color: #64748b; font-weight: 700;
}

/* ===== ROBOT IN SIDEBAR (compact) ===== */
.sidebar-robot {
  text-align: center; padding: 1rem 0;
  border-bottom: 2px solid #eeeeff; margin-bottom: 1rem;
}
.sidebar-robot .robot-anim { width: 80px; height: 80px; margin: 0 auto; }
.sidebar-robot .robot-speech-bubble {
  position: static; transform: none;
  margin-top: 0.5rem; font-size: 0.78rem;
  display: inline-block;
}
.sidebar-robot .robot-speech-bubble::before { display: none; }

/* ===== ROBOT FLOATING (bottom-right on other pages) ===== */
.robot-floating {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 1000; cursor: pointer;
  transition: transform 0.3s;
}
.robot-floating:hover { transform: scale(1.1); }
.robot-floating .robot-anim { width: 80px; height: 80px; }
.robot-floating .robot-wrapper {
  background: white; border-radius: 50%;
  padding: 8px; box-shadow: 0 6px 24px rgba(91, 94, 244, 0.25);
  border: 2px solid #e8eaff;
}
.robot-floating .robot-name-tag { display: none; }
.robot-floating .robot-speech-bubble {
  bottom: auto; top: -10px;
  transform: translateX(-50%) translateY(-100%);
  font-size: 0.75rem;
}
.robot-floating .robot-speech-bubble::before {
  top: auto; bottom: -8px;
  border-bottom: none;
  border-top: 8px solid white;
}

/* ===== CONFETTI BURST (on celebrate) ===== */
.robot-state-celebrate::after {
  content: '🎉✨⭐🎊';
  position: absolute; top: -20px;
  left: 50%; transform: translateX(-50%);
  font-size: 1.2rem; letter-spacing: 6px;
  animation: confettiBurst 1s ease-out forwards;
  pointer-events: none;
}
@keyframes confettiBurst {
  0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(0.5); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(1.3); }
}

/* ===== AGE GROUP THEMES ===== */

/* Junior (Class 6-7): Playful, colorful, bouncy */
.robot-junior .robot-name-tag {
  background: linear-gradient(135deg, #f97316, #fbbf24);
  font-size: 0.75rem;
}
.robot-junior .robot-speech-bubble {
  border-color: #fed7aa; background: #fffbf0;
  border-radius: 20px; font-size: 0.85rem;
}
.robot-junior.robot-state-idle .robot-anim {
  animation: robotFloat 2s ease-in-out infinite;
}
.robot-junior.robot-state-celebrate .robot-anim {
  animation: robotJump 0.4s ease-in-out 4;
  filter: drop-shadow(0 0 20px rgba(249,115,22,0.5));
}
.robot-junior.robot-state-celebrate::after {
  content: '🎉🌟⭐🎊🏆💫';
  font-size: 1.4rem; letter-spacing: 4px;
}

/* Mid (Class 8): Balanced, cool */
.robot-mid .robot-name-tag {
  background: linear-gradient(135deg, #5b5ef4, #7209b7);
}

/* Senior (Class 9-10): Sleek, minimal, professional */
.robot-senior .robot-name-tag {
  background: linear-gradient(135deg, #334155, #475569);
  font-size: 0.65rem; letter-spacing: 1px;
}
.robot-senior .robot-speech-bubble {
  border-color: #e2e8f0; background: #f8fafc;
  border-radius: 12px; font-size: 0.82rem;
  font-weight: 700;
}
.robot-senior.robot-state-idle .robot-anim {
  animation: robotFloat 4s ease-in-out infinite;
}
.robot-senior.robot-state-celebrate .robot-anim {
  animation: robotJump 0.6s ease-in-out 2;
  filter: drop-shadow(0 0 12px rgba(51,65,85,0.3));
}
.robot-senior.robot-state-celebrate::after {
  content: '✅⭐';
  font-size: 1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .robot-anim { width: 80px !important; height: 80px !important; }
  .robot-speech-bubble { font-size: 0.75rem; max-width: 180px; }
  .robot-floating { bottom: 10px; right: 10px; }
  .robot-floating .robot-anim { width: 60px !important; height: 60px !important; }
  .chat-robot-header .robot-anim { width: 45px !important; height: 45px !important; }
}
