/* ============================================================
   IChat — Asistente de formación IYC
   Estilos del widget · aislados bajo .iyc-chat / .cc-*
   ------------------------------------------------------------
   · No depende de ningún otro CSS. Define sus propias variables
     y una pila de fuentes con fallback del sistema. Si tu sitio
     ya carga DM Sans / Darker Grotesque, se usan automáticamente.
   · Posición por defecto: abajo a la IZQUIERDA.
     Para abajo-derecha: añade la clase .iyc-chat--right (o
     position:'right' en la config JS).
   ============================================================ */

.iyc-chat, .iyc-chat *{ box-sizing:border-box; }

.iyc-chat{
  /* paleta de marca */
  --w-ink:#001C55; --w-ink2:#3a4a78; --w-ink3:#7e89ab;
  --w-line:rgba(0,28,85,0.12); --w-line2:rgba(0,28,85,0.07);
  --w-soft:#f3f5fb;
  --grad:linear-gradient(135deg,#110AEE 0%,#F72585 100%);
  --ok:#18b368; --alert:#FF2D55;
  --elev:0 28px 70px -26px rgba(0,0,0,0.55), 0 6px 18px -8px rgba(0,0,0,0.35);
  --eo:cubic-bezier(.16,1,.3,1);
  --cc-sans:"DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cc-display:"Darker Grotesque", "DM Sans", system-ui, sans-serif;

  position:fixed; left:20px; bottom:20px; z-index:9999;
  font-family:var(--cc-sans);
}
.iyc-chat--right{ left:auto; right:20px; }

/* ---- launcher cerrado (círculo con wordmark IChat) ---- */
.iyc-chat .cc-launcher{
  position:relative; width:66px; height:66px; border-radius:50%; cursor:pointer; border:0;
  background:var(--grad); box-shadow:0 16px 40px -12px rgba(17,10,238,0.55), inset 0 1px 0 rgba(255,255,255,0.25);
  display:grid; place-items:center; color:#fff;
  transition:transform .26s var(--eo), box-shadow .26s;
}
.iyc-chat .cc-launcher::before{ content:""; position:absolute; inset:-3px; border-radius:50%; z-index:-1;
  background:conic-gradient(from 120deg,#110AEE,#F72585,#110AEE); opacity:.6; filter:blur(6px); }
.iyc-chat .cc-launcher:hover{ transform:translateY(-2px) scale(1.04); box-shadow:0 22px 50px -12px rgba(247,37,133,0.6); }
.iyc-chat .cc-name{ font:800 17px/1 var(--cc-display); letter-spacing:-0.01em; color:#fff; text-shadow:0 1px 8px rgba(0,28,85,0.35); }

/* badge + ping (aviso) */
.iyc-chat .cc-badge{
  position:absolute; top:-2px; right:-2px; min-width:22px; height:22px; padding:0 6px; border-radius:999px;
  background:var(--alert); color:#fff; border:2.5px solid #fff; font:700 12px/1 var(--cc-sans);
  display:grid; place-items:center; transform:scale(0); transition:transform .34s var(--eo); z-index:2;
}
.iyc-chat .cc-ping{ position:absolute; inset:-7px; border-radius:50%; border:2px solid var(--alert); opacity:0; pointer-events:none; }

/* teaser (aviso) — sale junto al launcher */
.iyc-chat .cc-teaser{
  position:absolute; left:0; bottom:80px; width:250px;
  background:#fff; color:var(--w-ink); border-radius:18px 18px 18px 4px;
  box-shadow:var(--elev); padding:14px 15px; display:flex; gap:11px; align-items:flex-start; cursor:pointer;
  transform:translateY(14px) scale(.96); opacity:0; pointer-events:none; transform-origin:bottom left;
  transition:transform .4s var(--eo), opacity .3s;
}
.iyc-chat--right .cc-teaser{ left:auto; right:0; border-radius:18px 18px 4px 18px; transform-origin:bottom right; }
.iyc-chat .cc-teaser .spark{ width:30px; height:30px; flex:0 0 30px; border-radius:9px; background:var(--grad); display:grid; place-items:center; color:#fff; }
.iyc-chat .cc-teaser .spark svg{ width:17px; height:17px; }
.iyc-chat .cc-teaser .tx{ font:400 13.5px/1.45 var(--cc-sans); }
.iyc-chat .cc-teaser .tx b{ font-weight:600; }
.iyc-chat .cc-teaser .x{ position:absolute; top:-8px; right:-8px; width:22px; height:22px; border-radius:50%; background:#fff; border:1px solid var(--w-line); display:grid; place-items:center; color:var(--w-ink2); }
.iyc-chat .cc-teaser .x svg{ width:12px; height:12px; }

/* ---- panel abierto (compacto) ---- */
.iyc-chat .cc-panel{
  position:absolute; left:0; bottom:0; width:344px; max-height:min(540px, calc(100vh - 40px));
  background:#fff; color:var(--w-ink); border-radius:22px; overflow:hidden;
  box-shadow:var(--elev); border:1px solid rgba(255,255,255,0.5);
  display:flex; flex-direction:column;
  transform-origin:bottom left; transform:translateY(20px) scale(.92); opacity:0; pointer-events:none;
  transition:transform .42s var(--eo), opacity .3s;
}
.iyc-chat--right .cc-panel{ left:auto; right:0; transform-origin:bottom right; }
.iyc-chat .cc-header{ position:relative; display:flex; align-items:center; gap:13px; padding:16px 16px 14px; border-bottom:1px solid var(--w-line2); overflow:hidden;
  background:linear-gradient(120deg, rgba(17,10,238,0.09), rgba(247,37,133,0.09)); }
.iyc-chat .cc-header::after{ content:""; position:absolute; inset:0; pointer-events:none; opacity:.5;
  background:repeating-linear-gradient(115deg, transparent 0 9px, rgba(17,10,238,0.04) 9px 10px); }
/* mark de marca (sin avatar) */
.iyc-chat .cc-mark{ position:relative; width:42px; height:42px; flex:0 0 42px; border-radius:12px; background:var(--grad); display:grid; place-items:center; color:#fff; box-shadow:0 10px 24px -10px rgba(17,10,238,0.65); }
.iyc-chat .cc-mark svg{ width:24px; height:24px; }
.iyc-chat .cc-id{ flex:1; min-width:0; position:relative; }
.iyc-chat .cc-id .nm{ font:800 18px/1.05 var(--cc-display); letter-spacing:-0.01em; }
.iyc-chat .cc-id .rl{ font:500 12.5px/1.3 var(--cc-sans); color:var(--w-ink2); margin-top:1px; }
.iyc-chat .cc-x{ position:relative; width:36px; height:36px; border-radius:50%; border:1px solid var(--w-line); background:#fff; color:var(--w-ink2); display:grid; place-items:center; cursor:pointer; transition:background .2s, transform .2s; }
.iyc-chat .cc-x:hover{ background:var(--w-soft); transform:rotate(90deg); }
.iyc-chat .cc-x svg{ width:18px; height:18px; }

/* scroll */
.iyc-chat .cc-scroll{ flex:1; overflow-y:auto; overflow-x:hidden; padding:16px 15px 6px; display:flex; flex-direction:column; gap:12px; scroll-behavior:smooth; }
.iyc-chat .cc-scroll::-webkit-scrollbar{ width:7px; } .iyc-chat .cc-scroll::-webkit-scrollbar-thumb{ background:rgba(0,28,85,0.16); border-radius:8px; }

/* saludo */
.iyc-chat .cc-greet h2{ font:800 24px/1.08 var(--cc-display); letter-spacing:-0.01em; margin:0; }
.iyc-chat .cc-greet h2 .pk{ background:var(--grad); -webkit-background-clip:text; background-clip:text; color:transparent; }
.iyc-chat .cc-greet p{ font:400 13.5px/1.5 var(--cc-sans); color:var(--w-ink2); margin:8px 0 0; }

/* botones de opción (con icono) */
.iyc-chat .cc-opts{ display:flex; flex-direction:column; gap:9px; }
.iyc-chat .cc-opt{
  display:flex; align-items:center; gap:12px; width:100%; text-align:left; cursor:pointer;
  font:500 14.5px/1.3 var(--cc-sans); border-radius:16px; padding:13px 15px;
  background:#fff; color:var(--w-ink); border:1px solid var(--w-line);
  transition:box-shadow .24s, border-color .24s, background .24s, transform .18s var(--eo);
}
.iyc-chat .cc-opt .ico{ width:34px; height:34px; flex:0 0 34px; border-radius:10px; display:grid; place-items:center; background:rgba(17,10,238,0.08); color:#110AEE; transition:background .24s, color .24s; }
.iyc-chat .cc-opt .ico svg{ width:18px; height:18px; }
.iyc-chat .cc-opt .lbl{ flex:1; }
.iyc-chat .cc-opt .arr{ width:24px; height:24px; flex:0 0 24px; border-radius:50%; border:1px solid var(--w-line); color:var(--w-ink3); display:grid; place-items:center; transition:transform .3s var(--eo), background .24s, color .24s, border-color .24s; }
.iyc-chat .cc-opt .arr svg{ width:13px; height:13px; }
.iyc-chat .cc-opt:hover{ border-color:rgba(247,37,133,0.5); box-shadow:0 10px 26px -14px rgba(247,37,133,0.5); }
.iyc-chat .cc-opt:hover .arr{ transform:rotate(-45deg); }
.iyc-chat .cc-opt--primary{ background:var(--grad); color:#fff; border-color:transparent; }
.iyc-chat .cc-opt--primary .ico{ background:rgba(255,255,255,0.18); color:#fff; }
.iyc-chat .cc-opt--primary .arr{ border-color:rgba(255,255,255,0.5); color:#fff; }
.iyc-chat .cc-opt--primary:hover{ box-shadow:0 12px 30px -12px rgba(247,37,133,0.6); }
.iyc-chat .cc-opt--primary:hover .arr{ transform:rotate(-45deg); background:rgba(255,255,255,0.18); }

/* mensajes */
.iyc-chat .cc-msg{ max-width:88%; font:400 14.5px/1.5 var(--cc-sans); padding:12px 15px; border-radius:18px; animation:cc-rise .4s var(--eo) both; }
@keyframes cc-rise{ from{ transform:translateY(10px); opacity:0; } to{ transform:none; opacity:1; } }
@keyframes cc-fade-up{ from{ opacity:0; transform:translateY(12px); } to{ opacity:1; transform:none; } }
.iyc-chat .cc-msg--bot{ align-self:flex-start; background:var(--w-soft); border:1px solid var(--w-line2); border-bottom-left-radius:6px; color:var(--w-ink); }
.iyc-chat .cc-msg--user{ align-self:flex-end; background:var(--grad); color:#fff; border-bottom-right-radius:6px; }
.iyc-chat .cc-row-av{ display:flex; gap:8px; align-items:flex-end; align-self:flex-start; max-width:92%; }
.iyc-chat .cc-row-av .mini{ width:26px; height:26px; flex:0 0 26px; border-radius:8px; background:var(--grad); display:grid; place-items:center; color:#fff; margin-bottom:2px; }
.iyc-chat .cc-row-av .mini svg{ width:15px; height:15px; }

/* escribiendo… */
.iyc-chat .cc-typing{ align-self:flex-start; display:flex; gap:4px; background:var(--w-soft); border:1px solid var(--w-line2); padding:13px 15px; border-radius:18px 18px 18px 6px; margin-left:34px; }
.iyc-chat .cc-typing i{ width:7px; height:7px; border-radius:50%; background:var(--w-ink3); animation:cc-blink 1.2s infinite ease-in-out; }
.iyc-chat .cc-typing i:nth-child(2){ animation-delay:.18s; } .iyc-chat .cc-typing i:nth-child(3){ animation-delay:.36s; }
@keyframes cc-blink{ 0%,80%,100%{ opacity:.3; transform:translateY(0); } 40%{ opacity:1; transform:translateY(-3px); } }

/* barra de entrada */
.iyc-chat .cc-input{ display:flex; align-items:center; gap:9px; padding:12px 14px calc(14px + env(safe-area-inset-bottom)); border-top:1px solid var(--w-line2); }
.iyc-chat .cc-input input{ flex:1; height:46px; border-radius:999px; border:1px solid var(--w-line); background:#fff; padding:0 18px; font:400 14.5px/1 var(--cc-sans); color:var(--w-ink); outline:none; transition:border-color .2s, box-shadow .2s; }
.iyc-chat .cc-input input::placeholder{ color:var(--w-ink3); }
.iyc-chat .cc-input input:focus{ border-color:rgba(247,37,133,0.5); box-shadow:0 0 0 3px rgba(247,37,133,0.14); }
.iyc-chat .cc-send{ width:46px; height:46px; flex:0 0 46px; border-radius:50%; border:0; background:var(--grad); color:#fff; display:grid; place-items:center; cursor:pointer; transition:transform .2s var(--eo), box-shadow .24s; }
.iyc-chat .cc-send:hover{ transform:translateY(-1px); box-shadow:0 12px 28px -10px rgba(247,37,133,0.6); }
.iyc-chat .cc-send:active{ transform:scale(.94); }
.iyc-chat .cc-send svg{ width:20px; height:20px; }
.iyc-chat .cc-footer{ text-align:center; font:500 11px/1 var(--cc-sans); color:var(--w-ink3); padding:0 0 12px; }
.iyc-chat .cc-footer b{ color:var(--w-ink2); font-weight:600; }

/* ---- estados abiertos + animaciones de aparición ---- */
.iyc-chat[data-open="true"] .cc-panel{ transform:none; opacity:1; pointer-events:auto; }
.iyc-chat[data-open="true"] .cc-launcher{ transform:scale(.9); opacity:0; pointer-events:none; }
.iyc-chat[data-open="true"] .cc-teaser{ opacity:0 !important; pointer-events:none !important; }
.iyc-chat[data-alert="true"] .cc-badge{ transform:scale(1); }
.iyc-chat[data-alert="true"] .cc-ping{ animation:cc-ping 2.4s var(--eo) infinite; }
.iyc-chat[data-teaser="true"] .cc-teaser{ opacity:1; transform:none; pointer-events:auto; }
@keyframes cc-ping{ 0%{ transform:scale(.8); opacity:.6; } 70%,100%{ transform:scale(1.5); opacity:0; } }

.iyc-chat[data-open="true"] .cc-greet{ animation:cc-fade-up .5s var(--eo) both; animation-delay:.10s; }
.iyc-chat[data-open="true"] #ccOpts .cc-opt{ animation:cc-fade-up .5s var(--eo) both; }
.iyc-chat[data-open="true"] #ccOpts .cc-opt:nth-child(1){ animation-delay:.18s; }
.iyc-chat[data-open="true"] #ccOpts .cc-opt:nth-child(2){ animation-delay:.26s; }
.iyc-chat[data-open="true"] #ccOpts .cc-opt:nth-child(3){ animation-delay:.34s; }

@media (prefers-reduced-motion: reduce){
  .iyc-chat *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
}

/* ---- MÓVIL: panel a pantalla completa ---- */
@media (max-width:560px){
  .iyc-chat{ left:16px; bottom:16px; }
  .iyc-chat--right{ left:auto; right:16px; }
  .iyc-chat .cc-panel{
    position:fixed; inset:0; width:100vw; height:100dvh; max-height:none; border-radius:0; border:0;
    transform:translateY(100%); transform-origin:center;
  }
  .iyc-chat[data-open="true"] .cc-panel{ transform:none; }
  .iyc-chat .cc-header{ padding-top:max(16px, env(safe-area-inset-top)); }
  .iyc-chat .cc-greet h2{ font-size:28px; }
}

/* Suprimir transiciones durante el montaje inicial del widget.
   Evita el flash de "abre y cierra" al navegar entre paginas.
   La clase se quita tras 2 frames via widget.js */
.iyc-chat.iyc-no-transition *,
.iyc-chat.iyc-no-transition .cc-panel {
  transition: none !important;
  animation: none !important;
}
