/* ── ELLIE WIDGET STYLES ── */
#ellie-widget * { box-sizing: border-box; margin: 0; font-family: 'Open Sans', 'Segoe UI', sans-serif; }

#ellie-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── BUBBLE BUTTON ── */
#ellie-bubble {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #253957;
  border: 3px solid #f6b431;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37,57,87,0.45);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  flex-shrink: 0;
}
#ellie-bubble:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 28px rgba(37,57,87,0.55);
}
#ellie-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
#ellie-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ── GREETING TOOLTIP ── */
#ellie-tooltip {
  background: #fff;
  border: 1px solid #dde1e8;
  border-left: 4px solid #f6b431;
  border-radius: 8px;
  padding: 12px 16px;
  max-width: 240px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  font-size: 0.84rem;
  color: #1f2937;
  line-height: 1.5;
  position: relative;
  cursor: pointer;
  animation: ellieSlideIn 0.4s ease;
}
#ellie-tooltip strong { color: #253957; display: block; margin-bottom: 3px; font-size: 0.86rem; }
#ellie-tooltip-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none; border: none;
  color: #9ca3af; cursor: pointer;
  font-size: 0.9rem; line-height: 1;
}

/* ── CHAT WINDOW ── */
#ellie-window {
  display: none;
  flex-direction: column;
  width: 370px;
  height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(37,57,87,0.25);
  overflow: hidden;
  animation: ellieSlideIn 0.3s ease;
  border: 1px solid #dde1e8;
}
#ellie-widget.open #ellie-window { display: flex; }

@keyframes ellieSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── HEADER ── */
#ellie-header {
  background: #253957;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 3px solid #f6b431;
  flex-shrink: 0;
}
#ellie-header-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid #f6b431;
  overflow: hidden;
  flex-shrink: 0;
}
#ellie-header-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
}
#ellie-header-info { flex: 1; }
#ellie-header-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 0.02em;
}
#ellie-header-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
#ellie-header-status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
#ellie-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  transition: color 0.2s;
  line-height: 1;
}
#ellie-close-btn:hover { color: #f6b431; }

/* ── POWERED BY ── */
#ellie-powered {
  background: #1a2a42;
  text-align: center;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.3);
  padding: 3px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── MESSAGES ── */
#ellie-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8fa;
  scroll-behavior: smooth;
}
#ellie-messages::-webkit-scrollbar { width: 4px; }
#ellie-messages::-webkit-scrollbar-track { background: transparent; }
#ellie-messages::-webkit-scrollbar-thumb { background: #dde1e8; border-radius: 4px; }

.ellie-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
}
.ellie-msg.ellie { align-self: flex-start; }
.ellie-msg.user  { align-self: flex-end; flex-direction: row-reverse; }

.ellie-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid #f6b431;
}
.ellie-msg-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

.ellie-bubble-text {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: #1f2937;
}
.ellie-msg.ellie .ellie-bubble-text {
  background: #fff;
  border: 1px solid #dde1e8;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.ellie-msg.user .ellie-bubble-text {
  background: #253957;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── QUICK REPLIES ── */
#ellie-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 4px;
  background: #f7f8fa;
  flex-shrink: 0;
}
.ellie-qr {
  background: #fff;
  border: 1.5px solid #253957;
  color: #253957;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.ellie-qr:hover { background: #253957; color: #f6b431; }

/* ── INPUT BAR ── */
#ellie-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #dde1e8;
  flex-shrink: 0;
}
#ellie-input {
  flex: 1;
  border: 1.5px solid #dde1e8;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 0.84rem;
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
}
#ellie-input:focus { border-color: #f6b431; }
#ellie-input::placeholder { color: #9ca3af; }
#ellie-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #f6b431;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  font-size: 1rem;
}
#ellie-send:hover { background: #d99e22; transform: scale(1.06); }

/* ── TYPING INDICATOR ── */
.ellie-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
  background: #fff;
  border: 1px solid #dde1e8;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.ellie-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #c8cdd6;
  animation: ellieTyping 1.2s infinite;
}
.ellie-typing span:nth-child(2) { animation-delay: 0.2s; }
.ellie-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ellieTyping {
  0%, 60%, 100% { transform: translateY(0); background: #c8cdd6; }
  30% { transform: translateY(-5px); background: #f6b431; }
}

/* ── LEAD CAPTURE CARD ── */
.ellie-lead-card {
  background: #fff;
  border: 1px solid #dde1e8;
  border-left: 3px solid #f6b431;
  border-radius: 10px;
  padding: 13px;
  font-size: 0.82rem;
}
.ellie-lead-card p { color: #253957; font-weight: 600; margin-bottom: 10px; }
.ellie-lead-input {
  width: 100%;
  border: 1px solid #dde1e8;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  margin-bottom: 7px;
  outline: none;
  font-family: inherit;
}
.ellie-lead-input:focus { border-color: #f6b431; }
.ellie-lead-btn {
  width: 100%;
  background: #253957;
  color: #f6b431;
  border: none;
  border-radius: 6px;
  padding: 9px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s;
}
.ellie-lead-btn:hover { background: #1a2a42; }

/* ── DISCLAIMER ── */
#ellie-disclaimer {
  padding: 6px 14px 8px;
  font-size: 0.62rem;
  color: #9ca3af;
  background: #fff;
  line-height: 1.4;
  border-top: 1px solid #f0f2f5;
  flex-shrink: 0;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
  #ellie-widget.open #ellie-window {
    width: 100vw;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 100000;
  }
  #ellie-widget {
    bottom: 16px;
    right: 0;
    left: 0;
    width: 100%;
  }
  .admin-bar #ellie-widget.open #ellie-window {
    top: 32px;
    height: calc(100% - 32px);
    height: calc(100dvh - 32px);
  }
  @media screen and (max-width: 782px) {
    .admin-bar #ellie-widget.open #ellie-window {
      top: 46px;
      height: calc(100% - 46px);
      height: calc(100dvh - 46px);
    }
  }
  #ellie-widget.open #ellie-bubble,
  #ellie-widget.open #ellie-tooltip {
    display: none;
  }
  #ellie-bubble, #ellie-tooltip {
    margin-right: 16px;
    margin-bottom: 16px;
  }
}
