/* ==========================================================================
   INSPECTOR FLUXO · ASISTENTE TÉCNICO AUTOMÁTICO REBT 2026
   Estilo visual técnico de marca Fluxo: Dark #08080d, Card #14141f, Naranja #ff6b35
   0 emojis (SVG inline) · dvh responsive · Accesibilidad WCAG
   ========================================================================== */

/* Botón flotante launcher */
.inspector-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #14141f;
  border: 2px solid rgba(255, 107, 53, 0.6);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55), 0 0 16px rgba(255, 107, 53, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1),
              border-color 0.2s ease,
              box-shadow 0.2s ease,
              bottom 0.3s ease;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.inspector-launcher:hover {
  transform: scale(1.06);
  border-color: #ff6b35;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.7), 0 0 24px rgba(255, 107, 53, 0.45);
}

.inspector-launcher:focus-visible {
  outline: 3px solid #ff6b35;
  outline-offset: 3px;
}

.inspector-launcher-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Ocultar botón email-float previo si existe en la página para dar paso al Inspector Fluxo */
.email-float {
  display: none !important;
}

/* Estado textual para lectores de pantalla */
.inspector-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ajuste contra solapamiento si el banner de cookies está activo */
body:has(#cookie-banner) .inspector-launcher {
  bottom: 85px;
}
@media (max-width: 640px) {
  body:has(#cookie-banner) .inspector-launcher {
    bottom: 125px;
  }
}

/* Globito de bienvenida (tooltip de 1 sola vez por visitante) */
.inspector-bubble {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 99998;
  max-width: 270px;
  background: #14141f;
  border: 1px solid rgba(255, 107, 53, 0.45);
  border-radius: 12px;
  padding: 12px 32px 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 18px rgba(255, 107, 53, 0.15);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #f0f0f5;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s ease, bottom 0.3s ease;
  animation: inspectorBubbleIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes inspectorBubbleIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.inspector-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 24px;
  width: 10px;
  height: 10px;
  background: #14141f;
  border-right: 1px solid rgba(255, 107, 53, 0.45);
  border-bottom: 1px solid rgba(255, 107, 53, 0.45);
  transform: rotate(45deg);
}

body:has(#cookie-banner) .inspector-bubble {
  bottom: 155px;
}
@media (max-width: 640px) {
  body:has(#cookie-banner) .inspector-bubble {
    bottom: 195px;
  }
}

.inspector-bubble-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #8f8fa3;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.inspector-bubble-close:hover {
  color: #ff6b35;
  background: rgba(255, 107, 53, 0.1);
}

/* Modal / Ventana del chat */
.inspector-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 8, 13, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.inspector-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.inspector-modal {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000000;
  width: min(410px, calc(100vw - 32px));
  height: min(620px, 85dvh);
  background: #0d0d15;
  border: 1px solid rgba(255, 107, 53, 0.35);
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 107, 53, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.inspector-modal.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Cabecera técnica */
.inspector-header {
  background: #14141f;
  border-bottom: 1px solid rgba(255, 107, 53, 0.22);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.inspector-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.inspector-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #ff6b35;
  object-fit: cover;
  background: #08080d;
  flex-shrink: 0;
}

.inspector-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inspector-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspector-header-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-badge-auto {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #ffaa55;
  background: rgba(255, 170, 85, 0.12);
  border: 1px solid rgba(255, 170, 85, 0.35);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.inspector-header-subtitle {
  margin: 2px 0 0 0;
  font-size: 11px;
  color: #9d9db3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #9d9db3;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.inspector-close-btn:hover {
  color: #ff6b35;
  border-color: rgba(255, 107, 53, 0.3);
  background: rgba(255, 107, 53, 0.1);
}

.inspector-close-btn:focus-visible {
  outline: 2px solid #ff6b35;
}

/* Área de mensajes con auto-scroll */
.inspector-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: radial-gradient(circle at 90% 10%, rgba(255, 107, 53, 0.04) 0%, transparent 60%);
}

.inspector-messages::-webkit-scrollbar {
  width: 6px;
}
.inspector-messages::-webkit-scrollbar-track {
  background: transparent;
}
.inspector-messages::-webkit-scrollbar-thumb {
  background: #252538;
  border-radius: 3px;
}
.inspector-messages::-webkit-scrollbar-thumb:hover {
  background: #383852;
}

/* Mensajes */
.inspector-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
  animation: inspectorMsgFade 0.2s ease-out;
}

@keyframes inspectorMsgFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.inspector-msg.from-bot {
  align-self: flex-start;
}

.inspector-msg.from-user {
  align-self: flex-end;
  max-width: 82%;
}

.inspector-bubble-text {
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.inspector-msg.from-bot .inspector-bubble-text {
  background: #151522;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px 12px 12px 2px;
  color: #e5e5f0;
}

.inspector-msg.from-user .inspector-bubble-text {
  background: rgba(255, 107, 53, 0.16);
  border: 1px solid rgba(255, 107, 53, 0.4);
  border-radius: 12px 12px 2px 12px;
  color: #ffffff;
}

/* Icono rayo en cabecera de mensaje bot */
.inspector-bot-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #ff6b35;
  margin-bottom: 3px;
}

.inspector-rayo-svg {
  width: 12px;
  height: 12px;
  fill: #ff6b35;
  flex-shrink: 0;
}

/* Caja de CTA */
.inspector-cta-card {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(255, 107, 53, 0.08);
  border: 1px solid rgba(255, 107, 53, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-cta-prompt {
  font-size: 12px;
  color: #d1d1e0;
  line-height: 1.4;
  margin: 0;
}

.inspector-cta-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ff6b35;
  color: #08080d !important;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  align-self: flex-start;
}

.inspector-cta-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.inspector-cta-link svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

/* Menú de 1-Tap (Botones rápidos) */
.inspector-quick-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.inspector-quick-btn {
  background: #191928;
  border: 1px solid rgba(255, 107, 53, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  color: #e2e2ee;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s ease;
}

.inspector-quick-btn:hover {
  background: rgba(255, 107, 53, 0.12);
  border-color: #ff6b35;
  color: #ffffff;
  transform: translateX(2px);
}

.inspector-quick-btn:focus-visible {
  outline: 2px solid #ff6b35;
}

.inspector-quick-btn svg {
  width: 12px;
  height: 12px;
  fill: #ff6b35;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
}

.inspector-quick-btn:hover svg {
  opacity: 1;
  transform: translateX(2px);
}

/* Botón para volver al menú de consultas */
.inspector-back-btn {
  margin-top: 6px;
  background: transparent;
  border: none;
  color: #ffaa55;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  align-self: flex-start;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inspector-back-btn:hover {
  color: #ff6b35;
}

/* Barra inferior de entrada */
.inspector-input-bar {
  background: #14141f;
  border-top: 1px solid rgba(255, 107, 53, 0.22);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.inspector-input {
  flex: 1;
  background: #0d0d15;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
}

.inspector-input::placeholder {
  color: #727288;
}

.inspector-input:focus {
  border-color: #ff6b35;
  box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.3);
}

.inspector-send-btn {
  background: #ff6b35;
  border: none;
  color: #08080d;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.inspector-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.04);
}

.inspector-send-btn:disabled {
  background: #252538;
  color: #636378;
  cursor: not-allowed;
  transform: none;
}

.inspector-send-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .inspector-modal {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    height: min(580px, 86dvh);
    border-radius: 14px;
  }
  .inspector-launcher {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }
  .inspector-bubble {
    right: 16px;
    bottom: 80px;
    max-width: 250px;
  }
}
