/* ── Chat Widget ── */
.chat-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border: none;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}

.chat-widget-btn .icon-chat,
.chat-widget-btn .icon-close {
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
}

.chat-widget-btn .icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.chat-widget-btn.open .icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.chat-widget-btn.open .icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ── Widget Container ── */
#widgetPanel {
  position: fixed !important;
  bottom: 90px !important;
  right: 24px !important;
  width: 360px !important;
  height: 480px !important;
  z-index: 9998 !important;
  display: none !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

#widgetPanel.open {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.chat-widget-container * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── Chatbot Card ── */
.chatbot-container {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.chatbot-header {
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #f0f0f0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.header-info h1 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1.2;
}

.status-dot-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #888;
  margin-top: 1px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  padding: 6px 12px;
  gap: 4px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #888;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}

.mode-btn:hover {
  background: #f0f0f0;
  color: #555;
}

.mode-btn.active {
  background: #ffffff;
  color: #6366f1;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* ── Chat View ── */
.chat-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-view.active {
  display: flex;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 3px;
}

.messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

/* ── Messages ── */
.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: fadeUp 0.3s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-top: 2px;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #6366f1;
}

.message-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
}

.message.bot .message-content {
  background: #f5f5f7;
  border-top-left-radius: 4px;
}

.message.user .message-content {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-top-right-radius: 4px;
}

.message-content p {
  margin: 0;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bbb;
  animation: bounce 1.4s infinite;
}

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

/* ── Chat Input ── */
.chat-input-area {
  padding: 10px 12px 14px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: #f5f5f7;
  border-radius: 14px;
  padding: 4px 4px 4px 14px;
  transition: box-shadow 0.2s;
}

.input-wrapper:focus-within {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.chat-widget-container textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: #333;
  resize: none;
  outline: none;
  padding: 8px 0;
  max-height: 80px;
  line-height: 1.4;
}

.chat-widget-container textarea::placeholder {
  color: #aaa;
}

.send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* ── Call View ── */
.call-view {
  display: none;
  flex: 1;
  min-height: 0;
}

.call-view.active {
  display: flex;
}

.call-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.call-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  width: 100%;
}

.call-state.hidden {
  display: none;
}

.call-state h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
}

.call-description {
  font-size: 13px;
  color: #888;
  line-height: 1.5;
  max-width: 260px;
}

/* Call Illustration */
.call-illustration {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.call-icon-large {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  z-index: 1;
}

.pulse-ring {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.25);
  animation: pulse 2s ease-out infinite;
}

/* Call Action Buttons */
.call-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 32px;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 4px;
}

.call-action-btn:hover {
  transform: scale(1.03);
}

.call-action-btn:active {
  transform: scale(0.97);
}

.start-call {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

.end-call {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

/* Call Controls */
.call-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.call-control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  color: #555;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-family: inherit;
  transition: all 0.2s;
}

.call-control-btn:hover {
  background: #e5e5e5;
}

.call-control-btn.muted {
  background: #fee2e2;
  color: #ef4444;
}

.call-control-btn span {
  font-size: 9px;
  font-weight: 500;
}

/* Sound Wave */
.call-visualization {
  margin-bottom: 12px;
}

.sound-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 60px;
}

.sound-wave span {
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(to top, #6366f1, #a78bfa);
  animation: wave 1.2s ease-in-out infinite;
}

.sound-wave span:nth-child(1)  { height: 16px; animation-delay: 0.0s; }
.sound-wave span:nth-child(2)  { height: 28px; animation-delay: 0.1s; }
.sound-wave span:nth-child(3)  { height: 20px; animation-delay: 0.2s; }
.sound-wave span:nth-child(4)  { height: 36px; animation-delay: 0.3s; }
.sound-wave span:nth-child(5)  { height: 44px; animation-delay: 0.4s; }
.sound-wave span:nth-child(6)  { height: 40px; animation-delay: 0.5s; }
.sound-wave span:nth-child(7)  { height: 32px; animation-delay: 0.6s; }
.sound-wave span:nth-child(8)  { height: 24px; animation-delay: 0.7s; }
.sound-wave span:nth-child(9)  { height: 36px; animation-delay: 0.8s; }
.sound-wave span:nth-child(10) { height: 16px; animation-delay: 0.9s; }

.call-timer {
  font-size: 28px;
  font-weight: 300;
  color: #888;
  font-variant-numeric: tabular-nums;
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1.2); }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .chat-widget-container {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .chatbot-container {
    border-radius: 0;
  }

  .chat-widget-btn {
    bottom: 16px;
    right: 16px;
  }

  .chat-widget-container.open ~ .chat-widget-btn {
    display: none;
  }
}
