/* ===================================================
   AI ANIMATIONS & EFFECTS
=================================================== */

/* AI Particles Animation for Hero */
.hero-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 60% 70%, white, transparent),
    radial-gradient(1px 1px at 50% 50%, white, transparent),
    radial-gradient(1px 1px at 80% 10%, white, transparent),
    radial-gradient(2px 2px at 90% 60%, white, transparent),
    radial-gradient(1px 1px at 33% 80%, white, transparent);
  background-size: 200% 200%;
  background-position: 0% 0%;
  animation: particleFloat 20s ease-in-out infinite;
  opacity: 0.4;
  pointer-events: none;
  z-index: 1;
}

@keyframes particleFloat {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

/* AI Brain Icon Animation */
.ai-brain-icon {
  display: inline-block;
  animation: brainPulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.5));
}

@keyframes brainPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* AI Chat Bubble Animation */
.ai-chat-container {
  position: relative;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  border: 2px solid #0ea5e9;
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.15);
}

.ai-chat-bubble {
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  animation: slideInRight 0.5s ease-out;
  border-right: 3px solid #0ea5e9;
}

.ai-chat-bubble.user {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white;
  border-right: none;
  border-left: 3px solid #1e40af;
  animation: slideInLeft 0.5s ease-out;
}

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

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

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem 1rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #0ea5e9;
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
  30% { transform: translateY(-10px); opacity: 1; }
}

/* AI Avatar */
.ai-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  animation: avatarGlow 2s ease-in-out infinite;
}

@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(14, 165, 233, 0.6); }
}

/* Interactive Button with Hover Effect */
.ai-button {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
  position: relative;
  overflow: hidden;
}

.ai-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;
}

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

.ai-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(14, 165, 233, 0.5);
}

.ai-button:active {
  transform: translateY(0);
}

/* Gradient Text Animation */
.gradient-text {
  background: linear-gradient(90deg, #0ea5e9, #2563eb, #7c3aed, #0ea5e9);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s linear infinite;
  font-weight: 700;
}

@keyframes gradientShift {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* Code Block with AI Theme */
.ai-code-block {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.25rem;
  border-radius: 12px;
  font-family: 'Courier New', monospace;
  position: relative;
  overflow: hidden;
  border: 1px solid #334155;
}

.ai-code-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #0ea5e9, #2563eb, #7c3aed);
  animation: codeLineMove 2s linear infinite;
}

@keyframes codeLineMove {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Sparkle Effect */
.sparkle {
  position: relative;
  display: inline-block;
}

.sparkle::after {
  content: '✨';
  position: absolute;
  top: -10px;
  right: -10px;
  animation: sparkleFloat 2s ease-in-out infinite;
}

@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 1; }
  50% { transform: translateY(-5px) rotate(180deg); opacity: 0.7; }
}

/* Loading Spinner AI Style */
.ai-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(14, 165, 233, 0.2);
  border-top-color: #0ea5e9;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Pulse Effect for Important Elements */
.pulse-effect {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(14, 165, 233, 0.3); }
  50% { box-shadow: 0 0 25px rgba(14, 165, 233, 0.6); }
}

/* Hover Lift Effect */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(14, 165, 233, 0.25);
}

/* Enhanced Hero Section */
.hero-section {
  position: relative;
  z-index: 1;
}

.hero-section > * {
  position: relative;
  z-index: 2;
}

/* Animated Gradient Background */
.gradient-bg {
  background: linear-gradient(-45deg, #0ea5e9, #2563eb, #7c3aed, #0891b2);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Floating Animation */
.float-animation {
  animation: floatUpDown 3s ease-in-out infinite;
}

@keyframes floatUpDown {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* Shine Effect on Buttons */
.ai-button {
  position: relative;
  overflow: hidden;
}

.ai-button::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { left: -50%; }
  100% { left: 150%; }
}

/* Card Flip Effect */
.flip-card {
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* Neon Glow Effect */
.neon-glow {
  text-shadow: 
    0 0 5px rgba(14, 165, 233, 0.5),
    0 0 10px rgba(14, 165, 233, 0.4),
    0 0 20px rgba(14, 165, 233, 0.3),
    0 0 40px rgba(14, 165, 233, 0.2);
  animation: neonPulse 2s ease-in-out infinite;
}

@keyframes neonPulse {
  0%, 100% { 
    text-shadow: 
      0 0 5px rgba(14, 165, 233, 0.5),
      0 0 10px rgba(14, 165, 233, 0.4),
      0 0 20px rgba(14, 165, 233, 0.3);
  }
  50% { 
    text-shadow: 
      0 0 10px rgba(14, 165, 233, 0.8),
      0 0 20px rgba(14, 165, 233, 0.6),
      0 0 30px rgba(14, 165, 233, 0.4),
      0 0 40px rgba(14, 165, 233, 0.2);
  }
}

/* Progress Bar Animation */
.progress-animated {
  position: relative;
  overflow: hidden;
}

.progress-animated::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Bounce In Animation */
.bounce-in {
  animation: bounceIn 0.8s ease-out;
}

@keyframes bounceIn {
  0% { 
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* Slide In From Right */
.slide-in-right {
  animation: slideInFromRight 0.6s ease-out;
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide In From Left */
.slide-in-left {
  animation: slideInFromLeft 0.6s ease-out;
}

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

/* Rotate In */
.rotate-in {
  animation: rotateIn 0.6s ease-out;
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg) scale(0);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

/* Fade In Up */
.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

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

/* Heartbeat Animation */
.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  10%, 30% { transform: scale(0.9); }
  20%, 40% { transform: scale(1.1); }
}

/* Shake Animation */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Glow Border */
.glow-border {
  position: relative;
  border: 2px solid transparent;
  background: linear-gradient(white, white) padding-box,
              linear-gradient(45deg, #0ea5e9, #2563eb, #7c3aed) border-box;
  animation: borderGlow 3s linear infinite;
}

@keyframes borderGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .ai-chat-bubble {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }
  
  .ai-avatar {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .ai-button {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}

/* Ripple Effect Animation */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* Enhanced AI Chat Bubbles with Delay */
.ai-chat-bubble:nth-child(2) {
  animation-delay: 0.1s;
}

.ai-chat-bubble:nth-child(3) {
  animation-delay: 0.2s;
}

.ai-chat-bubble:nth-child(4) {
  animation-delay: 0.3s;
}

.ai-chat-bubble:nth-child(5) {
  animation-delay: 0.4s;
}

/* Smooth Scroll Behavior */
html {
  scroll-behavior: smooth;
}

/* Enhanced Badge Animations */
.badge {
  transition: all 0.3s ease;
}

.badge:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Card Hover Effects */
.card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* Gradient Text Hover */
.gradient-text:hover {
  animation-play-state: paused;
}

/* AI Avatar Hover */
.ai-avatar:hover {
  transform: scale(1.1) rotate(5deg);
  transition: transform 0.3s ease;
}

/* Enhanced Typing Indicator */
.typing-indicator {
  display: inline-flex;
}

/* Smooth Transitions for All Interactive Elements */
button, a, .nav-link {
  transition: all 0.3s ease;
}

/* Focus States for Accessibility */
button:focus, a:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* Loading State */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Success State */
.success-state {
  animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); background-color: #10b981; }
  100% { transform: scale(1); }
}

/* Error State */
.error-state {
  animation: errorShake 0.5s ease-out;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Tooltip Style */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  padding: 0.5rem 0.75rem;
  background: #1e293b;
  color: white;
  border-radius: 6px;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* Print Styles */
@media print {
  .navbar, #scrollTopBtn, .ai-button, .typing-indicator {
    display: none !important;
  }
  
  .ai-chat-container {
    break-inside: avoid;
  }
  
  .chapter-section {
    page-break-inside: avoid;
  }
}
