/* ============================================================
   asistente-ti.css | Copiloto TI · Levapan
   Estilos del widget flotante. Se carga en todas las vistas que
   montan el workspace autenticado.
   ============================================================ */

.ws-asistente {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.ws-asistente[hidden],
body:not([data-autenticado="true"]) .ws-asistente {
  display: none !important;
}

.ws-asistente-boton {
  height: 54px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  border: 1px solid #a27d54;
  background: linear-gradient(135deg, #990012, #7a000e);
  color: #f6f4f2;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(153, 0, 18, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s;
}
.ws-asistente-boton:hover { transform: translateY(-4px) scale(1.02); }
.ws-asistente-boton:active { transform: scale(0.97); }
.ws-asistente-ico { color: #f7e1c7; font-size: 1.1rem; }
.ws-asistente-texto { white-space: nowrap; }
.ws-asistente-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #35d07f;
  box-shadow: 0 0 0 4px rgba(53, 208, 127, 0.18), 0 0 12px rgba(53, 208, 127, 0.8);
  animation: aiPulso 2s ease-in-out infinite;
}
@keyframes aiPulso { 50% { opacity: 0.55; transform: scale(0.86); } }

.ws-asistente-panel {
  width: 390px;
  max-width: calc(100vw - 32px);
  max-height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 24px 60px rgba(17, 17, 17, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
}
.ws-asistente-panel[hidden] { display: none !important; }

.ws-asistente-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  background: linear-gradient(135deg, #990012, #7a000e);
  border-bottom: 1px solid rgba(162, 125, 84, 0.6);
}
.ws-asistente-cab strong { color: #f6f4f2; font-family: "Plus Jakarta Sans", sans-serif; font-size: 0.92rem; }
.ws-asistente-cab small { color: #f7e1c7; font-size: 0.68rem; }
.ws-asistente-cab .ws-cerrar { color: #f6f4f2; border-color: rgba(247, 225, 199, 0.5); background: rgba(255, 255, 255, 0.12); }

.ws-chat-sugerencias { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.ws-chat-sugerencias button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(162, 125, 84, 0.4);
  background: rgba(247, 225, 199, 0.55);
  color: #111111;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
}

.ws-chat-mensajes {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ws-chat-burbuja {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.ws-chat-burbuja.usuario {
  align-self: flex-end;
  background: #990012;
  color: #f6f4f2;
}
.ws-chat-burbuja.asistente {
  align-self: flex-start;
  background: #ffffff;
  color: #111111;
  border: 1px solid rgba(162, 125, 84, 0.24);
}
.ws-chat-tarjeta {
  align-self: stretch;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(153, 0, 18, 0.22);
  background: rgba(247, 225, 199, 0.32);
}
.ws-chat-tarjeta h4 { margin: 0 0 8px; font-family: "JetBrains Mono", monospace; color: #990012; }
.ws-chat-tarjeta dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px 10px; margin: 0; }
.ws-chat-tarjeta dt { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; color: #a27d54; }
.ws-chat-tarjeta dd { margin: 0; font-size: 0.76rem; color: #111111; }
.ws-chat-acciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ws-chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(162, 125, 84, 0.22); }
.ws-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(162, 125, 84, 0.32);
  background: #ffffff;
  color: #111111;
  font: inherit;
  font-size: 0.8rem;
}

@media (max-width: 520px) {
  .ws-asistente { right: 12px; bottom: 12px; }
  .ws-asistente-texto { display: none; }
}

/* Blindaje Edge: capa superior garantizada y eventos activos. */
.ws-asistente {
  z-index: 999999 !important;
  pointer-events: none;
}
.ws-asistente-boton,
.ws-asistente-panel {
  z-index: 999999 !important;
  pointer-events: auto !important;
  position: relative;
}
.ws-chat-burbuja.ws-chat-error {
  color: #990012 !important;
  border-color: rgba(153, 0, 18, 0.5) !important;
  background: rgba(247, 225, 199, 0.75) !important;
  font-weight: 600;
}
.ws-chat-burbuja.ws-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
}
.ws-chat-burbuja.ws-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #990012;
  animation: aiTyping 1s ease-in-out infinite;
}
.ws-chat-burbuja.ws-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ws-chat-burbuja.ws-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
#wsAsistentePanel[hidden] { display: none !important; }
