.e4ia-root, .e4ia-root * { box-sizing: border-box; }
.e4ia-root {
  --red: #e31e24; --red-dark: #b9151a; --ink: #141414; --paper: #ffffff; --soft: #f3f3f1; --line: #dcdcd8; --wa: #1fa855;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--ink);
}
.e4ia-root button { font-family: inherit; cursor: pointer; }
.e4ia-root a { text-decoration: none; }

/* Botón flotante */
.e4ia-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 99998;
  display: flex; align-items: center; gap: 10px;
  background: var(--red); color: #fff; border: 0; border-radius: 999px;
  padding: 12px 20px; font-size: 15px; font-weight: 700;
  box-shadow: 0 8px 22px rgba(227, 30, 36, .38);
  transition: transform .15s ease, background .15s ease;
}
.e4ia-launcher:hover { background: var(--red-dark); transform: translateY(-2px); }
.e4ia-launcher:focus-visible, .e4ia-root button:focus-visible, .e4ia-input:focus-visible { outline: 3px solid #ffb300; outline-offset: 2px; }
.e4ia-launcher.is-hidden { display: none; }
.e4ia-root.is-off .e4ia-launcher { background: var(--ink); box-shadow: 0 6px 16px rgba(0, 0, 0, .3); }
.e4ia-top .e4ia-launcher { bottom: auto; top: 90px; }

/* Panel */
.e4ia-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 99999;
  width: 400px; max-width: calc(100vw - 24px); height: 640px; max-height: calc(100vh - 40px);
  display: none; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .32);
}
.e4ia-panel.is-open { display: flex; }
.e4ia-top .e4ia-panel { bottom: auto; top: 90px; max-height: calc(100vh - 110px); }

.e4ia-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; padding: 12px 14px; border-bottom: 3px solid var(--red);
}
.e4ia-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.e4ia-whotxt { min-width: 0; }
.e4ia-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--red); display: grid; place-items: center; font-size: 20px; }
.e4ia-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e4ia-sub { font-size: 11.5px; opacity: .75; }
.e4ia-tools { display: flex; gap: 6px; flex: none; }
.e4ia-tool { background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 6px; padding: 6px 9px; font-size: 12px; }
.e4ia-tool:hover { background: var(--red); }

/* Barra de pasos */
.e4ia-steps { display: none; justify-content: space-between; gap: 4px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.e4ia-steps.is-on { display: flex; }
.e4ia-stepitem { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: #9a9a96; text-transform: uppercase; letter-spacing: .02em; }
.e4ia-stepnum { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #e4e4e0; color: #555; font-size: 11px; }
.e4ia-stepitem.is-active { color: var(--red); }
.e4ia-stepitem.is-active .e4ia-stepnum { background: var(--red); color: #fff; }
.e4ia-stepitem.is-done { color: #1d8a4a; }
.e4ia-stepitem.is-done .e4ia-stepnum { background: #1fa855; color: #fff; }
.e4ia-note { padding: 0 12px 8px; background: #fff; text-align: center; font-size: 11px; color: #777; }
@media (max-width: 380px) { .e4ia-steptxt { display: none; } }

/* Datos que se van llenando + aviso de voz */
.e4ia-summary { display: none; flex-wrap: wrap; gap: 5px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.e4ia-summary.has-items { display: flex; }
.e4ia-pill { background: #fdeaea; color: var(--red-dark); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e4ia-voicebar { border: 0; background: #ffb300; color: #141414; font-weight: 700; font-size: 13px; padding: 9px 12px; text-align: center; }
.e4ia-voicebar[hidden] { display: none; }

/* Mensajes */
.e4ia-msgs { flex: 1; overflow-y: auto; padding: 14px; background: var(--soft); display: flex; flex-direction: column; gap: 10px; }
.e4ia-msg { max-width: 86%; padding: 10px 13px; border-radius: 12px; word-break: break-word; white-space: pre-wrap; }
.e4ia-bot { align-self: flex-start; background: #fff; border-left: 4px solid var(--red); box-shadow: 0 1px 4px rgba(0, 0, 0, .06); }
.e4ia-user { align-self: flex-end; background: var(--red); color: #fff; border-bottom-right-radius: 3px; }
.e4ia-typing { display: flex; gap: 4px; padding: 14px 16px; }
.e4ia-typing span { width: 7px; height: 7px; border-radius: 50%; background: #999; animation: e4ia-bounce 1s infinite; }
.e4ia-typing span:nth-child(2) { animation-delay: .15s; }
.e4ia-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes e4ia-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Tarjetas de producto */
.e4ia-cards { display: flex; flex-direction: column; gap: 8px; }
.e4ia-card { display: flex; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.e4ia-card-cat { border-left: 4px solid var(--red); background: #fdf6f6; }
.e4ia-card-note { font-size: 11px; color: #777; margin-top: 2px; }
.e4ia-card-img { flex: none; width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #e8e8e5; }
.e4ia-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.e4ia-card-title { color: var(--ink); font-weight: 700; font-size: 13px; line-height: 1.3; }
.e4ia-card-title:hover { color: var(--red); }
.e4ia-card-price { color: var(--red); font-weight: 700; }
.e4ia-card-acts { display: flex; gap: 6px; margin-top: auto; }

.e4ia-btn-ghost, .e4ia-btn-wa {
  display: inline-block; padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center;
}
.e4ia-btn-ghost { background: #fff; color: var(--ink) !important; border: 1px solid var(--ink); }
.e4ia-btn-ghost:hover { background: var(--ink); color: #fff !important; }
.e4ia-btn-wa { background: var(--wa); color: #fff !important; border: 1px solid var(--wa); }
.e4ia-btn-wa:hover { filter: brightness(.92); }
.e4ia-btn-big { padding: 10px 14px; font-size: 13px; flex: 1; }
.e4ia-contact { display: flex; gap: 8px; flex-wrap: wrap; }

/* Atajos */
.e4ia-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; background: var(--soft); }
.e4ia-chips:not(:empty) { padding-bottom: 10px; }
.e4ia-chip { background: #fff; border: 1px solid var(--red); color: var(--red); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.e4ia-chip:hover { background: var(--red); color: #fff; }

/* Entrada */
.e4ia-row { display: flex; gap: 6px; align-items: center; padding: 10px; background: #fff; border-top: 1px solid var(--line); }
.e4ia-input { flex: 1; min-width: 0; border: 1px solid #bbb; border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit; }
.e4ia-input:focus { border-color: var(--red); }
.e4ia-input:disabled { background: #f0f0f0; }
.e4ia-mic { width: 40px; height: 40px; border: 0; border-radius: 8px; background: #eee; font-size: 16px; }
.e4ia-mic.is-rec { background: var(--red); color: #fff; animation: e4ia-pulse 1s infinite; }
@keyframes e4ia-pulse { 50% { opacity: .55; } }
.e4ia-send { height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--red); color: #fff; font-weight: 700; }
.e4ia-send:disabled { opacity: .5; cursor: default; }

/* Móvil: pantalla completa */
@media (max-width: 520px) {
  .e4ia-panel, .e4ia-top .e4ia-panel { inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; border-radius: 0; }
  .e4ia-launcher { right: 12px; bottom: 14px; }
  .e4ia-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .e4ia-launcher, .e4ia-typing span, .e4ia-mic.is-rec { animation: none; transition: none; }
}

/* Tamaños del panel (cambia con las flechas 🔽 / 🔼) */
.e4ia-panel.e4ia-size-s  { width: 340px; height: 520px; }
.e4ia-panel.e4ia-size-m  { width: 400px; height: 640px; }
.e4ia-panel.e4ia-size-l  { width: 460px; height: 760px; }
.e4ia-panel.e4ia-size-xl { width: 520px; height: 88vh; }
@media (max-width: 520px) {
  .e4ia-panel.e4ia-size-s, .e4ia-panel.e4ia-size-m, .e4ia-panel.e4ia-size-l, .e4ia-panel.e4ia-size-xl {
    width: 100vw; height: 100dvh; max-width: none; max-height: none;
  }
}
.e4ia-tool:disabled { opacity: .35; cursor: default; }

/* Tamaños del panel (cambia con las flechas 🔽 / 🔼) */
.e4ia-panel.e4ia-size-s  { width: 340px; height: 520px; }
.e4ia-panel.e4ia-size-m  { width: 400px; height: 640px; }
.e4ia-panel.e4ia-size-l  { width: 460px; height: 760px; }
.e4ia-panel.e4ia-size-xl { width: 520px; height: 88vh; }
@media (max-width: 520px) {
  .e4ia-panel.e4ia-size-s, .e4ia-panel.e4ia-size-m, .e4ia-panel.e4ia-size-l, .e4ia-panel.e4ia-size-xl {
    width: 100vw; height: 100dvh; max-width: none; max-height: none;
  }
}
.e4ia-tool:disabled { opacity: .35; cursor: default; }
