/* Andi (asistente) y su chat · Lima 3D. Colores de Ambiental Andina. */
:root { --a-amarillo: #FCCC00; --a-celeste: #009CE4; --a-turquesa: #24A8C0; --a-petroleo: #24849C; --a-verde: #3C9C48; --a-lima: #78C03C;
        --n-critico: #c2306a; --n-alto: #dd3b2a; --n-medio: #f39a32; }

/* ------------------------------------------------------------------ personaje (andi.js) */
svg.andi { width: 100%; height: 100%; overflow: visible; display: block; }
svg.andi .sombra { fill: #000; animation: a-sombra 3.4s ease-in-out infinite; transform-origin: 60px 146px; }
svg.andi .cuerpo { animation: a-flotar 3.4s ease-in-out infinite; transform-origin: 60px 120px; }
svg.andi .cuerpo-in { transform-origin: 60px 120px; transition: transform .45s ease; }
svg.andi .brazo-i, svg.andi .brazo-d { fill: none; stroke-width: 7; stroke-linecap: round; }
svg.andi .brazo-i { stroke: var(--a-turquesa); }
svg.andi .brazo-d { stroke: var(--a-lima); transform-origin: 98px 104px; transform-box: view-box; }
svg.andi .ojo { fill: #c9f6ff; transform-box: fill-box; transform-origin: center; animation: a-parpadeo 5.5s infinite; }
svg.andi .ojos { transition: transform .4s ease; }
svg.andi .feliz path { fill: none; stroke: #c9f6ff; stroke-width: 3; stroke-linecap: round; }
svg.andi .alerta-ojos { fill: #ffd28a; }
svg.andi .boca { fill: var(--a-amarillo); transform-box: fill-box; transform-origin: center; }
svg.andi .espiral { transform-box: fill-box; transform-origin: center; }
svg.andi .puntos { fill: var(--a-amarillo); }
svg.andi .exc circle:first-child { fill: var(--n-medio); stroke: #0b1424; stroke-width: 2; }
svg.andi .exc rect, svg.andi .exc circle + rect + circle { fill: #fff; }
svg.andi .feliz, svg.andi .alerta-ojos, svg.andi .puntos, svg.andi .exc { opacity: 0; transition: opacity .25s; }
svg.andi .ojos-normales { transition: opacity .25s; }
svg.andi .visor { transition: stroke .3s; stroke: transparent; stroke-width: 2; }
@keyframes a-flotar { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes a-sombra { 0%, 100% { transform: scaleX(1); opacity: .28 } 50% { transform: scaleX(.82); opacity: .16 } }
@keyframes a-parpadeo { 0%, 45%, 49%, 100% { transform: scaleY(1) } 47% { transform: scaleY(.08) } }
@keyframes a-girar { to { transform: rotate(360deg) } }
@keyframes a-hablar { 0%, 100% { transform: scaleY(1) } 50% { transform: scaleY(1.9) } }
@keyframes a-punto { 0%, 100% { opacity: .25; transform: translateY(0) } 50% { opacity: 1; transform: translateY(-3px) } }
@keyframes a-temblor { 0%, 100% { transform: translateX(0) } 25% { transform: translateX(-1.5px) } 75% { transform: translateX(1.5px) } }
@keyframes a-saludo { 0%, 100% { transform: rotate(0) } 30% { transform: rotate(-28deg) } 60% { transform: rotate(-8deg) } }
svg.andi.pensando .ojos { transform: translate(0, -3px); }
svg.andi.pensando .espiral { animation: a-girar 1.4s linear infinite; }
svg.andi.pensando .puntos { opacity: 1; }
svg.andi.pensando .puntos circle { animation: a-punto 1.1s ease-in-out infinite; }
svg.andi.pensando .puntos circle:nth-child(2) { animation-delay: .18s; }
svg.andi.pensando .puntos circle:nth-child(3) { animation-delay: .36s; }
svg.andi.hablando .boca { animation: a-hablar .3s ease-in-out infinite; }
svg.andi.alerta .ojos-normales { opacity: 0; } svg.andi.alerta .alerta-ojos, svg.andi.alerta .exc { opacity: 1; }
svg.andi.alerta .visor { stroke: var(--n-medio); }
svg.andi.alerta .cuerpo-in { animation: a-temblor .45s ease-in-out 3; }
svg.andi.navegando .ojos { transform: translate(5px, 0); }
svg.andi.navegando .cuerpo-in { transform: rotate(6deg); }
svg.andi.contento .ojos-normales { opacity: 0; } svg.andi.contento .feliz { opacity: 1; }
svg.andi.contento .brazo-d { animation: a-saludo 1.1s ease-in-out 2; }
@media (prefers-reduced-motion: reduce) { svg.andi * { animation: none !important; } }

/* ------------------------------------------------------------------ lanzador (abajo a la derecha) */
#andi_btn { position: absolute; right: 18px; bottom: 30px; z-index: 8; width: 86px; height: 104px; padding: 0; border: 0; background: none;
  cursor: pointer; filter: drop-shadow(0 8px 18px rgba(0,0,0,.45)); transition: transform .2s ease; }
#andi_btn:hover { transform: translateY(-3px) scale(1.04); }
#andi_btn:focus-visible { outline: 2px solid var(--a-celeste); outline-offset: 4px; border-radius: 12px; }
#andi_btn .etq { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); white-space: nowrap; font-size: 10.5px; font-weight: 800;
  letter-spacing: 1.4px; color: #fff; background: rgba(11,20,36,.9); border: 1px solid rgba(255,255,255,.14); padding: 2px 8px; border-radius: 10px; }
body.chat-abierto #andi_btn { transform: scale(.82); transform-origin: bottom right; }
body.chat-abierto #andi_btn:hover { transform: scale(.86); }

/* burbuja de sugerencias según el contexto */
#andi_burbuja { position: absolute; right: 116px; bottom: 78px; z-index: 8; width: 270px; background: #fff; color: #12233b;
  border-radius: 14px 14px 4px 14px; padding: 11px 30px 11px 13px; font-size: 13px; line-height: 1.42; box-shadow: 0 12px 32px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(6px) scale(.98); pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
#andi_burbuja.ver { opacity: 1; transform: none; pointer-events: auto; }
#andi_burbuja::after { content: ''; position: absolute; right: -7px; bottom: 10px; border: 8px solid transparent; border-left-color: #fff; border-right: 0; }
#andi_burbuja .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: #7d8a9b; cursor: pointer; font-size: 14px; padding: 2px; }
#andi_burbuja .x:hover { color: #12233b; }
#andi_burbuja .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#andi_burbuja .chips button { border: 1px solid var(--a-petroleo); color: var(--a-petroleo); background: #fff; border-radius: 14px; padding: 3px 10px;
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
#andi_burbuja .chips button:hover { background: var(--a-petroleo); color: #fff; }
body.chat-abierto #andi_burbuja { display: none; }

/* ------------------------------------------------------------------ chat */
#chat { position: absolute; right: 16px; bottom: 132px; top: 136px;   /* debajo del buscador */ width: min(410px, calc(100vw - 32px)); z-index: 9; display: flex;
  flex-direction: column; overflow: hidden; border-radius: 14px; background: rgba(11, 20, 36, .94); border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 50px rgba(0,0,0,.5); backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease; }
#chat.abierto { opacity: 1; transform: none; pointer-events: auto; }
#chat::before { content: ''; height: 3px; flex: none;
  background: linear-gradient(90deg, var(--a-lima), var(--a-verde), var(--a-petroleo), var(--a-turquesa), var(--a-celeste)); }
#chat .cab { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
#chat .cab .av { width: 38px; height: 46px; flex: none; }
#chat .cab .nom { flex: 1; min-width: 0; }
#chat .cab .nom b { display: block; font-size: 15px; letter-spacing: .2px; }
#chat .cab .nom span { display: block; font-size: 11.5px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat .cab .nom span::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--a-lima);
  margin-right: 6px; vertical-align: 1px; box-shadow: 0 0 0 3px rgba(120,192,60,.2); }
#chat .cab .nom span.off::before { background: #8a96a8; box-shadow: none; }
#chat .cab button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--suave); cursor: pointer;
  display: grid; place-items: center; }
#chat .cab button:hover, #chat .cab button:focus-visible { background: rgba(255,255,255,.08); color: var(--texto); outline: none; }
#chat .cab svg.ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#chat_log { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 12px; font-size: 13.5px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
#chat .msg { max-width: 94%; line-height: 1.45; animation: m-entra .22s ease; }
@keyframes m-entra { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
#chat .msg.yo { align-self: flex-end; background: linear-gradient(135deg, #1f6fa8, #24849C); color: #fff; padding: 8px 12px;
  border-radius: 14px 14px 4px 14px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#chat .msg.ag { align-self: stretch; max-width: 100%; display: flex; gap: 8px; }
#chat .msg.ag .mini { width: 26px; height: 32px; flex: none; margin-top: 2px; }
#chat .msg.ag .cmsg { flex: 1; min-width: 0; }
#chat .msg.ag .txt { background: rgba(255,255,255,.065); border: 1px solid rgba(255,255,255,.06); padding: 9px 12px; border-radius: 4px 14px 14px 14px; }
#chat .resumen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
#chat .cnt { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; color: #fff; }
#chat .cnt.Crítico { background: var(--n-critico); } #chat .cnt.Alto { background: var(--n-alto); } #chat .cnt.Medio { background: var(--n-medio); color: #1b1300; }
#chat .vertodo { margin-left: auto; border: 1px solid rgba(92,200,255,.55); background: transparent; color: #5cc8ff; border-radius: 14px;
  padding: 3px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
#chat .vertodo:hover { background: rgba(92,200,255,.12); }
#chat .lista { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; max-height: 330px; overflow-y: auto; padding-right: 2px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
#chat .item { display: grid; grid-template-columns: 24px 1fr auto; gap: 9px; align-items: center; text-align: left; width: 100%;
  background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.08); border-left: 3px solid #8a96a8; border-radius: 9px;
  padding: 7px 9px; color: var(--texto); font: inherit; font-size: 12.5px; cursor: pointer; transition: background .15s, border-color .15s; }
#chat .item:hover, #chat .item:focus-visible { background: rgba(255,255,255,.08); outline: none; }
#chat .item.sel { background: rgba(92,200,255,.10); border-color: rgba(92,200,255,.45); }
#chat .item[disabled] { cursor: default; }
#chat .item.Crítico { border-left-color: var(--n-critico); } #chat .item.Alto { border-left-color: var(--n-alto); }
#chat .item.Medio { border-left-color: var(--n-medio); } #chat .item.zona { border-left-color: var(--a-celeste); }
#chat .item .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.08); color: var(--suave); }
#chat .item.sel .n { background: #5cc8ff; color: #06202e; }
#chat .item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat .item .d { color: var(--suave); font-size: 11.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat .item .c { min-width: 0; }
#chat .niv { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px; white-space: nowrap; color: #fff; background: #5d6b80; }
#chat .niv.Crítico, #chat .niv.muy { background: var(--n-critico); } #chat .niv.Alto, #chat .niv.alto { background: var(--n-alto); }
#chat .niv.Medio { background: var(--n-medio); color: #1b1300; }
#chat .pie { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; color: #8796aa; padding-left: 2px; }
#chat .pie .esp { flex: 1; }
#chat .pie button { width: 26px; height: 24px; border-radius: 6px; border: 1px solid rgba(255,255,255,.1); background: none; color: var(--suave);
  cursor: pointer; font-size: 12px; display: grid; place-items: center; }
#chat .pie button:hover:not(:disabled) { border-color: rgba(255,255,255,.3); }
#chat .pie button.ok { border-color: #5cc8ff; background: rgba(92,200,255,.12); }
#chat .pie .gracias { width: 100%; color: var(--a-lima); }
#chat .sug { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#chat .sug button, #chat_sug button { background: rgba(36,168,192,.10); border: 1px solid rgba(36,168,192,.45); color: var(--texto); border-radius: 15px;
  padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
#chat .sug button:hover, #chat_sug button:hover { background: rgba(36,168,192,.25); }
#chat_sug { display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px 0; scrollbar-width: none; }
#chat_sug button { white-space: nowrap; flex: none; }
#chat form { display: flex; gap: 8px; padding: 10px 12px 12px; }
#chat input { flex: 1; min-width: 0; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 22px;
  color: var(--texto); padding: 10px 15px; font: inherit; font-size: 14px; transition: border-color .15s, background .15s; }
#chat input::placeholder { color: #7f8da1; }
#chat input:focus { outline: none; border-color: var(--a-turquesa); background: rgba(255,255,255,.09); }
#chat form button { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a-celeste), var(--a-turquesa)); color: #fff; box-shadow: 0 4px 14px rgba(0,156,228,.35); }
#chat form button:disabled { opacity: .5; cursor: default; }
#chat form button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#chat .escribiendo .txt { display: inline-flex; gap: 4px; padding: 12px 14px; }
#chat .escribiendo i { width: 6px; height: 6px; border-radius: 50%; background: var(--suave); animation: a-punto 1s ease-in-out infinite; }
#chat .escribiendo i:nth-child(2) { animation-delay: .15s; } #chat .escribiendo i:nth-child(3) { animation-delay: .3s; }
#chat .pie-legal { font-size: 10.5px; color: #6f7d91; text-align: center; padding: 0 12px 8px; margin-top: -4px; }

@media (max-width: 700px) {
  #andi_btn { width: 64px; height: 78px; right: 10px; bottom: 22px; }
  #andi_burbuja { right: 80px; bottom: 56px; width: min(250px, calc(100vw - 100px)); }
  #chat { top: auto; right: 8px; left: 8px; width: auto; bottom: 8px; height: 66vh; }
  #chat.mini { height: 34vh; }
  body.chat-abierto #andi_btn { display: none; }
}
