/* Botón flotante */
#ri-chat-launcher{
  position:fixed; right:18px; bottom:18px; z-index:9999;
  width:56px; height:56px; border-radius:50%;
  background:#41ff9d; color:#06251a; border:0; cursor:pointer;
  display:flex; align-items:center; justify-content:center; font-size:22px;
  box-shadow:0 10px 30px rgba(0,0,0,.3); font-weight:800;
}

/* Panel */
#ri-chat{
  position:fixed; right:18px; bottom:84px; z-index:9999;
  width:360px; max-width:92vw; height:520px;
  background:#121a2e; border:1px solid #1f2a44; border-radius:16px;
  overflow:hidden; box-shadow:0 16px 40px rgba(0,0,0,.35);
  display:none; /* oculto por defecto */
}
#ri-chat.open{
  display:flex;           /* visible al abrir */
  flex-direction:column;  /* lo movemos aquí */
}

/* Header */
#ri-chat header{
  padding:12px 14px; background:#0f1629; border-bottom:1px solid #1f2a44;
  display:flex; align-items:center; gap:8px;
}
#ri-chat header .title{font-weight:800}
#ri-chat header .sub{color:#8ea0c0; font-size:12px; margin-left:auto}

/* Mensajes */
#ri-chat-messages{ flex:1; overflow:auto; padding:12px; display:flex; flex-direction:column; gap:10px; }
.ri-msg{ max-width:85%; padding:10px 12px; border-radius:14px; line-height:1.35; white-space:pre-wrap; word-wrap:break-word; }
.ri-user{ align-self:flex-end; background:#1a243d; border:1px solid #2a3a5c; }
.ri-ai{ align-self:flex-start; background:#0b1220; border:1px solid #1f2a44; }
.ri-ai .tag{display:inline-block; font-size:11px; color:#8ea0c0; margin-bottom:4px}

/* Input */
#ri-chat-input{ border-top:1px solid #1f2a44; padding:10px; background:#0f1629; }
#ri-chat-input form{ display:flex; gap:8px; }
#ri-chat-input textarea{
  flex:1; resize:none; min-height:42px; max-height:120px; padding:10px;
  background:#0b1220; color:#e8f0ff; border-radius:10px; border:1px solid #1f2a44;
}
#ri-send{ padding:10px 14px; border-radius:10px; border:0; cursor:pointer; font-weight:700;
  background:#41ff9d; color:#001e10; }
#ri-send[disabled]{ opacity:.6; cursor:not-allowed; }

/* Typing dots */
.ri-typing{ display:inline-block; min-width:24px }
.ri-typing i{ display:inline-block; width:6px; height:6px; margin-right:3px; border-radius:50%; background:#8ea0c0; animation:blink 1.2s infinite ease-in-out; }
.ri-typing i:nth-child(2){ animation-delay:.2s } .ri-typing i:nth-child(3){ animation-delay:.4s }
@keyframes blink{ 0%,80%,100%{opacity:.25} 30%{opacity:1} }

/* Botón cerrar */
#ri-chat header #ri-chat-close{
  margin-left:8px; background:transparent; color:#8ea0c0;
  border:0; cursor:pointer; font-size:18px; line-height:1;
  padding:6px; border-radius:8px;
}
#ri-chat header #ri-chat-close:hover{ background:#1a243d; color:#e8f0ff; }

