/* ══ Chat de la web (consultas): la burbuja, su gancho y la ventana ══════════
   Lo pinta httpdocs/assets/js/consultas-chat.js dentro de #cs-raiz
   (app/Views/consultas/_burbuja.php). Ocupa el sitio del botón de WhatsApp. */

.cs-raiz { --cs-oro: #EFB814; --cs-negro: #0d0d0d; --cs-papel: #f6f4ef; --cs-linea: #e6e1d6; --cs-gris: #6b6b6b; font-size: 14px; }

/* ── La burbuja ── */
.cs-lanzador {
  position: fixed; right: 22px; bottom: 22px; z-index: 2400;
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cs-negro); color: var(--cs-oro);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28), 0 0 0 3px var(--cs-oro);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}
.cs-lanzador:hover { transform: translateY(-3px) scale(1.04); }
.cs-lanzador:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.cs-lanzador i { font-size: 30px; line-height: 1; transition: transform .25s, opacity .2s; position: absolute; }
.cs-lanzador .cs-ico-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.cs-raiz.abierto .cs-lanzador .cs-ico-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.cs-raiz.abierto .cs-lanzador .cs-ico-x { opacity: 1; transform: none; }
/* Un latido suave hasta que se abre por primera vez: invita sin molestar. */
.cs-raiz.latido .cs-lanzador::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 3px solid var(--cs-oro); animation: csLatido 2.4s ease-out infinite;
}
@keyframes csLatido { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(1.45); opacity: 0; } }
.cs-punto {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: #e11d48; color: #fff; font: 800 12px/22px system-ui, sans-serif;
  box-shadow: 0 0 0 2px #fff;
}

/* ── El gancho: «¿Tienes alguna duda?» ── */
.cs-gancho {
  position: fixed; right: 96px; bottom: 30px; z-index: 2399; max-width: 260px;
  background: #fff; color: var(--cs-negro); padding: 13px 34px 13px 15px;
  border-radius: 16px 16px 4px 16px; box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
  line-height: 1.45; cursor: pointer; animation: csEntra .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.cs-gancho strong { display: block; font-size: 15px; margin-bottom: 2px; }
.cs-gancho span { font-size: 13px; color: var(--cs-gris); }
.cs-gancho-x {
  position: absolute; top: 6px; right: 7px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--cs-papel); color: var(--cs-gris); cursor: pointer; font-size: 15px; line-height: 22px; padding: 0;
}
@keyframes csEntra { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }

/* ── La ventana ── */
.cs-panel {
  position: fixed; right: 22px; bottom: 98px; z-index: 2401;
  width: 384px; height: min(620px, calc(100vh - 130px)); max-height: 620px;
  background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3); display: flex; flex-direction: column;
  transform-origin: bottom right; animation: csAbre .3s cubic-bezier(.34, 1.4, .64, 1) both;
}
.cs-panel[hidden] { display: none; }
@keyframes csAbre { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }

.cs-cab {
  display: flex; align-items: center; gap: 10px; padding: 16px 14px 16px 18px; flex: none;
  background: radial-gradient(circle at 85% -20%, rgba(239, 184, 20, .35), transparent 55%), var(--cs-negro);
  color: #fff;
}
.cs-cab-txt { flex: 1; min-width: 0; }
.cs-cab-tit { font-weight: 900; font-size: 18px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-cab-sub { font-size: 12px; color: rgba(255, 255, 255, .62); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-cab-sub .cs-en-linea { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; margin-right: 5px; vertical-align: 1px; }
.cs-ibtn {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .1); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.cs-ibtn:hover { background: rgba(255, 255, 255, .2); }
.cs-ibtn[hidden] { display: none; }

.cs-cuerpo { flex: 1; min-height: 0; overflow-y: auto; background: var(--cs-papel); display: flex; flex-direction: column; }

/* Inicio */
.cs-hola { padding: 20px 18px 10px; }
.cs-hola h3 { margin: 0 0 6px; font-size: 22px; font-weight: 900; color: var(--cs-negro); }
.cs-hola p { margin: 0; color: var(--cs-gris); line-height: 1.55; }
.cs-nueva-btn {
  margin: 14px 18px 6px; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 15px 16px; border-radius: 14px; border: 0; cursor: pointer; width: calc(100% - 36px);
  background: var(--cs-oro); color: #000; font: inherit; font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 20px rgba(239, 184, 20, .35); transition: transform .15s;
}
.cs-nueva-btn:hover { transform: translateY(-2px); }
.cs-nueva-btn i { font-size: 24px; }
.cs-nueva-btn small { display: block; font-weight: 500; font-size: 12px; opacity: .75; margin-top: 1px; }
.cs-seccion { padding: 14px 18px 4px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--cs-gris); }
.cs-lista { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.cs-item {
  display: flex; gap: 11px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--cs-linea); border-radius: 12px; padding: 11px 12px; font: inherit; color: inherit;
}
.cs-item:hover { border-color: var(--cs-oro); }
.cs-item-ico { width: 36px; height: 36px; border-radius: 50%; background: var(--cs-papel); flex: none; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--cs-negro); }
.cs-item-txt { flex: 1; min-width: 0; }
.cs-item-tit { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-item-sub { font-size: 12px; color: var(--cs-gris); margin-top: 2px; }
.cs-pill { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 9px; margin-right: 5px; }
.cs-pill.espera { background: #fef3c7; color: #92400e; }
.cs-pill.respuesta { background: #dcfce7; color: #166534; }
.cs-pill.cerrada { background: #ececec; color: #666; }
.cs-nuevo-dot { width: 10px; height: 10px; border-radius: 50%; background: #e11d48; flex: none; }
.cs-wa {
  margin: auto 18px 16px; padding-top: 12px; border-top: 1px solid var(--cs-linea);
  font-size: 13px; color: var(--cs-gris); display: flex; align-items: center; gap: 8px;
}
.cs-wa a { color: #128c4b; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.cs-wa a i { font-size: 18px; }

/* Nueva consulta */
.cs-form { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.cs-et { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--cs-gris); margin-bottom: 6px; }
.cs-temas { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cs-tema {
  display: flex; align-items: center; gap: 7px; padding: 9px 10px; border-radius: 11px; cursor: pointer;
  background: #fff; border: 1.5px solid var(--cs-linea); font: inherit; font-size: 13px; font-weight: 600; color: var(--cs-negro); text-align: left;
}
.cs-tema i { font-size: 17px; color: #a17a00; }
.cs-tema.activo { border-color: var(--cs-oro); background: #fff8df; }
.cs-campo {
  width: 100%; box-sizing: border-box; border: 1.5px solid var(--cs-linea); border-radius: 11px; background: #fff;
  padding: 10px 12px; font: inherit; font-size: 14px; color: var(--cs-negro);
}
.cs-campo:focus { outline: none; border-color: var(--cs-oro); box-shadow: 0 0 0 3px rgba(239, 184, 20, .2); }
textarea.cs-campo { resize: none; min-height: 96px; line-height: 1.5; }
.cs-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cs-acepto { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--cs-gris); line-height: 1.45; cursor: pointer; }
.cs-acepto input { margin-top: 2px; accent-color: var(--cs-negro); }
.cs-acepto a { color: var(--cs-negro); }
.cs-trampa { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.cs-fila-envio { display: flex; align-items: center; gap: 8px; }
.cs-adj-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%; border: 1.5px solid var(--cs-linea); background: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 19px; color: var(--cs-negro);
}
.cs-adj-btn:hover { border-color: var(--cs-oro); }
.cs-adj-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 6px 5px 10px; border-radius: 16px;
  background: #fff; border: 1px solid var(--cs-linea); font-size: 12px; color: var(--cs-negro);
}
.cs-adj-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.cs-adj-chip button { border: 0; background: var(--cs-papel); border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 20px; padding: 0; }
.cs-enviar {
  margin-left: auto; height: 42px; padding: 0 20px; border-radius: 21px; border: 0; cursor: pointer;
  background: var(--cs-negro); color: var(--cs-oro); font: inherit; font-weight: 800; display: inline-flex; align-items: center; gap: 7px;
}
.cs-enviar:disabled { opacity: .5; cursor: wait; }
.cs-error { background: #fee2e2; color: #991b1b; border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.cs-error[hidden] { display: none; }

/* Conversación */
.cs-mensajes { flex: 1; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 4px; }
.cs-dia { align-self: center; font-size: 11px; color: var(--cs-gris); background: rgba(0, 0, 0, .05); padding: 3px 10px; border-radius: 10px; margin: 8px 0; }
.cs-m { display: flex; gap: 8px; align-items: flex-end; max-width: 86%; margin-top: 6px; }
.cs-m.yo { align-self: flex-end; flex-direction: row-reverse; }
.cs-m.sigue { margin-top: 0; }
.cs-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--cs-negro); color: var(--cs-oro);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px;
}
.cs-m.sigue .cs-avatar { visibility: hidden; }
.cs-burbuja {
  background: #fff; border-radius: 16px 16px 16px 5px; padding: 9px 12px; color: var(--cs-negro);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06); min-width: 0; overflow-wrap: anywhere;
}
.cs-m.yo .cs-burbuja { background: var(--cs-oro); border-radius: 16px 16px 5px 16px; }
.cs-quien { font-size: 11px; font-weight: 800; color: #a17a00; margin-bottom: 2px; }
.cs-texto { white-space: pre-wrap; line-height: 1.5; }
.cs-hora { font-size: 10px; color: rgba(0, 0, 0, .45); text-align: right; margin-top: 3px; }
.cs-img { display: block; margin-top: 4px; border-radius: 10px; overflow: hidden; max-width: 230px; }
.cs-img img { display: block; width: 100%; height: auto; }
.cs-pdf { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .05); color: inherit; text-decoration: none; font-size: 13px; }
.cs-pdf i { font-size: 22px; color: #b91c1c; }
.cs-pdf small { display: block; color: rgba(0, 0, 0, .5); }
.cs-aviso { align-self: center; text-align: center; max-width: 92%; font-size: 12.5px; color: var(--cs-gris); background: #fff; border: 1px dashed var(--cs-linea); border-radius: 12px; padding: 9px 12px; margin: 10px 0 4px; line-height: 1.5; }
.cs-cerrada { margin: 8px 14px 14px; text-align: center; font-size: 13px; color: var(--cs-gris); background: #fff; border-radius: 12px; padding: 12px; }
.cs-cerrada button { margin-top: 8px; border: 0; background: var(--cs-oro); color: #000; font: inherit; font-weight: 800; padding: 9px 16px; border-radius: 18px; cursor: pointer; }
.cs-compositor { flex: none; background: #fff; border-top: 1px solid var(--cs-linea); padding: 10px 12px; }
.cs-compositor .cs-fila-envio { align-items: flex-end; }
.cs-compositor textarea.cs-campo { min-height: 42px; max-height: 130px; padding: 10px 12px; border-radius: 21px; flex: 1; }
.cs-compositor .cs-enviar { width: 42px; padding: 0; justify-content: center; margin-left: 0; font-size: 18px; }
.cs-compositor .cs-adj-chip { margin-bottom: 8px; }
.cs-cargando { margin: auto; color: var(--cs-gris); font-size: 13px; padding: 30px; }

/* Móvil: la ventana a pantalla completa */
@media (max-width: 600px) {
  .cs-lanzador { right: 14px; bottom: 14px; width: 56px; height: 56px; }
  .cs-lanzador i { font-size: 27px; }
  .cs-gancho { right: 80px; bottom: 20px; max-width: calc(100vw - 100px); }
  .cs-panel { inset: 0; width: auto; height: auto; max-height: none; border-radius: 0; }
  .cs-raiz.abierto .cs-lanzador { display: none; }
  .cs-temas { grid-template-columns: 1fr 1fr; }
  .cs-dos { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-raiz *, .cs-raiz *::after { animation: none !important; transition: none !important; }
}
