/* ============================================
   SUPERPADHAI TUTOR V2 - BEAUTIFUL UI
   ============================================ */

/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  /* Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-light: #8b9cff;
  --primary-dark: #5a67d8;
  
  --canvas-bg: #ffffff;
  --canvas-grid: #f5f5f5;
  --canvas-grid-major: #e0e0e0;
  
  --chat-overlay-bg: rgba(255, 255, 255, 0.85);
  --chat-backdrop-blur: 20px;
  
  --tutor-message-bg: #ffffff;
  --tutor-message-border: #e0e0e0;
  --student-message-text: #ffffff;
  
  --blackboard-bg: #1a3d2e;
  --blackboard-text: #ffffff;
  --blackboard-chalk: #e8f4ea;
  
  --success: #4caf50;
  --warning: #ff9800;
  --error: #ef5350;
  --info: #2196f3;
  --pending: #999999;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Timing */
  --duration-fast: 200ms;
  --duration-medium: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;
  
  /* Easing */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 12px 36px rgba(0, 0, 0, 0.25);
}

/* ========================================
   RESET & BASE
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100vh;
  /* Checkered grid background matching canvas grid */
  background-color: #ffffff;
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.015) 1px, transparent 1px);
  background-size: 
    100px 100px,
    100px 100px,
    20px 20px,
    20px 20px;
  background-position: 
    -1px -1px,
    -1px -1px,
    -1px -1px,
    -1px -1px;
}

/* ========================================
   CANVAS CONTAINER - Full Screen
   ======================================== */
.canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent; /* Let the body's checkered pattern show through */
  transition: opacity var(--duration-medium) var(--ease-in-out);
  /* Removed z-index to avoid creating stacking context */
  /* This allows children (like orbit-widget) to have independent z-index */
}

/* Canvas dims when chat is focused or blackboard is open */
.canvas-container.dimmed {
  opacity: 0.9;
}

#canvas,
#geometry-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1; /* Keep canvas in background, but allow siblings to stack independently */
}

/* ========================================
   LANDING HERO - Bottom Section
   ======================================== */
/* Canvas overlay for better readability */
.canvas-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40vh;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 100%);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease-out;
}

.canvas-overlay.visible {
  opacity: 1;
}

.landing-hero {
  position: fixed;
  bottom: 50px;
  left: 0;
  width: 100%;
  padding: 60px 40px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  z-index: 100;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.landing-hero.visible {
  opacity: 1;
  pointer-events: auto;
}

.hero-headline {
  font-size: 56px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(30px);
  animation: slideUpFade 0.8s ease-out forwards;
}

.hero-subheading {
  font-size: 20px;
  color: #6b7280;
  text-align: center;
  max-width: 600px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(30px);
  animation: slideUpFade 0.8s ease-out 0.2s forwards;
  margin-top: -16px;
}

.suggestion-cards {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}

.suggestion-card {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0;
  transform: translateY(30px);
  min-width: 260px;
  max-width: 280px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 16px;
}

.suggestion-card:nth-child(1) {
  animation: slideUpFade 0.8s ease-out 0.4s forwards;
}

.suggestion-card:nth-child(2) {
  animation: slideUpFade 0.8s ease-out 0.5s forwards;
}

.suggestion-card:nth-child(3) {
  animation: slideUpFade 0.8s ease-out 0.6s forwards;
}

.suggestion-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: #667eea;
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.2);
}

.suggestion-card-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.suggestion-card-text {
  font-size: 15px;
  color: #374151;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
}

@keyframes slideUpFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-input-container {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 800px;
  width: 100%;
  opacity: 0;
  transform: translateY(30px);
  animation: slideUpFade 0.8s ease-out 0.7s forwards;
  position: relative;
}

.hero-input {
  flex: 1;
  padding: 18px 28px;
  font-size: 17px;
  border: 2px solid transparent;
  border-radius: 16px;
  outline: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.95);
  color: #1f2937;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 
              0 0 0 1px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  font-weight: 400;
}

.hero-input:focus {
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25),
              0 0 0 2px rgba(102, 126, 234, 0.4);
  background: rgba(255, 255, 255, 1);
  transform: translateY(-2px);
}

.hero-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.hero-send-btn {
  padding: 18px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 16px;
  color: white;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4),
              0 2px 4px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.hero-send-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hero-send-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.5),
              0 4px 8px rgba(102, 126, 234, 0.4);
}

.hero-send-btn:hover::before {
  opacity: 1;
}

.hero-send-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.hero-send-btn.loading {
  pointer-events: none;
  opacity: 0.8;
  cursor: not-allowed;
}

.hero-send-btn.loading svg.send-icon {
  display: none;
}

.hero-send-btn svg.send-icon {
  display: block;
}

.hero-send-btn.loading svg.spinner-icon {
  display: block;
  animation: spin 1s linear infinite;
}

.hero-send-btn svg.spinner-icon {
  display: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   CHAT OVERLAY - Hidden Initially
   ======================================== */
.chat-overlay.hidden-initially {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
  transition: all 0.6s ease-out;
}

.chat-overlay.show-chat {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ========================================
   CHAT OVERLAY - Floating Elements (NO Background)
   ======================================== */
.chat-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 50vh; /* Increased from 40vh to 50vh */
  min-height: 120px;
  
  /* TRANSPARENT - No frosted glass background */
  background: transparent;
  
  /* Smooth transitions */
  transition: max-height var(--duration-medium) var(--ease-in-out),
              transform var(--duration-medium) var(--ease-in-out);
  
  /* Layering - above canvas, below blackboard */
  z-index: 100;
  
  display: flex;
  flex-direction: column;
  
  /* Allow clicks to pass through transparent areas */
  pointer-events: none;
  
  padding: var(--space-md) var(--space-xl) var(--space-lg);
}

/* Expand state */
.chat-overlay.expanded {
  max-height: 70vh;
}

/* NO gradient fade - fully transparent */

/* ========================================
   CHAT MESSAGES - Floating Bubbles with Gradient Fade
   ======================================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 0;
  /* Transparent container */
  background: transparent;
  pointer-events: none; /* Pass through clicks */
  position: relative;
  margin-bottom: 24px; /* More spacing before input box */
  
  /* Match input container width and centering */
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  
  /* Show only latest message by default */
  max-height: 120px; /* Height for one message */
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Gradient mask - messages fade out at top */
  -webkit-mask-image: linear-gradient(to bottom, 
    transparent 0%,
    black 60px,
    black 100%
  );
  mask-image: linear-gradient(to bottom, 
    transparent 0%,
    black 60px,
    black 100%
  );
}

/* Expand on hover to show more messages */
.chat-messages:hover {
  max-height: 400px; /* Show multiple messages */
  pointer-events: auto; /* Enable scrolling when hovering */
}

/* Hide scrollbar completely */
.chat-messages::-webkit-scrollbar {
  width: 0;
  display: none;
}

.chat-messages {
  /* Hide scrollbar for Firefox */
  scrollbar-width: none;
  /* Hide scrollbar for IE and Edge */
  -ms-overflow-style: none;
}

/* Message container - Floating element */
.message {
  display: flex;
  gap: var(--space-sm);
  animation: messageSlideIn var(--duration-medium) var(--ease-out);
  max-width: 85%;
  pointer-events: auto;
  margin-bottom: 8px; /* Better spacing between messages */
}

/* Custom message (for waiting content, MCQs, flashcards, etc.) */
.message.custom-message {
  max-width: 100%;
  width: 100%;
}

.message.custom-message .message-content.full-width {
  width: 100%;
  max-width: 100%;
}

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

/* Tutor messages (left-aligned with premium input wrapper edge) */
.tutor-message {
  align-self: flex-start;
  margin-left: 0; /* Align with the left edge of premium input wrapper */
}

/* Student messages (right-aligned) */
.student-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Avatar emoji - keep but subtle */
.message-avatar {
  width: 40px;
  height: 40px;
  font-size: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-fast);
}

.message-avatar:hover {
  transform: scale(1.1);
}

/* Message bubble - FLOATING with improved depth and spacing */
.message-bubble {
  padding: 14px 18px; /* Slightly more spacious */
  border-radius: 18px; /* Slightly rounder */
  line-height: 1.6; /* Better readability */
  font-size: 15px;
  word-wrap: break-word;
  transition: all var(--duration-fast);
}

.tutor-message .message-bubble {
  background: var(--tutor-message-bg);
  border: 1px solid var(--tutor-message-border);
  /* Enhanced shadow for floating effect */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 
              0 2px 4px rgba(0, 0, 0, 0.08);
  color: #333;
  padding-right: 38px; /* 20px more than the default 18px */
}

.tutor-message .message-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 
              0 3px 6px rgba(0, 0, 0, 0.10);
}

.student-message .message-bubble {
  background: var(--primary-gradient);
  color: var(--student-message-text);
  /* Enhanced shadow with primary color glow */
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35), 
              0 2px 6px rgba(102, 126, 234, 0.2);
}

.student-message .message-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4), 
              0 3px 8px rgba(102, 126, 234, 0.25);
}

/* Hand gesture */
.hand-gesture {
  font-size: 20px;
  margin-right: 8px;
  display: inline-block;
  animation: handSlideIn 400ms var(--ease-out);
}

@keyframes handSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Thinking indicator */
.typing-indicator .message-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: #667eea;
  border-radius: 50%;
  animation: thinking 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) {
  animation-delay: 0s;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ========================================
   REVOLUTIONARY CHAT INPUT - 10X PREMIUM
   ======================================== */
.chat-input-container {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.premium-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(40px) saturate(180%);
  border-radius: 28px;
  padding: 8px 8px 8px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08),
              0 4px 16px rgba(0, 0, 0, 0.04),
              0 0 0 1px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.8);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: visible;
  pointer-events: auto; /* Ensure clicks work */
}

.premium-input-wrapper:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.10),
              0 6px 20px rgba(0, 0, 0, 0.06),
              0 0 0 1px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

.premium-input-wrapper:focus-within {
  box-shadow: 0 12px 48px rgba(102, 126, 234, 0.20),
              0 6px 24px rgba(102, 126, 234, 0.12),
              0 0 0 2px rgba(102, 126, 234, 0.3);
  transform: translateY(-2px);
  border-color: rgba(102, 126, 234, 0.3);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
  color: #1f2937;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
  padding: 12px 0;
  box-shadow: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.chat-input:focus,
#chatInput:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.chat-input::placeholder,
#chatInput::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

/* Disabled state for chat input */
.chat-input:disabled,
#chatInput:disabled {
  cursor: not-allowed;
  color: #9ca3af;
}

.chat-input:disabled::placeholder,
#chatInput:disabled::placeholder {
  color: #d1d5db;
}

/* Additional safeguards for textarea */
#chatInput {
  flex: 1;
  background: transparent;
  border: none !important;
  outline: none !important;
  font-size: 16px;
  line-height: 1.5;
  color: #1f2937;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
  padding: 12px 0;
  box-shadow: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  pointer-events: auto; /* Ensure input works */
}

.chat-input::-webkit-scrollbar,
#chatInput::-webkit-scrollbar {
  width: 4px;
}

.chat-input::-webkit-scrollbar-thumb,
#chatInput::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.chat-input::-webkit-scrollbar-track,
#chatInput::-webkit-scrollbar-track {
  background: transparent;
}

.send-button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4),
              0 2px 8px rgba(102, 126, 234, 0.2);
  position: relative;
  overflow: hidden;
  pointer-events: auto; /* Ensure clicks work */
}

.send-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5),
              0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-button:hover:not(:disabled)::before {
  width: 120%;
  height: 120%;
}

.send-button:active:not(:disabled) {
  transform: scale(0.96);
}

.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Loading state */
.send-button.loading {
  opacity: 0.7;
  pointer-events: none;
}

.send-button.loading svg {
  animation: spin 1s linear infinite;
}

.send-button svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.send-button:hover:not(:disabled) svg {
  transform: translateX(2px) translateY(-2px);
}

.send-button.loading:hover svg {
  transform: none;
  animation: spin 1s linear infinite;
}

/* Legacy wrapper for backward compatibility */
.input-wrapper {
  display: contents;
}

.input-prompt {
  display: none;
}

.prompt-emoji {
  display: none;
}

/* ========================================
   SUGGESTED QUESTIONS
   ======================================== */
.suggested-questions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
  animation: slideUp 400ms var(--ease-out);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggested-chip {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  transition: all var(--duration-fast);
  animation: fadeInUp 400ms var(--ease-out);
  animation-fill-mode: both;
  /* Floating shadow */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08), 
              0 1px 3px rgba(0, 0, 0, 0.05);
}

.suggested-chip:hover {
  background: #ffffff;
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2), 
              0 3px 8px rgba(102, 126, 234, 0.12);
  color: #667eea;
  border-color: #667eea;
}

.suggested-chip:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.15), 
              0 2px 5px rgba(102, 126, 234, 0.1);
}

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

/* ========================================
   TUTOR AVATAR - Draggable Widget (Top Left)
   ======================================== */
.tutor-avatar {
  position: fixed;
  top: 30px;
  left: 30px; /* Moved to top left */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-gradient);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4),
              0 3px 10px rgba(102, 126, 234, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250; /* Above everything */
  cursor: pointer;
  transition: all var(--duration-fast);
  
  /* Breathing animation */
  /* animation: avatarBreathe 3s ease-in-out infinite; */
}

.tutor-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.5),
              0 4px 14px rgba(102, 126, 234, 0.3);
}


@keyframes avatarBreathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: var(--shadow-lg);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(102, 126, 234, 0.4);
  }
}

.avatar-emoji {
  font-size: 20px;
  transition: all var(--duration-medium) var(--ease-bounce);
}

/* State-specific animations */
.tutor-avatar.thinking .avatar-emoji {
  animation: linear infinite;
}

/* @keyframes avatarRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
} */

.tutor-avatar.celebrating .avatar-emoji {
  animation: avatarCelebrate 600ms var(--ease-bounce);
}

@keyframes avatarCelebrate {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.2) rotate(-15deg);
  }
  75% {
    transform: scale(1.2) rotate(15deg);
  }
}

.tutor-avatar:hover .avatar-emoji {
  transform: scale(1.1);
}

/* ========================================
   TASK PROGRESS - Floating Indicator
   ======================================== */
.task-progress {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  background: white;
  border-radius: 12px;
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 300px;
  transform: translateX(120%);
  transition: transform var(--duration-slow) var(--ease-out);
  z-index: 500;
}

.task-progress:not(.hidden) {
  transform: translateX(0);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.progress-bar {
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  transition: width 400ms var(--ease-out);
  border-radius: 2px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  font-size: 13px;
  color: #666;
}

.task-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.task-item.inProgress {
  color: #667eea;
  font-weight: 500;
}

.task-item.inProgress .task-icon {
  animation: taskPulse 1s ease-in-out infinite;
}

@keyframes taskPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
}

.task-item.complete {
  color: var(--success);
}

.task-item.check-bounce {
  animation: checkBounce 600ms var(--ease-bounce);
}

@keyframes checkBounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

/* ========================================
   BLACKBOARD - Floating, Draggable Widget (Top Right)
   ======================================== */
.blackboard {
  position: fixed;
  top: 3px;
  right: 3px;
  width: 710px;
  min-height: 400px;
  max-height: 400px;
  background: var(--blackboard-bg);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  /* Visible by default, but collapsed */
  opacity: 1;
  transform: scale(1);
  /* Smooth transitions for ALL properties */
  transition: max-height var(--duration-medium) var(--ease-out),
              min-height var(--duration-medium) var(--ease-out),
              width var(--duration-medium) var(--ease-out),
              opacity var(--duration-medium) var(--ease-out),
              transform var(--duration-medium) var(--ease-out),
              top var(--duration-medium) var(--ease-out);
  pointer-events: auto;
  overflow: hidden; /* Important for smooth animation */
}

.blackboard.hidden {
  top: -500px !important; /* Off-screen above */
  opacity: 0;
  pointer-events: none;
  transition: none !important; /* Disable transition when hidden */
}

/* Slide-in animation with bounce */
@keyframes slideInBounce {
  0% {
    top: -500px;
    opacity: 0;
  }
  60% {
    top: 10px; /* Overshoot slightly */
    opacity: 1;
  }
  80% {
    top: -5px; /* Bounce back up a bit */
  }
  100% {
    top: 3px; /* Settle into final position */
    opacity: 1;
  }
}

.blackboard.slide-in {
  animation: slideInBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Slide out animation - smooth exit to the right */
@keyframes slideOutRight {
  0% {
    right: 3px;
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  100% {
    right: -800px;
    opacity: 0;
    transform: scale(0.85) rotate(5deg);
  }
}

.blackboard.slide-out {
  animation: slideOutRight 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  pointer-events: none;
}

/* Hide axes, grid, and labels initially */
#axes-layer,
#grid-layer {
  opacity: 0;
  pointer-events: none;
}

/* Axes slide in animation - to 50% opacity */
@keyframes slideInAxes {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 0.5;
  }
}

/* Grid fade in - to 50% opacity */
@keyframes fadeInGrid {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 0.5;
  }
}

#axes-layer.animate-in {
  animation: slideInAxes 0.8s ease-out forwards;
  pointer-events: auto;
  transition: opacity 0.8s ease-out; /* For the 50% to 100% fade */
}

#grid-layer.fade-in {
  animation: fadeInGrid 0.6s ease-out forwards;
  pointer-events: auto;
  transition: opacity 0.8s ease-out; /* For the 50% to 100% fade */
}

/* Full opacity when message received */
#axes-layer.full-opacity,
#grid-layer.full-opacity {
  opacity: 1 !important;
}

.blackboard.collapsed .blackboard-content {
  display: none;
}

.blackboard.collapsed {
  min-height: 48px; /* Collapsed to header only */
  max-height: 48px;
  width: 720px; /* Same width as open state */
}

/* Maximized state - nearly full screen with margins */
.blackboard.maximized {
  top: 20px !important;
  left: 20px !important;
  right: 20px !important;
  bottom: 20px !important;
  width: calc(100vw - 40px) !important;
  min-height: calc(100vh - 40px) !important;
  max-height: calc(100vh - 40px) !important;
  border-radius: 16px;
  z-index: 300 !important; /* Above chat container (z-index: 100) */
}

.blackboard.maximized .blackboard-header {
  cursor: default; /* Can't drag when maximized */
}

.blackboard.maximized .blackboard-content {
  max-height: calc(100vh - 120px); /* Full height minus header and padding */
  overflow-y: auto; /* Always scrollable when maximized */
}

/* Blackboard Header (drag handle) */
.blackboard-header {
  background: rgba(0, 0, 0, 0.2);
  padding: var(--space-sm) var(--space-md);
  border-radius: 12px 12px 0 0;
  cursor: move;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.blackboard-header:hover {
  background: rgba(0, 0, 0, 0.3);
}

.blackboard-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.blackboard-controls {
  display: flex;
  gap: 8px;
}

.blackboard-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

.blackboard-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.blackboard-content {
  padding: var(--space-lg);
  color: var(--blackboard-chalk);
  font-family: 'Architects Daughter', cursive;
  font-size: 18px;
  line-height: 1.8;
  overflow-y: auto; /* Allow scrolling for accumulated content */
  flex: 1;
  min-height: 140px; /* Ensures content area has room for "Hello!" */
  max-height: 420px; /* Scrollable in normal mode */
}

.blackboard-content::-webkit-scrollbar {
  width: 6px;
}

.blackboard-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.blackboard-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.chalk-line {
  margin: 12px 0;
  animation: chalkWrite 600ms var(--ease-out);
  animation-fill-mode: both;
}

.blackboard-padhai-text {
  text-align: center;
  font-size: 162px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  min-height: 140px;
  opacity: 0.9;
}

/* Super Text Quantum Animation */
.super-text-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  overflow: hidden;
  transition: opacity 0.6s ease-out, transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.super-text-container.fall-off {
  opacity: 0;
  transform: translateY(100vh) rotate(8deg) scale(0.8);
}

.super-text-svg {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: visible;
  pointer-events: all;
  display: block;
}

@keyframes chalkWrite {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Dragging state */
.blackboard.dragging {
  cursor: grabbing;
  transition: none;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1024px) {
  .blackboard {
    width: 40%;
  }
  
  .task-progress {
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  /* Avatar smaller */
  .tutor-avatar {
    width: 60px;
    height: 60px;
    bottom: 20px;
    left: 20px;
  }
  
  .avatar-emoji {
    font-size: 32px;
  }
  
  /* Chat takes more space */
  .chat-overlay {
    max-height: 50vh;
    border-radius: 16px 16px 0 0;
  }
  
  .chat-messages {
    padding: var(--space-md);
  }
  
  /* Blackboard becomes full-screen overlay */
  .blackboard {
    width: 100%;
    max-width: 100%;
  }
  
  /* Task progress minimized */
  .task-progress {
    top: var(--space-md);
    right: var(--space-md);
    min-width: auto;
    padding: var(--space-sm);
  }
  
  .task-progress .task-list {
    display: none;
  }
  
  /* Message max-width */
  .message {
    max-width: 90%;
  }
  
  /* Input padding */
  .chat-input-container {
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }
}

/* ========================================
   COMPETENCY INDICATOR (NEW - Phase 15)
   ======================================== */
.competency-indicator {
  position: fixed;
  top: calc(var(--space-xl) + 100px); /* Below task progress */
  right: var(--space-xl);
  background: white;
  border-radius: 12px;
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 50;
  animation: slideInRight var(--duration-medium) var(--ease-out);
  transition: all var(--duration-medium) var(--ease-in-out);
}

.competency-indicator:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.competency-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  color: #666;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.competency-icon {
  font-size: 14px;
}

.competency-level {
  margin-bottom: var(--space-sm);
}

.level-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  transition: all var(--duration-fast) var(--ease-in-out);
}

.level-badge.beginner {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  color: #b30000;
}

.level-badge.intermediate {
  background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
  color: #d63031;
}

.level-badge.advanced {
  background: linear-gradient(135deg, #74ebd5 0%, #0ac194 100%);
  color: #00695c;
}

.level-bar {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-xs);
}

.level-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 4px;
  transition: width var(--duration-slow) var(--ease-out);
}

.competency-stats {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid #f0f0f0;
}

.stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: 12px;
}

.stat-label {
  color: #666;
}

.stat-value {
  font-weight: 600;
  color: #667eea;
}

/* Animation */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================
   UTILITIES
   ======================================== */
.hidden {
  display: none !important;
}

/* ========================================
   INTERACTION BUTTONS (Adaptive UI)
   ======================================== */
.interaction-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  padding: 16px;
  animation: fadeInUp 0.3s ease-out;
}

.primary-cta {
  padding: 14px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  flex: 1;
  max-width: 280px;
}

.primary-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.primary-cta:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.secondary-cta {
  padding: 14px 28px;
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 280px;
}

.secondary-cta:hover {
  background: #f7f7ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.secondary-cta:active {
  transform: translateY(0);
}

.small-button {
  padding: 10px 20px;
  font-size: 14px;
  max-width: 240px;
  align-self: center;
}

/* Continue button (single button for graph/board) */
.continue-button {
  min-width: 260px;
}

/* Understanding buttons layout */
.interaction-buttons .understand-button,
.interaction-buttons .doubt-button {
  flex: 1;
  max-width: 220px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   EVALUATION CTAs (PHASE 17)
   ======================================== */
.evaluation-ctas {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding: 20px 16px;
  animation: fadeInUp 0.4s ease-out;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
  border-radius: 16px;
  margin: 8px 0;
}

.cta-button {
  padding: 16px 32px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  max-width: 300px;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.cta-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.cta-button:hover::before {
  width: 300px;
  height: 300px;
}

/* Primary CTA - Fix gap now / I understand */
.evaluation-ctas .primary-cta {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

.evaluation-ctas .primary-cta:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.45);
}

.evaluation-ctas .primary-cta:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

/* Secondary CTA - Mark for later */
.evaluation-ctas .secondary-cta {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.12);
}

.evaluation-ctas .secondary-cta:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
  border-color: #764ba2;
}

.evaluation-ctas .secondary-cta:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

/* Disabled CTA - Coming Soon */
.evaluation-ctas .disabled-cta {
  background: #f5f5f5;
  color: #999999;
  border: 2px solid #e0e0e0;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

.evaluation-ctas .disabled-cta:hover {
  background: #f5f5f5;
  color: #999999;
  transform: none;
  box-shadow: none;
}

.evaluation-ctas .disabled-cta:active {
  transform: none;
}

/* Disabled state */
.cta-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading state */
.cta-button.loading {
  pointer-events: none;
  opacity: 0.7;
}

.cta-button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: button-loading-spinner 1s ease infinite;
}

@keyframes button-loading-spinner {
  from {
    transform: rotate(0turn);
  }
  to {
    transform: rotate(1turn);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .evaluation-ctas {
    flex-direction: column;
    gap: 12px;
  }
  
  .cta-button {
    max-width: 100%;
  }
}



/* ================================================================
   MODEL SELECTOR - AI model toggle
   ================================================================ */

.model-selector-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  border-radius: 8px;
  border: 2px solid rgba(102, 126, 234, 0.4);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.model-label {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.model-select {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(102, 126, 234, 0.5);
  border-radius: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.model-select:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(102, 126, 234, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.model-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3);
}

.model-select option {
  background: #2d3748;
  color: white;
  padding: 8px;
  font-weight: 600;
}

/* Embedded diagnostic-widgets.css */
/* ============================================
   DIAGNOSTIC WIDGETS - MCQ & FLASHCARDS
   Center-screen, smooth animations, modern UI
   ============================================ */

/* Base Diagnostic Widget - Top Left Positioning (like blackboard but opposite side) */
/* .diagnostic-widget {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 520px;
  max-width: calc(100vw - 20px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(40px) saturate(180%);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15),
              0 4px 16px rgba(0, 0, 0, 0.10),
              0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 350 !important;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(0.98);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
} */

