#chatbot-root {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
}

#chatbot-toggle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(49, 87, 213, 0.35);
  transition: transform 200ms ease, box-shadow 200ms ease, background 200ms ease;
}

#chatbot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(49, 87, 213, 0.4);
  background: var(--primary-dark);
}

#chatbot-toggle svg {
  width: 1.6rem;
  height: 1.6rem;
}

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

#chatbot-panel {
  position: fixed;
  right: 1rem;
  bottom: 5.5rem;
  width: min(22rem, calc(100vw - 2rem));
  height: min(30rem, calc(100vh - 6.5rem));
  height: min(30rem, calc(100dvh - 6.5rem));
  max-height: calc(100dvh - 6.5rem);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  border-radius: 1.25rem;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

#chatbot-header {
  padding: 1rem 1.1rem;
  background: var(--primary);
  color: white;
}

#chatbot-header strong {
  display: block;
  font-size: 0.95rem;
}

#chatbot-header span {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}

#chatbot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.88rem;
}

.chatbot-msg {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chatbot-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

.chatbot-msg.assistant {
  align-self: flex-start;
  background: rgba(49, 87, 213, 0.09);
  color: var(--text-main);
  border-bottom-left-radius: 0.25rem;
}

.chatbot-msg.error {
  align-self: center;
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  font-size: 0.8rem;
}

#chatbot-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

#chatbot-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-size: 0.88rem;
  font-family: inherit;
}

#chatbot-input:focus {
  outline: none;
  border-color: var(--primary);
}

#chatbot-form button[type='submit'] {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.8rem;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

#chatbot-form button[type='submit']:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#chatbot-form button[type='submit'] svg {
  width: 1.1rem;
  height: 1.1rem;
}

@media (max-width: 480px) {
  #chatbot-panel {
    right: 0.75rem;
    bottom: 5rem;
    width: calc(100vw - 1.5rem);
    height: min(30rem, calc(100dvh - 6rem));
    max-height: calc(100dvh - 6rem);
    border-radius: 1rem;
  }
}
