/* Website chatbot widget styles. Self-contained; all classes are namespaced
   chatbot-* and the widget avoids global/body/html resets so it will not break
   the host website. This is the only chatbot stylesheet. */

.chatbot-root {
  --chatbot-accent: #1f7a8c;
  --chatbot-accent-dark: #145e6e;
  --chatbot-bg: #ffffff;
  --chatbot-panel-bg: #f7fafb;
  --chatbot-text: #1c2b2f;
  --chatbot-muted: #5d7176;
  --chatbot-bot-bubble: #eef4f5;
  --chatbot-user-bubble: #1f7a8c;
  --chatbot-border: #e2ebec;
  --chatbot-shadow: 0 12px 40px rgba(20, 60, 70, 0.18);
  position: fixed;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--chatbot-text);
}

.chatbot-root.chatbot-pos-bottom-right { right: 20px; bottom: 20px; }
.chatbot-root.chatbot-pos-bottom-left { left: 20px; bottom: 20px; }

/* Launcher bubble */
.chatbot-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--chatbot-accent);
  color: #fff;
  box-shadow: var(--chatbot-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease;
}
.chatbot-launcher:hover { background: var(--chatbot-accent-dark); transform: translateY(-2px); }
.chatbot-launcher:focus-visible { outline: 3px solid rgba(31, 122, 140, 0.4); outline-offset: 2px; }
.chatbot-launcher svg { width: 28px; height: 28px; }

/* Panel */
.chatbot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  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(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.chatbot-pos-bottom-left .chatbot-panel { right: auto; left: 0; }
.chatbot-root.chatbot-open .chatbot-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.chatbot-root.chatbot-open .chatbot-launcher { transform: scale(0.92); }

/* Header */
.chatbot-header {
  background: var(--chatbot-accent);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chatbot-header-text { flex: 1 1 auto; min-width: 0; }
.chatbot-title { font-weight: 600; font-size: 15px; }
.chatbot-subtitle { font-size: 11.5px; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbot-header-actions { display: flex; gap: 4px; }
.chatbot-icon-btn {
  background: transparent; border: none; color: #fff; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.chatbot-icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.chatbot-icon-btn svg { width: 18px; height: 18px; }

/* Messages */
.chatbot-messages {
  flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px;
  background: var(--chatbot-panel-bg);
}
.chatbot-msg { width: fit-content; max-width: 86%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

/* Links rendered inside bot answers (clickable URLs, media, emails). */
.chatbot-link { color: var(--chatbot-accent-dark); text-decoration: none; word-break: break-all; max-width: 100%; }
.chatbot-link:hover { text-decoration: underline; }
.chatbot-msg-user .chatbot-link { color: #eaf6f8; text-decoration: underline; }
.chatbot-msg-bot { align-self: flex-start; margin-right: auto; background: var(--chatbot-bot-bubble); color: var(--chatbot-text); border-bottom-left-radius: 4px; }
.chatbot-msg-user { align-self: flex-end; margin-left: auto; background: var(--chatbot-user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.chatbot-msg-error { background: #fdecec; color: #a12626; }

/* Typing indicator */
.chatbot-typing { display: flex; gap: 4px; align-items: center; }
.chatbot-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--chatbot-muted); opacity: 0.5;
  animation: chatbot-bounce 1.2s 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-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* Composer */
.chatbot-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--chatbot-border); background: #fff; }
.chatbot-input {
  flex: 1 1 auto; resize: none; border: 1px solid var(--chatbot-border); border-radius: 12px; padding: 9px 12px;
  font-family: inherit; font-size: 14px; line-height: 1.4; max-height: 120px; min-height: 40px; color: var(--chatbot-text); background: #fff;
}
.chatbot-input:focus { outline: none; border-color: var(--chatbot-accent); }
.chatbot-input:disabled { background: #f1f5f6; color: var(--chatbot-muted); cursor: not-allowed; }
.chatbot-send {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--chatbot-accent); color: #fff; display: flex; align-items: center; justify-content: center; transition: background 0.15s ease;
}
.chatbot-send:hover { background: var(--chatbot-accent-dark); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chatbot-send svg { width: 18px; height: 18px; }

.chatbot-footer { text-align: center; font-size: 10.5px; color: var(--chatbot-muted); padding: 0 0 3px; background: #fff; }
.chatbot-footer:empty { display: none; }
.chatbot-footer-warning { color: #a12626; font-weight: 500; }

/* Platform attribution, one line below the footer. Uses the same theme variables
   as everything else, so it inherits each site's palette rather than introducing
   a colour of its own. */
.chatbot-powered { text-align: center; font-size: 10px; line-height: 1; padding: 2px 0 8px; background: #fff; }
.chatbot-powered-link {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  color: var(--chatbot-muted); text-decoration: none; letter-spacing: 0.01em;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.chatbot-powered-link:hover {
  background: var(--chatbot-panel-bg);
  box-shadow: inset 0 0 0 1px var(--chatbot-border);
}
.chatbot-powered-link:focus-visible { outline: 2px solid var(--chatbot-accent); outline-offset: 2px; }
.chatbot-powered-mark {
  display: inline-block; width: 11px; height: 11px; margin-right: 4px; vertical-align: -1.5px;
  color: var(--chatbot-accent); transition: transform 0.4s ease;
}
.chatbot-powered-mark svg { display: block; width: 100%; height: 100%; }
.chatbot-powered-link:hover .chatbot-powered-mark { transform: rotate(90deg) scale(1.15); }
.chatbot-powered-brand { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; color: var(--chatbot-accent-dark); }
.chatbot-powered-by { opacity: 0.85; }
.chatbot-powered-vendor { font-weight: 600; color: var(--chatbot-text); }

/* Gradient wordmark with a sheen that sweeps across on hover. Browsers without
   background-clip:text keep the solid accent-dark colour above. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .chatbot-powered-brand {
    background-image: linear-gradient(100deg, var(--chatbot-accent-dark) 0%, var(--chatbot-accent) 40%, var(--chatbot-accent-dark) 60%, var(--chatbot-accent) 100%);
    background-size: 220% 100%; background-position: 0% 50%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    transition: background-position 0.8s ease;
  }
  .chatbot-powered-link:hover .chatbot-powered-brand { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-powered-mark, .chatbot-powered-brand { transition: none; }
  .chatbot-powered-link:hover .chatbot-powered-mark { transform: none; }
}

/* Operational status line. Deliberately NOT styled like a message bubble: it must
   never read as the assistant speaking. */
.chatbot-status {
  font-size: 11.5px; color: var(--chatbot-muted); background: #f6f7f8;
  border-top: 1px solid #e7e9ec; padding: 7px 14px; text-align: center;
}

/* Dedicated lead field, revealed only when the backend sets usage.showEmailPrompt. */
.chatbot-lead { display: flex; gap: 6px; padding: 8px 12px; background: #f6f7f8; border-top: 1px solid #e7e9ec; }
.chatbot-lead-input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 7px 10px;
  border: 1px solid #d8dbe0; border-radius: 8px; background: #fff; color: inherit;
}
.chatbot-lead-input:focus { outline: 2px solid var(--chatbot-accent); outline-offset: -1px; }
.chatbot-lead-save {
  flex: none; font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px;
  border: 0; border-radius: 8px; cursor: pointer; background: var(--chatbot-accent); color: #fff;
}
.chatbot-lead-save:hover { background: var(--chatbot-accent-dark); }

@media (max-width: 480px) {
  .chatbot-root.chatbot-pos-bottom-right, .chatbot-root.chatbot-pos-bottom-left { right: 12px; left: 12px; bottom: 12px; }
  .chatbot-panel {
    width: auto; left: 0; right: 0; height: 70vh; max-height: calc(100vh - 90px); bottom: 74px;
  }
}
