/* ---------- Text Chatbot Widget ---------- */
.chatbot-fab {
  position: fixed;
  right: var(--ds-space-5);
  bottom: calc(var(--ds-space-5) + 66px);
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ds-blue), var(--ds-navy-700));
  color: var(--ds-white);
  box-shadow: var(--ds-shadow-lg);
  z-index: 1030;
  cursor: pointer;
  transition: transform var(--ds-duration-fast) var(--ds-ease),
              box-shadow var(--ds-duration-fast) var(--ds-ease);
}

.chatbot-fab:hover {
  transform: translateY(-3px) scale(1.04);
  color: var(--ds-white);
}

.chatbot-fab:focus-visible {
  outline: 2px solid var(--ds-teal);
  outline-offset: 3px;
}

.chatbot-panel {
  position: fixed;
  right: var(--ds-space-5);
  bottom: var(--ds-space-5);
  width: min(390px, calc(100vw - 2rem));
  height: min(540px, calc(100vh - 104px));
  background: var(--ds-white);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
}

.chatbot-panel[hidden] {
  display: none;
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  background: linear-gradient(135deg, var(--ds-navy), var(--ds-navy-700));
  color: var(--ds-white);
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  min-width: 0;
}

.chatbot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: var(--ds-teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-title {
  margin: 0;
  font-size: var(--ds-fs-sm);
  font-weight: var(--ds-fw-semibold);
  color: var(--ds-white);
  line-height: 1.25;
}

.chatbot-subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ds-text-on-dark-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.chatbot-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--ds-radius-sm);
  background: transparent;
  color: var(--ds-text-on-dark-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--ds-duration-fast) var(--ds-ease),
              color var(--ds-duration-fast) var(--ds-ease);
}

.chatbot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ds-white);
}

.chatbot-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--ds-space-4);
  background: var(--ds-gray-50);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
}

.chatbot-msg {
  max-width: 86%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--ds-radius-md);
  font-size: var(--ds-fs-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chatbot-msg-assistant {
  align-self: flex-start;
  background: var(--ds-white);
  color: var(--ds-navy);
  border: 1px solid var(--ds-border);
  border-bottom-left-radius: 4px;
}

.chatbot-msg-user {
  align-self: flex-end;
  background: var(--ds-navy);
  color: var(--ds-white);
  border-bottom-right-radius: 4px;
}

.chatbot-msg-error {
  align-self: flex-start;
  background: #fff3f3;
  color: #a91e1e;
  border: 1px solid #f4c7c7;
  border-bottom-left-radius: 4px;
}

.chatbot-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.7rem 0.9rem;
  background: var(--ds-white);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  border-bottom-left-radius: 4px;
}

.chatbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-gray-500);
  animation: chatbot-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes chatbot-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: var(--ds-space-2) var(--ds-space-4);
  background: var(--ds-white);
  border-top: 1px solid var(--ds-border);
}

.chatbot-suggestions[hidden] {
  display: none;
}

.chatbot-chip {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-blue-50);
  color: var(--ds-navy);
  font-size: var(--ds-fs-xs);
  font-weight: var(--ds-fw-medium);
  cursor: pointer;
  transition: background-color var(--ds-duration-fast) var(--ds-ease),
              border-color var(--ds-duration-fast) var(--ds-ease);
}

.chatbot-chip:hover {
  background: var(--ds-blue-100);
  border-color: var(--ds-blue);
}

.chatbot-form {
  display: flex;
  align-items: flex-end;
  gap: var(--ds-space-2);
  padding: var(--ds-space-3);
  background: var(--ds-white);
  border-top: 1px solid var(--ds-border);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 112px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--ds-gray-300);
  border-radius: var(--ds-radius-md);
  font-family: inherit;
  font-size: var(--ds-fs-sm);
  line-height: 1.4;
  color: var(--ds-navy);
  background: var(--ds-white);
  resize: none;
  overflow-y: auto;
}

.chatbot-input:focus {
  outline: none;
  border-color: var(--ds-blue);
  box-shadow: 0 0 0 3px rgba(99, 147, 255, 0.2);
}

.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--ds-radius-md);
  background: var(--ds-blue);
  color: var(--ds-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color var(--ds-duration-fast) var(--ds-ease),
              opacity var(--ds-duration-fast) var(--ds-ease);
}

.chatbot-send-btn:hover:not(:disabled) {
  background: var(--ds-blue-600);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 575.98px) {
  .chatbot-fab {
    width: 48px;
    height: 48px;
    right: var(--ds-space-4);
    bottom: calc(var(--ds-space-4) + 60px);
  }

  .chatbot-panel {
    right: var(--ds-space-3);
    left: var(--ds-space-3);
    bottom: var(--ds-space-3);
    width: auto;
    height: min(520px, calc(100vh - 96px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-typing span {
    animation: none;
  }
}
