/* ======================================================================
   alfred.css — Alfred, asistente virtual del panel Equiser
   Burbuja flotante + ventana de chat con colores corporativos.
   ====================================================================== */

:root {
  --alf-navy: #17365E;
  --alf-navy-2: #0F2544;
  --alf-gold: #E29F36;
  --alf-gold-soft: #F6E3C2;
  --alf-bg: #FFFFFF;
  --alf-line: #E3E7EE;
  --alf-text: #22314A;
  --alf-muted: #6B7686;
}

[data-theme="dark"] {
  --alf-bg: #182233;
  --alf-line: #2C3A52;
  --alf-text: #E7ECF4;
  --alf-muted: #93A0B4;
  --alf-gold-soft: #3A2E18;
}

/* --------------------------- Burbuja flotante ------------------------ */
.alf-bubble {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2.5px solid var(--alf-gold);
  background: var(--alf-navy);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(15, 37, 68, .35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.alf-bubble:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 12px 30px rgba(15, 37, 68, .45); }
.alf-bubble:focus-visible { outline: 3px solid var(--alf-gold); outline-offset: 3px; }
.alf-bubble svg { width: 30px; height: 30px; }
.alf-bubble .alf-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--alf-gold);
  border: 2.5px solid #fff;
}

/* --------------------------- Ventana de chat ------------------------- */
.alf-panel {
  position: fixed;
  right: 22px;
  bottom: 94px;
  z-index: 1200;
  width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 130px));
  background: var(--alf-bg);
  border: 1px solid var(--alf-line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 37, 68, .30);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.alf-panel.open { opacity: 1; transform: none; pointer-events: auto; }

/* Encabezado */
.alf-head {
  background: linear-gradient(135deg, var(--alf-navy) 0%, var(--alf-navy-2) 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 3px solid var(--alf-gold);
  flex: 0 0 auto;
}
.alf-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--alf-gold);
  color: var(--alf-navy-2);
  font-weight: 800;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.alf-head-txt { flex: 1 1 auto; min-width: 0; }
.alf-head-txt strong { display: block; font-size: 15px; letter-spacing: .2px; }
.alf-head-txt span { display: block; font-size: 11px; opacity: .82; margin-top: 1px; }
.alf-head-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.alf-iconbtn {
  background: rgba(255, 255, 255, .12);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.alf-iconbtn:hover { background: rgba(255, 255, 255, .25); }

/* Cuerpo de mensajes */
.alf-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.alf-msg { max-width: 86%; display: flex; flex-direction: column; gap: 3px; }
.alf-msg .alf-meta { font-size: 10px; color: var(--alf-muted); padding: 0 4px; }
.alf-msg .alf-txt {
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.alf-msg.alfredo { align-self: flex-start; }
.alf-msg.alfredo .alf-txt {
  background: var(--alf-bg);
  border: 1px solid var(--alf-line);
  border-left: 3px solid var(--alf-gold);
  color: var(--alf-text);
  border-top-left-radius: 4px;
}
.alf-msg.usuario { align-self: flex-end; align-items: flex-end; }
.alf-msg.usuario .alf-txt {
  background: var(--alf-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.alf-msg.sistema { align-self: center; max-width: 94%; }
.alf-msg.sistema .alf-txt {
  background: var(--alf-gold-soft);
  color: var(--alf-text);
  border: 1px dashed var(--alf-gold);
  font-size: 12px;
  border-radius: 10px;
}

/* texto enriquecido mínimo dentro de mensajes */
.alf-txt strong { font-weight: 700; }
.alf-txt code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; font-size: 12px; }

/* Indicador "escribiendo" */
.alf-typing { display: inline-flex; gap: 4px; padding: 10px 12px; }
.alf-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--alf-gold);
  animation: alfbounce 1.1s infinite ease-in-out;
}
.alf-typing i:nth-child(2) { animation-delay: .18s; }
.alf-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes alfbounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Chips de sugerencias */
.alf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px 8px;
  flex: 0 0 auto;
}
.alf-chip {
  border: 1px solid var(--alf-gold);
  background: transparent;
  color: var(--alf-text);
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
.alf-chip:hover { background: var(--alf-gold-soft); }

/* Barra de entrada */
.alf-inputbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--alf-line);
  background: var(--alf-bg);
}
.alf-inputbar textarea {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--alf-line);
  border-radius: 10px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  max-height: 90px;
  color: var(--alf-text);
  background: var(--alf-bg);
}
.alf-inputbar textarea:focus { outline: 2px solid var(--alf-gold); outline-offset: -1px; border-color: var(--alf-gold); }
.alf-send {
  flex: 0 0 auto;
  width: 42px;
  border: none;
  border-radius: 10px;
  background: var(--alf-gold);
  color: var(--alf-navy-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter .15s ease;
}
.alf-send:hover { filter: brightness(1.08); }
.alf-send:disabled { opacity: .5; cursor: not-allowed; }
.alf-send svg { width: 19px; height: 19px; }

@media (max-width: 480px) {
  .alf-panel { right: 10px; bottom: 84px; }
  .alf-bubble { right: 14px; bottom: 14px; }
}
