/* ============================================================================
   SMARTIN JOBS - el asistente. Boton flotante y ventana de conversacion.
   ============================================================================ */

#sj-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

/* ---------------------------------------------------------------- el boton */

.sj-chat__abrir {
  display: block;
  padding: 0;
  border: 0;
  background: none;          /* el boton ES el robot: nada de pildora detras */
  cursor: pointer;
  line-height: 0;
  filter: drop-shadow(0 10px 18px rgba(14, 26, 44, .22));
  transition: transform 160ms cubic-bezier(.2, .7, .4, 1), filter 160ms;
}
.sj-chat__abrir:hover { transform: translateY(-3px) scale(1.04); filter: drop-shadow(0 14px 24px rgba(14,26,44,.28)); }
.sj-chat__abrir:active { transform: translateY(-1px) scale(.99); }
.sj-chat__abrir:focus-visible { outline: 2px solid var(--sj-oro-vivo, #DCB43F); outline-offset: 6px; border-radius: 12px; }
/* Con el panel abierto desaparece el robot grande: ya esta en la cabecera. */
#sj-chat.sj-chat--abierto .sj-robot__wrap { display: none; }

/* ---------------------------------------------------------------- la ventana */

.sj-chat__panel[hidden] { display: none; }
.sj-chat__panel {
  width: min(430px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--sj-papel, #fff);
  border: 1px solid var(--sj-linea, #E4DCCF);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(14, 26, 44, .12), 0 24px 60px rgba(14, 26, 44, .2);
  overflow: hidden;
}
html.dark .sj-chat__panel { background: #16243A; border-color: rgba(255,255,255,.12); }

.sj-chat__cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--sj-tinta, #0E1A2C);
  color: #fff;
}
.sj-chat__cab b { font-size: 15px; font-weight: 650; display: block; }
.sj-chat__cab span { font-size: 11.5px; color: #A8B1BD; }
.sj-chat__cerrar {
  background: transparent; border: 0; color: #A8B1BD; cursor: pointer;
  padding: 6px; border-radius: 4px; display: grid; place-items: center;
}
.sj-chat__cerrar:hover { background: rgba(255,255,255,.1); color: #fff; }
.sj-chat__cerrar svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- el hilo */

.sj-chat__hilo {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sj-fondo, #F8F5EF);
}
html.dark .sj-chat__hilo { background: #0F1B2B; }

.sj-chat__bienvenida p {
  margin: 0 0 14px;
  color: var(--sj-tinta-2, #5A6472);
  font-size: 14px;
  line-height: 1.55;
}
.sj-chat__sugerencias { display: flex; flex-direction: column; gap: 7px; }
.sj-chat__sug {
  text-align: left;
  padding: 10px 13px;
  border: 1px solid var(--sj-linea, #E4DCCF);
  border-radius: 6px;
  background: var(--sj-papel, #fff);
  color: var(--sj-tinta, #0E1A2C);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}
.sj-chat__sug:hover { border-color: var(--sj-oro, #B8862B); background: #FBF7EE; }
html.dark .sj-chat__sug { background: rgba(255,255,255,.05); color: #EDE8DF; border-color: rgba(255,255,255,.12); }

.sj-chat__msg {
  max-width: 94%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.sj-chat__msg p { margin: 0 0 8px; }
.sj-chat__msg p:last-child { margin-bottom: 0; }
.sj-chat__msg ul { margin: 0 0 8px; padding-left: 19px; }
.sj-chat__msg li { margin: 3px 0; }
.sj-chat__msg b { font-weight: 650; }

.sj-chat__msg--yo {
  align-self: flex-end;
  background: var(--sj-tinta, #0E1A2C);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.sj-chat__msg--el {
  align-self: flex-start;
  background: var(--sj-papel, #fff);
  color: var(--sj-tinta, #0E1A2C);
  border: 1px solid var(--sj-linea, #E4DCCF);
  border-bottom-left-radius: 3px;
}
html.dark .sj-chat__msg--el { background: rgba(255,255,255,.06); color: #EDE8DF; border-color: rgba(255,255,255,.1); }

/* El codigo de tarea, como pastilla: se distingue de la prosa. */
.sj-chat__cod {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #F3EBDB;
  color: var(--sj-oro, #B8862B);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  vertical-align: 1px;
}
html.dark .sj-chat__cod { background: rgba(184,134,43,.22); color: #E8CB7A; }

a.sj-chat__cod { text-decoration: none; transition: background 140ms, color 140ms; }
a.sj-chat__cod:hover { background: var(--sj-oro, #B8862B); color: #fff; }

/* Un codigo que el modelo nombro pero que NO existe: se ve distinto a proposito. */
.sj-chat__cod--muerto {
  background: #F6E7E2;
  color: #8E2A2E;
  text-decoration: line-through;
}

/* ---------------------------------------------------------------- pensando */

.sj-chat__puntos { display: inline-flex; gap: 5px; padding: 2px 0; }
.sj-chat__puntos i {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--sj-tinta-3, #8B95A3);
  animation: sj-latido 1.2s infinite ease-in-out;
}
.sj-chat__puntos i:nth-child(2) { animation-delay: .15s; }
.sj-chat__puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes sj-latido { 0%,80%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------------------------------------------------------------- avisos y acciones */

.sj-chat__aviso {
  margin-top: 8px !important;
  padding: 9px 11px;
  border-radius: 6px;
  background: #F6E7E2;
  color: #8E2A2E;
  font-size: 13px;
  border-left: 3px solid var(--sj-rojo, #B3443B);
}
html.dark .sj-chat__aviso { background: rgba(179,68,59,.2); color: #F0C2BC; }

.sj-chat__accion {
  margin-top: 11px;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1px dashed var(--sj-oro, #B8862B);
  background: #FBF7EE;
}
html.dark .sj-chat__accion { background: rgba(184,134,43,.12); }
.sj-chat__accion p { margin: 0 0 9px; font-size: 13.5px; }
.sj-chat__accion div { display: flex; gap: 8px; }
.sj-chat__accion button {
  padding: 7px 14px; border-radius: 3px; font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.sj-chat__si { background: var(--sj-oro, #B8862B); color: #fff; }
.sj-chat__si:hover { background: var(--sj-oro-alto, #9A6B20); }
.sj-chat__no { background: transparent; border-color: var(--sj-linea-2, #D6CBB8) !important; color: var(--sj-tinta-2, #5A6472); }
.sj-chat__nota { color: var(--sj-tinta-3, #8B95A3); font-size: 13px; margin: 0 !important; }
.sj-chat__hecho { color: var(--sj-verde, #4E7A5A); font-size: 13.5px; margin: 0 !important; font-weight: 600; }
.sj-chat__hecho a { color: inherit; }

/* ---------------------------------------------------------------- escribir */

.sj-chat__pie {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--sj-linea, #E4DCCF);
  background: var(--sj-papel, #fff);
}
html.dark .sj-chat__pie { background: #16243A; border-color: rgba(255,255,255,.1); }

.sj-chat__pie textarea {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--sj-linea-2, #D6CBB8);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  max-height: 130px;
  background: var(--sj-papel, #fff);
  color: var(--sj-tinta, #0E1A2C);
}
html.dark .sj-chat__pie textarea { background: rgba(255,255,255,.06); color: #EDE8DF; border-color: rgba(255,255,255,.14); }
.sj-chat__pie textarea:focus {
  outline: none;
  border-color: var(--sj-oro, #B8862B);
  box-shadow: 0 0 0 3px rgba(184, 134, 43, .15);
}

.sj-chat__pie button[type=submit] {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 6px;
  background: var(--sj-oro, #B8862B);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background 140ms;
}
.sj-chat__pie button[type=submit]:hover { background: var(--sj-oro-alto, #9A6B20); }
.sj-chat__pie button[type=submit] svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- estrecho */

@media (max-width: 560px) {
  #sj-chat { right: 12px; bottom: 12px; left: 12px; }
  .sj-chat__panel { width: 100%; height: min(78vh, 560px); }
  .sj-chat__abrir { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .sj-chat__abrir, .sj-chat__puntos i { transition: none; animation: none; }
}

/* ============================================================================
   El robot. Es el boton del chat y vive siempre en la esquina.
   Las animaciones son lentas y cortas a proposito: algo que se mueve sin parar en
   la esquina de la pantalla cansa en diez minutos.
   ============================================================================ */

.sj-robot__wrap { position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.sj-chat__abrir {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  cursor: pointer;
  line-height: 0;
}
.sj-chat__abrir:hover { transform: none; box-shadow: none; }

.sj-robot { width: 124px; height: 146px; overflow: visible; }
.sj-robot--boton { filter: drop-shadow(0 8px 18px rgba(14, 26, 44, .22)); }
.sj-robot__sombra { fill: #0E1A2C; opacity: .10; }

/* Respira: sube y baja muy poco, muy despacio. */
.sj-robot--boton .sj-robot__cuerpo {
  transform-origin: 85px 190px;
  animation: sj-respira 4.2s ease-in-out infinite;
}
@keyframes sj-respira {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(-7px) }
}

/* Parpadea de vez en cuando. */
.sj-robot__ojos { transform-origin: 85px 67px; animation: sj-parpadeo 6.5s infinite; }
@keyframes sj-parpadeo {
  0%, 92%, 100% { transform: scaleY(1) }
  95%           { transform: scaleY(.1) }
}

/* La antena late. */
.sj-robot__antena { animation: sj-late 2.6s ease-in-out infinite; transform-origin: 85px 9px; }
@keyframes sj-late {
  0%, 100% { opacity: .55; transform: scale(1) }
  50%      { opacity: 1;   transform: scale(1.22) }
}

.sj-chat__abrir:hover .sj-robot--boton { filter: drop-shadow(0 12px 24px rgba(14,26,44,.3)); }
.sj-chat__abrir:hover .sj-robot__cuerpo { animation-duration: 2.1s; }

/* Mientras espera respuesta, el simbolo del pecho gira. */
/* El simbolo del pecho es el logo Orbita: orbita SIEMPRE, despacio. Antes solo
   giraba mientras el asistente pensaba y en reposo parecia una pieza rota. */
.sj-robot__orbita { transform-origin: 0 0; animation: sj-gira 14s linear infinite; }
.sj-chat__abrir:hover .sj-robot__orbita { animation-duration: 7s; }
/* Al preguntar acelera: es la señal de que esta trabajando. */
#sj-chat.sj-chat--pensando .sj-robot__orbita { animation-duration: 1.6s; }
@keyframes sj-gira { to { transform: rotate(360deg) } }

#sj-chat.sj-chat--abierto .sj-robot__wrap { display: none; }

/* ---------------------------------------------------------------- el bocadillo */

.sj-robot__burbuja {
  max-width: 260px;
  padding: 10px 14px;
  border-radius: 12px 12px 3px 12px;
  background: var(--sj-tinta, #0E1A2C);
  color: #F3EFE7;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(14, 26, 44, .24);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 320ms, transform 320ms;
}
.sj-robot__burbuja--entra { opacity: 1; transform: translateY(0); }

/* ---------------------------------------------------------------- en la cabecera */

.sj-robot--cabecera { width: 42px; height: 50px; flex: none; }
.sj-robot--cabecera .sj-robot__sombra { display: none; }
#sj-chat.sj-chat--pensando .sj-robot--cabecera .sj-robot__cuerpo {
  animation: sj-respira 1.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sj-robot__cuerpo, .sj-robot__ojos, .sj-robot__antena, .sj-robot__orbita { animation: none !important; }
  .sj-robot__burbuja { transition: none; }
}

/* En pantallas bajas el robot se encoge: no puede comerse la esquina util. */
@media (max-height: 620px), (max-width: 560px) {
  .sj-robot { width: 86px; height: 102px; }
  .sj-robot__burbuja { max-width: 200px; font-size: 12.5px; }
}

/* Las fichas de pregunta rapida viven sobre el campo, no dentro de la bienvenida:
   se responden sin motor (en milisegundos) y tienen que estar siempre a mano. */
.sj-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  border-top: 1px solid var(--sj-linea, #E4DCCF);
}
html.dark .sj-chat__chips { border-color: rgba(255,255,255,.1); }
.sj-chat__chips .sj-chat__sug {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}
