.ai-chat-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-max);
  background: var(--bg-tertiary);
  color: var(--success);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.ai-chat-toggle:hover {
  filter: brightness(1.3);
}

.ai-chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 350px;
  height: 500px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    opacity 0.3s,
    transform 0.3s;
  transform-origin: bottom right;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.ai-chat-window.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.ai-chat-header {
  padding: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.ai-chat-header .header-info {
  display: flex;
  flex-direction: column;
}

.ai-chat-header .header-info i {
  color: var(--primary);
}

.ai-chat-footer span {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-max);
}

.ai-chat-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s;
  display: flex;
}

.ai-chat-close:hover {
  color: var(--text-primary);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.5rem 0;
  padding-left: 0.5rem;
}

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body code {
  background: var(--bg-tertiary);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

.markdown-body pre {
  background: var(--bg-tertiary);
  padding: 0.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
}

.markdown-body strong {
  font-weight: 600;
}

.ai-chat-input-area input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  transition: var(--transition);
  padding: 0 1rem;
  color: var(--text-primary);
  outline: none;
}

.ai-chat-input-area button {
  background: var(--color-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-xl);
  width: 38px;
  height: 38px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid transparent;
}

.ai-chat-input-area button:hover,
.ai-chat-input-area input:hover,
.ai-chat-input-area input:focus {
  filter: brightness(1.3);
}
.ai-chat-footer {
  padding-bottom: 0.5rem;
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-align: center;
  background: var(--bg-tertiary);
}

/* AI Chat Widget */
.ai-chat-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
}

.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message .msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-message.user .msg-bubble {
  background: var(--color-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-right-radius: 4px;
}

.chat-message.bot .msg-bubble {
  background: var(--color-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

@media (max-width: 768px) {
  .ai-chat-widget {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
  }

  .ai-chat-window {
    width: calc(100vw - 40px);
    right: 0;
    bottom: 70px;
    height: 60vh;
  }
}
