/* =========================================================
   WhatsApp Floating Button
   ========================================================= */
.whatsapp-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25d366;
  color: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(37, 211, 102, 0.4);
  transition: transform 0.25s ease;
}

.whatsapp-fab:hover {
  transform: scale(1.06);
}

/* =========================================================
   Chat teaser bubble (appears automatically, never covers content)
   ========================================================= */
.chat-teaser {
  position: absolute;
  bottom: 76px;
  left: 0;
  width: 250px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 14px 30px 14px 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  cursor: pointer;
}

.chat-teaser.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 22px;
  width: 14px;
  height: 14px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  transform: rotate(45deg);
}

.chat-teaser p {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
}

.chat-teaser__close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.chat-teaser__close:hover {
  color: var(--color-text);
}

/* =========================================================
   AI Chat Widget
   ========================================================= */
.chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 2000;
  font-family: var(--font-main);
}

.chat-widget__toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gradient-accent);
  color: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(62, 166, 255, 0.4);
  transition: transform 0.25s ease;
}

.chat-widget__toggle:hover {
  transform: scale(1.06);
}

.chat-widget__toggle .icon--close {
  display: none;
}

.chat-widget.open .chat-widget__toggle .icon--chat {
  display: none;
}

.chat-widget.open .chat-widget__toggle .icon--close {
  display: block;
}

.chat-widget__panel {
  position: absolute;
  bottom: 76px;
  left: 0;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 140px));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-widget.open .chat-widget__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-widget__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}

.chat-widget__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-widget__heading {
  flex: 1;
  min-width: 0;
}

.chat-widget__heading h3 {
  font-size: 0.95rem;
  margin: 0;
}

.chat-widget__status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22e07a;
  box-shadow: 0 0 0 3px rgba(34, 224, 122, 0.2);
  flex-shrink: 0;
}

.chat-widget__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.chat-widget__close:hover {
  color: var(--color-text);
}

.chat-widget__voice-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 8px;
  cursor: pointer;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.chat-widget__voice-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.chat-widget__voice-toggle[aria-pressed="true"] {
  background: var(--gradient-accent);
  color: #05070d;
  border-color: transparent;
}

/* =========================================================
   Voice mode
   ========================================================= */
.chat-widget__panel.voice-mode {
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 120px));
}

.chat-widget__voice-stage {
  position: relative;
  flex-shrink: 0;
  height: 38%;
  background: radial-gradient(circle at 50% 35%, rgba(62, 166, 255, 0.16), var(--color-bg) 70%);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.chat-widget__voice-stage[hidden] {
  display: none;
}

.voice-stage__status {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  pointer-events: none;
}

.voice-mic-hint {
  position: absolute;
  bottom: 74px;
  left: 12px;
  right: 12px;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.45;
  color: #ff9d9d;
  background: var(--color-surface);
  border: 1px solid rgba(255, 90, 90, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.voice-mic-hint[hidden] {
  display: none;
}

.voice-lang-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px;
}

.voice-lang-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.voice-lang-btn.active {
  background: var(--gradient-accent);
  color: #05070d;
}

/* Animated voice orb — abstract audio-reactive visual, no face/avatar */
.voice-orb {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-orb__core {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gradient-accent);
  box-shadow: 0 0 36px rgba(62, 166, 255, 0.45);
  animation: orbIdle 3s ease-in-out infinite;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.voice-orb__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--color-accent-2);
  opacity: 0;
}

.chat-widget__voice-stage.speaking .voice-orb__core {
  animation: orbSpeaking 0.7s ease-in-out infinite;
}

.chat-widget__voice-stage.speaking .voice-orb__ring {
  animation: orbRing 1.3s ease-out infinite;
}

.chat-widget__voice-stage.speaking .voice-orb__ring:nth-child(2) {
  animation-delay: 0.4s;
}

.chat-widget__voice-stage.listening .voice-orb__core {
  background: #ff5a5a;
  box-shadow: 0 0 36px rgba(255, 90, 90, 0.45);
  animation: orbListening 0.9s ease-in-out infinite;
}

.chat-widget__voice-stage.listening .voice-orb__ring {
  border-color: #ff5a5a;
  animation: orbRing 1.1s ease-out infinite;
}

.chat-widget__voice-stage.listening .voice-orb__ring:nth-child(2) {
  animation-delay: 0.35s;
}

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

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

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

@keyframes orbRing {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.7); opacity: 0; }
}

.mic-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-accent);
  color: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(62, 166, 255, 0.35);
  transition: transform 0.15s ease;
}

.mic-btn:hover {
  transform: translateX(-50%) scale(1.05);
}

.mic-btn[aria-pressed="true"] {
  background: #ff5a5a;
  color: #fff;
  animation: micPulse 1.4s ease-in-out infinite;
}

.mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 90, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(255, 90, 90, 0); }
}

.chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
  color: var(--color-text);
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--gradient-accent);
  color: #05070d;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.chat-msg--error {
  align-self: center;
  background: transparent;
  color: #ff6b6b;
  font-size: 0.82rem;
  text-align: center;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

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

.chat-widget__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.suggestion-chip {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.suggestion-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.chat-widget__input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--color-border);
}

.chat-widget__input input {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9rem;
}

.chat-widget__input input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.chat-widget__send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-accent);
  color: #05070d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.chat-widget__send:hover {
  transform: scale(1.06);
}

.chat-widget__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Scrollbar polish inside chat */
.chat-widget__messages::-webkit-scrollbar {
  width: 6px;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

@media (max-width: 480px) {
  .chat-widget {
    bottom: 16px;
    left: 16px;
  }

  .chat-widget__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 72px;
    left: -8px;
  }

  .chat-teaser {
    width: min(250px, calc(100vw - 48px));
    bottom: 72px;
  }

  .whatsapp-fab {
    bottom: 16px;
    right: 16px;
  }
}
