/* ==========================================================================
   Consultants Jobs - WhatsApp Chatbox Widget Styles
   Diseño inspirado en WhatsApp Web / Mobile con soporte para:
   - Botón flotante animado y badge de notificación
   - Burbujas de chat auténticas (entrantes y salientes)
   - Preguntas predeterminadas en formato chips interactivos
   - Respuestas automáticas con indicador de escritura
   - Acciones directas a WhatsApp (wa.me)
   - 100% responsivo para móviles y escritorio
   ========================================================================== */

:root {
  --cj-wa-green: #25D366;
  --cj-wa-teal-dark: #075E54;
  --cj-wa-teal-light: #128C7E;
  --cj-wa-bg: #efeae2;
  --cj-wa-bubble-in: #ffffff;
  --cj-wa-bubble-out: #d9fdd3;
  --cj-wa-check-blue: #53bdeb;
  --cj-wa-text: #111b21;
  --cj-wa-text-muted: #667781;
  --cj-wa-font: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --cj-wa-shadow: 0 16px 40px rgba(7, 94, 84, 0.22), 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ─────────────────────────────────────────────────────────────
   1. Botón Flotante (Launcher)
   ───────────────────────────────────────────────────────────── */
#cj-wa-widget {
  font-family: var(--cj-wa-font);
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

#cj-wa-widget * {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

/* Tooltip / Callout emergente sobre el botón */
.cj-wa-callout {
  pointer-events: auto;
  position: relative;
  background: #ffffff;
  color: var(--cj-wa-text);
  padding: 10px 16px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  animation: cjWaFadeInUp 0.5s ease forwards;
  max-width: 250px;
}

.cj-wa-callout:hover {
  transform: translateY(-2px);
}

.cj-wa-callout-close {
  color: #8696a0;
  font-size: 0.8rem;
  padding: 2px 4px;
  cursor: pointer;
  margin-left: 4px;
  border-radius: 4px;
}

.cj-wa-callout-close:hover {
  color: #ff3b30;
  background: #f0f2f5;
}

.cj-wa-callout::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.05);
}

/* Botón disparador */
.cj-wa-launcher {
  pointer-events: auto;
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #1ea952 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  outline: none;
}

.cj-wa-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6);
}

.cj-wa-launcher:active {
  transform: scale(0.95);
}

/* Pulso animado tipo radar */
.cj-wa-launcher::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.6);
  animation: cjWaPulse 2.4s infinite cubic-bezier(0.24, 0, 0.38, 1);
  pointer-events: none;
}

/* Badge de notificación no leída */
.cj-wa-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff3b30;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  animation: cjWaBounce 1s infinite alternate;
}

/* Iconos de cambio entre WhatsApp y Cerrar */
.cj-wa-launcher .cj-wa-icon-wa,
.cj-wa-launcher .cj-wa-icon-close {
  position: absolute;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.cj-wa-launcher .cj-wa-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
  font-size: 24px;
}

#cj-wa-widget.is-open .cj-wa-launcher .cj-wa-icon-wa {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

#cj-wa-widget.is-open .cj-wa-launcher .cj-wa-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#cj-wa-widget.is-open .cj-wa-badge,
#cj-wa-widget.is-open .cj-wa-callout {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────
   2. Ventana de Chat (Chatbox)
   ───────────────────────────────────────────────────────────── */
.cj-wa-box {
  pointer-events: auto;
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--cj-wa-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(24px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  visibility: hidden;
}

#cj-wa-widget.is-open .cj-wa-box {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

/* Encabezado */
.cj-wa-header {
  background: linear-gradient(135deg, var(--cj-wa-teal-dark) 0%, var(--cj-wa-teal-light) 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 10;
}

.cj-wa-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cj-wa-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.cj-wa-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #0a2540;
}

.cj-wa-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #25D366;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.cj-wa-title {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cj-wa-verified-icon {
  color: #53bdeb;
  font-size: 0.8rem;
}

.cj-wa-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.cj-wa-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #25D366;
  border-radius: 50%;
}

.cj-wa-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cj-wa-btn-icon {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.cj-wa-btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* ─────────────────────────────────────────────────────────────
   3. Cuerpo de Mensajes (Chat Body)
   ───────────────────────────────────────────────────────────── */
.cj-wa-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--cj-wa-bg);
  background-image: radial-gradient(#d3cbbe 0.75px, transparent 0.75px), radial-gradient(#d3cbbe 0.75px, var(--cj-wa-bg) 0.75px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar estilizado */
.cj-wa-body::-webkit-scrollbar {
  width: 5px;
}
.cj-wa-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

/* Divisor de fecha */
.cj-wa-date-divider {
  align-self: center;
  background: rgba(255, 255, 255, 0.9);
  color: var(--cj-wa-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 4px;
}

/* Burbujas de mensajes */
.cj-wa-msg {
  max-width: 86%;
  position: relative;
  padding: 9px 13px;
  font-size: 0.86rem;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.13);
  word-break: break-word;
  animation: cjWaBubbleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Mensaje entrante (Bot) */
.cj-wa-msg-in {
  align-self: flex-start;
  background: var(--cj-wa-bubble-in);
  color: var(--cj-wa-text);
  border-radius: 0 14px 14px 14px;
}

.cj-wa-msg-in::before {
  content: '';
  position: absolute;
  top: 0;
  left: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent var(--cj-wa-bubble-in) transparent transparent;
}

/* Mensaje saliente (Usuario) */
.cj-wa-msg-out {
  align-self: flex-end;
  background: var(--cj-wa-bubble-out);
  color: var(--cj-wa-text);
  border-radius: 14px 0 14px 14px;
}

.cj-wa-msg-out::before {
  content: '';
  position: absolute;
  top: 0;
  right: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 8px 0 0;
  border-color: var(--cj-wa-bubble-out) transparent transparent transparent;
}

/* Meta del mensaje (Hora y checks) */
.cj-wa-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--cj-wa-text-muted);
  margin-top: 4px;
  user-select: none;
}

.cj-wa-check {
  color: var(--cj-wa-check-blue);
  font-size: 0.72rem;
}

/* Estilos de texto dentro del mensaje */
.cj-wa-msg p {
  margin: 0 0 6px 0;
}
.cj-wa-msg p:last-child {
  margin-bottom: 0;
}
.cj-wa-msg strong {
  font-weight: 700;
  color: #0c447c;
}
.cj-wa-msg ul {
  margin: 6px 0;
  padding-left: 18px;
}
.cj-wa-msg li {
  margin-bottom: 3px;
}

/* ─────────────────────────────────────────────────────────────
   4. Botones de Acción dentro del Mensaje
   ───────────────────────────────────────────────────────────── */
.cj-wa-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.cj-wa-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: center;
}

/* Botón primario: Abrir WhatsApp wa.me */
.cj-wa-action-wa {
  background: #25D366;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.35);
}

.cj-wa-action-wa:hover {
  background: #1ea952;
  transform: translateY(-1px);
  color: #ffffff;
}

/* Botón secundario: Volver a preguntas */
.cj-wa-action-reset {
  background: #f0f2f5;
  color: #185fa5 !important;
}

.cj-wa-action-reset:hover {
  background: #e4e6eb;
}

/* ─────────────────────────────────────────────────────────────
   5. Opciones de Preguntas Predeterminadas (Chips)
   ───────────────────────────────────────────────────────────── */
.cj-wa-quick-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
}

.cj-wa-quick-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #556b7d;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cj-wa-chip {
  background: #ffffff;
  border: 1px solid rgba(12, 68, 124, 0.15);
  border-left: 3px solid #185fa5;
  color: #0c447c;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.81rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  width: 100%;
  line-height: 1.35;
}

.cj-wa-chip i {
  color: #25D366;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.cj-wa-chip:hover {
  background: #f0f7ff;
  border-color: #378add;
  border-left-color: #25D366;
  transform: translateX(3px);
  box-shadow: 0 3px 8px rgba(24, 95, 165, 0.15);
}

.cj-wa-chip:active {
  transform: scale(0.98);
}

/* ─────────────────────────────────────────────────────────────
   6. Indicador de Escritura (Typing indicator)
   ───────────────────────────────────────────────────────────── */
.cj-wa-typing {
  align-self: flex-start;
  background: #ffffff;
  padding: 8px 14px;
  border-radius: 0 14px 14px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--cj-wa-text-muted);
}

.cj-wa-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cj-wa-dot {
  width: 6px;
  height: 6px;
  background: #8696a0;
  border-radius: 50%;
  animation: cjWaDotBounce 1.4s infinite ease-in-out;
}

.cj-wa-dot:nth-child(1) { animation-delay: -0.32s; }
.cj-wa-dot:nth-child(2) { animation-delay: -0.16s; }
.cj-wa-dot:nth-child(3) { animation-delay: 0s; }

/* ─────────────────────────────────────────────────────────────
   7. Barra de Entrada de Texto (Input Footer)
   ───────────────────────────────────────────────────────────── */
.cj-wa-footer {
  background: #f0f2f5;
  padding: 10px 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cj-wa-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cj-wa-input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #d1d7db;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: var(--cj-wa-text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cj-wa-input:focus {
  border-color: #25D366;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

.cj-wa-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #25D366;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: transform 0.2s, background 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.3);
}

.cj-wa-send-btn:hover {
  background: #1ea952;
  transform: scale(1.05);
}

.cj-wa-send-btn:active {
  transform: scale(0.95);
}

.cj-wa-footer-note {
  font-size: 0.69rem;
  color: var(--cj-wa-text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.cj-wa-footer-note i {
  color: #25D366;
}

/* ─────────────────────────────────────────────────────────────
   8. Animaciones
   ───────────────────────────────────────────────────────────── */
@keyframes cjWaPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes cjWaBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}

@keyframes cjWaBubbleIn {
  0% { opacity: 0; transform: translateY(8px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cjWaFadeInUp {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes cjWaDotBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────
   9. Responsividad Mobile (< 480px)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cj-wa-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .cj-wa-box {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 76px;
    height: calc(100vh - 100px);
    max-height: 580px;
    border-radius: 16px;
  }
  
  .cj-wa-launcher {
    width: 56px;
    height: 56px;
    font-size: 28px;
  }
}
