/* ===================================
   Chatbot Widget - Styles
   =================================== */

:root {
  --chatbot-primary: #C0CA33;
  --chatbot-primary-hover: #558B2F;
  --chatbot-bg: #ffffff;
  --chatbot-msg-user: #C0CA33;
  --chatbot-msg-agent: #f1f3f5;
  --chatbot-text: #212529;
  --chatbot-text-light: #6c757d;
  --chatbot-border: #dee2e6;
  --chatbot-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  --chatbot-radius: 12px;
  --chatbot-width: 380px;
  --chatbot-height: 540px;
}

/* --- Floating Button --- */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
}

.chatbot-toggle:hover {
  background: var(--chatbot-primary-hover);
  transform: scale(1.05);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.chatbot-toggle.chatbot-open .chatbot-icon-chat {
  display: none;
}

.chatbot-toggle.chatbot-open .chatbot-icon-close {
  display: block;
}

.chatbot-toggle:not(.chatbot-open) .chatbot-icon-close {
  display: none;
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: var(--chatbot-width);
  height: var(--chatbot-height);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--chatbot-text);
}

.chatbot-window.chatbot-visible {
  display: flex;
}

/* --- Header --- */
.chatbot-header {
  background: var(--chatbot-primary);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

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

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

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-title {
  font-weight: 600;
  font-size: 15px;
}

.chatbot-header-status {
  font-size: 12px;
  opacity: 0.85;
}

/* --- Messages --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}

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

.chatbot-msg-agent {
  align-self: flex-start;
  background: var(--chatbot-msg-agent);
  color: var(--chatbot-text);
  border-bottom-left-radius: 4px;
}

.chatbot-msg-system {
  align-self: center;
  background: transparent;
  color: var(--chatbot-text-light);
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

/* --- Typing Indicator --- */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--chatbot-msg-agent);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chatbot-typing.chatbot-active {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chatbot-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chatbot-text-light);
  border-radius: 50%;
  animation: chatbot-bounce 1.2s infinite;
}

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

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

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

/* --- Input Area --- */
.chatbot-input-area {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--chatbot-border);
  gap: 8px;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary);
}

.chatbot-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s, opacity 0.2s;
}

.chatbot-send:hover {
  background: var(--chatbot-primary-hover);
}

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

.chatbot-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* --- Markdown in Agent Messages --- */
.chatbot-msg-agent p {
  margin: 0 0 8px 0;
}

.chatbot-msg-agent p:last-child {
  margin-bottom: 0;
}

.chatbot-msg-agent strong {
  font-weight: 600;
}

.chatbot-msg-agent ul,
.chatbot-msg-agent ol {
  margin: 4px 0;
  padding-left: 20px;
}

.chatbot-msg-agent code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 13px;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
  }
}
