/* Ella Chatbot Widget — minimal CSS, no frameworks */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --sa-navy:    #1A3C5E;
  --sa-blue:    #2E75B6;
  --sa-white:   #ffffff;
  --sa-bg:      #f4f6f9;
  --sa-border:  #dce1e9;
  --sa-text:    #2c3e50;
  --sa-radius:  16px;
  --sa-shadow:  0 8px 32px rgba(0,0,0,.18);
  --sa-font:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Bubble ─────────────────────────────────────────────────────────────── */
.sa-chat-bubble {
  position: fixed;
  bottom: 24px;
  z-index: 99998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  user-select: none;
}
.sa-chat-bubble:hover,
.sa-chat-bubble:focus {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(0,0,0,.3);
  outline: none;
}
.sa-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  pointer-events: none;
}
.sa-pos-bottom-right { right: 24px; }
.sa-pos-bottom-left  { left: 24px; }

/* Notification dot */
.sa-bubble-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: #e74c3c;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Proactive message */
.sa-proactive-msg {
  position: fixed;
  bottom: 92px;
  z-index: 99997;
  background: #fff;
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  padding: 10px 16px;
  font: 14px/1.4 var(--sa-font);
  color: var(--sa-text);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-width: 220px;
  cursor: pointer;
  animation: sa-fade-in .3s ease;
}
.sa-proactive-msg.sa-pos-bottom-right { right: 24px; }
.sa-proactive-msg.sa-pos-bottom-left  { left: 24px; }

/* ── Panel ──────────────────────────────────────────────────────────────── */
.sa-chat-panel {
  position: fixed;
  bottom: 94px;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  background: var(--sa-white);
  border-radius: var(--sa-radius);
  box-shadow: var(--sa-shadow);
  font: 14px/1.5 var(--sa-font);
  color: var(--sa-text);
  overflow: hidden;
  transform: translateY(16px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
.sa-chat-panel.sa-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.sa-chat-panel.sa-pos-bottom-right { right: 24px; }
.sa-chat-panel.sa-pos-bottom-left  { left: 24px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.sa-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: #fff;
  flex-shrink: 0;
}
.sa-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sa-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.sa-chat-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.sa-chat-header-text strong { font-size: 15px; }
.sa-chat-header-text span   { font-size: 12px; opacity: .82; }
.sa-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sa-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background .15s;
}
.sa-close-btn:hover { background: rgba(255,255,255,.15); }
.sa-close-btn svg { width: 20px; height: 20px; fill: #fff; }

/* ── Messages ───────────────────────────────────────────────────────────── */
.sa-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sa-bg);
  scroll-behavior: smooth;
}

/* Message rows */
.sa-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: sa-fade-in .2s ease;
}
.sa-msg-user {
  flex-direction: row-reverse;
}

/* Avatars */
.sa-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sa-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

/* Bubbles */
.sa-msg-bubble {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}
.sa-msg-ella .sa-msg-bubble {
  background: #fff;
  border: 1px solid var(--sa-border);
  border-bottom-left-radius: 4px;
}
.sa-msg-user .sa-msg-bubble {
  background: var(--sa-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Markdown inside bubbles */
.sa-msg-bubble p    { margin: 0 0 6px; }
.sa-msg-bubble p:last-child { margin-bottom: 0; }
.sa-msg-bubble ul   { margin: 6px 0; padding-left: 20px; }
.sa-msg-bubble li   { margin-bottom: 3px; }
.sa-msg-bubble a    { color: var(--sa-blue); }
.sa-msg-user .sa-msg-bubble a { color: #a8d0f7; }

/* ── Typing indicator ───────────────────────────────────────────────────── */
.sa-typing {
  align-items: flex-end;
  gap: 8px;
}
.sa-typing-dots {
  background: #fff;
  border: 1px solid var(--sa-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.sa-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b0bec5;
  display: inline-block;
  animation: sa-bounce .9s infinite;
}
.sa-typing-dots span:nth-child(2) { animation-delay: .15s; }
.sa-typing-dots span:nth-child(3) { animation-delay: .30s; }

/* ── Input area ─────────────────────────────────────────────────────────── */
.sa-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--sa-border);
  background: #fff;
  flex-shrink: 0;
}
.sa-chat-input {
  flex: 1;
  border: 1px solid var(--sa-border);
  border-radius: 20px;
  padding: 9px 14px;
  font: 14px/1.4 var(--sa-font);
  color: var(--sa-text);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .15s;
}
.sa-chat-input:focus {
  border-color: var(--sa-blue);
}
.sa-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
.sa-send-btn:hover:not(:disabled) { opacity: .88; transform: scale(1.07); }
.sa-send-btn:disabled { opacity: .45; cursor: not-allowed; }
.sa-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Lead form ──────────────────────────────────────────────────────────── */
.sa-lead-form {
  background: #fff;
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 88%;
}
.sa-lead-intro {
  margin: 0 0 4px;
  font-size: 13px;
  color: #555;
}
.sa-field {
  border: 1px solid var(--sa-border);
  border-radius: 8px;
  padding: 8px 12px;
  font: 13px/1.4 var(--sa-font);
  color: var(--sa-text);
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.sa-field:focus { border-color: var(--sa-blue); }
textarea.sa-field { resize: none; }
.sa-lead-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sa-lead-submit {
  border: none;
  border-radius: 20px;
  color: #fff;
  font: 600 13px/1 var(--sa-font);
  padding: 9px 18px;
  cursor: pointer;
  transition: opacity .15s;
}
.sa-lead-submit:hover:not(:disabled) { opacity: .88; }
.sa-lead-submit:disabled { opacity: .5; cursor: not-allowed; }
.sa-lead-cancel {
  font-size: 12px;
  color: #999;
  text-decoration: none;
}
.sa-lead-cancel:hover { color: #555; text-decoration: underline; }

/* ── Inline embed mode ──────────────────────────────────────────────────── */
.sa-chatbot-inline-container {
  width: 100%;
}

.sa-chat-panel.sa-inline {
  position: relative;
  bottom: auto;
  right: auto;
  left: auto;
  width: 100%;
  max-width: 100%;
  height: 560px;
  max-height: 80vh;
  transform: none;
  opacity: 1;
  pointer-events: auto;
  transition: none;
  z-index: auto;
  border-radius: var(--sa-radius);
  box-shadow: var(--sa-shadow);
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sa-chat-panel:not(.sa-inline) {
    position: fixed;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .sa-chat-panel.sa-inline {
    height: 480px;
    max-height: 70vh;
  }
  .sa-chat-bubble.sa-pos-bottom-right { right: 16px; }
  .sa-chat-bubble.sa-pos-bottom-left  { left: 16px; }
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes sa-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sa-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}
