/* ============================================================
   GlobalSoftServer — orion.css
   Widget de chat del asistente virtual "Orión"
   Tema oscuro azul/cian. Usa las variables del sitio con
   valores de respaldo por si styles.css no está cargado.
   ============================================================ */

.orion-raiz {
  --o-accent: var(--accent, #2f7bff);
  --o-accent-2: var(--accent-2, #22d3ee);
  --o-gradient: var(--gradient, linear-gradient(135deg, #2f7bff 0%, #22d3ee 100%));
  --o-surface: var(--surface, #141d3a);
  --o-bg-alt: var(--bg-alt, #0f1730);
  --o-border: var(--border, #24304f);
  --o-text: var(--text, #e6ecf7);
  --o-text-muted: var(--text-muted, #94a3c4);
  --o-radius: var(--radius, 14px);
  --o-shadow: var(--shadow, 0 10px 30px rgba(0, 0, 0, .35));
  --o-font: var(--font, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);

  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: 1000;
  font-family: var(--o-font);
  color: var(--o-text);
}

.orion-raiz *,
.orion-raiz *::before,
.orion-raiz *::after { box-sizing: border-box; }

/* ---------- Botón flotante (FAB) ---------- */
.orion-fab {
  position: relative;
  width: 64px;
  height: 64px;
  border: 1px solid var(--o-border);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, var(--o-surface), var(--o-bg-alt));
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(47, 123, 255, .45),
              inset 0 0 0 1px rgba(34, 211, 238, .12);
  transition: transform .18s ease, box-shadow .18s ease;
}
.orion-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 16px 36px rgba(47, 123, 255, .55),
              inset 0 0 0 1px rgba(34, 211, 238, .22);
}
.orion-fab:active { transform: scale(.97); }
.orion-fab:focus-visible {
  outline: 3px solid var(--o-accent-2);
  outline-offset: 3px;
}
.orion-fab svg { width: 28px; height: 28px; display: block; }
.orion-fab .orion-fab-chat { display: grid; place-items: center; width: 100%; height: 100%; }
.orion-fab .orion-fab-chat .orion-avatar-svg { width: 50px; height: 50px; }
.orion-fab .orion-fab-cerrar { color: var(--o-text); }

/* icono cerrar dentro del fab (cuando está abierto) */
.orion-fab .orion-fab-cerrar { display: none; }
.orion-raiz.orion-abierto .orion-fab .orion-fab-chat { display: none; }
.orion-raiz.orion-abierto .orion-fab .orion-fab-cerrar { display: block; }

/* Badge / puntito */
.orion-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #34d399;
  border: 2px solid var(--o-bg-alt);
  box-shadow: 0 0 0 rgba(52, 211, 153, .6);
  animation: orion-pulso 2.2s infinite;
}
@keyframes orion-pulso {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
  70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.orion-raiz.orion-abierto .orion-badge { display: none; }

/* ---------- Ventana de chat ---------- */
.orion-ventana {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--o-bg-alt);
  border: 1px solid var(--o-border);
  border-radius: 18px;
  box-shadow: var(--o-shadow);
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
}
.orion-ventana[hidden] { display: none; }
.orion-raiz:not(.orion-abierto) .orion-ventana {
  opacity: 0;
  transform: translateY(10px) scale(.96);
  pointer-events: none;
}
.orion-raiz.orion-abierto .orion-ventana {
  opacity: 1;
  transform: none;
}

/* ---------- Encabezado ---------- */
.orion-encabezado {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--o-surface);
  border-bottom: 1px solid var(--o-border);
}
.orion-avatar {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--o-border);
  background: radial-gradient(circle at 50% 34%, var(--o-surface), var(--o-bg-alt));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(47, 123, 255, .4),
              inset 0 0 0 1px rgba(34, 211, 238, .12);
}
.orion-avatar .orion-avatar-svg { width: 44px; height: 44px; }

/* ---------- Avatar SVG: animaciones sutiles ---------- */
.orion-avatar-svg {
  display: block;
  overflow: visible;
  animation: orion-respira 4.5s ease-in-out infinite;
}
@keyframes orion-respira {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 1px rgba(34, 211, 238, .25)); }
  50%      { transform: scale(1.035); filter: drop-shadow(0 0 5px rgba(34, 211, 238, .55)); }
}
/* Parpadeo de los ojos cada pocos segundos */
.orion-avatar-svg .orion-ojo {
  transform-box: fill-box;
  transform-origin: center;
  animation: orion-parpadeo 5.4s infinite;
}
@keyframes orion-parpadeo {
  0%, 91%, 100% { transform: scaleY(1); }
  94%           { transform: scaleY(.08); }
  97%           { transform: scaleY(1); }
}
/* Antena con leve latido de glow */
.orion-avatar-svg .orion-antena {
  transform-box: fill-box;
  transform-origin: center;
  animation: orion-antena 3.2s ease-in-out infinite;
}
@keyframes orion-antena {
  0%, 100% { opacity: .85; }
  50%      { opacity: 1; }
}
.orion-titulo-bloque { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.orion-titulo {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.orion-estado-punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  display: inline-block;
}
.orion-subtitulo {
  font-size: .78rem;
  color: var(--o-text-muted);
}
.orion-cerrar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--o-text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}
.orion-cerrar:hover { background: rgba(255, 255, 255, .07); color: var(--o-text); }
.orion-cerrar:focus-visible { outline: 2px solid var(--o-accent-2); outline-offset: 2px; }

/* ---------- Botón de voz (altavoz) ---------- */
.orion-voz {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--o-accent-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}
.orion-voz svg { width: 18px; height: 18px; display: block; }
.orion-voz:hover { background: rgba(255, 255, 255, .07); }
.orion-voz:focus-visible { outline: 2px solid var(--o-accent-2); outline-offset: 2px; }
.orion-voz[disabled] { opacity: .4; cursor: not-allowed; }
.orion-voz .orion-voz-off { display: none; }
.orion-voz.orion-muted { color: var(--o-text-muted); }
.orion-voz.orion-muted .orion-voz-on { display: none; }
.orion-voz.orion-muted .orion-voz-off { display: block; }

/* ---------- Cuerpo / mensajes ---------- */
.orion-mensajes {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--o-border) transparent;
}
.orion-mensajes::-webkit-scrollbar { width: 8px; }
.orion-mensajes::-webkit-scrollbar-thumb {
  background: var(--o-border);
  border-radius: 8px;
}

.orion-burbuja {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: orion-aparece .22s ease;
}
@keyframes orion-aparece {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.orion-burbuja-orion {
  align-self: flex-start;
  background: var(--o-surface);
  border: 1px solid var(--o-border);
  border-bottom-left-radius: 4px;
  color: var(--o-text);
}
.orion-burbuja-usuario {
  align-self: flex-end;
  background: var(--o-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.orion-burbuja a { color: inherit; text-decoration: underline; }

/* ---------- Chips de sugerencias ---------- */
.orion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 6px;
}
.orion-chip {
  border: 1px solid var(--o-border);
  background: var(--o-surface);
  color: var(--o-accent-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.orion-chip:hover {
  background: var(--o-bg-alt);
  border-color: var(--o-accent);
  transform: translateY(-1px);
}
.orion-chip:focus-visible { outline: 2px solid var(--o-accent-2); outline-offset: 2px; }

/* ---------- Indicador escribiendo ---------- */
.orion-escribiendo {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: var(--o-surface);
  border: 1px solid var(--o-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.orion-escribiendo span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--o-text-muted);
  animation: orion-rebote 1.2s infinite ease-in-out;
}
.orion-escribiendo span:nth-child(2) { animation-delay: .18s; }
.orion-escribiendo span:nth-child(3) { animation-delay: .36s; }
@keyframes orion-rebote {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Pie / input ---------- */
.orion-pie {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--o-surface);
  border-top: 1px solid var(--o-border);
}
.orion-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--o-border);
  background: var(--o-bg-alt);
  color: var(--o-text);
  font-family: inherit;
  font-size: .9rem;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s ease;
}
.orion-input::placeholder { color: var(--o-text-muted); }
.orion-input:focus { border-color: var(--o-accent); }

.orion-enviar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--o-gradient);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s ease, opacity .15s ease;
}
.orion-enviar svg { width: 20px; height: 20px; }
.orion-enviar:hover { transform: translateY(-1px); }
.orion-enviar:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.orion-enviar:focus-visible { outline: 2px solid var(--o-accent-2); outline-offset: 2px; }

/* ---------- Responsive: móvil casi pantalla completa ---------- */
@media (max-width: 480px) {
  .orion-raiz { right: 14px; bottom: 14px; }
  .orion-ventana {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 84px;
    top: 12px;
    width: auto;
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orion-badge,
  .orion-escribiendo span,
  .orion-burbuja,
  .orion-fab,
  .orion-ventana,
  .orion-avatar-svg,
  .orion-avatar-svg .orion-ojo,
  .orion-avatar-svg .orion-antena { animation: none; transition: none; }
  .orion-avatar-svg { transform: none; filter: none; }
}
