/* Elementos flotantes: columna a la derecha (de abajo hacia arriba): chatbot, WhatsApp y "volver arriba". */
:root {
  --float-gap: 12px;
  --float-size: 58px;
  --float-right: calc(16px + env(safe-area-inset-right, 0px));
  --float-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  --z-chat: 60;
}

/* ---------- WhatsApp ---------- */
.wa-float {
  position: fixed; z-index: var(--z-float);
  right: var(--float-right);
  bottom: calc(var(--float-bottom) + var(--float-size) + var(--float-gap));
  width: var(--float-size); height: var(--float-size); display: grid; place-items: center; border-radius: 50%;
  background: var(--wa); color: #fff; box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.7);
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.wa-float:hover { transform: scale(1.06); }
.wa-float .ico { width: 30px; height: 30px; }

/* ---------- Volver arriba ---------- */
alux-back-to-top {
  position: fixed; z-index: var(--z-float);
  right: calc(var(--float-right) + (var(--float-size) - 48px) / 2);
  bottom: calc(var(--float-bottom) + 2 * (var(--float-size) + var(--float-gap)));
  opacity: 0; transform: translateY(12px) scale(0.9); pointer-events: none; visibility: hidden;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
alux-back-to-top.is-visible {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out), visibility 0s;
}
.to-top {
  position: relative; width: 48px; height: 48px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: rgba(19, 17, 13, 0.92); color: var(--gold-hi);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  transition: transform var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
  touch-action: manipulation;
}
.to-top:hover { background: var(--panel); transform: translateY(-2px); }
.to-top:active { transform: scale(0.95); }
.to-top .ico { width: 22px; height: 22px; stroke-width: 2; }
.to-top__ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.to-top__ring circle { fill: none; stroke-width: 2.5; }
.to-top__track { stroke: var(--line); }
.to-top__bar { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 80ms linear; }

/* ---------- Chatbot: lanzador ---------- */
alux-chat { display: contents; }
.chat-launcher {
  position: fixed; z-index: var(--z-chat);
  right: var(--float-right); bottom: var(--float-bottom);
  width: var(--float-size); height: var(--float-size); display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: var(--gold-grad); color: var(--on-gold);
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(244, 223, 164, 0.4) inset;
  transition: transform var(--dur) var(--ease-out);
  touch-action: manipulation;
}
.chat-launcher:hover { transform: scale(1.06); }
.chat-launcher:active { transform: scale(0.95); }
.chat-launcher > span { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.chat-launcher .ico { width: 28px; height: 28px; stroke-width: 1.9; }
.chat-launcher__close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
.chat-launcher[aria-expanded="true"] .chat-launcher__open { opacity: 0; transform: rotate(45deg) scale(0.6); }
.chat-launcher[aria-expanded="true"] .chat-launcher__close { opacity: 1; transform: none; }

.chat-teaser {
  position: fixed; z-index: var(--z-chat);
  right: calc(var(--float-right) + var(--float-size) + var(--float-gap));
  bottom: calc(var(--float-bottom) + 6px);
  max-width: min(250px, calc(100vw - 110px));
  display: flex; align-items: flex-start; gap: 6px;
  padding: 12px 8px 12px 16px; border-radius: var(--radius) var(--radius) 4px var(--radius);
  background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: var(--fs-sm); line-height: 1.4; color: var(--muted); cursor: pointer;
  animation: chat-pop 320ms var(--ease-out);
}
.chat-teaser[hidden] { display: none; }
.chat-teaser strong { display: block; color: var(--text); font-weight: 600; }
.chat-teaser__close {
  flex: none; width: 32px; height: 32px; margin: -6px 0 -6px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
}
.chat-teaser__close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.chat-teaser__close .ico { width: 16px; height: 16px; }

/* ---------- Chatbot: panel ---------- */
.chat-panel {
  position: fixed; z-index: var(--z-chat);
  inset: 0;
  display: flex; flex-direction: column;
  background: var(--ink-2);
  animation: chat-pop 260ms var(--ease-out);
}
.chat-panel[hidden] { display: none; }
@media (min-width: 640px) {
  .chat-panel {
    inset: auto;
    right: var(--float-right);
    bottom: calc(var(--float-bottom) + var(--float-size) + var(--float-gap));
    width: 384px; height: min(620px, calc(100dvh - var(--header-h) - 110px));
    border: 1px solid var(--line-strong); border-radius: 18px; overflow: hidden;
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.85);
    transform-origin: bottom right;
  }
}
@keyframes chat-pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Con el chat abierto se ocultan los otros flotantes para no taparlo. */
body.chat-open .wa-float,
body.chat-open alux-back-to-top { opacity: 0; pointer-events: none; visibility: hidden; }
@media (max-width: 639.98px) {
  body.chat-open { overflow: hidden; }
  body.chat-open .chat-launcher { display: none; }
}

.chat-panel__head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px 16px;
  background: linear-gradient(180deg, #1d1912, var(--ink-2));
  border-bottom: 1px solid var(--line);
}
@media (min-width: 640px) { .chat-panel__head { padding-top: 12px; } }
.chat-panel__head img { width: 52px; height: auto; flex: none; }
.chat-panel__head div { flex: 1; min-width: 0; }
.chat-panel__head h2 { font-family: var(--f-brand); font-size: 1.05rem; letter-spacing: 0.08em; color: var(--gold-hi); }
.chat-panel__head h2:focus { outline: none; }
.chat-panel__head p { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18); }
.chat-panel__close {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
}
.chat-panel__close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.chat-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
}
.chat-msg {
  max-width: 88%; padding: 10px 14px; border-radius: 16px;
  font-size: 0.9375rem; line-height: 1.5; overflow-wrap: anywhere;
}
.chat-msg p + p { margin-top: 6px; }
.chat-msg strong { color: var(--gold-hi); font-weight: 600; }
.chat-msg--bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg--user { align-self: flex-end; background: var(--gold); color: var(--on-gold); font-weight: 500; border-bottom-right-radius: 4px; }
.chat-link { margin-top: 10px; white-space: normal; text-align: center; }

.chat-typing { display: flex; gap: 5px; padding: 14px 16px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); opacity: 0.35; animation: chat-blink 1s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-blink { 30% { opacity: 1; transform: translateY(-2px); } }

.chat-models { display: grid; gap: 8px; margin-top: 10px; }
.chat-model {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 6px 10px 6px 6px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--ink);
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.chat-model:hover { border-color: var(--line-strong); background: #100e0b; }
.chat-model img { width: 56px; height: 48px; object-fit: contain; }
.chat-model span { display: grid; font-size: var(--fs-sm); color: var(--gold); font-variant-numeric: tabular-nums; }
.chat-model strong { color: var(--text); }
.chat-model__more { display: flex !important; align-items: center; font-size: var(--fs-xs) !important; color: var(--muted) !important; white-space: nowrap; }
.chat-model__more .ico { width: 16px; height: 16px; }

.chat-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none;
}
.chat-chips:empty { display: none; }
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chip {
  flex: none; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: transparent;
  font-size: var(--fs-sm); color: var(--gold-hi); white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out);
}
.chat-chip:hover { background: rgba(214, 173, 96, 0.12); }

.chat-form {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--line); background: var(--ink-2);
}
.chat-form input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--ink); font-size: 1rem;
}
.chat-form input::placeholder { color: #8f8574; }
.chat-form input:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; border-radius: var(--radius-pill); }
.chat-form__send {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: var(--gold-grad); color: var(--on-gold);
}
.chat-form__send .ico { width: 20px; height: 20px; stroke-width: 2; }
.chat-panel__foot {
  padding: 0 16px calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 0.75rem; color: var(--muted); text-align: center; background: var(--ink-2);
}
.chat-panel__foot a { color: var(--gold); }

/* ---------- Acceso al chat desde Contacto ---------- */
.contact__chat {
  display: flex; align-items: center; gap: 12px; width: fit-content; max-width: 100%;
  min-height: 48px; padding: 10px 18px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: rgba(214, 173, 96, 0.06); color: var(--muted); font-size: var(--fs-sm);
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.contact__chat:hover { background: rgba(214, 173, 96, 0.12); border-color: var(--gold); }
.contact__chat .ico { width: 24px; height: 24px; color: var(--gold); }
.contact__chat strong { display: block; color: var(--text); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .chat-typing span { animation: none; opacity: 0.8; }
}
