/* AI Live Support Chatbot widget styles. */

.chatbot-widget[hidden] { display: none !important; }

.chatbot-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --chatbot-accent: #5b6cf2;
  --chatbot-accent-dark: #4c5de4;
  --chatbot-bg: #ffffff;
  --chatbot-bg-secondary: #f5f6fa;
  --chatbot-text: #1a1a2e;
  --chatbot-text-secondary: #6b7280;
  --chatbot-border: #e2e4ec;
  --chatbot-shadow: 0 12px 40px rgba(20, 20, 50, 0.18);
  --chatbot-user-bubble: var(--chatbot-accent);
  --chatbot-user-bubble-text: #ffffff;
  --chatbot-assistant-bubble: #f0f1f8;
  --chatbot-assistant-bubble-text: var(--chatbot-text);
}

.chatbot-widget.chatbot-widget--dark {
  --chatbot-bg: #17162a;
  --chatbot-bg-secondary: #1e1c38;
  --chatbot-text: #f0f0f5;
  --chatbot-text-secondary: #a3a3b8;
  --chatbot-border: #2c2a48;
  --chatbot-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --chatbot-assistant-bubble: #232140;
  --chatbot-assistant-bubble-text: #f0f0f5;
}

.chatbot-launcher-container {
  position: relative;
  display: flex;
  align-items: flex-start;
  min-height: 60px;
  max-width: 60px;
  max-height: 60px;
  border-radius: 30px;
  background: var(--chatbot-assistant-bubble);
  box-shadow: var(--chatbot-shadow);
  overflow: hidden;
  /* the "expanding launcher": widening (and, once the text needs to wrap,
     heightening) this container is what makes the avatar look like it
     physically stretches out to reveal the nudge text */
  transition: max-width 0.4s cubic-bezier(0.34, 1.15, 0.64, 1),
    max-height 0.4s cubic-bezier(0.34, 1.15, 0.64, 1);
}
.chatbot-launcher-container[data-expanded="true"] {
  max-width: 260px;
  max-height: 180px;
}
.chatbot-widget[data-state="open"] .chatbot-launcher-container {
  max-width: 60px !important;
  max-height: 60px !important;
}

.chatbot-launcher {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s ease;
}
.chatbot-launcher:hover { transform: scale(1.06); }
.chatbot-launcher-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transform: scale(1.2); /* crops the source image's white ring border out of frame */
}
.chatbot-launcher-icon-close { display: none; font-size: 22px; }
.chatbot-widget[data-state="open"] .chatbot-launcher-avatar { display: none; }
.chatbot-widget[data-state="open"] .chatbot-launcher-icon-close { display: inline-block; }

.chatbot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--chatbot-bg);
  border-radius: 16px;
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.chatbot-widget[data-state="open"] .chatbot-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--chatbot-accent), var(--chatbot-accent-dark));
  color: #fff;
  flex-shrink: 0;
}
.chatbot-header-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.chatbot-header-avatar-wrap {
  position: relative; display: inline-flex; flex-shrink: 0;
  width: 26px; height: 26px;
}
.chatbot-header-avatar-clip {
  display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}
.chatbot-header-avatar {
  width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.2); /* crops the source image's white ring border out of frame */
}
.chatbot-header-dot {
  position: absolute; bottom: -1px; right: -1px; z-index: 1;
  width: 8px; height: 8px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 0 2px var(--chatbot-accent-dark);
}
.chatbot-header-actions { display: flex; gap: 4px; }
.chatbot-icon-btn {
  width: 28px; height: 28px; border: none; background: rgba(255, 255, 255, 0.15);
  color: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; transition: background 0.15s ease;
}
.chatbot-icon-btn:hover { background: rgba(255, 255, 255, 0.28); }

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--chatbot-bg);
  scroll-behavior: smooth;
}

.chatbot-message { display: flex; gap: 8px; }
.chatbot-message--user { justify-content: flex-end; }
.chatbot-message--assistant, .chatbot-message--error { justify-content: flex-start; align-items: flex-end; }

.chatbot-avatar-wrap {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
}
.chatbot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.2); /* crops the source image's white ring border out of frame */
  display: block;
}

.chatbot-message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 82%;
}
.chatbot-message--user .chatbot-message-content { align-items: flex-end; }
.chatbot-message--assistant .chatbot-message-content,
.chatbot-message--error .chatbot-message-content { align-items: flex-start; }

.chatbot-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chatbot-message--user .chatbot-bubble {
  background: var(--chatbot-user-bubble);
  color: var(--chatbot-user-bubble-text);
  border-bottom-right-radius: 4px;
}
.chatbot-message--assistant .chatbot-bubble {
  background: var(--chatbot-assistant-bubble);
  color: var(--chatbot-assistant-bubble-text);
  border-bottom-left-radius: 4px;
}
.chatbot-bubble p { margin: 0 0 8px; }
.chatbot-bubble p:last-child { margin-bottom: 0; }
.chatbot-bubble ul, .chatbot-bubble ol { margin: 4px 0 8px 18px; padding: 0; }
.chatbot-bubble a { color: inherit; text-decoration: underline; }
.chatbot-bubble code { background: rgba(0, 0, 0, 0.08); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.chatbot-widget--dark .chatbot-bubble code { background: rgba(255, 255, 255, 0.12); }
.chatbot-bubble pre.chatbot-code-block {
  background: rgba(0, 0, 0, 0.06); padding: 8px 10px; border-radius: 8px; overflow-x: auto; margin: 4px 0 8px;
}
.chatbot-widget--dark .chatbot-bubble pre.chatbot-code-block { background: rgba(255, 255, 255, 0.08); }
.chatbot-bubble pre.chatbot-code-block code { background: none; padding: 0; }

.chatbot-message--error .chatbot-bubble { background: #fde8e8; color: #b91c1c; }
.chatbot-widget--dark .chatbot-message--error .chatbot-bubble { background: #3a1a1a; color: #fca5a5; }

.chatbot-feedback { display: flex; gap: 2px; padding-left: 2px; }
.chatbot-feedback-btn {
  width: 22px; height: 22px; border: none; background: none; border-radius: 6px;
  color: var(--chatbot-text-secondary); font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.chatbot-feedback-btn:hover { background: var(--chatbot-bg-secondary); color: var(--chatbot-text); }
.chatbot-feedback-btn--active { color: var(--chatbot-accent); }
.chatbot-feedback-btn--active:hover { background: var(--chatbot-bg-secondary); }

.chatbot-typing { display: flex; gap: 4px; padding: 0 16px 10px; flex-shrink: 0; }
.chatbot-typing[hidden] { display: none; }
.chatbot-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--chatbot-text-secondary);
  opacity: 0.5; animation: chatbot-typing-bounce 1.1s infinite ease-in-out;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chatbot-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--chatbot-border);
  flex-shrink: 0;
  background: var(--chatbot-bg);
}
.chatbot-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--chatbot-border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  max-height: 120px;
  background: var(--chatbot-bg-secondary);
  color: var(--chatbot-text);
  caret-color: var(--chatbot-accent);
  outline: none;
}
.chatbot-input:focus { border-color: var(--chatbot-accent); }
.chatbot-input:disabled { opacity: 0.6; }
.chatbot-send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--chatbot-accent); color: #fff; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.chatbot-send-btn:hover:not(:disabled) { background: var(--chatbot-accent-dark); }
.chatbot-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chatbot-launcher-nudge {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 12px 12px 2px;
  color: var(--chatbot-assistant-bubble-text);
  font-size: 13.5px;
  line-height: 1.4;
  white-space: normal;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.chatbot-launcher-container[data-expanded="true"] .chatbot-launcher-nudge {
  opacity: 1;
  transition: opacity 0.25s ease 0.15s;
}
.chatbot-launcher-nudge #chatbot-proactive-text {
  min-width: 0;
  overflow-wrap: break-word;
}
.chatbot-proactive-close {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.2);
  color: var(--chatbot-text-secondary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatbot-launcher-nudge p { margin: 0; }

/* Mobile: full-screen chat panel. Height while open is set inline by chatbot.js
   from window.visualViewport so the on-screen keyboard never covers the input. */
@media (max-width: 640px) {
  .chatbot-widget { bottom: 16px; right: 16px; }
  .chatbot-widget[data-state="open"] .chatbot-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .chatbot-launcher-container[data-expanded="true"] { max-width: min(300px, calc(100vw - 32px)); }
}
