/* =============================================================================
   Inexa · Chatbot · estilos
   -----------------------------------------------------------------------------
   Reutiliza los tokens de la web cuando existen (--brand, --bg, --card...).
   Si no, cae a valores propios para que funcione en cualquier página.
   ============================================================================= */

#inexa-bot {
  --nbot-brand:    var(--brand, #E8541E);
  --nbot-bg:       var(--card,  #26241F);
  --nbot-bg-alt:   var(--bg-alt,#1D1B17);
  --nbot-bg-deep:  var(--bg,    #161512);
  --nbot-text:     var(--text,  #F3EFE7);
  --nbot-muted:    var(--muted, #9B958A);
  --nbot-line:     var(--line,  #38342D);
  --nbot-serif:    var(--serif, 'Fraunces', Georgia, serif);
  --nbot-sans:     var(--sans,  'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);

  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--nbot-sans);
  color: var(--nbot-text);
  transition: opacity .3s ease, visibility 0s linear 0s;
}

/* Mientras el banner de cookies está visible, ocultamos la burbuja del chat
   para que no colisione con sus botones (consentimiento primero). */
.cookie-banner.show ~ #inexa-bot {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease, visibility 0s linear .3s;
}

/* --- Burbuja flotante --------------------------------------------------- */

.nbot-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--nbot-brand);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(232, 84, 30, 0.35), 0 4px 10px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.22s cubic-bezier(.4,1.4,.6,1), box-shadow 0.22s;
}

.nbot-bubble:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 34px rgba(232, 84, 30, 0.45), 0 6px 14px rgba(0,0,0,0.3);
}

.nbot-bubble:active {
  transform: scale(0.96);
}

/* Anillo de pulso/radar alrededor de la burbuja */
.nbot-bubble::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--nbot-brand);
  opacity: 0.6;
  pointer-events: none;
  animation: nbot-bubble-pulse 2.4s infinite;
}

@keyframes nbot-bubble-pulse {
  0%   { transform: scale(0.95); opacity: 0.65; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Se oculta cuando el panel está abierto, para no distraer */
#inexa-bot.nbot-open .nbot-bubble::before {
  display: none;
}

.nbot-bubble-icon {
  width: 26px;
  height: 26px;
  position: absolute;
  transition: opacity 0.18s, transform 0.18s;
}

.nbot-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
#inexa-bot.nbot-open .nbot-icon-chat  { opacity: 0; transform: rotate(90deg) scale(0.6); }
#inexa-bot.nbot-open .nbot-icon-close { opacity: 1; transform: rotate(0)    scale(1); }

.nbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #fff;
  color: var(--nbot-brand);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* --- Panel -------------------------------------------------------------- */

.nbot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: min(380px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 120px));
  background: var(--nbot-bg-deep);
  border: 1px solid var(--nbot-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), 0 8px 20px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(.4,1.2,.6,1), visibility 0s linear 0.22s;
}

.nbot-panel-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(.4,1.2,.6,1), visibility 0s;
}

/* --- Header ------------------------------------------------------------- */

.nbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--nbot-bg);
  border-bottom: 1px solid var(--nbot-line);
  flex-shrink: 0;
}

.nbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--nbot-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--nbot-serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.nbot-header-text {
  flex: 1;
  min-width: 0;
}

.nbot-title {
  font-family: var(--nbot-serif);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  color: var(--nbot-text);
}

.nbot-sub {
  font-size: 12px;
  color: var(--nbot-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.nbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: nbot-pulse 2s infinite;
}

@keyframes nbot-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(74, 222, 128, 0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0   rgba(74, 222, 128, 0); }
}

.nbot-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--nbot-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.nbot-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--nbot-text);
}

.nbot-close svg { width: 18px; height: 18px; }

/* --- Mensajes ----------------------------------------------------------- */

.nbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--nbot-line) transparent;
}

.nbot-messages::-webkit-scrollbar { width: 6px; }
.nbot-messages::-webkit-scrollbar-track { background: transparent; }
.nbot-messages::-webkit-scrollbar-thumb { background: var(--nbot-line); border-radius: 3px; }

.nbot-msg {
  max-width: 86%;
  padding: 9px 14px 6px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  display: flex;
  flex-direction: column;
}

.nbot-msg-bot {
  align-self: flex-start;
  background: var(--nbot-bg);
  color: var(--nbot-text);
  border-bottom-left-radius: 4px;
}

.nbot-msg-user {
  align-self: flex-end;
  background: var(--nbot-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.nbot-msg-text { white-space: normal; }

.nbot-msg-time {
  align-self: flex-end;
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1;
  opacity: 0.6;
  letter-spacing: 0.02em;
}

.nbot-msg-bot .nbot-msg-time  { color: var(--nbot-muted); opacity: 0.8; }
.nbot-msg-user .nbot-msg-time { color: #fff; }

.nbot-msg-enter {
  animation: nbot-msg-in 0.28s cubic-bezier(.4,1.2,.6,1) both;
}

@keyframes nbot-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Indicador de "escribiendo…" --------------------------------------- */

.nbot-typing {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.nbot-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nbot-muted);
  opacity: 0.5;
  animation: nbot-typing-bounce 1.2s infinite ease-in-out;
}

.nbot-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.nbot-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes nbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 0.9; }
}

/* --- Opciones (botones) ------------------------------------------------- */

.nbot-options {
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--nbot-line) transparent;
}

.nbot-options::-webkit-scrollbar { width: 6px; }
.nbot-options::-webkit-scrollbar-thumb { background: var(--nbot-line); border-radius: 3px; }

.nbot-opt {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--nbot-line);
  background: transparent;
  color: var(--nbot-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1.35;
}

.nbot-opt:hover {
  background: var(--nbot-bg);
  border-color: var(--nbot-brand);
  color: var(--nbot-text);
}

.nbot-opt:active {
  transform: scale(0.98);
}

/* Botón principal (CTA dentro del formulario) */
.nbot-opt-primary {
  background: var(--nbot-brand);
  border-color: var(--nbot-brand);
  color: #fff;
  text-align: center;
  font-weight: 600;
}

.nbot-opt-primary:hover {
  background: var(--nbot-brand);
  border-color: var(--nbot-brand);
  color: #fff;
  filter: brightness(1.08);
}

/* Botón secundario / de escape */
.nbot-opt-ghost {
  text-align: center;
  font-size: 13px;
  color: var(--nbot-muted);
  border-color: transparent;
}

.nbot-opt-ghost:hover {
  background: transparent;
  border-color: var(--nbot-line);
  color: var(--nbot-text);
}

/* --- Formulario de captura --------------------------------------------- */

.nbot-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.nbot-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--nbot-muted);
}

.nbot-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--nbot-line);
  background: var(--nbot-bg-alt);
  color: var(--nbot-text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nbot-input::placeholder { color: var(--nbot-muted); opacity: 0.7; }

.nbot-input:focus {
  outline: none;
  border-color: var(--nbot-brand);
  box-shadow: 0 0 0 3px rgba(232, 84, 30, 0.18);
}

.nbot-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.nbot-form-error {
  font-size: 12px;
  color: #f87171;
  margin: -2px 0 2px;
}

/* --- Saludo proactivo (teaser) ----------------------------------------- */

.nbot-teaser {
  position: absolute;
  bottom: 74px;
  right: 4px;
  width: max-content;
  max-width: 240px;
  background: var(--nbot-bg);
  color: var(--nbot-text);
  border: 1px solid var(--nbot-line);
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  padding: 12px 14px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.25);
  animation: nbot-teaser-in 0.35s cubic-bezier(.4,1.3,.6,1) both;
}

.nbot-teaser-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.4;
  cursor: pointer;
  padding-right: 12px;
}

.nbot-teaser-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--nbot-line);
  background: var(--nbot-bg-deep);
  color: var(--nbot-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}

.nbot-teaser-close:hover { color: var(--nbot-text); background: var(--nbot-bg); }
.nbot-teaser-close svg { width: 12px; height: 12px; }

@keyframes nbot-teaser-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mientras el banner de cookies está visible, ocultamos también el teaser. */
.cookie-banner.show ~ #inexa-bot .nbot-teaser { display: none; }

@media (prefers-reduced-motion: reduce) {
  .nbot-typing-dot,
  .nbot-bubble::before,
  .nbot-dot { animation: none; }
}

/* --- Footer ------------------------------------------------------------- */

.nbot-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--nbot-line);
  background: var(--nbot-bg-alt);
  font-size: 11px;
  color: var(--nbot-muted);
  text-align: center;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

/* --- Móvil -------------------------------------------------------------- */

@media (max-width: 480px) {
  #inexa-bot {
    bottom: 16px;
    right: 16px;
  }
  .nbot-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    right: -8px;
    bottom: 72px;
    border-radius: 16px;
  }
  .nbot-bubble {
    width: 56px;
    height: 56px;
  }
}
