.chatbot-widget {
  --chatbot-blue: #315efb;
  --chatbot-blue-dark: #243fd2;
  --chatbot-cyan: #18a8c9;
  --chatbot-ink: #0b1f33;
  --chatbot-muted: #687c8f;
  --chatbot-line: rgba(10, 34, 57, .13);
  --chatbot-soft: #eef6ff;
  --chatbot-surface: #ffffff;
  --chatbot-shadow: 0 24px 70px rgba(13, 43, 68, .22);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  font-family: Inter, "Aptos", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--chatbot-ink);
}

.chatbot-toggle {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chatbot-surface);
  box-shadow: 0 18px 44px rgba(49, 94, 251, .30), 0 0 0 1px rgba(49, 94, 251, .12);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.chatbot-toggle:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 52px rgba(49, 94, 251, .35), 0 0 0 1px rgba(49, 94, 251, .18);
}

.chatbot-toggle:focus-visible,
.chatbot-close:focus-visible,
.chatbot-send:focus-visible,
.chatbot-input:focus-visible {
  outline: 3px solid rgba(24, 168, 201, .35);
  outline-offset: 3px;
}

.chatbot-toggle img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
}

.chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 92px;
  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 132px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(10, 34, 57, .16);
  border-radius: 20px;
  background: var(--chatbot-surface);
  box-shadow: var(--chatbot-shadow);
  transform: translateY(14px) scale(.98);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

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

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--chatbot-line);
  background: linear-gradient(135deg, #ffffff 0%, #eef7ff 62%, #eefbff 100%);
}

.chatbot-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chatbot-title img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(49, 94, 251, .14);
}

.chatbot-title strong {
  display: block;
  font-size: 15px;
  line-height: 1.15;
}

.chatbot-title span {
  display: block;
  margin-top: 3px;
  color: var(--chatbot-muted);
  font-size: 12px;
  line-height: 1.25;
}

.chatbot-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(10, 34, 57, .12);
  border-radius: 50%;
  background: rgba(255, 255, 255, .78);
  color: var(--chatbot-ink);
  cursor: pointer;
}

.chatbot-close svg {
  width: 18px;
  height: 18px;
  display: block;
}

.chatbot-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(246, 248, 251, .72), rgba(255, 255, 255, .96)),
    linear-gradient(rgba(49, 94, 251, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(49, 94, 251, .045) 1px, transparent 1px);
  background-size: auto, 34px 34px, 34px 34px;
}

.chatbot-message {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chatbot-message.bot {
  align-self: flex-start;
  border: 1px solid var(--chatbot-line);
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, .94);
  color: var(--chatbot-ink);
  box-shadow: 0 10px 24px rgba(13, 43, 68, .055);
}

.chatbot-message.user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--chatbot-blue), var(--chatbot-blue-dark));
  color: #fff;
}

.chatbot-sources {
  display: grid;
  gap: 7px;
  width: min(88%, 315px);
  margin-top: -4px;
}

.chatbot-source {
  display: block;
  padding: 9px 11px;
  border: 1px solid rgba(49, 94, 251, .14);
  border-radius: 12px;
  background: rgba(238, 246, 255, .92);
  color: #2049c9;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.chatbot-source:hover {
  border-color: rgba(49, 94, 251, .28);
  background: #e8f2ff;
}

.chatbot-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

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

.chatbot-typing i:nth-child(2) { animation-delay: .12s; }
.chatbot-typing i:nth-child(3) { animation-delay: .24s; }

@keyframes chatbotTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chatbot-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  align-self: end;
  gap: 8px;
  height: max-content;
  min-height: 58px;
  max-height: 112px;
  padding: 8px 12px;
  border-top: 1px solid var(--chatbot-line);
  background: rgba(255, 255, 255, .98);
}

.chatbot-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  max-height: 86px;
  resize: none;
  padding: 9px 12px;
  border: 1px solid rgba(10, 34, 57, .16);
  border-radius: 12px;
  color: var(--chatbot-ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
}

.chatbot-input::placeholder {
  color: #7d8d9a;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-blue), var(--chatbot-cyan));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(49, 94, 251, .24);
}

.chatbot-send:disabled {
  cursor: wait;
  opacity: .62;
}

.chatbot-send svg {
  width: 18px;
  height: 18px;
  display: block;
}

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

  .chatbot-toggle {
    width: 66px;
    height: 66px;
  }

  .chatbot-toggle img {
    width: 52px;
    height: 52px;
  }

  .chatbot-panel {
    right: -8px;
    bottom: 82px;
    width: calc(100vw - 24px);
    height: min(520px, calc(100vh - 112px));
    border-radius: 18px;
  }

  .chatbot-message {
    max-width: 92%;
  }
}
