/* ══════════════════════════════════════════════════════════════════════
   HERITAGE REAL ESTATE — asistente y botones flotantes
   Usa los tokens de styles.css (--navy, --forest, --taupe, --ease…).
   El panel repite el mismo vidrio esmerilado del formulario de contacto:
   fondo navy translúcido + blur + borde claro fino.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Botones flotantes ─────────────────────────────────────────────────
   Esquina inferior derecha, uno debajo del otro. Discretos a propósito:
   el objetivo es que estén disponibles, no que tapen el contenido. */
.flota {
  position: fixed; z-index: 55; right: clamp(16px, 2.4vw, 28px); bottom: clamp(16px, 2.4vw, 28px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
/* Con el menú móvil abierto, o con el asistente ya abierto, los botones
   sobran: en móvil el panel ocupa el ancho completo y el de WhatsApp le
   quedaba encima. */
body.is-locked .flota,
body.chat-abierto .flota { display: none; }

.flota-chat,
.flota-wa {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid rgba(171, 152, 122, 0.5);
  border-radius: var(--radius-pill);
  font-family: var(--sans);
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(3, 46, 32, 0.28);
  transition: background 0.35s var(--ease), border-color 0.35s var(--ease),
              transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.flota-chat:hover,
.flota-wa:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(3, 46, 32, 0.36); }

/* Píldora del asistente — lleva el monograma de Heritage */
.flota-chat {
  padding: 9px 18px 9px 9px;
  background: rgba(22, 22, 39, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--cream);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.flota-chat:hover { background: rgba(22, 71, 50, 0.86); }

/* Botón de WhatsApp — verde de la marca, no el verde corporativo de WhatsApp */
.flota-wa {
  justify-content: center;
  width: 54px; height: 54px;
  padding: 0;
  background: var(--forest);
  color: var(--cream);
}
.flota-wa:hover { background: var(--deep); border-color: var(--taupe); }
.flota-wa svg { width: 26px; height: 26px; }

/* Monograma sobre disco crema: el PNG oficial es navy y sobre fondo oscuro
   no se vería. El disco lo resuelve sin retocar el archivo de marca. */
.marca-disco {
  display: grid; place-items: center;
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--cream);
}
.marca-disco img { width: 60%; height: auto; }

/* ── Panel del asistente ───────────────────────────────────────────── */
.chat {
  position: fixed; z-index: 60;
  right: clamp(16px, 2.4vw, 28px); bottom: clamp(16px, 2.4vw, 28px);
  display: flex; flex-direction: column;
  width: min(384px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 22px;
  background: rgba(10, 13, 28, 0.62);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 30px 70px rgba(3, 46, 32, 0.4);
  color: #fff;
  font-size: 14.5px;
  line-height: 1.55;
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.chat.is-abierto { opacity: 1; transform: none; pointer-events: auto; }
.chat[hidden] { display: none; }

.chat-head {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 13px 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(22, 22, 39, 0.4);
}
.chat-quien { flex: 1; min-width: 0; }
.chat-quien b {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.chat-quien span {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sand);
  opacity: 0.85;
}
.chat-quien span::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #7ac29a;
}

/* Volver atrás — a la izquierda del monograma */
.chat-atras {
  flex: none;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), opacity 0.3s var(--ease);
}
.chat-atras svg { width: 15px; height: 15px; }
.chat-atras:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); border-color: var(--taupe); }
.chat-atras:disabled { opacity: 0.25; cursor: default; }

.chat-idioma,
.chat-min,
.chat-cerrar {
  flex: none;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--cream);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}
.chat-idioma:hover,
.chat-min:hover,
.chat-cerrar:hover { background: rgba(255, 255, 255, 0.14); border-color: var(--taupe); }
.chat-min,
.chat-cerrar { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; font-size: 16px; line-height: 1; }
.chat-min { font-size: 18px; }

/* Minimizado: queda solo la cabecera, la conversación se conserva intacta.
   La cabecera entera funciona como botón para volver a desplegarlo. */
.chat.is-min .chat-cuerpo,
.chat.is-min .chat-pie { display: none; }
.chat.is-min { max-height: none; }
.chat.is-min .chat-head { cursor: pointer; }
.chat.is-min .chat-atras { display: none; }

/* ── Conversación ──────────────────────────────────────────────────── */
.chat-cuerpo {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}
.chat-cuerpo::-webkit-scrollbar { width: 6px; }
.chat-cuerpo::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 3px; }

.msg {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 16px;
  animation: msg-in 0.42s var(--ease) both;
}
.msg-bot {
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 5px;
}
.msg-yo {
  align-self: flex-end;
  background: var(--forest);
  border: 1px solid rgba(171, 152, 122, 0.45);
  border-bottom-right-radius: 5px;
}
.msg b { font-weight: 600; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Tarjeta de proyecto dentro de la conversación */
.msg-proyecto {
  align-self: flex-start;
  width: 86%;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  animation: msg-in 0.42s var(--ease) both;
}
.msg-proyecto img { width: 100%; height: 116px; object-fit: cover; }
.msg-proyecto div { padding: 12px 15px; }
.msg-proyecto b { display: block; font-family: var(--serif); font-size: 16px; font-weight: 400; }
.msg-proyecto p { margin-top: 3px; font-size: 12.5px; color: var(--sand); }
.msg-proyecto a {
  display: inline-block; margin-top: 9px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--taupe);
  border-bottom: 1px solid currentColor;
}

/* Puntos de "escribiendo…" */
.msg-tec { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.msg-tec i { width: 6px; height: 6px; border-radius: 50%; background: var(--sand); animation: tec 1.1s infinite; }
.msg-tec i:nth-child(2) { animation-delay: 0.16s; }
.msg-tec i:nth-child(3) { animation-delay: 0.32s; }
@keyframes tec {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Opciones y campo de texto ─────────────────────────────────────── */
.chat-pie { padding: 6px 16px 16px; }
.chat-ops { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-op {
  padding: 9px 15px;
  border: 1px solid rgba(171, 152, 122, 0.5);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.chat-op:hover { background: var(--forest); border-color: var(--forest); }
.chat-op--fuerte { background: var(--taupe); border-color: var(--taupe); color: var(--navy); font-weight: 500; }
.chat-op--fuerte:hover { background: var(--cream); border-color: var(--cream); color: var(--navy); }

.chat-campo { display: flex; gap: 8px; }
.chat-campo input {
  flex: 1; min-width: 0;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-pill);
  background: rgba(10, 13, 28, 0.45);
  color: #fff;
  font-family: var(--sans);
  font-size: 14px;
}
.chat-campo input::placeholder { color: rgba(255, 255, 255, 0.45); }
.chat-campo input:focus { outline: none; border-color: var(--taupe); box-shadow: 0 0 18px rgba(171, 152, 122, 0.32); }
.chat-enviar {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--taupe);
  border-radius: 50%;
  background: var(--taupe);
  color: var(--navy);
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.chat-enviar:hover { background: var(--cream); border-color: var(--cream); }
.chat-enviar svg { width: 18px; height: 18px; }

.chat-aviso {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sand);
}
.chat-aviso.is-error { color: #f0b3a1; }

/* ── Móvil: hoja inferior a ancho completo ─────────────────────────── */
@media (max-width: 560px) {
  .chat {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-height: 86vh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
  }
  .flota-txt { display: none; }
  .flota-chat { padding: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat { transition: none; }
  .msg, .msg-proyecto { animation: none; }
  .msg-tec i { animation: none; opacity: 0.6; }
}
