/* ══════════════════════════════════════════
   SOFTBYTE CHATBOX — ByteBot
══════════════════════════════════════════ */

/* #sb-chat se mantiene oculto (CSS crítico en el HTML) y chatbox.js lo revela
   recién cuando la página terminó de cargar (window 'load'), para que el chat
   NO aparezca antes que el contenido principal. */

.sb-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1b2559, #33459b);
  box-shadow: 0 6px 24px rgba(27, 37, 89, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9997;
  transition: transform .25s, box-shadow .25s;
  border: none;
  outline: none;
}
.sb-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 30px rgba(27, 37, 89, 0.6);
}
.sb-btn svg { width: 26px; height: 26px; }

.sb-popup {
  position: fixed;
  bottom: 90px;
  right: 28px;
  width: 340px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 56px rgba(37, 99, 235, 0.18);
  z-index: 9996;
  overflow: hidden;
  transform: scale(.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  display: flex;
  flex-direction: column;
  max-height: 500px;
}
.sb-popup.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.sb-header {
  background: linear-gradient(135deg, #1b2559, #33459b);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sb-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sb-header-info h3 {
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  margin: 0;
}
.sb-header-info span {
  color: rgba(255,255,255,.75);
  font-size: .75rem;
  display: flex; align-items: center; gap: 5px;
}
.sb-online-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: sb-blink 1.6s ease-in-out infinite;
}
@keyframes sb-blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.sb-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: background .2s;
  line-height: 1;
}
.sb-close:hover { background: rgba(255,255,255,.2); color: #fff; }

.sb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f5f8ff;
  scroll-behavior: smooth;
}
.sb-messages::-webkit-scrollbar { width: 4px; }
.sb-messages::-webkit-scrollbar-track { background: transparent; }
.sb-messages::-webkit-scrollbar-thumb { background: #a9c3fb; border-radius: 4px; }

.sb-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.sb-msg.bot  { align-self: flex-start; }
.sb-msg.user { align-self: flex-end; }

.sb-msg .bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .85rem;
  line-height: 1.55;
  word-break: break-word;
}
.sb-msg.bot .bubble {
  background: #ffffff;
  color: #0f1a3a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(37,99,235,.1);
}
.sb-msg.user .bubble {
  background: linear-gradient(135deg, #3b6cf6, #1d4ed8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.sb-msg .time {
  font-size: .7rem;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}
.sb-msg.user .time { text-align: right; }

.sb-typing .bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.sb-typing .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6f9bf5;
  animation: sb-bounce .9s ease-in-out infinite;
}
.sb-typing .dot:nth-child(2) { animation-delay: .15s; }
.sb-typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes sb-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

.sb-footer {
  background: #ffffff;
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #e2e9fb;
  flex-shrink: 0;
}
.sb-input {
  flex: 1;
  border: 1.5px solid #e2e9fb;
  background: #f5f8ff;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  color: #0f1a3a;
  transition: border-color .2s;
}
.sb-input:focus { border-color: #2563eb; background: #fff; }
.sb-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b6cf6, #1d4ed8);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .15s, opacity .2s;
}
.sb-send:hover { transform: scale(1.08); }
.sb-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.sb-send svg { width: 16px; height: 16px; fill: white; }

@media (max-width: 768px) {
  .sb-btn { bottom: 20px; right: 16px; width: 50px; height: 50px; }
  .sb-popup { bottom: 80px; right: 16px; left: 16px; width: auto; max-height: 70vh; }
}

.sb-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}
.sb-option-btn {
  background: white;
  border: 1px solid #e2e9fb;
  color: #0f1a3a;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(37,99,235,0.05);
}
.sb-option-btn:hover {
  background: #f5f8ff;
  border-color: #6f9bf5;
  transform: translateY(-1px);
}
.sb-lead-form {
  background: white;
  border: 1px solid #e2e9fb;
  padding: 15px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 85%;
  margin-top: 5px;
  box-shadow: 0 2px 4px rgba(37,99,235,0.05);
}
.sb-lead-form input {
  padding: 10px;
  border: 1px solid #e2e9fb;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  color: #0f1a3a;
}
.sb-lead-form input:focus { border-color: #2563eb; }
.sb-submit-btn {
  background: linear-gradient(135deg, #3b6cf6, #1d4ed8);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.sb-submit-btn:hover { opacity: 0.9; }
.sb-submit-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.sb-tooltip {
  position: fixed;
  bottom: 36px;
  right: 92px;
  background: #ffffff;
  color: #0f1a3a;
  font-size: .82rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 20px;
  box-shadow: 0 4px 18px rgba(37,99,235,0.18);
  border: 1px solid #e2e9fb;
  white-space: nowrap;
  z-index: 9997;
  cursor: pointer;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.sb-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}
.sb-tooltip-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.sb-tooltip-close:hover { background: #1d4ed8; }
.sb-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #ffffff;
  filter: drop-shadow(2px 0 1px rgba(37,99,235,0.1));
}

@media (max-width: 768px) {
  .sb-tooltip {
    bottom: 26px;
    right: 78px;
    left: auto;
    max-width: none;
    white-space: nowrap;
    font-size: .72rem;
    padding: 8px 12px;
  }
}
