.ea-root {
  --ea-primary: #11ffff;
  --ea-primary-hover: #38f0ff;
  --ea-accent: #0088aa;
  --ea-bg: #03060a;
  --ea-bg-soft: #071018;
  --ea-surface: rgba(7, 16, 24, 0.95);
  --ea-text: #9af7ff;
  --ea-text-soft: rgba(154, 247, 255, 0.55);
  --ea-border: rgba(17, 255, 255, 0.2);
  --ea-user-bubble: #11ffff;
  --ea-user-text: #03060a;
  --ea-bot-bubble: rgba(7, 16, 24, 0.85);
  --ea-bot-text: #9af7ff;
  --ea-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  --ea-focus-ring: rgba(17, 255, 255, 0.1);
  --ea-font: 'Figtree', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --ea-font-display: 'Oxanium', sans-serif;

  font-family: var(--ea-font);
  font-size: 15px;
  color: var(--ea-text);
  line-height: 1.55;
  box-sizing: border-box;
  color-scheme: dark; /* [RECOMENDADO]: la referencia no lo declara */
}

/* ============================================================
   Tema Claro — [VALORES INICIALES RECOMENDADOS]
   No provienen del proyecto de referencia: son una propuesta
   coherente con la identidad neón de Electri Ariel, con
   contraste AA (texto #0A2B33 sobre #FFFFFF ≈ 14:1; botón
   principal #00758A con texto blanco ≈ 5:1). Ajustable.
   Activación: .ea-root[data-theme="light"] (JS: toggleTheme).
   ============================================================ */
.ea-root[data-theme="light"] {
  --ea-primary: #00758A;
  --ea-primary-hover: #0090A8;
  --ea-accent: #0088AA;
  --ea-bg: #FFFFFF;
  --ea-bg-soft: #F0F8FA;
  --ea-surface: rgba(255, 255, 255, 0.95);
  --ea-text: #0A2B33;
  --ea-text-soft: #45606A;
  --ea-border: #C9E2E8;
  --ea-user-bubble: #00758A;
  --ea-user-text: #FFFFFF;
  --ea-bot-bubble: #F0F8FA;
  --ea-bot-text: #0A2B33;
  --ea-shadow: 0 16px 48px rgba(10, 43, 51, 0.18);
  --ea-focus-ring: rgba(0, 117, 138, 0.15);
  color-scheme: light;
}

/* Ajustes de glows/bordes hardcoded que solo lucen en oscuro: */
.ea-root[data-theme="light"] .ea-avatar {
  background: rgba(0, 117, 138, 0.08);
  border-color: rgba(0, 117, 138, 0.25);
}
.ea-root[data-theme="light"] .ea-icon-btn:hover {
  background: rgba(0, 117, 138, 0.08);
}
.ea-root[data-theme="light"] .ea-quick button:hover {
  background: rgba(0, 117, 138, 0.08);
}
.ea-root[data-theme="light"] .ea-msg-bot,
.ea-root[data-theme="light"] .ea-typing {
  border-color: rgba(0, 117, 138, 0.1);
}
.ea-root[data-theme="light"] .ea-card-row {
  border-bottom-color: rgba(0, 117, 138, 0.12);
}

.ea-root *,
.ea-root *::before,
.ea-root *::after {
  box-sizing: border-box;
}

.ea-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--ea-primary);
  border: none;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 24px rgba(17, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
  animation: ea-welcome-bounce 8s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ea-bubble:hover {
  animation-play-state: paused;
  transform: scale(1.06);
  box-shadow: 0 0 40px rgba(17, 255, 255, 0.55);
}
.ea-bubble svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}
.ea-bubble-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}
.ea-bubble.ea-hidden { display: none; }

.ea-bubble::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ea-primary);
  opacity: .5;
  animation: ea-pulse 2.2s ease-out infinite;
}
@keyframes ea-pulse {
  0%   { transform: scale(0.9);  opacity: .6; }
  100% { transform: scale(1.5);  opacity: 0;  }
}

@keyframes ea-welcome-bounce {
  0%, 100% { transform: translateY(0); }
  35%      { transform: translateY(-20vh); }
  70%      { transform: translateY(0); }
}

.ea-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  top: auto;
  left: auto;
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  min-height: 0;
  background: var(--ea-bg);
  border-radius: 12px;
  box-shadow: var(--ea-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
  border: 1px solid var(--ea-border);
  animation: ea-slide-up .25s ease-out;
}
.ea-window.ea-open { display: flex; }

/* Columna flexible: solo los mensajes se encogen y desplazan. */
.ea-header { flex: 0 0 auto; min-width: 0; }
.ea-header-info { flex: 1 1 auto; min-width: 0; }
.ea-header-actions { flex: 0 0 auto; align-items: center; }
.ea-quick {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  max-height: none;
  overflow: visible;
  scrollbar-width: auto;
}
.ea-quick button {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.ea-messages {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ea-input-wrap { flex: 0 0 auto; min-width: 0; }
.ea-footer { flex: 0 0 auto; min-width: 0; flex-wrap: wrap; }
.ea-footer > span { flex: 1 1 130px; min-width: 0; overflow-wrap: anywhere; }
.ea-wa { flex: 0 0 auto; white-space: nowrap; }

@keyframes ea-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ea-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ea-bg-soft);
  border-bottom: 1px solid var(--ea-border);
}
.ea-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(17, 255, 255, 0.12);
  border: 1px solid rgba(17, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.ea-header-info { flex: 1; min-width: 0; }
.ea-header-title {
  font-family: var(--ea-font-display);
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  color: var(--ea-primary);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ea-header-status {
  font-size: 11px;
  color: var(--ea-text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.ea-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}
.ea-status-dot.ea-off { background: #f0a020; }

.ea-header-actions {
  display: flex;
  gap: 4px;
}
.ea-icon-btn {
  background: transparent;
  border: none;
  color: var(--ea-text-soft);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.ea-icon-btn:hover {
  background: rgba(17, 255, 255, 0.1);
  color: var(--ea-primary);
}
.ea-icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

.ea-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ea-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ea-messages::-webkit-scrollbar { width: 5px; }
.ea-messages::-webkit-scrollbar-track { background: transparent; }
.ea-messages::-webkit-scrollbar-thumb {
  background: var(--ea-border);
  border-radius: 3px;
}

.ea-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: ea-msg-in .2s ease-out;
  font-size: 14px;
  line-height: 1.55;
}
@keyframes ea-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ea-msg strong {
  color: var(--ea-primary);
  font-weight: 600;
}

.ea-msg-user {
  align-self: flex-end;
  background: var(--ea-user-bubble);
  color: var(--ea-user-text);
  border-bottom-right-radius: 4px;
}
.ea-msg-bot {
  align-self: flex-start;
  background: var(--ea-bot-bubble);
  color: var(--ea-bot-text);
  border: 1px solid rgba(17, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.ea-typing {
  align-self: flex-start;
  background: var(--ea-bot-bubble);
  border: 1px solid rgba(17, 255, 255, 0.08);
  padding: 12px 16px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  animation: ea-msg-in .2s ease-out;
}
.ea-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ea-primary);
  opacity: 0.6;
  animation: ea-blink 1.2s infinite ease-in-out;
}
.ea-typing span:nth-child(2) { animation-delay: .2s; }
.ea-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ea-blink {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.3; }
  40%           { transform: scale(1);   opacity: 1; }
}

.ea-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--ea-bg-soft);
  border-bottom: 1px solid var(--ea-border);
  overflow: visible;
}
.ea-quick button {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--ea-border);
  background: transparent;
  color: var(--ea-text-soft);
  font-family: var(--ea-font);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.ea-quick button:hover {
  background: rgba(17, 255, 255, 0.1);
  color: var(--ea-primary);
  border-color: var(--ea-primary);
}

.ea-input-wrap {
  padding: 10px 12px;
  background: var(--ea-bg-soft);
  border-top: 1px solid var(--ea-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ea-input {
  flex: 1;
  border: 1px solid var(--ea-border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--ea-font);
  background: var(--ea-bg);
  color: var(--ea-text);
  resize: none;
  max-height: 100px;
  min-height: 40px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  line-height: 1.35;
}
.ea-input:focus {
  border-color: var(--ea-primary);
  box-shadow: 0 0 0 3px var(--ea-focus-ring, rgba(17, 255, 255, 0.1));
}
.ea-input::placeholder { color: var(--ea-text-soft); }

.ea-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ea-primary);
  border: none;
  color: var(--ea-user-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.ea-send:hover:not(:disabled) {
  background: var(--ea-primary-hover);
  box-shadow: 0 0 20px rgba(17, 255, 255, 0.3);
}
.ea-send:active:not(:disabled) { transform: scale(0.94); }
.ea-send:disabled { opacity: 0.4; cursor: not-allowed; }
.ea-send svg { width: 18px; height: 18px; fill: currentColor; }

.ea-footer {
  padding: 8px 12px 10px;
  background: var(--ea-bg-soft);
  border-top: 1px solid var(--ea-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--ea-text-soft);
  letter-spacing: 0.05em;
}
.ea-footer span {
  font-family: var(--ea-font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ---------- Píldora de WhatsApp (estándar del widget) ---------- */
.ea-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #25D366;
  color: #fff !important;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease;
}
.ea-wa:hover { background: #1EB954; }
.ea-wa svg { width: 14px; height: 14px; fill: currentColor; }

.ea-card {
  align-self: stretch;
  background: var(--ea-bot-bubble);
  border: 1px solid var(--ea-border);
  border-radius: 10px;
  padding: 14px;
  animation: ea-msg-in .3s ease-out;
}
.ea-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-family: var(--ea-font-display);
  color: var(--ea-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.04em;
}
.ea-card-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(17, 255, 255, 0.1);
  font-size: 13px;
}
.ea-card-row:last-of-type { border-bottom: none; }
.ea-card-row strong {
  color: var(--ea-text-soft);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ea-card-row span {
  color: var(--ea-text);
  font-weight: 500;
  text-align: right;
}
.ea-card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.ea-card-actions button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--ea-font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background .15s ease, box-shadow .15s ease;
}
.ea-btn-primary {
  background: var(--ea-primary);
  color: var(--ea-user-text);
}
.ea-btn-primary:hover {
  background: var(--ea-primary-hover);
  box-shadow: 0 0 20px rgba(17, 255, 255, 0.25);
}

/* Cierre del chat en móvil: bloquea el scroll de la página de fondo. */
body.ea-chat-locked { overflow: hidden; }

@media (max-width: 480px) {
  /* Móvil: ventana completa, respetando las áreas seguras del dispositivo
     y sincronizada con el viewport visible (teclado) vía --ea-vv-*. */
  .ea-window {
    top: var(--ea-vv-top, env(safe-area-inset-top, 0px));
    right: max(0px, env(safe-area-inset-right));
    bottom: auto;
    left: max(0px, env(safe-area-inset-left));
    width: auto;
    height: var(--ea-vv-height, 100dvh);
    max-height: var(--ea-vv-height, 100dvh);
    border-radius: 0;
    border: none;
  }
  .ea-bubble {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }
  .ea-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: 10px;
    padding-left: max(12px, env(safe-area-inset-left));
  }
  .ea-icon-btn {
    width: 40px;
    height: 40px;
  }
  .ea-messages {
    padding: 12px;
  }
  .ea-quick {
    padding: 6px 10px;
  }
  .ea-quick button {
    font-size: 11px;
    padding: 5px 10px;
  }
  .ea-input-wrap {
    padding: 8px 10px;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }
  .ea-input {
    font-size: 16px; /* evita el zoom automático de iOS */
  }
  .ea-footer {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }
}

@media (max-width: 360px) {
  .ea-bubble {
    right: 12px;
    bottom: 12px;
    width: 50px;
    height: 50px;
  }
  .ea-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .ea-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  .ea-header-title {
    font-size: 12px;
  }
  .ea-msg {
    max-width: 88%;
    padding: 8px 12px;
    font-size: 13px;
  }
  .ea-quick button {
    font-size: 10px;
    padding: 4px 8px;
  }
  .ea-input {
    padding: 8px 12px;
    min-height: 36px;
  }
  .ea-send {
    width: 36px;
    height: 36px;
  }
  .ea-send svg {
    width: 16px;
    height: 16px;
  }
}

/* Móvil en horizontal o ventanas con poca altura. */
@media (max-height: 520px) {
  .ea-window {
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    bottom: 6px;
  }
  .ea-header {
    padding-top: 5px;
    padding-bottom: 5px;
  }
  .ea-avatar {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
  .ea-quick {
    gap: 4px;
    padding-top: 5px;
    padding-bottom: 5px;
  }
  .ea-footer {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

/* Móvil en horizontal: ventana flotante compacta y WhatsApp visible. */
@media (max-width: 480px) and (max-height: 520px) {
  .ea-window {
    top: var(--ea-vv-top, 0px);
    right: max(6px, env(safe-area-inset-right));
    bottom: auto;
    left: max(6px, env(safe-area-inset-left));
    height: calc(var(--ea-vv-height, 100dvh) - 12px);
    max-height: calc(var(--ea-vv-height, 100dvh) - 12px);
    border-radius: 12px;
  }
  .ea-footer > span { display: none; }
  .ea-wa { margin-left: auto; }
}

/* Accesibilidad: foco visible por teclado y menos movimiento. */
.ea-bubble:focus-visible,
.ea-quick button:focus-visible,
.ea-wa:focus-visible,
.ea-send:focus-visible,
.ea-icon-btn:focus-visible,
.ea-input:focus-visible {
  outline: 2px solid var(--ea-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ea-bubble,
  .ea-bubble::after,
  .ea-msg,
  .ea-typing,
  .ea-card,
  .ea-window {
    animation: none !important;
    transition: none !important;
  }
}
