/* SAFI Avatar - Living AI Persona */

.safi-avatar-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  perspective: 1200px;
}

.safi-avatar-wrapper {
  position: relative;
  border-radius: 24px;
  overflow: visible;
  background: linear-gradient(135deg, 
    rgba(0,100,255,0.08), 
    rgba(0,255,200,0.08),
    rgba(100,0,255,0.05)
  );
  padding: 24px;
  backdrop-filter: blur(12px);
  border: 2px solid rgba(0,200,255,0.3);
  box-shadow: 
    0 8px 32px rgba(0,150,255,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  animation: subtleFloat 7s ease-in-out infinite;
  transition: transform 0.3s ease-out;
}

.safi-avatar-image {
  width: 100%;
  height: auto;
  border-radius: 16px;
  display: block;
  position: relative;
  z-index: 2;
  animation: breathe 5s ease-in-out infinite;
  filter: brightness(1.08) contrast(1.12) saturate(1.1);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  pointer-events: auto;
}

.safi-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 130%;
  height: 130%;
  background: radial-gradient(
    circle, 
    rgba(0,180,255,0.4) 0%, 
    rgba(0,255,180,0.2) 30%,
    transparent 70%
  );
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation: pulseGlow 4s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
  filter: blur(20px);
}

.safi-glow-secondary {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 150%;
  background: radial-gradient(
    circle, 
    rgba(100,0,255,0.25) 0%, 
    rgba(0,255,150,0.15) 40%,
    transparent 70%
  );
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation: pulseGlow 4s ease-in-out infinite 2s;
  z-index: -1;
  pointer-events: none;
  filter: blur(25px);
}

@keyframes breathe {
  0%, 100% {
    transform: scale(1) translateZ(0);
  }
  50% {
    transform: scale(1.025) translateZ(10px);
  }
}

@keyframes subtleFloat {
  0%, 100% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
  33% {
    transform: translateY(-10px) rotateX(2deg) rotateY(-1deg);
  }
  66% {
    transform: translateY(-5px) rotateX(-1deg) rotateY(2deg);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.safi-status {
  position: absolute;
  bottom: 35px;
  right: 35px;
  width: 14px;
  height: 14px;
  background: #00ff88;
  border-radius: 50%;
  box-shadow: 
    0 0 20px rgba(0,255,136,1),
    0 0 40px rgba(0,255,136,0.5);
  z-index: 20;
  animation: statusPulse 2s ease-in-out infinite;
  border: 2px solid rgba(255,255,255,0.3);
  pointer-events: none;
}

.safi-status::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  background: rgba(0,255,136,0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ripple 2s ease-out infinite;
}

.safi-status.thinking {
  background: #ffaa00;
  box-shadow: 
    0 0 20px rgba(255,170,0,1),
    0 0 40px rgba(255,170,0,0.5);
  animation: statusThinking 0.6s ease-in-out infinite;
}

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

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

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

.safi-voice-wave {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.3s;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
  border-radius: 25px;
  padding: 10px;
  pointer-events: none;
  z-index: 15;
}

.safi-voice-wave.active {
  opacity: 1;
}

.wave-bar {
  width: 4px;
  height: 6px;
  background: linear-gradient(to top, #00ff88, #0088ff, #8800ff);
  border-radius: 3px;
  animation: waveAnimation 1.2s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(0,255,136,0.6);
  pointer-events: none;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.5s; }
.wave-bar:nth-child(7) { animation-delay: 0.4s; }
.wave-bar:nth-child(8) { animation-delay: 0.3s; }
.wave-bar:nth-child(9) { animation-delay: 0.2s; }
.wave-bar:nth-child(10) { animation-delay: 0.1s; }

@keyframes waveAnimation {
  0%, 100% { 
    height: 6px; 
    opacity: 0.5;
  }
  50% { 
    height: 30px; 
    opacity: 1;
  }
}

.safi-response {
  margin-top: 25px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(0,20,40,0.6), rgba(0,40,80,0.4));
  border-radius: 16px;
  border-left: 4px solid #00ff88;
  border-right: 1px solid rgba(0,255,136,0.2);
  font-size: 16px;
  line-height: 1.7;
  color: #fff;
  min-height: 80px;
  box-shadow: 
    0 4px 20px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
  overflow: hidden;
  z-index: 10;
  pointer-events: auto;
}

.safi-response::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(0,255,136,0.5), 
    transparent
  );
  animation: scanline 3s linear infinite;
  pointer-events: none;
}

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

.typing-cursor {
  display: inline-block;
  width: 3px;
  height: 1.2em;
  background: #00ff88;
  margin-left: 3px;
  animation: blink 0.9s step-end infinite;
  box-shadow: 0 0 8px rgba(0,255,136,0.8);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.safi-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
  border-radius: 24px;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(0,255,200,0.8);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0,255,200,0.8);
  animation: particleFloat 5s linear infinite;
  pointer-events: none;
}

.particle:nth-child(odd) {
  background: rgba(100,0,255,0.6);
  box-shadow: 0 0 6px rgba(100,0,255,0.6);
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-120px) translateX(30px);
    opacity: 0;
  }
}

.safi-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(0,255,200,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,200,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 3;
  opacity: 0.3;
  border-radius: 16px;
}

.safi-hologram-lines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,255,200,0.03) 0px,
    rgba(0,255,200,0.03) 2px,
    transparent 2px,
    transparent 4px
  );
  pointer-events: none;
  z-index: 4;
  animation: hologramScan 4s linear infinite;
  border-radius: 16px;
  opacity: 0.4;
}

@keyframes hologramScan {
  0% { transform: translateY(0); }
  100% { transform: translateY(20px); }
}

@media (max-width: 768px) {
  .safi-avatar-container {
    max-width: 320px;
  }
  
  .safi-avatar-wrapper {
    padding: 16px;
  }
  
  .safi-response {
    font-size: 14px;
    padding: 18px;
  }
  
  .safi-status {
    bottom: 25px;
    right: 25px;
    width: 12px;
    height: 12px;
  }
  
  .wave-bar {
    width: 3px;
  }
}

.safi-avatar-container.loading .safi-avatar-wrapper {
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% {
    border-color: rgba(0,200,255,0.3);
    box-shadow: 0 8px 32px rgba(0,150,255,0.3);
  }
  50% {
    border-color: rgba(0,255,200,0.6);
    box-shadow: 0 8px 48px rgba(0,255,200,0.5);
  }
}
