/* ==========================================================
   Blue Energy – Asistente virtual / Virtual assistant
   ========================================================== */
:root {
  --be-primary: #1977cc;
  --be-primary-dark: #145fa3;
  --be-navy: #2c4964;
  --be-bg: #f1f7fc;
  --be-surface: #ffffff;
  --be-text: #33414e;
  --be-muted: #6b7a89;
  --be-border: #dde7f0;
  --be-radius: 16px;
  --be-shadow: 0 18px 48px rgba(20, 45, 75, .22);
}

/* Keep the template's "scroll to top" button clear of the launcher */
.scroll-top { right: 15px !important; bottom: 92px !important; }

.be-chat, .be-chat * { box-sizing: border-box; }
.be-chat {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--be-text);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99998;
}

/* ---------- Launcher ---------- */
.be-launcher {
  width: 62px; height: 62px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--be-primary), var(--be-navy));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(25, 119, 204, .45);
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}
.be-launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 32px rgba(25, 119, 204, .55); }
.be-launcher:focus-visible { outline: 3px solid #9cc8f0; outline-offset: 3px; }
.be-launcher svg { width: 28px; height: 28px; transition: transform .25s ease, opacity .2s ease; }
.be-launcher .be-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
.be-chat.is-open .be-launcher .be-ico-chat { opacity: 0; transform: rotate(90deg); }
.be-chat.is-open .be-launcher .be-ico-close { opacity: 1; transform: rotate(0); }
.be-launcher .be-dot {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px;
  background: #e74c3c; color: #fff; border: 2px solid #fff;
  font: 700 11px/16px "Roboto", Arial, sans-serif; text-align: center;
  display: none;
}
.be-chat.has-teaser .be-dot { display: block; }
.be-chat.has-teaser .be-launcher { animation: be-pulse 2.4s ease-out 2; }

/* ---------- Mensaje proactivo / Proactive message ---------- */
.be-teaser {
  position: absolute; right: 76px; bottom: 0;
  width: 330px; max-width: calc(100vw - 110px);
  background: var(--be-surface); color: var(--be-text);
  padding: 16px 16px 14px; border-radius: 16px 16px 4px 16px;
  border-top: 3px solid var(--be-primary);
  box-shadow: 0 16px 40px rgba(20, 45, 75, .22);
  opacity: 0; transform: translateY(10px) scale(.98); transform-origin: bottom right;
  pointer-events: none; visibility: hidden;
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.be-teaser.show {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity .35s ease, transform .35s ease, visibility 0s;
}
.be-chat.is-open .be-teaser { display: none; }
.be-teaser-x {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: transparent; color: var(--be-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.be-teaser-x:hover { background: var(--be-bg); color: var(--be-navy); }
.be-teaser-x svg { width: 14px; height: 14px; }
.be-teaser-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding-right: 20px; }
.be-teaser-head .be-avatar {
  width: 36px; height: 36px; background: linear-gradient(135deg, var(--be-primary), var(--be-navy)); border: 0; color: #fff;
}
.be-teaser-head .be-avatar svg { width: 18px; height: 18px; }
.be-teaser-head strong { display: block; font-family: "Poppins", sans-serif; font-size: 14px; font-weight: 600; color: var(--be-navy); line-height: 1.2; }
.be-teaser-head span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--be-muted); }
.be-teaser-head span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; }
.be-teaser-text { margin: 0 0 12px; font-size: 14px; line-height: 1.5; cursor: pointer; }
.be-teaser-text strong { color: var(--be-navy); }
.be-teaser-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.be-teaser-actions .be-chip { font-size: 12.5px; padding: 6px 11px; }
.be-teaser-actions .be-chip:first-child { background: var(--be-primary); color: #fff; }
.be-teaser-actions .be-chip:first-child:hover { background: var(--be-primary-dark); border-color: var(--be-primary-dark); }

@keyframes be-pulse {
  0% { box-shadow: 0 10px 28px rgba(25,119,204,.45), 0 0 0 0 rgba(25,119,204,.45); }
  70% { box-shadow: 0 10px 28px rgba(25,119,204,.45), 0 0 0 18px rgba(25,119,204,0); }
  100% { box-shadow: 0 10px 28px rgba(25,119,204,.45), 0 0 0 0 rgba(25,119,204,0); }
}

/* ---------- Window ---------- */
.be-window {
  margin: 0; padding: 0;
  position: absolute; right: 0; bottom: 78px;
  width: 380px; height: min(620px, calc(100vh - 120px));
  background: var(--be-surface);
  border-radius: var(--be-radius);
  box-shadow: var(--be-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right;
  pointer-events: none; visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.be-chat.is-open .be-window {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

/* Header */
.be-header {
  background: linear-gradient(135deg, var(--be-navy) 0%, var(--be-primary) 100%);
  color: #fff; padding: 16px 16px 14px;
  display: flex; align-items: center; gap: 12px;
}
.be-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
}
.be-avatar svg { width: 22px; height: 22px; }
.be-title { flex: 1; min-width: 0; }
.be-title strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: "Poppins", sans-serif; font-weight: 600; font-size: 15px; letter-spacing: .2px; }
.be-title span { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .85; }
.be-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; }
.be-lang {
  display: flex; background: rgba(255,255,255,.15); border-radius: 20px; padding: 3px;
}
.be-lang button {
  border: 0; background: transparent; color: #fff; font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 16px; cursor: pointer; letter-spacing: .5px;
}
.be-lang button.active { background: #fff; color: var(--be-navy); }
.be-hbtn {
  border: 0; background: transparent; color: #fff; opacity: .85; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.be-hbtn:hover { opacity: 1; background: rgba(255,255,255,.14); }
.be-hbtn svg { width: 18px; height: 18px; }

/* Messages */
.be-body {
  flex: 1; overflow-y: auto; padding: 18px 14px 8px; background: var(--be-bg);
  scroll-behavior: smooth;
}
.be-body::-webkit-scrollbar { width: 6px; }
.be-body::-webkit-scrollbar-thumb { background: #c7d6e4; border-radius: 6px; }

.be-msg { display: flex; margin-bottom: 10px; animation: be-in .25s ease; }
.be-msg.bot { justify-content: flex-start; }
.be-msg.user { justify-content: flex-end; }
.be-bubble {
  max-width: 86%; padding: 10px 13px; font-size: 14px; line-height: 1.5;
  border-radius: 14px; word-wrap: break-word;
}
.be-msg.bot .be-bubble {
  background: var(--be-surface); color: var(--be-text);
  border: 1px solid var(--be-border); border-bottom-left-radius: 4px;
}
.be-msg.user .be-bubble {
  background: var(--be-primary); color: #fff; border-bottom-right-radius: 4px;
}
.be-bubble p { margin: 0 0 6px; }
.be-bubble p:last-child { margin-bottom: 0; }
.be-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
.be-bubble li { margin-bottom: 3px; }
.be-bubble strong { color: var(--be-navy); }
.be-msg.user .be-bubble strong { color: #fff; }
.be-bubble a { color: var(--be-primary); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* Quick replies */
.be-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; animation: be-in .3s ease; }
.be-chip {
  border: 1px solid var(--be-primary); background: var(--be-surface); color: var(--be-primary);
  font-size: 13px; padding: 6px 12px; border-radius: 18px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
  font-family: inherit;
}
.be-chip:hover, .be-chip:focus-visible { background: var(--be-primary); color: #fff; outline: none; }

/* Cards (CTA) */
.be-card {
  background: var(--be-surface); border: 1px solid var(--be-border); border-radius: 12px;
  padding: 12px; margin: 0 0 12px; animation: be-in .3s ease; max-width: 92%;
}
.be-card h6 { margin: 0 0 8px; font-family: "Poppins", sans-serif; font-size: 13.5px; color: var(--be-navy); font-weight: 600; }
.be-card .be-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 6px; }
.be-card .be-row:last-child { margin-bottom: 0; }
.be-card .be-row svg { width: 16px; height: 16px; color: var(--be-primary); flex: none; }
.be-card a { color: var(--be-navy); text-decoration: none; }
.be-card a:hover { color: var(--be-primary); }

/* Lead form */
.be-form { display: grid; gap: 8px; }
.be-form label { font-size: 12px; color: var(--be-muted); display: grid; gap: 3px; }
.be-form input, .be-form select, .be-form textarea {
  width: 100%; border: 1px solid var(--be-border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-family: inherit; color: var(--be-text); background: #fff;
}
.be-form input:focus, .be-form select:focus, .be-form textarea:focus { outline: none; border-color: var(--be-primary); box-shadow: 0 0 0 3px rgba(25,119,204,.15); }
.be-form textarea { resize: vertical; min-height: 56px; }
.be-form .be-err { color: #c0392b; font-size: 12px; min-height: 0; }
.be-btn {
  border: 0; background: var(--be-primary); color: #fff; font-weight: 600; font-size: 14px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer; font-family: inherit;
}
.be-btn:hover { background: var(--be-primary-dark); }
.be-btn.ghost { background: transparent; color: var(--be-primary); border: 1px solid var(--be-primary); }

/* Typing indicator */
.be-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.be-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #9fb3c6;
  animation: be-blink 1.2s infinite ease-in-out;
}
.be-typing i:nth-child(2) { animation-delay: .15s; }
.be-typing i:nth-child(3) { animation-delay: .3s; }

/* Composer */
.be-composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--be-border); background: var(--be-surface);
}
.be-composer textarea {
  flex: 1; border: 1px solid var(--be-border); border-radius: 12px; resize: none;
  padding: 10px 12px; font-size: 14px; font-family: inherit; line-height: 1.4;
  max-height: 96px; min-height: 42px; color: var(--be-text);
}
.be-composer textarea:focus { outline: none; border-color: var(--be-primary); box-shadow: 0 0 0 3px rgba(25,119,204,.12); }
.be-send {
  width: 42px; height: 42px; flex: none; border-radius: 12px; border: 0;
  background: var(--be-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.be-send:disabled { background: #b9cde0; cursor: default; }
.be-send svg { width: 18px; height: 18px; }
.be-foot { text-align: center; font-size: 11px; color: var(--be-muted); padding: 0 12px 8px; background: var(--be-surface); }

@keyframes be-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes be-blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Mobile: full-screen sheet */
@media (max-width: 520px) {
  .be-chat { right: 14px; bottom: 14px; }
  .be-window {
    position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0;
    transform: translateY(24px);
  }
  .be-chat.is-open .be-launcher { display: none; }
  .be-teaser { right: 70px; padding: 14px 14px 12px; }
  .be-teaser-text { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .be-chat *, .be-chat *::before { animation: none !important; transition: none !important; }
}
