#ai-chatbot-widget {
  --ai-primary: #42B1E0;
  --ai-primary-dark: #42B1E0;
  --ai-danger: #F00000;
  --ai-bg: #ffffff;
  --ai-bubble-bot: #f0f2f8;
  --ai-text: #1f2430;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#ai-chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 108, 247, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#ai-chatbot-toggle:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(79, 108, 247, 0.55);
}

#ai-chatbot-toggle svg {
  width: 26px;
  height: 26px;
}

#ai-chatbot-box {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  height: 540px;
  max-height: 540px;
  background: var(--ai-bg);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(79, 108, 247, 0.24), 0 4px 12px rgba(79, 108, 247, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

#ai-chatbot-box:not(.ai-chatbot-hidden) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#ai-chatbot-box.ai-chatbot-hidden {
  display: flex;
}

.ai-chatbot-header {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
  color: #fff;
  padding: 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chatbot-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chatbot-header-avatar svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.ai-chatbot-header-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.ai-chatbot-header-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chatbot-header-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.ai-chatbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
  display: inline-block;
}

.ai-chatbot-header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.ai-chatbot-header-btn svg {
  width: 15px;
  height: 15px;
}

.ai-chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-chatbot-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.ai-chatbot-tabs::-webkit-scrollbar {
  height: 4px;
}

.ai-chatbot-tabs::-webkit-scrollbar-thumb {
  background: #d7dae3;
  border-radius: 6px;
}

.ai-chatbot-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--ai-bubble-bot);
  color: var(--ai-text);
  border-radius: 16px;
  padding: 0px 5px;
  font-size: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ai-chatbot-tab:hover {
  background: #e6e9f3;
}

.ai-chatbot-tab.ai-chatbot-tab-active {
  background: rgba(79, 108, 247, 0.12);
  border-color: var(--ai-primary);
  color: var(--ai-primary-dark);
  font-weight: 600;
}

.ai-chatbot-tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--ai-danger);
}

.ai-chatbot-tab-close svg {
  width: 20px;
  height: 20px;
}

.ai-chatbot-tab-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.ai-chatbot-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px dashed #c7cce0;
  background: #fff;
  color: var(--ai-primary);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ai-chatbot-tab-add svg {
  width: 13px;
  height: 13px;
}

.ai-chatbot-tab-add:hover {
  background: #f0f2f8;
}

.ai-chatbot-messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  background: #fafbfd;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-chatbot-msg {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 82%;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: ai-chatbot-fade-in 0.18s ease;
}

@keyframes ai-chatbot-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chatbot-msg-user {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.ai-chatbot-msg-assistant {
  background: var(--ai-bubble-bot);
  color: var(--ai-text);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.ai-chatbot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px 10px;
  background: #fafbfd;
}

.ai-chatbot-typing.ai-chatbot-hidden {
  display: none;
}

.ai-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9bfd1;
  animation: ai-chatbot-bounce 1.2s infinite ease-in-out;
}

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

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

#ai-chatbot-form {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center !important;
  gap: 8px;
  border-top: 1px solid #eef0f5;
  padding: 10px 12px;
  background: #fff;
  flex-shrink: 0;
}

#ai-chatbot-form > #ai-chatbot-input {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: 40px !important;
  margin: 0 !important;
  vertical-align: top !important;
  box-sizing: border-box;
  border: 1px solid #e3e6ee;
  background: #f6f7fb;
  border-radius: 22px;
  padding: 0 16px;
  font-size: 14px;
  line-height: 38px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#ai-chatbot-form > #ai-chatbot-input:focus {
  border-color: var(--ai-primary);
  background: #fff;
}

#ai-chatbot-form > button[type="submit"] {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  box-sizing: border-box;
  flex-shrink: 0 !important;
  align-self: center !important;
  margin: 0 !important;
  position: static !important;
  vertical-align: top !important;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

#ai-chatbot-form > button[type="submit"]:hover {
  transform: scale(1.06);
}

#ai-chatbot-form > button[type="submit"] svg {
  width: 17px;
  height: 17px;
}

.ai-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d7dae3;
  border-radius: 6px;
}

@media (max-width: 480px) {
  #ai-chatbot-widget {
    bottom: 16px;
    right: 16px;
  }

  #ai-chatbot-box {
    width: calc(100vw - 32px);
    right: -8px;
    height: min(540px, calc(100vh - 120px));
    max-height: calc(100vh - 120px);
  }
}
