/* =============================================================================
   EXLIBRIC CHAT — Estilos del widget «Eduardo»
   -----------------------------------------------------------------------------
   Todo vive bajo  #exl-chat  con clases  cc-*.
   Sin conflicto con Elementor, jQuery ni los plugins IC Grupo (IFormulario,
   ICookie). z-index superior al popup de Elementor (2147483000).

   Fuentes: usa las que ya carga exlibric.com
     Prata      → display / headings (cargada en google-fonts-1)
     PT Serif   → texto de mensajes  (cargada en google-fonts-1)
     Roboto     → UI / botones       (cargada en google-fonts-1)
   El plugin NO encola fuentes adicionales.
   ============================================================================= */

#exl-chat {
  --cc-accent:       #D0021B;
  --cc-accent-deep:  #A60321;
  --cc-ink:          #0D0D0D;
  --cc-paper:        #FFFFFF;
  --cc-subtle:       #F2F2F2;
  --cc-hairline:     #D5D7D8;
  --cc-text:         #232628;
  --cc-muted:        #5F6366;
  --cc-faint:        #8A8E91;
  --cc-on-ink:       #FFFFFF;
  --cc-on-ink-muted: #B5B8BA;
  --cc-online:       #22C55E;
  --cc-font-display: "Prata", Georgia, "Times New Roman", serif;
  --cc-font-ui:      "Roboto", "Helvetica Neue", Arial, sans-serif;
  --cc-font-serif:   "PT Serif", Georgia, "Times New Roman", serif;
  --cc-radius:    2px;
  --cc-ease:      cubic-bezier(.22,.61,.36,1);
  --cc-ease-pop:  cubic-bezier(.34,1.56,.64,1);

  position: fixed; right: 26px; bottom: 26px; z-index: 2147483000;
  font-family: var(--cc-font-ui); line-height: 1.4;
}
#exl-chat *,#exl-chat *::before,#exl-chat *::after { box-sizing: border-box; }

#exl-chat                    { --cc-launcher: var(--cc-ink); }
#exl-chat[data-accent="red"] { --cc-launcher: var(--cc-accent); }

/* posición izquierda */
#exl-chat[data-pos="left"] { right: auto; left: 26px; }
#exl-chat[data-pos="left"] .cc-launcher { right: auto; left: 0; }
#exl-chat[data-pos="left"] .cc-badge    { right: auto; left: -4px; }
#exl-chat[data-pos="left"] .cc-panel    { right: auto; left: 0; transform-origin: bottom left; }
#exl-chat[data-pos="left"] .cc-peek     { right: auto; left: 80px; border-bottom-right-radius: var(--cc-radius); border-bottom-left-radius: 0; transform-origin: bottom left; }
#exl-chat[data-pos="left"] .cc-peek .cc-x { left: auto; right: -9px; }

/* ── Burbuja lanzadora ── */
#exl-chat .cc-launcher {
  position: absolute; right: 0; bottom: 0;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--cc-launcher); border: 0; cursor: pointer; color: #fff;
  box-shadow: 0 16px 34px rgba(13,13,13,.34);
  /* Contenedor relativo para apilar los dos iconos en el centro */
  display: flex; align-items: center; justify-content: center;
  animation: cc-in .5s var(--cc-ease-pop) both, cc-float 4.5s ease-in-out 1s infinite;
  transition: transform .25s var(--cc-ease), background .25s var(--cc-ease);
}
#exl-chat .cc-launcher:hover { transform: scale(1.07); background: var(--cc-accent); }
/* Ambos SVG se superponen exactamente en el centro */
#exl-chat .cc-launcher svg {
  width: 28px; height: 28px;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity .2s, transform .2s;
}
#exl-chat .cc-launcher .cc-ic-close { opacity: 0; transform: translate(-50%, -50%) rotate(-45deg); }
#exl-chat.cc-open .cc-launcher .cc-ic-chat  { opacity: 0; transform: translate(-50%, -50%) rotate(45deg); }
#exl-chat.cc-open .cc-launcher .cc-ic-close { opacity: 1; transform: translate(-50%, -50%) rotate(0deg); }
#exl-chat.cc-open .cc-launcher { animation: none; background: var(--cc-ink); }
#exl-chat .cc-launcher::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--cc-accent); opacity: 0;
}
#exl-chat.cc-alert:not(.cc-open) .cc-launcher::after { animation: cc-ring 2.2s ease-out infinite; }

/* ── Badge ── */
#exl-chat .cc-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--cc-accent); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(208,2,27,.5); border: 2px solid #fff;
  transform: scale(0); opacity: 0;
}
#exl-chat.cc-alert:not(.cc-open) .cc-badge { animation: cc-badge .45s var(--cc-ease-pop) forwards; }

/* ── Peek ── */
#exl-chat .cc-peek {
  position: absolute; bottom: 8px; right: 80px; width: 272px;
  background: var(--cc-paper); color: var(--cc-text);
  border: 1px solid var(--cc-hairline); border-radius: var(--cc-radius); border-bottom-right-radius: 0;
  padding: 14px 16px; box-shadow: 0 18px 48px rgba(13,13,13,.16);
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  transform: translateY(10px) scale(.92); transform-origin: bottom right;
  opacity: 0; pointer-events: none;
  transition: opacity .3s var(--cc-ease), transform .3s var(--cc-ease-pop);
}
#exl-chat.cc-peek:not(.cc-open) .cc-peek { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#exl-chat .cc-peek img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
#exl-chat .cc-peek .cc-nm { font-family: var(--cc-font-display); font-weight: 400; font-size: 14px; margin-bottom: 3px; }
#exl-chat .cc-peek .cc-tx { font-size: 13px; line-height: 1.45; color: var(--cc-muted); font-family: var(--cc-font-serif); }
#exl-chat .cc-peek .cc-x {
  position: absolute; top: -9px; left: -9px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; border: 1px solid var(--cc-hairline);
  color: #999; display: grid; place-items: center; font-size: 13px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(13,13,13,.07);
}

/* ── Panel ── */
#exl-chat .cc-panel {
  position: absolute; right: 0; bottom: 80px;
  width: 384px; max-height: min(624px, calc(100vh - 120px));
  background: var(--cc-paper); color: var(--cc-text);
  border-radius: var(--cc-radius); overflow: hidden;
  box-shadow: 0 28px 70px rgba(13,13,13,.3);
  display: flex; flex-direction: column; border: 1px solid var(--cc-hairline);
  transform: translateY(24px) scale(.94); transform-origin: bottom right;
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--cc-ease), transform .34s var(--cc-ease-pop);
}
#exl-chat.cc-open .cc-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* cabecera */
#exl-chat .cc-head { display: flex; align-items: center; gap: 13px; padding: 18px; background: var(--cc-ink); color: #fff; flex-shrink: 0; }
#exl-chat .cc-ava  { position: relative; width: 46px; height: 46px; flex: none; }
#exl-chat .cc-ava img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid var(--cc-accent); }
#exl-chat .cc-ava .cc-ava-ph { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--cc-accent); background: repeating-linear-gradient(135deg,#333 0 4px,#555 4px 8px); filter: grayscale(1); }
#exl-chat .cc-ava .cc-on { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--cc-online); border: 2.5px solid var(--cc-ink); }
#exl-chat .cc-ava .cc-on.offline { background: var(--cc-faint); }
#exl-chat .cc-head .cc-nm { font-family: var(--cc-font-display); font-weight: 400; font-size: 17px; line-height: 1.1; }
#exl-chat .cc-head .cc-rl { font-size: 12px; color: var(--cc-on-ink-muted); margin-top: 3px; }
#exl-chat .cc-head .cc-rl b { color: #7BD88F; font-weight: 600; }
#exl-chat .cc-head .cc-rl b.offline { color: var(--cc-faint); }
#exl-chat .cc-close { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.22); background: transparent; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; transition: background .2s; flex-shrink: 0; }
#exl-chat .cc-close svg { display: block; flex-shrink: 0; }
#exl-chat .cc-close:hover { background: rgba(255,255,255,.12); }

/* cuerpo */
#exl-chat .cc-body { flex: 1; overflow-y: auto; padding: 22px 18px 8px; background: var(--cc-paper); scroll-behavior: smooth; }
#exl-chat .cc-body::-webkit-scrollbar { width: 6px; }
#exl-chat .cc-body::-webkit-scrollbar-thumb { background: var(--cc-hairline); border-radius: 10px; }

/* saludo editorial */
#exl-chat .cc-intro-h { font-family: var(--cc-font-display); font-weight: 400; font-size: 22px; color: var(--cc-ink); margin: 0 0 8px; line-height: 1.2; }
#exl-chat .cc-intro-h i { font-style: italic; color: var(--cc-accent); }
#exl-chat .cc-intro-p { font-family: var(--cc-font-serif); font-size: 14px; line-height: 1.6; color: var(--cc-muted); margin: 0 0 18px; }

/* mensajes */
#exl-chat .cc-row-av { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
#exl-chat .cc-row-av > img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }
#exl-chat .cc-row-av .cc-mini-ph { width: 26px; height: 26px; border-radius: 50%; flex: none; background: repeating-linear-gradient(135deg,#c4cad8 0 4px,#d7dce6 4px 8px); filter: grayscale(1); }
#exl-chat .cc-msg { display: flex; animation: cc-msg .4s var(--cc-ease) both; }
#exl-chat .cc-msg--user { justify-content: flex-end; margin-bottom: 12px; }
#exl-chat .cc-msg .cc-bub { max-width: 80%; padding: 12px 15px; font-size: 14px; line-height: 1.55; border-radius: 4px; }
#exl-chat .cc-msg--bot .cc-bub { background: var(--cc-subtle); color: var(--cc-text); border-bottom-left-radius: 2px; font-family: var(--cc-font-serif); }
#exl-chat .cc-msg--bot .cc-bub p { margin: 0 0 8px; }
#exl-chat .cc-msg--bot .cc-bub p:last-child { margin-bottom: 0; }
#exl-chat .cc-msg--bot .cc-bub ul,#exl-chat .cc-msg--bot .cc-bub ol { margin: 6px 0 6px 16px; padding: 0; }
#exl-chat .cc-msg--bot .cc-bub li { margin-bottom: 4px; }
#exl-chat .cc-msg--bot .cc-bub a { color: var(--cc-accent); text-decoration: underline; }
#exl-chat .cc-msg--bot .cc-bub strong,#exl-chat .cc-msg--bot .cc-bub b { font-weight: 700; color: var(--cc-ink); }
#exl-chat .cc-msg--user .cc-bub { background: var(--cc-ink); color: #fff; border-bottom-right-radius: 2px; font-family: var(--cc-font-ui); }

/* error */
#exl-chat .cc-error { font-size: 13px; color: var(--cc-accent); background: rgba(208,2,27,.07); border: 1px dashed rgba(208,2,27,.3); border-radius: var(--cc-radius); padding: 10px 14px; margin-bottom: 12px; font-family: var(--cc-font-ui); animation: cc-msg .4s var(--cc-ease) both; }

/* opciones */
#exl-chat .cc-opts { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 8px; }
#exl-chat .cc-opt { width: 100%; text-align: left; font-family: var(--cc-font-ui); font-weight: 500; font-size: 14px; cursor: pointer; padding: 14px 16px; border-radius: var(--cc-radius); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--cc-paper); border: 1px solid var(--cc-hairline); color: var(--cc-ink); transition: transform .15s var(--cc-ease),border-color .2s,background .2s,color .2s; animation: cc-msg .4s var(--cc-ease) both; }
#exl-chat .cc-opt:hover { border-color: var(--cc-ink); }
#exl-chat .cc-opt--primary { background: var(--cc-ink); color: #fff; border-color: var(--cc-ink); }
#exl-chat .cc-opt--primary:hover { background: var(--cc-accent); border-color: var(--cc-accent); }
#exl-chat .cc-opt .arr { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--cc-subtle); color: var(--cc-ink); transition: background .2s,color .2s; }
#exl-chat .cc-opt--primary .arr { background: rgba(255,255,255,.16); color: #fff; }
#exl-chat .cc-opt:hover .arr { background: var(--cc-accent); color: #fff; }
#exl-chat .cc-opt--primary:hover .arr { background: rgba(255,255,255,.22); }
#exl-chat .cc-opt .arr svg { width: 14px; height: 14px; }
#exl-chat .cc-opts.cc-disabled .cc-opt { pointer-events: none; opacity: .45; }

/* typing */
#exl-chat .cc-typing { display: flex; gap: 4px; padding: 14px 16px; background: var(--cc-subtle); border-radius: 4px; border-bottom-left-radius: 2px; width: fit-content; }
#exl-chat .cc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--cc-faint); animation: cc-blink 1.2s infinite; }
#exl-chat .cc-typing span:nth-child(2) { animation-delay: .2s; }
#exl-chat .cc-typing span:nth-child(3) { animation-delay: .4s; }

/* límite de mensajes */
#exl-chat .cc-limit-notice { align-self: center; text-align: center; font-size: 13px; color: var(--cc-muted); border: 1px dashed var(--cc-hairline); padding: 10px 14px; border-radius: var(--cc-radius); max-width: 90%; font-family: var(--cc-font-serif); margin-bottom: 8px; animation: cc-msg .4s var(--cc-ease) both; }

/* input */
#exl-chat .cc-foot { padding: 12px 14px; border-top: 1px solid var(--cc-hairline); background: var(--cc-paper); flex-shrink: 0; }
#exl-chat .cc-input { display: flex; align-items: center; gap: 10px; background: var(--cc-subtle); border: 1px solid var(--cc-hairline); border-radius: 999px; padding: 6px 6px 6px 18px; transition: border-color .2s,background .2s,box-shadow .2s; }
#exl-chat .cc-input:focus-within { border-color: var(--cc-accent); background: #fff; box-shadow: 0 0 0 3px rgba(208,2,27,.15); }
#exl-chat .cc-input input { flex: 1; border: 0; background: transparent; font-family: var(--cc-font-ui); font-size: 14px; color: var(--cc-ink); outline: none; }
#exl-chat .cc-input input::placeholder { color: var(--cc-faint); }
#exl-chat .cc-input input:disabled { opacity: .5; cursor: not-allowed; }
#exl-chat .cc-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--cc-ink); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; flex: none; transition: transform .18s var(--cc-ease),background .18s; }
#exl-chat .cc-send svg { display: block; flex-shrink: 0; }
#exl-chat .cc-send:hover { transform: scale(1.08); background: var(--cc-accent); }
#exl-chat .cc-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#exl-chat .cc-legal { text-align: center; font-size: 11px; color: var(--cc-faint); margin-top: 9px; }
#exl-chat .cc-legal b { color: var(--cc-muted); font-weight: 600; }

/* ── Keyframes ── */
@keyframes cc-in    { from{transform:scale(0) translateY(20px);opacity:0} to{transform:scale(1) translateY(0);opacity:1} }
@keyframes cc-float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }
@keyframes cc-ring  { 0%{opacity:.8;transform:scale(1)} 100%{opacity:0;transform:scale(1.55)} }
@keyframes cc-badge { from{transform:scale(0);opacity:0} to{transform:scale(1);opacity:1} }
@keyframes cc-msg   { from{transform:translateY(10px);opacity:0} to{transform:translateY(0);opacity:1} }
@keyframes cc-blink { 0%,60%,100%{opacity:.3;transform:translateY(0)} 30%{opacity:1;transform:translateY(-3px)} }

@media (prefers-reduced-motion:reduce) {
  #exl-chat * { animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.05ms !important; }
}

/* ── Móvil (≤ 760px) — Elementor usa 767px, usamos 760 para no solapar ── */
@media (max-width:760px) {

  /* El widget ocupa toda la pantalla para poder posicionar
     el panel en fullscreen y el launcher en esquina */
  #exl-chat { right:0; bottom:0; left:0; }

  /* Bug 3: burbuja 20% más pequeña en móvil (64px → 52px) */
  #exl-chat .cc-launcher {
    right: 18px; bottom: 18px;
    width: 52px; height: 52px;
  }
  #exl-chat .cc-launcher svg { width: 22px; height: 22px; }
  #exl-chat[data-pos="left"] .cc-launcher { left: 18px; right: auto; }

  /* Bug 2: el badge se posiciona relativo a #exl-chat (que ocupa toda
     la pantalla en movil). El launcher esta en bottom:18px / right:18px
     y mide 52px. El badge (22px) debe aparecer en la esquina sup-der
     del launcher: right = 18-4 = 14px, bottom = 18+52-4 = 66px */
  #exl-chat .cc-badge {
    right:  14px;
    bottom: 66px;
    top: auto;
  }

  /* El peek se oculta siempre en móvil */
  #exl-chat .cc-peek { display: none; }

  /* Panel fullscreen */
  #exl-chat .cc-panel {
    right: 0; bottom: 0; left: 0;
    width: 100%; max-height: 100vh; height: 100dvh;
    border-radius: 0; border: 0;
    transform: translateY(100%);
  }
  #exl-chat.cc-open .cc-panel { transform: translateY(0); }

  /* Safe area en cabecera */
  #exl-chat .cc-head { padding-top: max(18px, env(safe-area-inset-top)); }

  /* Bug 4: ocultar el launcher cuando el panel está abierto en móvil.
     El panel ya ocupa toda la pantalla y tiene su propio botón de cerrar.
     El launcher flotante encima del panel es confuso y visualmente incorrecto. */
  #exl-chat.cc-open .cc-launcher { display: none; }
}
