/* ============================================================================
   TIERRA — Asesor de ventas guiado (estilos). PC + móvil.
   ========================================================================== */
:root { --tadv-gold: #C9A96E; --tadv-cream: #F2EEE4; --tadv-dark: #14201A; }

/* ---- FAB ---- */
#tadv-fab {
  position: fixed; z-index: 960;
  right: 28px; bottom: 28px;
  width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(145deg, #C9A96E, #a9884f);
  color: #14110c;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(201,169,110,.4), 0 4px 12px rgba(0,0,0,.3);
  transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s;
  animation: tadvPulse 3s ease-in-out infinite;
}
#tadv-fab:hover { transform: scale(1.07); }
#tadv-fab.active { animation: none; }
#tadv-fab svg { width: 27px; height: 27px; }
.tadv-fab-dot {
  position: absolute; top: 6px; right: 8px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #4ac26b; border: 2px solid #14201A;
}
@keyframes tadvPulse {
  0%,100% { box-shadow: 0 10px 30px rgba(201,169,110,.4), 0 0 0 0 rgba(201,169,110,.45); }
  50%     { box-shadow: 0 10px 30px rgba(201,169,110,.4), 0 0 0 12px rgba(201,169,110,0); }
}

/* ---- Panel ---- */
#tadv-panel {
  position: fixed; z-index: 961;
  right: 24px; bottom: 100px;
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 130px);
  background: rgba(18,26,21,.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(201,169,110,.28);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  opacity: 0; transform: translateY(20px) scale(.98); pointer-events: none;
  transition: opacity .3s ease, transform .3s cubic-bezier(.16,1,.3,1);
  font-family: 'DM Sans', sans-serif;
}
#tadv-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.tadv-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px; background: rgba(201,169,110,.08);
  border-bottom: 1px solid rgba(201,169,110,.18);
}
.tadv-av {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 20px;
  background: rgba(201,169,110,.16);
}
.tadv-hd-txt { flex: 1; min-width: 0; }
.tadv-name { font-size: 15px; font-weight: 600; color: var(--tadv-cream); }
.tadv-status { font-size: 11.5px; color: rgba(242,238,228,.6); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tadv-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ac26b; box-shadow: 0 0 0 0 rgba(74,194,107,.5); animation: tadvBlink 2s infinite; }
@keyframes tadvBlink { 0%,100%{opacity:1} 50%{opacity:.4} }
.tadv-x { background: none; border: none; color: rgba(242,238,228,.6); font-size: 18px; cursor: pointer; padding: 6px; line-height: 1; }
.tadv-x:hover { color: var(--tadv-cream); }

/* ---- Mensajes ---- */
.tadv-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.tadv-msg { max-width: 84%; padding: 11px 14px; font-size: 14px; line-height: 1.5; border-radius: 14px; animation: tadvIn .3s ease both; }
.tadv-msg.bot { align-self: flex-start; background: rgba(255,255,255,.06); color: var(--tadv-cream); border-bottom-left-radius: 4px; }
.tadv-msg.user { align-self: flex-end; background: var(--tadv-gold); color: #14110c; font-weight: 500; border-bottom-right-radius: 4px; }
@keyframes tadvIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tadv-typing { display: flex; gap: 4px; align-items: center; }
.tadv-typing span { width: 7px; height: 7px; border-radius: 50%; background: rgba(242,238,228,.5); animation: tadvBounce 1.2s infinite; }
.tadv-typing span:nth-child(2) { animation-delay: .2s; }
.tadv-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tadvBounce { 0%,60%,100%{transform:translateY(0);opacity:.5} 30%{transform:translateY(-5px);opacity:1} }

/* ---- Opciones (quick replies) ---- */
.tadv-opts { display: flex; flex-direction: column; gap: 8px; align-self: flex-end; align-items: flex-end; max-width: 92%; }
.tadv-opt {
  background: rgba(201,169,110,.1); color: var(--tadv-cream);
  border: 1px solid rgba(201,169,110,.4); border-radius: 20px;
  padding: 10px 16px; font-size: 13.5px; font-family: inherit; cursor: pointer;
  transition: background .2s, transform .15s; text-align: right;
}
.tadv-opt:hover { background: rgba(201,169,110,.22); transform: translateX(-2px); }

/* ---- Form dentro del chat ---- */
.tadv-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; animation: tadvIn .3s ease both; }
.tadv-form input {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 16px;
  color: var(--tadv-cream); background: rgba(255,255,255,.06);
  border: 1px solid rgba(201,169,110,.3); border-radius: 11px; padding: 12px 14px;
}
.tadv-form input:focus { outline: none; border-color: var(--tadv-gold); }
.tadv-form input::placeholder { color: rgba(242,238,228,.4); }
.tadv-form button {
  margin-top: 2px; min-height: 48px; border: none; border-radius: 11px; cursor: pointer;
  background: var(--tadv-gold); color: #14110c; font-family: inherit;
  font-size: 12.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}
.tadv-form button:disabled { opacity: .6; }
.tadv-status-msg { font-size: 12.5px; color: #e7a99a; margin: 2px 0 0; min-height: 4px; }

/* Input de pregunta libre (modo IA) */
.tadv-ai { flex-direction: row; align-items: stretch; }
.tadv-ai input { flex: 1; margin: 0; }
.tadv-ai button { width: auto; min-width: 50px; margin: 0; padding: 0 16px; font-size: 18px; letter-spacing: 0; }

.tadv-wa-cta {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin-top: 2px; text-decoration: none;
  background: #25D366; color: #06240f; font-weight: 600; font-size: 13.5px;
  padding: 11px 16px; border-radius: 12px; animation: tadvIn .3s ease both;
}
.tadv-wa-cta svg { width: 18px; height: 18px; }

/* ---- Móvil ---- */
@media (max-width: 768px) {
  #tadv-fab { right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); width: 54px; height: 54px; }
  #tadv-panel {
    right: 8px; left: 8px; bottom: 8px; width: auto;
    height: 76vh; max-height: calc(100vh - 90px);
  }
  /* al abrir el chat en móvil, ocultamos la barra inferior para no encimar */
  body.tadv-open .tmbar { transform: translateY(120%); }
}

@media (prefers-reduced-motion: reduce) {
  #tadv-fab { animation: none; }
  .tadv-msg, .tadv-form, .tadv-wa-cta { animation: none; }
}
