/* Chat de ventas de la landing (frontend/js/chat-widget.js) */
.chatv {
  --chatv-rojo: #e23b2e;
  --chatv-tinta: #11151c;
  --chatv-gris: #5d6b7a;
  --chatv-linea: #e7ebf0;
  --chatv-fondo: #f6f8fb;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  font-family: 'Inter', Arial, sans-serif;
  display: none;
}
.chatv.chatv-visible { display: block; }
.chatv [hidden] { display: none !important; }

.chatv-burbuja {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid #fff;
  padding: 0;
  cursor: pointer;
  background: var(--chatv-rojo);
  box-shadow: 0 10px 28px rgba(17, 21, 28, 0.25);
  animation: chatv-entra .35s ease;
}
.chatv-burbuja-foto { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
/* El logo del equipo entero (no recortado) sobre blanco */
.chatv-logo { object-fit: contain !important; background: #fff; padding: 12%; box-sizing: border-box; }
.chatv-punto {
  position: absolute; top: 0; right: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
}
.chatv-iniciales {
  display: grid; place-items: center;
  background: var(--chatv-rojo); color: #fff; font-weight: 800; font-size: 18px;
}

.chatv-globo {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 260px;
  background: #fff;
  color: var(--chatv-tinta);
  border-radius: 14px;
  padding: 14px 34px 14px 14px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(17, 21, 28, 0.18);
  cursor: pointer;
  animation: chatv-entra .35s ease;
}
.chatv-globo p { margin: 0; }
.chatv-globo-x, .chatv-x {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: transparent; color: var(--chatv-gris); font-size: 20px; line-height: 1; cursor: pointer;
}
.chatv-globo-x:hover, .chatv-x:hover { background: var(--chatv-fondo); color: var(--chatv-rojo); }

.chatv-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 360px;
  height: min(540px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--chatv-tinta);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(17, 21, 28, 0.25);
  animation: chatv-entra .2s ease;
}
.chatv-cab {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 40px 12px 14px;
  background: var(--chatv-tinta); color: #fff;
}
.chatv-cab .chatv-x { top: 50%; transform: translateY(-50%); color: #cbd5e1; }
.chatv-cab .chatv-x:hover { background: rgba(255,255,255,.1); color: #fff; }
.chatv-cab-foto { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: 14px; }
.chatv-cab-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chatv-cab-txt strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatv-estado { font-size: 12px; color: #9fb0cf; }
.chatv-estado::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; margin-right: 6px; }
.chatv-estado.chatv-on::before { background: #22c55e; }

.chatv-lista {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--chatv-fondo);
}
.chatv-msg { display: flex; align-items: flex-end; gap: 6px; max-width: 85%; }
.chatv-msg p {
  margin: 0; padding: 9px 12px; border-radius: 14px;
  font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.chatv-operador p, .chatv-sistema p { background: #fff; border: 1px solid var(--chatv-linea); border-bottom-left-radius: 4px; }
.chatv-visitante { align-self: flex-end; }
.chatv-visitante p { background: var(--chatv-rojo); color: #fff; border-bottom-right-radius: 4px; }
.chatv-aviso { align-self: center; max-width: 100%; }
.chatv-aviso p { background: transparent; color: var(--chatv-gris); font-size: 12px; padding: 2px 8px; }
.chatv-msg-foto { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: 0 0 26px; font-size: 10px; }

.chatv-contacto {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--chatv-linea); background: #fff8f1;
}
.chatv-contacto input { flex: 1 1 140px; min-width: 0; }
.chatv input, .chatv textarea {
  font: inherit; font-size: 14px; color: var(--chatv-tinta);
  border: 1.5px solid #cfd6df; border-radius: 10px; padding: 9px 11px; background: #fff;
}
.chatv input:focus, .chatv textarea:focus { outline: none; border-color: var(--chatv-rojo); }
.chatv-btn {
  border: none; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  background: var(--chatv-rojo); color: #fff; font-weight: 700; font: inherit; font-weight: 700;
}
.chatv-form { display: flex; gap: 8px; padding: 10px 14px 4px; border-top: 1px solid var(--chatv-linea); }
.chatv-form textarea { flex: 1; resize: none; max-height: 110px; }
.chatv-enviar {
  flex: 0 0 42px; height: 42px; align-self: flex-end;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--chatv-rojo); color: #fff; font-size: 16px;
}
.chatv-enviar:disabled { opacity: .5; cursor: wait; }
.chatv-error { margin: 0 14px; font-size: 12px; color: var(--chatv-rojo); }
.chatv-error:empty { display: none; }
.chatv-contacto .chatv-error { margin: 0; flex-basis: 100%; }
.chatv-legal { margin: 0; padding: 4px 14px 10px; font-size: 11px; color: var(--chatv-gris); }
.chatv-legal a { color: inherit; }
.chatv-trampa { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

@keyframes chatv-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Celular: burbuja chica en la esquina; el panel como hoja inferior a todo el ancho */
@media (max-width: 520px) {
  .chatv { right: 14px; bottom: 14px; }
  .chatv-burbuja { width: 52px; height: 52px; }
  .chatv-globo { width: min(260px, calc(100vw - 28px)); bottom: 64px; }
  .chatv-panel {
    position: fixed; left: 0; right: 0; bottom: 0;
    width: 100%; height: min(85vh, 600px);
    border-radius: 16px 16px 0 0;
  }
  /* Con el panel abierto la burbuja taparía el botón de enviar: se cierra con la × */
  .chatv.chatv-abierto .chatv-burbuja { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chatv-burbuja, .chatv-globo, .chatv-panel { animation: none; }
}
