/* ——— CHATBOT WIDGET ——— */
.chatbot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2000;
  font-family: var(--font);
}

/* Toggle button */
.chatbot__toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--red-soft);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(255, 84, 73, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}

.chatbot__toggle:hover {
  transform: translateY(-2px);
  background: #ff6a5f;
}

.chatbot__toggle-icon {
  width: 26px;
  height: 26px;
  position: absolute;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chatbot__toggle-icon--chat {
  transform-origin: 50% 85%;
  animation: bot-wave-breathe 4s ease-in-out infinite;
}

.chatbot__toggle-icon--close {
  opacity: 0;
  transform: scale(0.6) rotate(-45deg);
}

.chatbot.is-open .chatbot__toggle-icon--chat {
  opacity: 0;
}

.chatbot.is-open .chatbot__toggle-icon--close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

@keyframes bot-wave-breathe {
  0%,
  55%,
  100% {
    transform: scale(1) rotate(0deg);
  }
  5% {
    transform: scale(1.1) rotate(-14deg);
  }
  15% {
    transform: scale(1.15) rotate(12deg);
  }
  25% {
    transform: scale(1.05) rotate(-8deg);
  }
  35% {
    transform: scale(1.12) rotate(6deg);
  }
  45% {
    transform: scale(1) rotate(-3deg);
  }
}

.chatbot__toggle-dots {
  position: absolute;
  top: -8px;
  right: -10px;
  display: flex;
  gap: 3px;
  background: var(--ink);
  border-radius: 999px;
  padding: 5px 7px;
  border: 2px solid var(--white);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chatbot.is-open .chatbot__toggle-dots {
  opacity: 0;
  transform: scale(0.6);
}

.chatbot__toggle-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--white);
  display: inline-block;
  animation: dot-pop 1.2s infinite;
}

.chatbot__toggle-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.chatbot__toggle-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.chatbot__toggle-dot--accent {
  background: var(--red-soft);
}

@keyframes dot-pop {
  0%,
  60%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-3px) scale(1.25);
    opacity: 1;
  }
}

/* Greeting bubble */
.chatbot__greeting {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 240px;
  background: var(--white);
  color: var(--light-ink);
  border-radius: 16px 16px 4px 16px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: chatbot-pop 0.25s ease;
}

.chatbot__greeting p {
  font-size: 0.88rem;
  line-height: 1.4;
  padding-right: 0.75rem;
}

.chatbot__greeting-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--light-muted);
  padding: 2px;
}

@keyframes chatbot-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Panel */
.chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatbot-pop 0.2s ease;
}

.chatbot__panel[hidden] {
  display: none;
}

.chatbot__header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--red-soft), #c9332a);
  color: var(--white);
  flex-shrink: 0;
}

.chatbot__header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 6px;
}

.chatbot__header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chatbot__header-info {
  flex: 1;
  min-width: 0;
}

.chatbot__header-name {
  font-size: 0.92rem;
  font-weight: 700;
}

.chatbot__header-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chatbot__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ddc84;
  display: inline-block;
}

.chatbot__close {
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chatbot__msg {
  max-width: 84%;
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  animation: chatbot-pop 0.15s ease;
}

.chatbot__msg--bot {
  align-self: flex-start;
  background: var(--card-hover);
  color: var(--white);
  border-bottom-left-radius: 4px;
}

.chatbot__msg--user {
  align-self: flex-end;
  background: var(--red-soft);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.chatbot__msg--typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.7rem 0.9rem;
}

.chatbot__msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chatbot-typing 1s infinite ease-in-out;
}

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

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

.chatbot__action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chatbot__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  flex-shrink: 0;
}

.chatbot__chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--white);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chatbot__chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.chatbot__input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.chatbot__input {
  flex: 1;
  background: var(--card-hover);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.85rem;
}

.chatbot__input:focus {
  outline: none;
  border-color: var(--red-soft);
}

.chatbot__input::placeholder {
  color: var(--muted);
}

.chatbot__send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--red-soft);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.chatbot__send:hover {
  background: #ff6a5f;
}

.chatbot__messages::-webkit-scrollbar {
  width: 6px;
}
.chatbot__messages::-webkit-scrollbar-thumb {
  background: var(--red);
  border-radius: 999px;
}
.chatbot__messages::-webkit-scrollbar-thumb:hover {
  background: var(--red-soft);
}

@media (max-width: 640px) {
  .chatbot {
    right: 16px;
    bottom: 16px;
  }

  .chatbot__panel {
    right: -16px;
    bottom: 76px;
    width: calc(100vw - 24px);
    height: min(70vh, 560px);
  }

  .chatbot__greeting {
    right: -16px;
    width: 220px;
  }
}
