/* =====================================================
   SAVORIA AI — ChatGPT Style Circle (Cart Ke Left Side)
===================================================== */

/* ============ AI CIRCLE BUTTON ============ */
.ai-circle-btn {
  position: fixed;
  bottom: 22px;
  right: 300px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
  padding: 0;
  background: transparent;
  overflow: visible;
}

/* ============ LAYER 1: BASE CIRCLE ============ */
.ai-circle-btn .base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #6bb6ff 30%, #2c5fbd 70%, #1a3d7a 100%);
  box-shadow: 
    0 8px 32px rgba(44, 95, 189, 0.6),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2),
    inset 0 4px 12px rgba(255, 255, 255, 0.3);
  animation: aiIdlePulse 3s ease-in-out infinite;
}

/* ============ LAYER 2: GLOW ============ */
.ai-circle-btn .glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(107, 182, 255, 0.5), transparent 70%);
  animation: aiGlow 3s ease-in-out infinite;
  pointer-events: none;
}

/* ============ LAYER 3: RINGS (Listening) ============ */
.ai-circle-btn .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #6bb6ff;
  opacity: 0;
  pointer-events: none;
}
.ai-circle-btn.listening .ring:nth-child(1) { animation: aiRing 1.5s infinite; }
.ai-circle-btn.listening .ring:nth-child(2) { animation: aiRing 1.5s infinite 0.5s; }
.ai-circle-btn.listening .ring:nth-child(3) { animation: aiRing 1.5s infinite 1s; }

/* ============ LAYER 4: WAVEFORM (Listening) ============ */
.ai-circle-btn .waveform {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: radial-gradient(circle, #2c5fbd 0%, #1a3d7a 100%);
}
.ai-circle-btn.listening .waveform { display: flex; }
.ai-circle-btn.listening .base { display: none; }

.ai-circle-btn .waveform span {
  width: 3px;
  background: #fff;
  border-radius: 2px;
  animation: aiWave 0.8s infinite ease-in-out;
}
.ai-circle-btn .waveform span:nth-child(1) { animation-delay: 0s; }
.ai-circle-btn .waveform span:nth-child(2) { animation-delay: 0.1s; }
.ai-circle-btn .waveform span:nth-child(3) { animation-delay: 0.2s; }
.ai-circle-btn .waveform span:nth-child(4) { animation-delay: 0.3s; }
.ai-circle-btn .waveform span:nth-child(5) { animation-delay: 0.4s; }

/* ============ LAYER 5: DOTS (Thinking) ============ */
.ai-circle-btn .dots {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #2c5fbd 0%, #1a3d7a 100%);
}
.ai-circle-btn.thinking .dots { display: flex; }
.ai-circle-btn.thinking .base { display: none; }

.ai-circle-btn .dots span {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: aiDotSpin 2s linear infinite;
}
.ai-circle-btn .dots span:nth-child(1) { animation-delay: 0s; }
.ai-circle-btn .dots span:nth-child(2) { animation-delay: 0.5s; }
.ai-circle-btn .dots span:nth-child(3) { animation-delay: 1s; }
.ai-circle-btn .dots span:nth-child(4) { animation-delay: 1.5s; }

/* ============ LAYER 6: SPEAKING BLOBS ============ */
.ai-circle-btn .blobs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: none;
  background: radial-gradient(circle at 40% 40%, #ffd9a3 0%, #e29a4a 40%, #bd7a2c 100%);
  overflow: hidden;
}
.ai-circle-btn.speaking .blobs { display: block; }
.ai-circle-btn.speaking .base { display: none; }
.ai-circle-btn.speaking .glow {
  background: radial-gradient(circle, rgba(226, 154, 74, 0.6), transparent 70%);
}

.ai-circle-btn .blobs span {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  filter: blur(6px);
  animation: aiBlob 1.2s ease-in-out infinite;
}
.ai-circle-btn .blobs span:nth-child(1) {
  width: 20px; height: 20px;
  top: 20%; left: 30%;
  animation-delay: 0s;
}
.ai-circle-btn .blobs span:nth-child(2) {
  width: 16px; height: 16px;
  top: 50%; left: 50%;
  animation-delay: 0.3s;
}
.ai-circle-btn .blobs span:nth-child(3) {
  width: 18px; height: 18px;
  top: 60%; left: 25%;
  animation-delay: 0.6s;
}
.ai-circle-btn .blobs span:nth-child(4) {
  width: 14px; height: 14px;
  top: 30%; left: 55%;
  animation-delay: 0.9s;
}

/* ============ ICON (Idle) ============ */
.ai-circle-btn .icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-circle-btn.listening .icon,
.ai-circle-btn.thinking .icon { display: none; }

/* ============ ANIMATIONS ============ */
@keyframes aiIdlePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 
      0 8px 32px rgba(44, 95, 189, 0.6),
      inset 0 -4px 12px rgba(0, 0, 0, 0.2),
      inset 0 4px 12px rgba(255, 255, 255, 0.3);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 
      0 12px 42px rgba(44, 95, 189, 0.9),
      inset 0 -4px 12px rgba(0, 0, 0, 0.2),
      inset 0 4px 12px rgba(255, 255, 255, 0.4);
  }
}

@keyframes aiGlow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.8; transform: scale(1.15); }
}

@keyframes aiRing {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes aiWave {
  0%, 100% { height: 8px; }
  50%      { height: 24px; }
}

@keyframes aiDotSpin {
  0%   { transform: rotate(0deg) translateX(18px) rotate(0deg); opacity: 1; }
  50%  { opacity: 0.4; }
  100% { transform: rotate(360deg) translateX(18px) rotate(-360deg); opacity: 1; }
}

@keyframes aiBlob {
  0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.8; }
  50%      { transform: scale(1.6) translate(4px, -4px); opacity: 0.5; }
}

/* ============ TOAST ============ */
.ai-toast {
  position: fixed;
  bottom: 110px;
  right: 230px;
  max-width: 130px;
  background: linear-gradient(135deg, #1a1a2e, #2c5fbd);
  color: #fff;
  padding: 14px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  font-family: 'Poppins', sans-serif;
}
.ai-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.ai-toast::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 26px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #2c5fbd;
}

/* ============ LISTENING OVERLAY ============ */
.ai-listening-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(8px);
}
.ai-listening-overlay.show { display: flex; }

.ai-listening-box { text-align: center; color: #fff; }
.ai-listening-box .wave {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  height: 60px;
  margin-bottom: 20px;
}
.ai-listening-box .wave span {
  width: 6px;
  background: linear-gradient(180deg, #4a90e2, #7ab8f5);
  border-radius: 3px;
  animation: waveBar 0.8s infinite ease-in-out;
}
.ai-listening-box .wave span:nth-child(1) { animation-delay: 0s; }
.ai-listening-box .wave span:nth-child(2) { animation-delay: 0.1s; }
.ai-listening-box .wave span:nth-child(3) { animation-delay: 0.2s; }
.ai-listening-box .wave span:nth-child(4) { animation-delay: 0.3s; }
.ai-listening-box .wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveBar {
  0%, 100% { height: 15px; }
  50%      { height: 55px; }
}

.ai-listening-box h3 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  margin-bottom: 8px;
}
.ai-listening-box p {
  font-size: 12px;
  color: #a0a0a0;
}

/* ============ LANGUAGE MODAL ============ */
.ai-lang-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.ai-lang-modal.show { display: flex; }

.ai-lang-box {
  background: #161616;
  border: 1px solid #262626;
  border-radius: 22px;
  padding: 24px 20px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: popIn 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.ai-lang-box h3 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: #f5f0e8;
  margin-bottom: 8px;
}
.ai-lang-box p {
  font-size: 12px;
  color: #a0a0a0;
  margin-bottom: 20px;
}
.ai-lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.ai-lang-btn {
  padding: 12px 10px;
  border: 2px solid #262626;
  border-radius: 12px;
  background: #0f0f0f;
  color: #f5f0e8;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Poppins', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ai-lang-btn .flag { font-size: 22px; }
.ai-lang-btn:active {
  background: linear-gradient(135deg, #4a90e2, #7ab8f5);
  border-color: #4a90e2;
  color: #fff;
  transform: scale(0.96);
}
.ai-lang-close {
  background: none;
  border: none;
  color: #6b6b6b;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  font-family: 'Poppins', sans-serif;
  padding: 8px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 380px) {
  .ai-circle-btn {
    width: 56px;
    height: 56px;
    bottom: 20px;
    right: 220px;
  }
  .ai-toast {
    bottom: 100px;
    right: 220px;
    max-width: 200px;
  }
}