:root {
  --chat-primary: #0b63f6;
  --chat-primary-dark: #084fc5;
  --chat-bg: #ffffff;
  --chat-surface: #f5f8ff;
  --chat-border: #dbe3f0;
  --chat-text: #13213d;
  --chat-muted: #6b7896;
  --chat-shadow: 0 16px 40px rgba(15, 41, 88, 0.24);
}

.chatbot-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1400;
  font-family: "Inter", sans-serif;
}

.chatbot-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(140deg, var(--chat-primary), #3392ff);
  color: #fff;
  box-shadow: 0 0 0 8px rgba(11, 99, 246, 0.2), 0 18px 44px rgba(15, 41, 88, 0.34);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: chatButtonGlow 1.8s ease-in-out infinite;
}

.chatbot-toggle::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 999px;
  border: 3px solid rgba(11, 99, 246, 0.65);
  animation: chatRingPulse 1.6s ease-out infinite;
}

.chatbot-toggle::after {
  content: "";
  position: absolute;
  inset: -20px;
  border-radius: 999px;
  border: 2px solid rgba(51, 146, 255, 0.55);
  animation: chatRingPulseOuter 2.2s ease-out infinite;
}

.chatbot-toggle:hover,
.chatbot-toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 46px rgba(15, 41, 88, 0.3);
}

.chatbot-scroll-hint {
  position: absolute;
  right: 78px;
  bottom: 12px;
  background: #123069;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(18, 48, 105, 0.25);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.chatbot-scroll-hint.visible {
  opacity: 1;
  transform: translateY(0);
}

.chatbot-scroll-hint::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #123069;
  transform: translateY(-50%) rotate(45deg);
}

.chatbot-window {
  width: min(380px, calc(100vw - 24px));
  height: min(600px, calc(100vh - 92px));
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  position: absolute;
  right: 0;
  bottom: 80px;
}

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

.chatbot-header {
  background: linear-gradient(150deg, #0b2f7d 10%, #0b63f6 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chatbot-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.chatbot-step {
  margin: 2px 0 0;
  font-size: 0.77rem;
  color: rgba(255, 255, 255, 0.85);
}

.chatbot-actions {
  display: flex;
  gap: 8px;
}

.chatbot-icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.36);
  background: transparent;
  color: #fff;
  border-radius: 9px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.chatbot-body {
  flex: 1;
  background: linear-gradient(180deg, #f8faff 0%, #fff 40%);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 82%;
  border-radius: 14px;
  padding: 9px 11px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.msg.bot {
  background: #eef4ff;
  color: var(--chat-text);
  border: 1px solid #dde9ff;
  align-self: flex-start;
}

.msg.user {
  background: #0d6efd;
  color: #fff;
  align-self: flex-end;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 8px;
}

.quick-reply {
  border: 1px solid #c7d5ee;
  background: #fff;
  color: #123069;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.81rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.quick-reply:hover,
.quick-reply:focus-visible {
  background: #edf3ff;
  border-color: #9db6e2;
}

.chatbot-input-wrap {
  padding: 10px;
  border-top: 1px solid var(--chat-border);
  background: #fff;
}

.chatbot-input-row {
  display: flex;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  border: 1px solid #c9d4ea;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.88rem;
  outline: none;
}

.chatbot-input:focus {
  border-color: #4f83ea;
  box-shadow: 0 0 0 3px rgba(79, 131, 234, 0.15);
}

.chatbot-send {
  border: 0;
  border-radius: 12px;
  background: var(--chat-primary);
  color: #fff;
  padding: 0 15px;
  font-weight: 600;
  cursor: pointer;
}

.chatbot-send:hover,
.chatbot-send:focus-visible {
  background: var(--chat-primary-dark);
}

.chatbot-input-note,
.chatbot-error {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--chat-muted);
}

.chatbot-error {
  color: #bf1f1f;
}

.typing {
  width: 44px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  background: #7b8fb8;
  border-radius: 999px;
  animation: dotPulse 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.14s; }
.typing span:nth-child(3) { animation-delay: 0.28s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.72); opacity: 0.55; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes chatRingPulse {
  0% {
    transform: scale(0.82);
    opacity: 0.95;
  }
  75% {
    transform: scale(1.24);
    opacity: 0;
  }
  100% {
    transform: scale(1.24);
    opacity: 0;
  }
}

@keyframes chatRingPulseOuter {
  0% {
    transform: scale(0.88);
    opacity: 0.72;
  }
  80% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes chatButtonGlow {
  0%, 100% {
    box-shadow: 0 0 0 8px rgba(11, 99, 246, 0.2), 0 18px 44px rgba(15, 41, 88, 0.34);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(11, 99, 246, 0.28), 0 24px 52px rgba(15, 41, 88, 0.42);
  }
}

@media (max-width: 640px) {
  .chatbot-widget { right: 8px; bottom: 8px; }
  .chatbot-window {
    width: calc(100vw - 16px);
    height: min(580px, calc(100vh - 84px));
    right: 0;
  }
  .chatbot-toggle {
    width: 58px;
    height: 58px;
  }
  .chatbot-scroll-hint {
    right: 70px;
    bottom: 10px;
    font-size: 0.78rem;
  }
}
