/* Chatbot web L4F — estilos del widget (prefijo l4fc- para no colisionar) */

#l4fc-root {
  --l4fc-green: #16a34a;
  --l4fc-green-dark: #0b3d2e;
  --l4fc-bg: #ffffff;
  --l4fc-user: #dcfce7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Botón flotante ---- */
#l4fc-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--l4fc-green-dark), var(--l4fc-green));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
#l4fc-fab:hover { transform: scale(1.07); }
#l4fc-fab { animation: l4fc-fab-pop 0.22s ease-out; }
@keyframes l4fc-fab-pop {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}
/* toggle: con el chat abierto el robot se sustituye por una flecha "contraer" */
.l4fc-fab-icon-close { display: none !important; }
#l4fc-fab.l4fc-open .l4fc-fab-icon { display: none; }
#l4fc-fab.l4fc-open .l4fc-fab-icon-close { display: flex !important; }
#l4fc-fab.l4fc-open .l4fc-fab-ball { display: none; }
.l4fc-fab-icon { display: flex; align-items: center; justify-content: center; line-height: 1; }
.l4fc-fab-icon svg { display: block; }
.l4fc-fab-ball {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 18px;
  animation: l4fc-bounce 2.4s infinite;
}
@keyframes l4fc-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ---- Panel ---- */
/* El atributo hidden solo aplica display:none de navegador y cualquier regla
   de autor lo pisa — hay que forzarlo explícitamente */
#l4fc-panel[hidden] { display: none !important; }

#l4fc-panel {
  position: fixed;
  right: 20px;
  bottom: 92px; /* deja visible el botón flotante debajo (60px + márgenes) */
  z-index: 99991;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  background: var(--l4fc-bg);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* animación de apertura: pop desde el botón flotante (queda debajo) */
  transform-origin: calc(100% - 30px) calc(100% + 45px);
  animation: l4fc-pop-in 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#l4fc-panel.l4fc-closing {
  animation: l4fc-pop-out 0.24s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}
@keyframes l4fc-pop-in {
  from { opacity: 0; transform: scale(0.5) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes l4fc-pop-out {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.5) translateY(30px); }
}
@media (prefers-reduced-motion: reduce) {
  #l4fc-panel, #l4fc-panel.l4fc-closing, #l4fc-fab { animation: none; }
}
@media (max-width: 480px) {
  #l4fc-panel {
    right: 8px;
    left: 8px;
    bottom: 88px; /* el botón flotante sigue visible y usable como toggle */
    width: auto;
    height: calc(100vh - 104px);
    height: calc(100dvh - 104px);
    max-height: 560px;
  }
}

/* ---- Cabecera ---- */
.l4fc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--l4fc-green-dark), var(--l4fc-green));
  color: #fff;
}
.l4fc-head-txt {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.l4fc-head-txt strong { font-size: 14px; letter-spacing: 0.3px; }
.l4fc-head-txt span { font-size: 12px; opacity: 0.85; }
.l4fc-close, .l4fc-reset {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.18s ease, transform 0.28s ease, border-color 0.18s ease;
}
.l4fc-close svg, .l4fc-reset svg { display: block; }
.l4fc-reset:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(180deg);
}
.l4fc-close:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(90deg);
}
.l4fc-close:active, .l4fc-reset:active { transform: scale(0.88); }

/* ---- Mensajes ---- */
.l4fc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f3f6f4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.l4fc-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}
.l4fc-bot {
  background: #fff;
  color: #1d2a23;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.l4fc-user {
  background: var(--l4fc-user);
  color: #14352a;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.l4fc-msg a { color: var(--l4fc-green); text-decoration: underline; word-break: break-all; }
.l4fc-msg strong { font-weight: 700; }

/* indicador escribiendo */
.l4fc-typing { display: flex; gap: 4px; padding: 12px 14px; }
.l4fc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ab5a6;
  animation: l4fc-blink 1.2s infinite;
}
.l4fc-typing span:nth-child(2) { animation-delay: 0.2s; }
.l4fc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes l4fc-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* ---- Aviso IA en pausa ---- */
.l4fc-banner {
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  border-bottom: 1px solid #fde68a;
  color: #713f12;
  font-size: 12.5px;
  line-height: 1.4;
  padding: 8px 12px;
}
.l4fc-banner a { color: #166534; word-break: break-all; }

/* ---- Respuestas rápidas ---- */
.l4fc-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px;
  background: #f3f6f4;
}
.l4fc-opts:not(:empty) { padding-bottom: 10px; }
.l4fc-opt {
  border: 1.5px solid var(--l4fc-green);
  color: var(--l4fc-green-dark);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s ease;
  text-align: left;
}
.l4fc-opt:hover { background: var(--l4fc-user); }

/* ---- Input ---- */
.l4fc-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e3e9e5;
  background: #fff;
}
.l4fc-input {
  flex: 1;
  border: 1px solid #cfd9d2;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}
.l4fc-input:focus { border-color: var(--l4fc-green); }
.l4fc-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--l4fc-green);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  flex: 0 0 auto;
}
.l4fc-send:hover { background: var(--l4fc-green-dark); }
