/* ============================================================
   iChat IYC — Widget de chat comercial
   Estilos del widget · Marca Innovación y Cualificación
   ------------------------------------------------------------
   · Todo aislado bajo .iyc-chat / .cc-*  → no choca con
     los estilos de la web ni con Elementor.
   · Tipografías: DM Sans (UI) + Darker Grotesque (titulares).
     Ya cargadas en la web de IYC.
   ============================================================ */

.iyc-chat {
  --cc-font-sans:    "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cc-font-display: "Darker Grotesque", "DM Sans", system-ui, sans-serif;
  --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);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: var(--cc-font-sans);
}

.iyc-chat--left {
  right: auto;
  left: 24px;
}

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

/* ── Burbuja cerrada (glass) ── */
.cc-launcher {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  cursor: pointer;
  border: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 16px 40px -12px rgba(17, 10, 238, 0.5);
  display: grid;
  place-items: center;
  color: var(--w-ink);
  transition: transform .26s var(--eo), box-shadow .26s;
}

.cc-launcher::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  z-index: -1;
  background: conic-gradient(from 120deg, #110AEE, #F72585, #110AEE);
  opacity: .55;
  filter: blur(5px);
}

.cc-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 22px 50px -12px rgba(247, 37, 133, 0.55);
}

.cc-launcher .ic-chat-svg {
  width: 30px;
  height: 30px;
  transition: transform .3s var(--eo), opacity .2s;
}

.cc-launcher .ic-close-svg {
  position: absolute;
  width: 26px;
  height: 26px;
  opacity: 0;
  transform: rotate(-90deg) scale(.6);
  transition: transform .3s var(--eo), opacity .2s;
}

/* Badge de aviso */
.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-font-sans);
  display: grid;
  place-items: center;
  transform: scale(0);
  transition: transform .34s var(--eo);
  z-index: 2;
}

.cc-ping {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid var(--alert);
  opacity: 0;
  pointer-events: none;
}

/* Globo teaser */
.cc-teaser {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 248px;
  background: #fff;
  color: var(--w-ink);
  border-radius: 18px 18px 4px 18px;
  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 right;
  transition: transform .4s var(--eo), opacity .3s;
}

.cc-teaser .av-mini {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
}

.cc-teaser .tx {
  font: 400 13.5px/1.45 var(--cc-font-sans);
}

.cc-teaser .tx b {
  font-weight: 600;
}

.cc-teaser .cc-teaser-close {
  position: absolute;
  top: -8px;
  left: -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);
  cursor: pointer;
}

.cc-teaser .cc-teaser-close svg {
  width: 12px;
  height: 12px;
}

/* ── Panel abierto ── */
.cc-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 392px;
  max-height: min(680px, calc(100vh - 48px));
  background: #fff;
  color: var(--w-ink);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--elev);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  transform: translateY(20px) scale(.92);
  opacity: 0;
  pointer-events: none;
  transition: transform .42s var(--eo), opacity .3s;
}

/* Header del panel */
.cc-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--w-line2);
  background: linear-gradient(120deg, rgba(17, 10, 238, 0.07), rgba(247, 37, 133, 0.07));
  flex-shrink: 0;
}

.cc-avatar {
  position: relative;
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
}

.cc-avatar .shape {
  position: absolute;
  inset: -3px -6px -6px -3px;
  border-radius: 50% 50% 52% 48%;
  background: var(--grad);
  transform: rotate(-12deg);
}

/* Placeholder foto B/N */
.cc-avatar .photo,
.cc-teaser .av-mini .photo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid #fff;
  background: repeating-linear-gradient(135deg, #c4cad8 0 5px, #d7dce6 5px 10px);
  filter: grayscale(1) contrast(.95);
}

.cc-teaser .av-mini .photo {
  border-width: 0;
}

.cc-avatar .photo::after,
.cc-teaser .av-mini .photo::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 0 0;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 -13px 0 -6px rgba(255, 255, 255, 0.55);
}

.cc-teaser .av-mini .photo::after {
  width: 20px;
  height: 20px;
  box-shadow: 0 -9px 0 -4px rgba(255, 255, 255, 0.55);
}

/* Foto real cuando se configura desde el panel */
.cc-avatar img,
.cc-teaser .av-mini img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cc-avatar img {
  border: 2.5px solid #fff;
}

/* Led online/offline */
.cc-avatar .on {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid #fff;
  transition: background .4s;
}

.cc-avatar .on.offline {
  background: #b0b8d0;
}

.cc-id {
  flex: 1;
  min-width: 0;
}

.cc-id .nm {
  font: 600 16.5px/1.15 var(--cc-font-sans);
}

.cc-id .rl {
  font: 500 12.5px/1.3 var(--cc-font-sans);
  color: var(--w-ink2);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Punto inline del texto — eliminado, solo queda el led del avatar */
.cc-id .rl i {
  display: none;
}

.cc-id .rl b {
  color: var(--ok);
  font-weight: 600;
  transition: color .4s, opacity .4s;
}

/* Offline: ocultar el texto de estado completamente */
.cc-id .rl b.offline {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
  display: inline-block;
}

.cc-x {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--w-line);
  background: #fff;
  color: var(--w-ink2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s, transform .25s var(--eo);
  flex-shrink: 0;
  transform-origin: center center;
  padding: 0;
}

.cc-x:hover {
  background: var(--w-soft);
  transform: rotate(90deg);
}

.cc-x svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

/* Zona de scroll (conversación) */
.cc-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.cc-scroll::-webkit-scrollbar { width: 7px; }
.cc-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 28, 85, 0.16);
  border-radius: 8px;
}

/* Saludo editorial — usa div, nunca h1-h6, para no afectar al SEO ni heredar estilos del tema */
.cc-greet-title {
  font: 800 30px/1.04 var(--cc-font-display) !important;
  letter-spacing: -0.01em !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: none !important;
  color: var(--w-ink) !important;
  text-transform: none !important;
  line-height: 1.04 !important;
}

.cc-greet-title .pk {
  background: var(--grad) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
  display: inline !important;
}

.cc-greet-sub {
  font: 400 14.5px/1.5 var(--cc-font-sans) !important;
  color: var(--w-ink2) !important;
  margin: 10px 0 0 !important;
  padding: 0 !important;
}

/* Botones de opción (pills) */
.cc-opts {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.cc-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: 500 14.5px/1.3 var(--cc-font-sans);
  border-radius: 999px;
  padding: 13px 17px;
  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);
  animation: cc-rise .42s var(--eo);
}

.cc-opt:hover {
  border-color: rgba(247, 37, 133, 0.5);
  box-shadow: 0 10px 26px -14px rgba(247, 37, 133, 0.5);
}

.cc-opt .arr {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  border: 1px solid var(--w-line);
  color: var(--w-ink2);
  display: grid;
  place-items: center;
  transition: transform .3s var(--eo), background .24s, color .24s, border-color .24s;
}

.cc-opt .arr svg {
  width: 13px;
  height: 13px;
}

.cc-opt:hover .arr {
  transform: rotate(-45deg);
}

.cc-opt--primary {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
}

.cc-opt--primary .arr {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.cc-opt--primary:hover {
  box-shadow: 0 12px 30px -12px rgba(247, 37, 133, 0.6);
}

.cc-opt--primary:hover .arr {
  transform: rotate(-45deg);
  background: rgba(255, 255, 255, 0.18);
}

/* Burbujas de mensaje */
.cc-msg {
  max-width: 86%;
  font: 400 14.5px/1.5 var(--cc-font-sans);
  padding: 12px 15px;
  border-radius: 18px;
  animation: cc-rise .4s var(--eo);
}

/* Estilos para HTML enriquecido en mensajes del bot */
.cc-msg--bot p { margin: 0 0 8px; }
.cc-msg--bot p:last-child { margin-bottom: 0; }
.cc-msg--bot ul, .cc-msg--bot ol { margin: 6px 0 6px 16px; padding: 0; }
.cc-msg--bot li { margin: 3px 0; }
.cc-msg--bot strong, .cc-msg--bot b { font-weight: 700; }
.cc-msg--bot em, .cc-msg--bot i { font-style: italic; }
.cc-msg--bot a { color: #110AEE; text-decoration: underline; }
.cc-msg--bot h1, .cc-msg--bot h2, .cc-msg--bot h3, .cc-msg--bot h4 {
  font-family: var(--cc-font-display);
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--w-ink);
}
.cc-msg--bot code {
  background: rgba(17,10,238,.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.cc-msg--bot pre {
  background: #0a1230;
  color: #e7e9f7;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
}
.cc-msg--bot blockquote {
  border-left: 3px solid rgba(17,10,238,.3);
  margin: 6px 0;
  padding-left: 10px;
  color: var(--w-ink2);
  font-style: italic;
}

@keyframes cc-rise {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.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);
}

.cc-msg--user {
  align-self: flex-end;
  background: var(--grad);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.cc-row-av {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  align-self: flex-start;
  max-width: 90%;
}

.cc-row-av .mini {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  margin-bottom: 2px;
}

/* Indicador "escribiendo…" */
.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;
}

.cc-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--w-ink3);
  animation: cc-blink 1.2s infinite ease-in-out;
}

.cc-typing i:nth-child(2) { animation-delay: .18s; }
.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 — especificidad reforzada para sobrescribir reset de Hello Elementor */
.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);
  flex-shrink: 0;
}

.iyc-chat .cc-input input[type="text"],
.iyc-chat .cc-input input {
  flex: 1 !important;
  height: 46px !important;
  border-radius: 999px !important;
  border: 1px solid var(--w-line) !important;
  background: #fff !important;
  padding: 0 18px !important;
  font: 400 14.5px/1 var(--cc-font-sans) !important;
  color: var(--w-ink) !important;
  outline: none !important;
  transition: border-color .2s, box-shadow .2s !important;
  width: auto !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.iyc-chat .cc-input input[type="text"]::placeholder,
.iyc-chat .cc-input input::placeholder { color: var(--w-ink3); }

.iyc-chat .cc-input input[type="text"]:focus,
.iyc-chat .cc-input input:focus {
  border-color: rgba(247, 37, 133, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(247, 37, 133, 0.14) !important;
  outline: none !important;
}

.iyc-chat .cc-input input[type="text"]:disabled,
.iyc-chat .cc-input input:disabled {
  opacity: .6 !important;
  cursor: not-allowed !important;
}

.cc-send {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s var(--eo), box-shadow .24s;
  padding: 0;
  transform-origin: center center;
}

.cc-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -10px rgba(247, 37, 133, 0.6);
}

.cc-send:active { transform: scale(.94); }

.cc-send:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.cc-send svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  /* El icono de avión apunta arriba-derecha, compensamos visualmente */
  transform: translateX(1px);
}

.cc-footer {
  text-align: center;
  font: 500 11px/1 var(--cc-font-sans);
  color: var(--w-ink3);
  padding: 0 0 12px;
  flex-shrink: 0;
}

.cc-footer b {
  color: var(--w-ink2);
  font-weight: 600;
}

/* Error */
.cc-error {
  align-self: center;
  font: 400 13px/1.4 var(--cc-font-sans);
  color: #c33;
  background: #fee;
  border: 1px solid rgba(204,51,51,.2);
  padding: 8px 14px;
  border-radius: 10px;
  animation: cc-rise .3s var(--eo);
}

/* ── Conmutadores de estado (data-*) ── */
.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; }
}

/* Posición izquierda */
.iyc-chat--left .cc-panel   { right: auto; left: 0; transform-origin: bottom left; }
.iyc-chat--left .cc-teaser  { right: auto; left: 0; border-radius: 18px 18px 18px 4px; }
.iyc-chat--left .cc-teaser .cc-teaser-close { left: auto; right: -8px; }

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

/* ── Móvil: viewport completo ── */
@media (max-width: 560px) {
  .iyc-chat { right: 16px; bottom: 16px; }
  .iyc-chat--left { left: 16px; }

  .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;
  }

  .cc-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .cc-greet-title { font-size: 28px !important; }
  .cc-scroll { padding-left: 18px; padding-right: 18px; }
}
