/* ============================================
   LayerChat Widget — Standalone
   chat.licensemhp.xyz
   ============================================ */

/* === VARIABLES === */

:root {
  /* Colores del widget */
  --lc-blue:        #0084ff;
  --lc-blue-dark:   #0073e6;
  --lc-green:       #25d366;
  --lc-green-dark:  #1ebe57;
  --lc-red:         #ef4444;
  --lc-red-dark:    #dc2626;

  /* Superficies claras */
  --lc-white:       #ffffff;
  --lc-slate-50:    #f8fafc;
  --lc-slate-100:   #f1f5f9;
  --lc-slate-200:   #e2e8f0;
  --lc-slate-300:   #cbd5e1;
  --lc-slate-400:   #94a3b8;
  --lc-slate-500:   #64748b;
  --lc-slate-600:   #475569;
  --lc-slate-700:   #334155;
  --lc-slate-800:   #1e293b;
  --lc-slate-900:   #0f172a;

  /* Chat cliente (azul) */
  --lc-client-bg:   #2563eb;
  --lc-client-dark: #1d4ed8;

  /* Fondo del header */
  --lc-header-bg:   linear-gradient(135deg, #1e293b 0%, #0f172a 100%);

  /* Transición */
  --lc-t: 0.15s ease;
}

/* === CONTENEDOR PRINCIPAL === */

.layer-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  left: auto;
  z-index: 2147483645;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

.layer-chat [hidden] { display: none !important; }

/* === PANEL === */

.layer-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: min(24rem, calc(100vw - 2rem));
  overflow: hidden;
  isolation: isolate;
  border: none;
  border-radius: 0.75rem;
  background-color: transparent;
  box-shadow:
    0 20px 25px -5px rgba(15,23,42,.12),
    0 8px 10px -6px rgba(15,23,42,.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.layer-chat.is-open .layer-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* === HEADER === */

.layer-chat__header {
  position: relative;
  padding: 0.875rem 2.5rem 0.875rem 1rem;
  border-radius: 0.75rem 0.75rem 0 0;
  background: var(--lc-header-bg);
  color: var(--lc-white);
}

.layer-chat__title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.layer-chat__subtitle {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #cbd5e1;
}

.layer-chat__close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 1.25rem;
  line-height: 1;
  color: #e2e8f0;
  background: transparent;
  cursor: pointer;
  transition: background-color var(--lc-t), color var(--lc-t);
}

.layer-chat__close:hover { color: var(--lc-white); background-color: rgba(255,255,255,.1); }

/* === CUERPO === */

.layer-chat__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 0 0 0.75rem 0.75rem;
  background-color: var(--lc-white);
}

.layer-chat__view[hidden] { display: none; }

/* === OPCIONES DEL MENÚ === */

.layer-chat__option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--lc-slate-200);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--lc-slate-800);
  text-align: left;
  background-color: var(--lc-white);
  cursor: pointer;
  transition: border-color var(--lc-t), background-color var(--lc-t);
}

.layer-chat__option:hover { border-color: var(--lc-slate-300); background-color: var(--lc-slate-50); }

.layer-chat__option-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  color: var(--lc-white);
  background-color: var(--lc-slate-800);
}

.layer-chat__option--whatsapp .layer-chat__option-icon { background-color: var(--lc-green); }
.layer-chat__option--live     .layer-chat__option-icon { background-color: var(--lc-blue); }

.layer-chat__option-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.layer-chat__option-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.layer-chat__option-label {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  color: var(--lc-slate-900);
  white-space: nowrap;
}

.layer-chat__option-desc {
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--lc-slate-500);
  white-space: nowrap;
}

/* Badges */

.layer-chat__badge {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-transform: uppercase;
  color: #1d4ed8;
  background-color: #dbeafe;
}

.layer-chat__badge--live { color: #5b21b6; background-color: #ede9fe; }

/* === BOTÓN VOLVER === */

.layer-chat__back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.375rem;
  padding: 0;
  border: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--lc-slate-500);
  background: none;
  cursor: pointer;
  transition: color var(--lc-t);
}

.layer-chat__back:hover { color: var(--lc-slate-800); }

/* === FORMULARIOS === */

.layer-chat__form {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.layer-chat__form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.layer-chat__field { margin: 0; padding: 0; border: none; }

.layer-chat__label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--lc-slate-700);
}

.layer-chat__input,
.layer-chat__select,
.layer-chat__textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--lc-slate-200);
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--lc-slate-900);
  background-color: var(--lc-white);
  transition: border-color var(--lc-t), box-shadow var(--lc-t);
}

.layer-chat__input:focus,
.layer-chat__select:focus,
.layer-chat__textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.layer-chat__select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 1.75rem;
}

.layer-chat__textarea {
  padding-top: 0.8125rem;
  padding-bottom: 0.8125rem;
  resize: vertical;
  min-height: 9.5rem;
  max-height: 14rem;
}

/* Campo pre-rellenado (p.ej. desde WHMCS) — solo lectura */
.layer-chat__input[readonly] {
  background-color: var(--lc-slate-50);
  color: var(--lc-slate-600);
  cursor: default;
  border-color: var(--lc-slate-200);
}

/* Botón submit de WhatsApp */

.layer-chat__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.625rem;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--lc-white);
  background-color: var(--lc-green);
  cursor: pointer;
  transition: background-color var(--lc-t);
}

.layer-chat__submit:hover { background-color: var(--lc-green-dark); }

/* === FORMULARIO DE REGISTRO (chat en vivo) === */

.layer-chat__register-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.layer-chat__register-form .layer-chat__form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .layer-chat__register-form .layer-chat__form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.layer-chat__register-form .layer-chat__textarea {
  min-height: 5rem;
  max-height: 8rem;
}

.layer-chat__btn--primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--lc-white);
  background-color: var(--lc-blue);
  cursor: pointer;
  transition: background-color var(--lc-t);
}

.layer-chat__btn--primary:hover    { background-color: var(--lc-blue-dark); }
.layer-chat__btn--primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* === HILO DE MENSAJES === */

.layer-chat__thread {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-height: 18.5rem;
  max-height: 22rem;
  margin-bottom: 0.75rem;
  padding: 0.375rem 0.25rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--lc-slate-200) transparent;
}

.layer-chat__thread::-webkit-scrollbar       { width: 3px; }
.layer-chat__thread::-webkit-scrollbar-track { background: transparent; }
.layer-chat__thread::-webkit-scrollbar-thumb { background-color: var(--lc-slate-200); border-radius: 9999px; }
.layer-chat__thread::-webkit-scrollbar-thumb:hover { background-color: var(--lc-slate-300); }

/* Ocultar thread en vista de espera (los mensajes se clonan a convThread al unirse el agente) */
[data-layer-chat-view="waiting"] .layer-chat__thread { display: none; }

/* === MENSAJES === */

.layer-chat__msg {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.layer-chat__msg-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  color: #2563eb;
  background-color: #dbeafe;
}

.layer-chat__msg-avatar svg { width: 1rem; height: 1rem; }

.layer-chat__msg-body {
  max-width: calc(100% - 2.625rem);
  padding: 0.75rem 0.875rem;
  border-radius: 0.625rem 0.625rem 0.625rem 0.125rem;
  background-color: var(--lc-slate-100);
}

.layer-chat__msg-name {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--lc-slate-500);
}

.layer-chat__msg-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--lc-slate-800);
  white-space: pre-line;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.layer-chat__msg-text a {
  color: #2563eb;
  text-decoration: underline;
  word-break: break-all;
}

/* Variante cliente (burbuja derecha azul) */

.layer-chat__msg--client { flex-direction: row-reverse; }

.layer-chat__msg--client .layer-chat__msg-body {
  border-radius: 0.625rem 0.625rem 0.125rem 0.625rem;
  background-color: var(--lc-client-bg);
  color: var(--lc-white);
}

.layer-chat__msg--client .layer-chat__msg-text { color: var(--lc-white); }
.layer-chat__msg--client .layer-chat__msg-text a { color: rgba(255,255,255,.9); }
.layer-chat__msg--client .layer-chat__msg-name { display: none; }

.layer-chat__msg--client .layer-chat__msg-avatar {
  background-color: var(--lc-client-bg);
  color: var(--lc-white);
}

/* Mensaje del sistema */

.layer-chat__msg--system { justify-content: center; }

.layer-chat__msg--system .layer-chat__msg-body {
  max-width: 100%;
  background-color: transparent;
  text-align: center;
  padding: 0.5rem;
}

.layer-chat__msg--system .layer-chat__msg-text {
  font-size: 0.75rem;
  color: var(--lc-slate-400);
  font-style: italic;
}

/* Animación de entrada */

.layer-chat__msg--revealed { animation: layer-chat-msg-in 0.28s ease; }

@keyframes layer-chat-msg-in {
  from { opacity: 0; transform: translateY(0.35rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === BOTÓN DE RESPUESTA (hover-reveal) === */

.layer-chat__msg-reply-btn {
  flex-shrink: 0;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: var(--lc-slate-200);
  color: var(--lc-slate-500);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--lc-t), background-color var(--lc-t), color var(--lc-t);
}

.layer-chat__msg-reply-btn svg { width: 0.75rem; height: 0.75rem; pointer-events: none; }
.layer-chat__msg:hover .layer-chat__msg-reply-btn { opacity: 1; }
.layer-chat__msg-reply-btn:hover { background: var(--lc-slate-300); color: var(--lc-slate-700); }

/* === QUOTE / RESPUESTA DENTRO DE BURBUJA === */

.layer-chat__msg-quote {
  background: rgba(0,0,0,.07);
  border-left: 3px solid rgba(0,0,0,.18);
  border-radius: 0.3rem;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.375rem;
}

.layer-chat__msg--client .layer-chat__msg-quote {
  background: rgba(255,255,255,.18);
  border-left-color: rgba(255,255,255,.55);
}

.layer-chat__msg-quote__name {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 0.1rem;
}

.layer-chat__msg--client .layer-chat__msg-quote__name { color: rgba(255,255,255,.9); }

.layer-chat__msg-quote__text {
  display: -webkit-box;
  font-size: 0.75rem;
  color: var(--lc-slate-500);
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.layer-chat__msg--client .layer-chat__msg-quote__text { color: rgba(255,255,255,.75); }

/* Quote clicable */

.lc-quote-link[data-reply-id]       { cursor: pointer; transition: opacity 0.12s ease; }
.lc-quote-link[data-reply-id]:hover { opacity: 0.75; }

@keyframes lc-flash-anim {
  0%   { box-shadow: 0 0 0 0   rgba(37,99,235,.5); }
  40%  { box-shadow: 0 0 0 6px rgba(37,99,235,.2); }
  100% { box-shadow: 0 0 0 0   rgba(37,99,235,.0); }
}

.lc-flash { animation: lc-flash-anim 1.4s ease; border-radius: inherit; }

/* === BARRA DE REPLY PREVIEW === */

.layer-chat__reply-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.625rem;
  margin-bottom: 0.375rem;
  background: var(--lc-slate-100);
  border-radius: 0.5rem;
  border-left: 3px solid var(--lc-client-bg);
}

.layer-chat__reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.layer-chat__reply-preview-name {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--lc-client-bg);
  line-height: 1.2;
}

.layer-chat__reply-preview-text {
  display: block;
  font-size: 0.75rem;
  color: var(--lc-slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.layer-chat__reply-preview-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--lc-slate-400);
  cursor: pointer;
  transition: color var(--lc-t), background-color var(--lc-t);
}

.layer-chat__reply-preview-close:hover { color: var(--lc-slate-600); background: var(--lc-slate-200); }
.layer-chat__reply-preview-close svg   { width: 0.75rem; height: 0.75rem; pointer-events: none; }

/* === COMPOSITOR === */

.layer-chat__composer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.layer-chat__composer-input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--lc-slate-200);
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--lc-slate-400);
  background-color: var(--lc-slate-50);
  cursor: not-allowed;
}

.layer-chat__composer-send {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 9999px;
  color: var(--lc-white);
  background-color: var(--lc-slate-300);
  cursor: not-allowed;
}

.layer-chat__composer-send svg { width: 1rem; height: 1rem; }

/* Compositor activo */

.layer-chat__composer--active .layer-chat__composer-input {
  color: var(--lc-slate-900);
  background-color: var(--lc-white);
  cursor: text;
  border-color: var(--lc-slate-300);
}

.layer-chat__composer--active .layer-chat__composer-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  outline: none;
}

.layer-chat__composer--active .layer-chat__composer-send {
  background-color: var(--lc-client-bg);
  cursor: pointer;
}

.layer-chat__composer--active .layer-chat__composer-send:hover { background-color: var(--lc-client-dark); }

/* Botones de icono (emoji, imagen) */

.layer-chat__composer-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 9999px;
  border: none;
  background: none;
  color: #65676b;
  cursor: pointer;
  padding: 0;
  transition: background var(--lc-t), color var(--lc-t);
}

.layer-chat__composer-icon-btn:hover:not(:disabled) { background: rgba(0,0,0,.07); color: #1c1e21; }
.layer-chat__composer-icon-btn:disabled             { opacity: 0.38; cursor: default; }
.layer-chat__composer-icon-btn.is-active            { color: var(--lc-blue); background: rgba(0,132,255,.1); }
.layer-chat__composer-icon-btn svg                  { width: 1.0625rem; height: 1.0625rem; pointer-events: none; }

/* Botón de micrófono */

.layer-chat__composer-mic {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 9999px;
  color: var(--lc-slate-400);
  background: transparent;
  cursor: not-allowed;
  transition: background-color var(--lc-t), color var(--lc-t);
}

.layer-chat__composer-mic svg { width: 1.125rem; height: 1.125rem; pointer-events: none; }

.layer-chat__composer--active .layer-chat__composer-mic { color: var(--lc-slate-500); cursor: pointer; }
.layer-chat__composer--active .layer-chat__composer-mic:hover { background: var(--lc-slate-100); color: var(--lc-slate-700); }

/* === VISTA DE ESPERA === */

.layer-chat__waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0.5rem;
  text-align: center;
}

.layer-chat__waiting-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--lc-slate-600);
  max-width: 18rem;
}

.layer-chat__waiting-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--lc-slate-200);
  border-top-color: var(--lc-client-bg);
  border-radius: 50%;
  animation: layer-chat-spin 0.8s linear infinite;
}

@keyframes layer-chat-spin { to { transform: rotate(360deg); } }

/* === VISTA DE CONVERSACIÓN === */

.layer-chat__conversation-view {
  display: flex;
  flex-direction: column;
  min-height: 24rem;
}

.layer-chat__thread--conversation {
  min-height: 20rem;
  max-height: 26rem;
  margin-bottom: 0.5rem;
}

/* Animación de puntos suspensivos (typing) */

.layer-chat__msg-body--typing {
  display: flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.75rem 0.875rem;
}

.layer-chat__typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
}

.layer-chat__typing-dots span {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 9999px;
  background-color: var(--lc-slate-400);
  animation: layer-chat-typing 1.1s ease-in-out infinite;
}

.layer-chat__typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.layer-chat__typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes layer-chat-typing {
  0%, 60%, 100% { transform: translateY(0);       opacity: 0.4; }
  30%            { transform: translateY(-0.2rem); opacity: 1;   }
}

/* === OVERLAY DE CONFIRMACIÓN (SALIR) === */

.layer-chat__confirm {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15,23,42,.5);
  border-radius: 0.75rem;
  backdrop-filter: blur(2px);
}

.layer-chat__confirm-box {
  width: 100%;
  padding: 1.5rem;
  border-radius: 0.75rem;
  background: var(--lc-white);
  box-shadow:
    0 20px 25px -5px rgba(15,23,42,.25),
    0 8px 10px -6px rgba(15,23,42,.15);
  animation: layer-chat-msg-in 0.2s ease;
}

.layer-chat__confirm-title {
  margin: 0 0 0.375rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--lc-slate-900);
}

.layer-chat__confirm-msg {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--lc-slate-500);
}

.layer-chat__confirm-actions { display: flex; gap: 0.625rem; }

.layer-chat__confirm-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--lc-t), transform 0.1s ease;
}

.layer-chat__confirm-btn:active { transform: scale(0.97); }

.layer-chat__confirm-btn--cancel       { background: var(--lc-slate-100); color: var(--lc-slate-600); }
.layer-chat__confirm-btn--cancel:hover { background: var(--lc-slate-200); }
.layer-chat__confirm-btn--ok           { background: var(--lc-red); color: var(--lc-white); }
.layer-chat__confirm-btn--ok:hover     { background: var(--lc-red-dark); }

/* === LAUNCHER (botón flotante + burbuja) === */

.layer-chat__launcher {
  display: flex;
  align-items: flex-end;
  flex-direction: row;
  gap: 0.75rem;
}

/* Burbuja promo */

.layer-chat__bubble {
  position: relative;
  max-width: 11.5rem;
  margin: 0;
  padding: 0.625rem 1.75rem 0.625rem 0.875rem;
  border: 1px solid var(--lc-slate-200);
  border-radius: 1rem 1rem 1rem 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--lc-slate-700);
  background-color: var(--lc-white);
  box-shadow:
    0 10px 15px -3px rgba(15,23,42,.1),
    0 4px 6px -4px rgba(15,23,42,.06);
  animation: layer-chat-bubble-float 2.5s ease-in-out infinite;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.layer-chat__bubble::after {
  content: '';
  position: absolute;
  right: -0.4rem;
  bottom: 0.75rem;
  width: 0;
  height: 0;
  border-top: 0.4rem solid transparent;
  border-bottom: 0.4rem solid transparent;
  border-left: 0.45rem solid var(--lc-white);
  filter: drop-shadow(1px 0 0 var(--lc-slate-200));
}

.layer-chat__bubble-text strong { font-weight: 600; color: #1d4ed8; }

.layer-chat__bubble-dismiss {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  font-size: 1rem;
  line-height: 1;
  color: var(--lc-slate-400);
  background: transparent;
  cursor: pointer;
  transition: color var(--lc-t), background-color var(--lc-t);
}

.layer-chat__bubble-dismiss:hover { color: var(--lc-slate-600); background-color: var(--lc-slate-100); }

.layer-chat__bubble.is-dismissed,
.layer-chat.is-open .layer-chat__bubble {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-0.35rem);
  animation: none;
  pointer-events: none;
}

@keyframes layer-chat-bubble-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}

/* Botón toggle */

.layer-chat__toggle {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 9999px;
  color: var(--lc-white);
  background: linear-gradient(135deg, var(--lc-client-bg) 0%, var(--lc-client-dark) 100%);
  box-shadow:
    0 10px 15px -3px rgba(37,99,235,.35),
    0 4px 6px -4px rgba(37,99,235,.25);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.layer-chat__toggle:hover {
  transform: scale(1.04);
  box-shadow:
    0 12px 20px -3px rgba(37,99,235,.4),
    0 6px 8px -4px rgba(37,99,235,.3);
}

.layer-chat__toggle-icon          { width: 1.5rem; height: 1.5rem; }
.layer-chat__toggle-icon--close   { display: none; }

.layer-chat.is-open .layer-chat__toggle-icon--open  { display: none; }
.layer-chat.is-open .layer-chat__toggle-icon--close { display: block; }

.layer-chat__status {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid var(--lc-white);
  border-radius: 9999px;
  background-color: #22c55e;
}

/* === RESPONSIVE === */

@media (max-width: 640px) {
  .layer-chat { right: 1rem; bottom: 1rem; }

  .layer-chat__bubble {
    max-width: 9.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* === BARRA DE GRABACIÓN === */

.layer-chat__rec-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  margin-bottom: 0.375rem;
  background: #fef2f2;
  border-radius: 0.5rem;
  border: 1px solid #fecaca;
}

.layer-chat__rec-dot {
  flex-shrink: 0;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 9999px;
  background: var(--lc-red);
  animation: lc-rec-pulse 1s ease-in-out infinite;
}

@keyframes lc-rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

.layer-chat__rec-timer {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--lc-red);
  font-variant-numeric: tabular-nums;
}

.layer-chat__rec-cancel,
.layer-chat__rec-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border: none;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--lc-t);
}

.layer-chat__rec-cancel {
  background: transparent;
  color: var(--lc-slate-400);
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 9999px;
}

.layer-chat__rec-cancel:hover { background: #fee2e2; color: var(--lc-red); }

.layer-chat__rec-cancel svg,
.layer-chat__rec-stop svg { width: 0.75rem; height: 0.75rem; pointer-events: none; }

.layer-chat__rec-stop       { background: var(--lc-red); color: var(--lc-white); }
.layer-chat__rec-stop:hover { background: var(--lc-red-dark); }

/* === BARRA DE PREVISUALIZACIÓN DE AUDIO === */

.layer-chat__preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  margin-bottom: 0.375rem;
  background: var(--lc-slate-50);
  border-radius: 0.5rem;
  border: 1px solid var(--lc-slate-200);
}

.layer-chat__preview-cancel {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--lc-slate-400);
  cursor: pointer;
  transition: background-color var(--lc-t), color var(--lc-t);
}

.layer-chat__preview-cancel:hover { background: var(--lc-slate-100); color: var(--lc-slate-600); }
.layer-chat__preview-cancel svg   { width: 0.75rem; height: 0.75rem; pointer-events: none; }

.layer-chat__preview-player { flex: 1; min-width: 0; }

.layer-chat__preview-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 9999px;
  background: var(--lc-client-bg);
  color: var(--lc-white);
  cursor: pointer;
  transition: background-color var(--lc-t);
}

.layer-chat__preview-send:hover    { background: var(--lc-client-dark); }
.layer-chat__preview-send:disabled { background: var(--lc-slate-300); cursor: not-allowed; }
.layer-chat__preview-send svg      { width: 1rem; height: 1rem; pointer-events: none; }

/* === REPRODUCTOR DE AUDIO (en mensajes) === */

.lc-audio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 9rem;
  max-width: 14rem;
  padding: 0.125rem 0;
}

.lc-audio__btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 9999px;
  background: rgba(0,0,0,.12);
  color: inherit;
  cursor: pointer;
  transition: background-color var(--lc-t);
}

.layer-chat__msg--client .lc-audio__btn      { background: rgba(255,255,255,.25); }
.lc-audio__btn:hover                         { background: rgba(0,0,0,.2); }
.layer-chat__msg--client .lc-audio__btn:hover { background: rgba(255,255,255,.35); }
.lc-audio__btn svg                           { width: 0.875rem; height: 0.875rem; pointer-events: none; }

.lc-audio__track {
  flex: 1;
  position: relative;
  height: 1.25rem;
  display: flex;
  align-items: center;
}

.lc-audio__progress {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: rgba(0,0,0,.18);
  border-radius: 9999px;
  overflow: hidden;
}

.layer-chat__msg--client .lc-audio__progress { background: rgba(255,255,255,.3); }

.lc-audio__fill {
  height: 100%;
  width: 0%;
  background: currentColor;
  border-radius: 9999px;
  transition: width 0.1s linear;
}

.lc-audio__seek {
  position: absolute;
  left: 0; right: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.lc-audio__time {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
  min-width: 2rem;
  text-align: right;
}

/* === EMOJI PICKER (WIDGET) === */

.layer-chat__emoji-picker {
  flex-shrink: 0;
  background: var(--lc-white);
  border-top: 1px solid rgba(0,0,0,.09);
  display: flex;
  flex-direction: column;
  max-height: 190px;
  animation: lc-epicker-in .14s ease both;
}

@keyframes lc-epicker-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lc-emoji-picker__tabs {
  display: flex;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: #f7f8fa;
  flex-shrink: 0;
}

.lc-emoji-picker__tab {
  flex: 1;
  padding: 0.35rem 0.2rem;
  font-size: 0.9rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--lc-t), border-color var(--lc-t), background var(--lc-t);
}

.lc-emoji-picker__tab:hover    { opacity: 0.78; }
.lc-emoji-picker__tab.is-active { opacity: 1; border-bottom-color: var(--lc-blue); background: var(--lc-white); }

.lc-emoji-picker__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  padding: 0.2rem;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #cdd3da transparent;
}

.lc-emoji-picker__btn {
  font-size: 1.1rem;
  padding: 0.2rem;
  border-radius: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lc-emoji-picker__btn:hover { background: #f0f2f5; transform: scale(1.2); }

/* === MENSAJES DE IMAGEN === */

.lc-img-msg {
  display: block;
  max-width: 160px;
  border-radius: 0.625rem;
  overflow: hidden;
  cursor: zoom-in;
  margin-top: 0.125rem;
}

.lc-img-msg img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  transition: opacity var(--lc-t);
}

.lc-img-msg img:hover { opacity: 0.88; }

/* Lightbox */

.lc-img-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lc-lb-in .15s ease both;
}

@keyframes lc-lb-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lc-img-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
  cursor: default;
}

.lc-img-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: rgba(255,255,255,.15);
  color: var(--lc-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: background var(--lc-t);
}

.lc-img-lightbox__close:hover { background: rgba(255,255,255,.28); }
