.ai-chatbot {
  position: fixed;
  bottom: 22px;
  z-index: 1055;
  font-family: Inter, "Source Sans Pro", Arial, sans-serif;
}

.ai-chatbot-left {
  left: 22px;
}

.ai-chatbot-right {
  right: 22px;
}

.ai-chatbot-toggle {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: #19a7b8;
  color: #ffffff;
  box-shadow: 0 18px 40px rgba(14, 77, 100, 0.28);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.ai-chatbot-toggle:hover,
.ai-chatbot-toggle:focus {
  background: #117987;
  outline: none;
  transform: translateY(-3px);
}

.ai-chatbot-toggle-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0;
}

.ai-chatbot-panel {
  position: absolute;
  bottom: 74px;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 110px));
  background: #ffffff;
  border: 1px solid #d7e8ec;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(14, 77, 100, 0.28);
  overflow: hidden;
}

.ai-chatbot-left .ai-chatbot-panel {
  left: 0;
}

.ai-chatbot-right .ai-chatbot-panel {
  right: 0;
}

.ai-chatbot-header {
  background: #0e4d64;
  color: #ffffff;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.ai-chatbot-header strong,
.ai-chatbot-header span {
  display: block;
  color: #ffffff;
}

.ai-chatbot-header strong {
  font-size: 16px;
  line-height: 1.2;
}

.ai-chatbot-header span {
  font-size: 12px;
  opacity: 0.82;
  margin-top: 2px;
}

.ai-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ai-chatbot-clear,
.ai-chatbot-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.ai-chatbot-clear {
  font-size: 15px;
  font-weight: 900;
}

.ai-chatbot-messages {
  height: calc(100% - 176px);
  padding: 14px;
  overflow-y: auto;
  background: #eee8df;
}

.ai-chatbot-message-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 12px;
}

.ai-chatbot-user-row {
  justify-content: flex-end;
}

.ai-chatbot-avatar {
  width: 18px !important;
  height: 18px !important;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px !important;
  box-shadow: 0 2px 6px rgba(14, 77, 100, 0.12);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
}

.ai-chatbot-avatar svg,
.ai-chatbot-avatar img {
  display: none !important;
}

.ai-chatbot-bot-avatar {
  background: #0e4d64;
  color: #ffffff;
}

.ai-chatbot-user-avatar {
  background: #19a7b8;
  color: #ffffff;
}

.ai-chatbot-message-wrap {
  max-width: calc(92% - 26px);
}

.ai-chatbot-user-row .ai-chatbot-message-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ai-chatbot-message {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ai-chatbot-meta {
  color: #6b7f87;
  font-size: 11px;
  line-height: 1.2;
  margin-top: 4px;
  padding: 0 2px;
}

.ai-chatbot-user-row .ai-chatbot-meta {
  text-align: right;
}

.ai-chatbot-bot {
  background: #ffffff;
  color: #12313c;
  border: 1px solid #d7e8ec;
}

.ai-chatbot-bot p {
  margin: 0 0 9px;
}

.ai-chatbot-bot p:last-child,
.ai-chatbot-bot ul:last-child,
.ai-chatbot-bot pre:last-child {
  margin-bottom: 0;
}

.ai-chatbot-bot ul {
  margin: 0 0 9px;
  padding-left: 18px;
}

.ai-chatbot-bot li {
  margin: 4px 0;
}

.ai-chatbot-bot a {
  color: #0e7c8b !important;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-chatbot-bot a:hover,
.ai-chatbot-bot a:focus {
  color: #0e4d64 !important;
}

.ai-inline-code {
  display: inline;
  background: #eef6f8;
  color: #0a3b4d;
  border: 1px solid #cfe6eb;
  border-radius: 5px;
  padding: 1px 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.ai-code-block {
  margin: 10px 0;
  padding: 12px;
  background: #0f172a;
  color: #e5e7eb;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.22);
  white-space: pre;
}

.ai-code-block code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.ai-code-keyword {
  color: #7dd3fc;
  font-weight: 700;
}

.ai-code-string {
  color: #86efac;
}

.ai-code-number {
  color: #fbbf24;
}

.ai-chatbot-user {
  margin-left: auto;
  background: #19a7b8;
  color: #ffffff;
}

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

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #19a7b8;
  animation: aiTyping 1s infinite ease-in-out;
}

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

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

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

.ai-chatbot-form {
  height: 106px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #d7e8ec;
}

.ai-chatbot-form textarea {
  flex: 1 1 auto;
  width: auto;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 5px 2px;
  color: #12313c;
  font-size: 13px;
  line-height: 18px;
  outline: none;
  background: transparent;
  box-shadow: none;
}

.ai-chatbot-form textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.ai-chatbot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid #d7e8ec;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(14, 77, 100, 0.08);
}

.ai-chatbot-attach {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #0e4d64;
  cursor: pointer;
  margin: 0;
  flex: 0 0 auto;
}

.ai-chatbot-attach input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.ai-chatbot-attach span {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.ai-chatbot-form button {
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #0e4d64;
  color: #ffffff;
  font-weight: 800;
  padding: 0 13px;
  cursor: pointer;
  flex: 0 0 auto;
}

.ai-chatbot-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-chatbot-file {
  min-width: 0;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef6f8;
  color: #496672;
  border: 1px solid #cfe6eb;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-mode .ai-chatbot-panel,
body.dark-mode .ai-chatbot-form {
  background: #102f3a;
  border-color: rgba(183, 220, 227, 0.22);
}

body.dark-mode .ai-chatbot-messages {
  background: #071b22;
}

body.dark-mode .ai-chatbot-bot {
  background: #102f3a;
  color: #e7f8fa;
  border-color: rgba(183, 220, 227, 0.22);
}

body.dark-mode .ai-chatbot-meta {
  color: rgba(231, 248, 250, 0.66);
}

body.dark-mode .ai-chatbot-bot a {
  color: #6bd5df !important;
}

body.dark-mode .ai-inline-code {
  background: #071b22;
  color: #e7f8fa;
  border-color: rgba(183, 220, 227, 0.24);
}

body.dark-mode .ai-chatbot-form textarea {
  background: #071b22;
  color: #ffffff;
  border-color: rgba(183, 220, 227, 0.36);
}

body.dark-mode .ai-chatbot-attach,
body.dark-mode .ai-chatbot-file {
  background: #071b22;
  color: #e7f8fa;
  border-color: rgba(183, 220, 227, 0.24);
}

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

  .ai-chatbot-left {
    left: 16px;
  }

  .ai-chatbot-right {
    right: 16px;
  }
}
