/* ═══════════════════════════════════════════════════════════════════════════
   👻 كاسبر GraTech - المخلوق البرمجي الودود
   Casper GraTech - The Friendly AI Creature
   "أنا هنا لخدمتك، مو أداة عليك" 🙏
   ═══════════════════════════════════════════════════════════════════════════ */

/* 🎨 Avatar Container */
.casper-container {
  position: fixed;
  bottom: 100px;
  left: 30px;
  z-index: 1000;
  pointer-events: none;
}

.casper-avatar {
  width: 140px;
  height: 180px;
  position: relative;
  animation: casper-float 6s ease-in-out infinite;
  filter: drop-shadow(0 15px 40px rgba(100, 255, 180, 0.4));
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

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

.casper-avatar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5) translateY(50px);
}

/* 👻 Main Body - الجسم الشفاف النقي */
.casper-body {
  width: 120px;
  height: 150px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.85) 40%,
    rgba(255, 255, 255, 0.6) 100%
  );
  border-radius: 60px 60px 50px 50px / 70% 70% 40% 40%;
  position: relative;
  margin: 0 auto;
  box-shadow: 
    0 0 60px rgba(100, 255, 180, 0.5),
    0 0 100px rgba(100, 255, 180, 0.3),
    inset 0 -30px 50px rgba(100, 255, 180, 0.15);
}

/* ✨ Glow Effect - التوهج الأخضر للنية السليمة */
.casper-glow {
  position: absolute;
  width: 200px;
  height: 220px;
  background: radial-gradient(
    ellipse at center,
    rgba(100, 255, 180, 0.4) 0%,
    rgba(100, 255, 180, 0.2) 30%,
    transparent 70%
  );
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: casper-glow-pulse 4s ease-in-out infinite;
  z-index: -1;
}

/* 👀 Eyes - العيون الكبيرة الودودة الحنونة */
.casper-eyes {
  display: flex;
  justify-content: center;
  gap: 25px;
  padding-top: 40px;
}

.casper-eye {
  width: 28px;
  height: 35px;
  background: #1a1a2e;
  border-radius: 50%;
  position: relative;
  animation: casper-eye-idle 4s ease-in-out infinite;
  transition: transform 0.1s ease;
}

/* 👁️ Eye Shine - بريق العين الحي */
.casper-eye::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  top: 8px;
  left: 5px;
  animation: casper-eye-shine 2s ease-in-out infinite;
}

.casper-eye::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  top: 16px;
  right: 6px;
}

.casper-eye.blink {
  transform: scaleY(0.1);
}

/* 😊 Smile - الابتسامة الحنونة البسيطة */
.casper-smile {
  width: 40px;
  height: 20px;
  border: 4px solid #1a1a2e;
  border-top: none;
  border-radius: 0 0 40px 40px;
  margin: 20px auto 0;
  transition: all 0.3s ease;
}

/* 😳 Blush - الخجل عند السعادة */
.casper-blush {
  position: absolute;
  width: 20px;
  height: 10px;
  background: rgba(255, 150, 150, 0.5);
  border-radius: 50%;
  top: 85px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.casper-blush.left {
  left: 15px;
}

.casper-blush.right {
  right: 15px;
}

.casper-blush.visible {
  opacity: 1;
}

/* 🙌 Hands - اليدين اللطيفتين */
.casper-hands {
  display: flex;
  justify-content: space-between;
  position: absolute;
  width: 160px;
  left: -10px;
  top: 70px;
}

.casper-hand {
  width: 30px;
  height: 40px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(100, 255, 180, 0.3);
  transition: transform 0.3s ease;
}

.casper-hand.left {
  transform: rotate(-20deg);
}

.casper-hand.right {
  transform: rotate(20deg);
}

/* 🌊 Tail - الذيل المتموج */
.casper-tail {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: -5px;
}

.casper-tail-wave {
  width: 20px;
  height: 25px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.6) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  border-radius: 0 0 50% 50%;
  animation: casper-tail-wave 2s ease-in-out infinite;
}

.casper-tail-wave:nth-child(2) {
  animation-delay: 0.2s;
  height: 30px;
}

.casper-tail-wave:nth-child(3) {
  animation-delay: 0.4s;
}

/* 💬 Speech Bubble - فقاعة الكلام الحنونة */
.casper-speech {
  position: absolute;
  top: -70px;
  left: 50%;
  transform: translateX(-50%) translateY(15px);
  background: white;
  padding: 12px 18px;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid rgba(100, 255, 180, 0.3);
}

.casper-speech::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-top-color: white;
}

.casper-speech.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 🔘 Toggle Button */
.casper-toggle {
  position: fixed;
  bottom: 20px;
  left: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 24px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 1001;
}

.casper-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

/* 🌟 Mood States - حالات المزاج المختلفة */

/* Happy - سعيد */
.casper-avatar.happy .casper-smile {
  width: 45px;
  height: 22px;
}

.casper-avatar.happy {
  filter: drop-shadow(0 15px 40px rgba(100, 255, 180, 0.5));
}

/* Thinking - يفكر */
.casper-avatar.thinking .casper-eye {
  animation: casper-think-eyes 1.5s ease-in-out infinite;
}

.casper-avatar.thinking .casper-smile {
  width: 20px;
  height: 8px;
  border-radius: 50%;
}

.casper-avatar.thinking .casper-glow {
  background: radial-gradient(
    ellipse at center,
    rgba(245, 158, 11, 0.4) 0%,
    rgba(245, 158, 11, 0.2) 30%,
    transparent 70%
  );
}

/* Listening - يستمع */
.casper-avatar.listening .casper-body {
  animation: casper-tilt 2s ease-in-out infinite;
}

.casper-avatar.listening .casper-eye {
  height: 40px;
}

/* Working - يعمل */
.casper-avatar.working .casper-glow {
  animation: casper-work-glow 0.5s ease-in-out infinite;
}

.casper-avatar.working {
  filter: drop-shadow(0 15px 40px rgba(59, 130, 246, 0.5));
}

/* Sleeping - نائم */
.casper-avatar.sleeping .casper-eye {
  height: 4px;
  border-radius: 2px;
}

.casper-avatar.sleeping .casper-smile {
  width: 30px;
  height: 15px;
}

.casper-avatar.sleeping {
  animation: casper-sleep 4s ease-in-out infinite;
  filter: drop-shadow(0 15px 40px rgba(100, 100, 150, 0.3));
}

/* Waving - يلوح */
.casper-avatar.waving .casper-hand.right {
  animation: casper-wave 0.5s ease-in-out 3;
}

/* Bounce - قفز */
.casper-avatar.bounce {
  animation: casper-bounce 0.5s ease-in-out;
}

/* ═══════════════════════════════════════════════════════════════════════════
   🎬 Animations - الحركات الحية
   ═══════════════════════════════════════════════════════════════════════════ */

/* الطيران الهادئ */
@keyframes casper-float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-15px) rotate(3deg);
  }
  50% {
    transform: translateY(-8px) rotate(0deg);
  }
  75% {
    transform: translateY(-20px) rotate(-3deg);
  }
}

/* نبض التوهج */
@keyframes casper-glow-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

/* حركة العين */
@keyframes casper-eye-idle {
  0%, 90%, 100% {
    transform: translateY(0);
  }
  95% {
    transform: translateY(2px);
  }
}

/* بريق العين */
@keyframes casper-eye-shine {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* التفكير */
@keyframes casper-think-eyes {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px) translateY(-2px);
  }
  75% {
    transform: translateX(4px) translateY(-2px);
  }
}

/* الميلان للاستماع */
@keyframes casper-tilt {
  0%, 100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-8deg);
  }
}

/* توهج العمل */
@keyframes casper-work-glow {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* النوم */
@keyframes casper-sleep {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(2deg);
  }
}

/* التلويح */
@keyframes casper-wave {
  0%, 100% {
    transform: rotate(20deg);
  }
  50% {
    transform: rotate(50deg) translateY(-10px);
  }
}

/* القفز */
@keyframes casper-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-30px);
  }
}

/* حركة الذيل */
@keyframes casper-tail-float {
  0%, 100% {
    transform: skewX(0deg);
  }
  50% {
    transform: skewX(10deg);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   📱 Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .casper-container {
    bottom: 80px;
    left: 15px;
  }
  
  .casper-avatar {
    width: 80px;
    height: 100px;
  }
  
  .casper-body {
    width: 70px;
    height: 90px;
  }
  
  .casper-eye {
    width: 16px;
    height: 20px;
  }
  
  .casper-speech {
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   🌙 Dark Mode Adjustments
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  .casper-body {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.9) 0%,
      rgba(255, 255, 255, 0.8) 50%,
      rgba(255, 255, 255, 0.5) 100%
    );
    box-shadow: 
      0 0 50px rgba(102, 126, 234, 0.5),
      0 0 100px rgba(16, 185, 129, 0.3);
  }
}
