/* ============================================================
   Chatbot Jurídico — Estilos del widget flotante v2.0
   Paleta: azul marino + dorado + blanco cálido
   Optimizado para conversión y experiencia de usuario
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Source+Sans+3:wght@400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --cj-navy: #1a2744;
  --cj-navy-mid: #243154;
  --cj-navy-lite: #2f4070;
  --cj-gold: #c9a84c;
  --cj-gold-lite: #e6c97a;
  --cj-gold-deep: #a8863a;
  --cj-white: #f8f6f1;
  --cj-text: #2d2d2d;
  --cj-muted: #7a7a7a;
  --cj-radius: 14px;
  --cj-shadow: 0 16px 48px rgba(26, 39, 68, .32), 0 3px 10px rgba(0, 0, 0, .12);
  --cj-z: 99999;
  --cj-w: 380px;
  --cj-h: 560px;
  --cj-wa-green: #25d366;
  --cj-wa-dark: #128c5e;
}

/* ══════════════════════════════════════════════════════════
   LAUNCHER BUTTON
══════════════════════════════════════════════════════════ */
#cj-launcher {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: var(--cj-z);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px 13px 18px;
  background: linear-gradient(135deg, var(--cj-navy) 0%, var(--cj-navy-lite) 100%);
  border: 2px solid rgba(248, 246, 241, .25);
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(26, 39, 68, .45), 0 1px 4px rgba(0, 0, 0, .2);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
  user-select: none;
  outline: none;
}

#cj-launcher:hover,
#cj-launcher:focus {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 36px rgba(26, 39, 68, .55), 0 2px 6px rgba(0, 0, 0, .2);
}

#cj-launcher:active {
  transform: scale(.97);
}

#cj-launcher.cj-active {
  padding: 13px 20px;
  border-color: rgba(248, 246, 241, .2);
}

#cj-launcher svg {
  width: 22px;
  height: 22px;
  color: var(--cj-white);
  flex-shrink: 0;
}

.cj-launcher-label {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--cj-white);
  letter-spacing: .3px;
  white-space: nowrap;
}

#cj-launcher.cj-active .cj-launcher-label {
  display: none;
}

/* ── Badge de notificación ──────────────────────────────── */
#cj-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  background: #e53935;
  color: #fff;
  border-radius: 50%;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: opacity .3s ease, transform .4s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
}

#cj-badge.cj-badge-visible {
  opacity: 1;
  transform: scale(1);
}

/* Pulso de atención */
#cj-badge.cj-badge-visible::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #e53935;
  animation: cj-pulse 2s ease-out infinite;
}

@keyframes cj-pulse {
  0% {
    opacity: .7;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(2);
  }
}

/* ══════════════════════════════════════════════════════════
   WIDGET CONTAINER
══════════════════════════════════════════════════════════ */
#cj-widget {
  position: fixed;
  bottom: 90px;
  left: 28px;
  z-index: var(--cj-z);
  width: var(--cj-w);
  height: var(--cj-h);
  background: var(--cj-white);
  border-radius: var(--cj-radius);
  box-shadow: var(--cj-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .8);
  opacity: 0;
  transform: translateY(24px) scale(.96);
  pointer-events: none;
  transition: opacity .32s ease, transform .32s cubic-bezier(.34, 1.15, .64, 1);
}

#cj-widget.cj-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ══════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════ */
#cj-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: linear-gradient(135deg, var(--cj-navy) 0%, var(--cj-navy-lite) 100%);
  border-bottom: 1px solid rgba(201, 168, 76, .3);
  flex-shrink: 0;
  position: relative;
}

/* Línea decorativa dorada en la base del header */
#cj-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cj-gold), transparent);
}

.cj-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  border: 2px solid rgba(201, 168, 76, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.cj-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cj-header-name {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cj-white);
  line-height: 1.2;
}

.cj-header-status {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 11px;
  color: rgba(248, 246, 241, .75);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Punto pulsante "En línea" */
.cj-status-dot {
  width: 7px;
  height: 7px;
  background: #4caf50;
  border-radius: 50%;
  display: inline-block;
  animation: cj-blink 2.5s ease-in-out infinite;
}

@keyframes cj-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .4;
  }
}

#cj-reset-btn
{ font-size: 14px;}

#cj-close-btn {
  background: none;
  border: none;
  color: rgba(248, 246, 241, .6);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color .2s, background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cj-reset-btn {
  margin-right: 4px;
  color: rgba(248, 246, 241, .75);
  background: rgba(255, 255, 255, .12);
  border: 1.5px solid rgba(255, 255, 255, .25) !important;
  padding: 6px 8px;
}

#cj-reset-btn:hover {
  background: rgba(255, 255, 255, .22);
  color: var(--cj-white);
  border-color: rgba(255, 255, 255, .5) !important;
}

#cj-close-btn:hover {
  color: var(--cj-white);
  background: rgba(255, 255, 255, .12);
}

/* ══════════════════════════════════════════════════════════
   BODY / BOTUI WRAPPER
══════════════════════════════════════════════════════════ */
#cj-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f0eee9;
  overflow: hidden;
  min-height: 0;
}

#cj-botui {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ══════════════════════════════════════════════════════════
   BOTUI OVERRIDES
══════════════════════════════════════════════════════════ */
.botui-app-container {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background: transparent !important;
  font-family: 'Source Sans 3', sans-serif !important;
  font-size: 14px !important;
}

/* ── Área de mensajes ─────────────────────────────────── */
.botui-messages-container {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  min-height: 0 !important;
  padding: 16px 14px 12px !important;
  background: transparent !important;
  scroll-behavior: smooth;
}

.botui-messages-container::-webkit-scrollbar {
  width: 5px;
}

.botui-messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.botui-messages-container::-webkit-scrollbar-thumb {
  background: rgba(26, 39, 68, .2);
  border-radius: 8px;
}

.botui-messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 39, 68, .38);
}

/* ── Burbuja del bot ─────────────────────────────────── */
.botui-message {
  margin-bottom: 10px !important;
}

.botui-message-content {
  background: #ffffff !important;
  color: var(--cj-text) !important;
  border: 1px solid rgba(26, 39, 68, .09) !important;
  border-radius: 4px 16px 16px 16px !important;
  padding: 11px 15px !important;
  font-size: 13.5px !important;
  line-height: 1.6 !important;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .07), 0 0 0 0 transparent !important;
  max-width: 86% !important;
  word-break: break-word !important;
  /* Animación de entrada */
  animation: cj-msgIn .25s ease-out both;
}

@keyframes cj-msgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Burbuja humana ──────────────────────────────────── */
.botui-message-content.human {
  background: linear-gradient(135deg, var(--cj-navy) 0%, var(--cj-navy-lite) 100%) !important;
  color: var(--cj-white) !important;
  border-color: transparent !important;
  border-radius: 16px 16px 4px 16px !important;
  margin-left: auto !important;
  box-shadow: 0 2px 8px rgba(26, 39, 68, .22) !important;
}

/* Links dentro de burbujas */
.botui-message-content a {
  color: var(--cj-navy) !important;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.botui-message-content.human a {
  color: var(--cj-gold-lite) !important;
}

/* ── Loading dots mejorados ──────────────────────────── */
.botui-message-content-loading {
  padding: 14px 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
}

.botui-message-content-loading span {
  width: 7px !important;
  height: 7px !important;
  background: var(--cj-navy) !important;
  border-radius: 50% !important;
  opacity: .35;
  animation: cj-dot 1.2s ease-in-out infinite !important;
}

.botui-message-content-loading span:nth-child(2) {
  animation-delay: .2s !important;
}

.botui-message-content-loading span:nth-child(3) {
  animation-delay: .4s !important;
}

@keyframes cj-dot {

  0%,
  80%,
  100% {
    transform: scale(.8);
    opacity: .35;
  }

  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════════════════
   ÁREA DE ACCIONES (BOTONES)
══════════════════════════════════════════════════════════ */
.botui-actions-container {
  padding: 8px 12px 12px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 7px !important;
  background: rgba(248, 246, 241, .95) !important;
  border-top: 1px solid rgba(26, 39, 68, .09) !important;
  flex: 0 0 auto !important;
  backdrop-filter: blur(4px);
}

/* ── Botones generales ───────────────────────────────── */
.botui-actions-buttons-button {
  background: #fff !important;
  color: var(--cj-navy) !important;
  border: 1.5px solid rgba(26, 39, 68, .3) !important;
  border-radius: 9px !important;
  padding: 8px 13px !important;
  font-family: 'Source Sans 3', sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: background .18s ease, color .18s ease, border-color .18s ease,
    transform .15s ease, box-shadow .18s ease !important;
  text-align: left !important;
  line-height: 1.3 !important;
}

.botui-actions-buttons-button:hover {
  background: var(--cj-navy) !important;
  color: var(--cj-white) !important;
  border-color: var(--cj-navy) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 3px 10px rgba(26, 39, 68, .22) !important;
}

.botui-actions-buttons-button:active {
  transform: scale(.97) !important;
  box-shadow: none !important;
}

/* ── Botón WhatsApp — siempre destacado ──────────────── */
.botui-actions-buttons-button[data-value="whatsapp_direct"],
.botui-actions-buttons-button[data-value="whatsapp"] {
  background: var(--cj-wa-green) !important;
  color: #fff !important;
  border-color: var(--cj-wa-green) !important;
  order: -1;
  /* aparece primero */
}

.botui-actions-buttons-button[data-value="whatsapp_direct"]:hover,
.botui-actions-buttons-button[data-value="whatsapp"]:hover {
  background: var(--cj-wa-dark) !important;
  border-color: var(--cj-wa-dark) !important;
  color: #fff !important;
}

/* ── Botón CTA principal (link/agendar) ──────────────── */
.botui-actions-buttons-button[data-value="link"] {
  background: linear-gradient(135deg, var(--cj-navy) 0%, var(--cj-navy-lite) 100%) !important;
  color: var(--cj-white) !important;
  border-color: transparent !important;
  box-shadow: 0 2px 8px rgba(26, 39, 68, .2) !important;
}

.botui-actions-buttons-button[data-value="link"]:hover {
  background: linear-gradient(135deg, var(--cj-navy-lite) 0%, var(--cj-navy) 100%) !important;
  box-shadow: 0 4px 14px rgba(26, 39, 68, .32) !important;
  transform: translateY(-1px) !important;
}

/* ── Botón evaluacion gratuita ───────────────────────── */
.botui-actions-buttons-button[data-value="evaluacion"] {
  background: linear-gradient(135deg, var(--cj-gold-deep) 0%, var(--cj-gold) 100%) !important;
  color: var(--cj-navy) !important;
  border-color: transparent !important;
  font-weight: 700 !important;
}

.botui-actions-buttons-button[data-value="evaluacion"]:hover {
  background: linear-gradient(135deg, var(--cj-gold) 0%, var(--cj-gold-lite) 100%) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 3px 12px rgba(201, 168, 76, .35) !important;
}

/* ── Animación de entrada de botones ─────────────────── */
.botui-actions-buttons-button {
  animation: cj-btnIn .2s ease-out both;
}

.botui-actions-buttons-button:nth-child(2) {
  animation-delay: .05s;
}

.botui-actions-buttons-button:nth-child(3) {
  animation-delay: .10s;
}

.botui-actions-buttons-button:nth-child(4) {
  animation-delay: .15s;
}

.botui-actions-buttons-button:nth-child(5) {
  animation-delay: .20s;
}

.botui-actions-buttons-button:nth-child(6) {
  animation-delay: .25s;
}

.botui-actions-buttons-button:nth-child(7) {
  animation-delay: .30s;
}

@keyframes cj-btnIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ══════════════════════════════════════════════════════════
   FOOTER "powered by" sutil
══════════════════════════════════════════════════════════ */
#cj-footer {
  padding: 5px 14px 7px;
  background: rgba(248, 246, 241, .95);
  border-top: 1px solid rgba(26, 39, 68, .06);
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

#cj-footer span {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 10.5px;
  color: var(--cj-muted);
  letter-spacing: .2px;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  :root {
    --cj-w: calc(100vw - 16px);
    --cj-h: 76vh;
  }

  #cj-widget {
    left: 8px;
    bottom: 78px;
  }

  #cj-launcher {
    left: 14px;
    bottom: 14px;
  }

  .botui-actions-buttons-button {
    font-size: 12px !important;
    padding: 9px 12px !important;
  }
}