:root{
  --bot-bg: rgba(10, 15, 28, 0.92);
  --bot-border: rgba(255,255,255,0.12);
  --bot-text: rgba(255,255,255,0.94);
  --bot-muted: rgba(255,255,255,0.72);

  --bot-accent: #22c55e;
  --bot-accent-2: #00e676;
  --bot-cyan: #38bdf8;

  --bot-shadow: 0 26px 80px rgba(0,0,0,0.55);
  --bot-glow: 0 0 0 1px rgba(255,255,255,0.06), 0 0 22px rgba(34,197,94,0.10);

  --bot-radius: 20px;
  --bot-radius-sm: 14px;
}

/* =========================
   FAB (botón flotante)
========================= */
#fab-bot{
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: radial-gradient(120% 120% at 30% 20%, rgba(34,197,94,0.25), rgba(2,6,23,0.88));
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 999999;
  box-shadow: 0 20px 55px rgba(0,0,0,0.48), 0 0 0 1px rgba(255,255,255,0.06), 0 0 22px rgba(34,197,94,0.18);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  pointer-events: auto;
}

#fab-bot:hover{
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 26px 75px rgba(0,0,0,0.60), 0 0 26px rgba(34,197,94,0.28), 0 0 22px rgba(56,189,248,0.12);
  filter: brightness(1.05);
}

/* =========================
   Ventana del bot
========================= */
#ts-bot{
  position: fixed;
  right: 18px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: min(370px, calc(100vw - 36px));
  height: min(540px, calc(100dvh - 120px));
  max-height: calc(100dvh - 120px);

  background:
    radial-gradient(120% 90% at 20% 10%, rgba(34,197,94,0.12), transparent 60%),
    radial-gradient(120% 90% at 90% 20%, rgba(56,189,248,0.10), transparent 55%),
    rgba(10, 15, 28, 0.90);

  border: 1px solid var(--bot-border);
  border-radius: var(--bot-radius);
  box-shadow: var(--bot-shadow);
  z-index: 1000000;
  overflow: hidden;

  backdrop-filter: blur(14px) saturate(1.25);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  transform-origin: bottom right;

  display: none;
  flex-direction: column;
}

#ts-bot.open{
  display: flex;
  animation: tsbPop .22s ease-out;
}

@keyframes tsbPop{
  from{ opacity: 0; transform: translateY(10px) scale(0.98); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================
   Header
========================= */
.tsb-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(135deg, rgba(34,197,94,0.18), rgba(2,6,23,0.38));
  flex-shrink: 0;
}

.tsb-title{
  display:flex;
  gap:10px;
  align-items:center;
  min-width:0;
}

.tsb-avatar{
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display:grid;
  place-items:center;
  background: radial-gradient(120% 120% at 30% 20%, rgba(34,197,94,0.35), rgba(34,197,94,0.12));
  border: 1px solid rgba(34,197,94,0.40);
  box-shadow: 0 0 28px rgba(34,197,94,0.18);
  flex: 0 0 auto;
  color: rgba(255,255,255,0.95);
  font-weight: 900;
  font-size: 0.92rem;
}

.tsb-names{
  display:flex;
  flex-direction:column;
  line-height:1.12;
  min-width:0;
}

.tsb-names strong{
  font-size: 0.98rem;
  color: var(--bot-text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.tsb-names span{
  font-size: 0.78rem;
  color: var(--bot-muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.tsb-close{
  border: 0;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  width: 36px;
  height: 36px;
  border-radius: 14px;
  cursor:pointer;
  display:grid;
  place-items:center;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}

.tsb-close:hover{
  background: rgba(255,255,255,0.14);
  transform: scale(1.04);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}

/* =========================
   Mensajes
========================= */
.tsb-messages{
  padding: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.tsb-messages::-webkit-scrollbar{ width: 10px; }
.tsb-messages::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(2,6,23,0.35);
  border-radius: 12px;
}
.tsb-messages::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.18);
}

.tsb-msg{
  width: 100%;
  display: flex;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  max-width: 100%;
  animation: msgIn .18s ease-out;
}

@keyframes msgIn{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: translateY(0); }
}

.tsb-msg.bot{ justify-content: flex-start; }
.tsb-msg.user{ justify-content: flex-end; }

.tsb-bubble{
  max-width: 78%;
  padding: 11px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--bot-text);
  font-size: 0.92rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}

.tsb-msg.bot .tsb-bubble{
  background:
    radial-gradient(120% 120% at 20% 10%, rgba(56,189,248,0.18), rgba(56,189,248,0.08)),
    rgba(255,255,255,0.04);
  border-color: rgba(56,189,248,0.22);
}

.tsb-msg.user .tsb-bubble{
  background: linear-gradient(135deg, rgba(34,197,94,0.30), rgba(34,197,94,0.14));
  border-color: rgba(34,197,94,0.28);
  box-shadow: 0 10px 24px rgba(34,197,94,0.10), 0 10px 22px rgba(0,0,0,0.18);
}

/* =========================
   Acciones
========================= */
.tsb-actions{
  width: 100%;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tsb-actions a{
  flex: 1;
  min-width: 170px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid rgba(34,197,94,0.40);
  background: linear-gradient(135deg, rgba(34,197,94,0.24), rgba(0,230,118,0.10));
  color: rgba(255,255,255,0.98);
  text-decoration: none;
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 0 24px rgba(34,197,94,0.10), 0 10px 22px rgba(0,0,0,0.18);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  user-select: none;
}

.tsb-actions a:hover{
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 0 30px rgba(34,197,94,0.18), 0 12px 26px rgba(0,0,0,0.22);
}

/* =========================
   Typing
========================= */
.tsb-typing{
  display:none;
  font-size: 0.82rem;
  color: var(--bot-muted);
  padding: 0 12px 10px;
  flex-shrink: 0;
}
.tsb-typing.show{ display:block; }

/* =========================
   Input + botón enviar
========================= */
.tsb-input{
  min-height: 60px;
  border-top: 1px solid rgba(255,255,255,0.10);
  padding: 10px;
  display:flex;
  gap:8px;
  align-items:center;
  flex-shrink: 0;
  background: rgba(2,6,23,0.42);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.tsb-input input{
  flex:1;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(15,23,42,0.62);
  color: rgba(255,255,255,0.94);
  padding: 0 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.tsb-input input:focus{
  border-color: rgba(34,197,94,0.45);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.16);
}

.tsb-input input::placeholder{
  color: rgba(255,255,255,0.55);
}

.tsb-input input:disabled{
  opacity: 0.7;
  cursor: not-allowed;
}

.tsb-send{
  height: 40px;
  width: 46px;
  border-radius: 14px;
  border: 1px solid rgba(34,197,94,0.40);
  background: linear-gradient(135deg, rgba(34,197,94,0.42), rgba(0,230,118,0.18));
  color: rgba(255,255,255,0.98);
  cursor:pointer;
  display:grid;
  place-items:center;
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease, opacity .15s ease;
  box-shadow: 0 0 22px rgba(34,197,94,0.14);
}

.tsb-send:hover{
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.06);
  box-shadow: 0 0 28px rgba(34,197,94,0.22);
}

.tsb-send:disabled{
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* =========================
   LINKS dentro del bot
========================= */
.tsb-link{
  color: rgba(56,189,248,0.98);
  text-decoration: none;
  font-weight: 800;
  border-bottom: 1px solid rgba(56,189,248,0.35);
}
.tsb-link:hover{
  text-decoration: underline;
  border-bottom-color: rgba(56,189,248,0.80);
}

/* =========================
   CTA WhatsApp dentro del bot
========================= */
.ts-bot-cta{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(34,197,94,0.40);
  background: linear-gradient(135deg, rgba(34,197,94,0.34), rgba(0,230,118,0.16));
  color: rgba(255,255,255,0.98);
  text-decoration:none;
  font-weight: 900;
  margin-top: 6px;
  box-shadow: 0 0 24px rgba(34,197,94,0.12);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}

.ts-bot-cta:hover{
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 0 30px rgba(34,197,94,0.20);
}

/* =========================
   Responsive
========================= */
@media (max-width: 520px){
  #ts-bot{
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
    height: min(540px, calc(100dvh - 110px));
    max-height: calc(100dvh - 110px);
    border-radius: 18px;
  }

  #fab-bot{
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .tsb-bubble{
    max-width: 88%;
  }

  .tsb-actions a{
    min-width: 150px;
  }
}




