/* cnathia-public.css - Versión optimizada y minimalista */

/* Sistema de variables CSS optimizado */
:root {
  /* Paleta de colores principal */
  --cnathia-primary: #0073aa;
  --cnathia-primary-dark: #005a87;
  --cnathia-light: #ffffff;
  --cnathia-gray-100: #f8f9fa;
  --cnathia-gray-200: #e9ecef;
  --cnathia-gray-300: #dee2e6;
  --cnathia-gray-400: #ced4da;
  --cnathia-gray-500: #adb5bd;
  --cnathia-gray-600: #6c757d;
  --cnathia-gray-700: #495057;
  --cnathia-error: #dc3545;
  --cnathia-success: #28a745;
  --cnathia-whatsapp: #25D366;
  --cnathia-whatsapp-dark: #128C7E;

  /* Colores específicos */
  --cnathia-bot-bubble: var(--cnathia-gray-200);
  --cnathia-user-bubble: var(--cnathia-primary);
  --cnathia-typing-dots: var(--cnathia-gray-500);
  --cnathia-suggest-bg: var(--cnathia-gray-100);
  --cnathia-suggest-border: var(--cnathia-gray-300);
  
  /* Bordes y sombras */
  --cnathia-border-radius-sm: 10px;
  --cnathia-border-radius: 18px;
  --cnathia-border-radius-lg: 24px;
  --cnathia-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --cnathia-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --cnathia-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.16);
  
  /* Espaciado consistente */
  --cnathia-space-xs: 4px;
  --cnathia-space-sm: 8px;
  --cnathia-space: 12px;
  --cnathia-space-md: 16px;
  --cnathia-space-lg: 24px;
  
  /* Específicos del chat */
  --cnathia-message-padding: 8px 14px;
  --cnathia-message-gap: 6px;
  --cnathia-avatar-gap: 8px;
  
  /* Medidas específicas */
  --cnathia-icon-size: 54px;
  --cnathia-icon-size-mobile: 48px;
  --cnathia-window-width: 360px;
  --cnathia-window-width-mobile: 90%;
  --cnathia-header-height: 60px;
  --cnathia-input-height: 50px;
  
  /* Transiciones */
  --cnathia-transition-fast: 150ms ease;
  --cnathia-transition: 250ms ease;
  --cnathia-transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset box model */
.cnathia-chat-window *, 
.cnathia-chat-window *:before, 
.cnathia-chat-window *:after {
  box-sizing: border-box;
}

/* ===== ICONO FLOTANTE ===== */
.cnathia-chat-icon {
  position: fixed;
  bottom: var(--cnathia-space-md);
  right: var(--cnathia-space-md);
  width: var(--cnathia-icon-size);
  height: var(--cnathia-icon-size);
  background-color: var(--cnathia-primary);
  color: var(--cnathia-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--cnathia-shadow);
  z-index: 9999;
  transition: transform var(--cnathia-transition), box-shadow var(--cnathia-transition);
  -webkit-tap-highlight-color: transparent;
}

.cnathia-chat-icon:hover {
  transform: scale(1.05);
  box-shadow: var(--cnathia-shadow-lg);
}

.cnathia-chat-icon svg {
  width: 45%;
  height: 45%;
  fill: currentColor;
}

/* Indicador de notificación */
.cnathia-chat-icon.cnathia-has-new-message::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background-color: #ff3b30;
  border-radius: 50%;
  border: 2px solid var(--cnathia-light);
  box-shadow: var(--cnathia-shadow-sm);
}

/* ===== OVERLAY Y VENTANA DEL CHAT ===== */
.cnathia-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 9998;
  display: none;
  opacity: 0;
  transition: opacity var(--cnathia-transition);
  pointer-events: none;
}

body.cnathia-chat-open .cnathia-chat-overlay {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.cnathia-chat-window {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--cnathia-window-width);
  max-width: 100%;
  height: 100vh;
  background-color: var(--cnathia-light);
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: none;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform var(--cnathia-transition-slow);
  pointer-events: none;
}

.cnathia-chat-window.show {
  transform: translateX(0);
  pointer-events: auto;
  display: flex;
}

/* ===== CABECERA DEL CHAT ===== */
.cnathia-chat-header {
  background-color: var(--cnathia-primary);
  color: var(--cnathia-light);
  padding: var(--cnathia-space);
  display: flex;
  align-items: center;
  height: var(--cnathia-header-height);
  flex-shrink: 0;
  user-select: none;
}

.cnathia-avatar-header {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: var(--cnathia-space);
  border: 1px solid rgba(255, 255, 255, 0.4);
  object-fit: cover;
  flex-shrink: 0;
}

.cnathia-chat-name {
  font-weight: 600;
  font-size: 1.05rem;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cnathia-close-chat {
  background: none;
  border: none;
  color: var(--cnathia-light);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: var(--cnathia-space-xs);
  opacity: 0.85;
  transition: all var(--cnathia-transition);
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.cnathia-close-chat:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* ===== CUERPO DEL CHAT ===== */
.cnathia-chat-body {
  flex-grow: 1;
  padding: var(--cnathia-space);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background-color: #f5f7fa;
  gap: var(--cnathia-message-gap);
  -webkit-overflow-scrolling: touch;
}

/* Contenedor de mensajes */
.cnathia-chat-body > div {
  display: flex;
  width: 100%;
  align-items: flex-start;
  margin-bottom: var(--cnathia-space-xs);
}

.cnathia-chat-body > div.user-message-container {
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.cnathia-chat-body > div.bot-message-container {
  justify-content: flex-start;
}

/* Avatares */
.cnathia-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  margin-right: var(--cnathia-avatar-gap);
  margin-left: 0;
}

.user-message-container .cnathia-message-avatar {
  margin-right: 0;
  margin-left: var(--cnathia-avatar-gap);
}

/* Burbujas de mensaje */
.cnathia-message {
  padding: var(--cnathia-message-padding);
  border-radius: var(--cnathia-border-radius);
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--cnathia-shadow-sm);
  font-size: 0.95rem;
  max-width: 82%;
  width: fit-content;
  flex-grow: 0;
  flex-shrink: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cnathia-message.user {
  background-color: var(--cnathia-user-bubble);
  color: var(--cnathia-light);
  border-top-right-radius: var(--cnathia-border-radius);
  border-top-left-radius: var(--cnathia-border-radius);
  border-bottom-left-radius: var(--cnathia-border-radius);
  border-bottom-right-radius: var(--cnathia-border-radius-sm);
}

.cnathia-message.bot {
  background-color: var(--cnathia-bot-bubble);
  color: var(--cnathia-gray-700);
  border-top-right-radius: var(--cnathia-border-radius);
  border-top-left-radius: var(--cnathia-border-radius);
  border-bottom-right-radius: var(--cnathia-border-radius);
  border-bottom-left-radius: var(--cnathia-border-radius-sm);
}

/* Metadata de mensajes (hora/estado) */
.cnathia-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.5);
  margin-top: var(--cnathia-space-xs);
  gap: var(--cnathia-space-xs);
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
}

.cnathia-message.user .cnathia-message-meta {
  color: rgba(255, 255, 255, 0.75);
}

.cnathia-message-time {
  white-space: nowrap;
}

.cnathia-message-status {
  white-space: nowrap;
}

.cnathia-message-status.sending {
  color: rgba(255, 255, 255, 0.6);
}

.cnathia-message-status.sent {
  color: rgba(255, 255, 255, 0.75);
}

.cnathia-message-status.read {
  color: var(--cnathia-light);
}

/* Indicador de escritura */
.cnathia-typing-indicator {
  justify-content: flex-start;
}

.cnathia-typing-indicator .cnathia-message-avatar {
  margin-left: 0;
  margin-right: var(--cnathia-avatar-gap);
}

.cnathia-typing-indicator .cnathia-message {
  padding: 8px 12px;
  background-color: var(--cnathia-bot-bubble);
  border-bottom-left-radius: var(--cnathia-border-radius-sm);
  max-width: 70px;
  width: auto;
}

.cnathia-typing-indicator .cnathia-message > div {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cnathia-typing-indicator .cnathia-message > div span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--cnathia-typing-dots);
  border-radius: 50%;
  opacity: 0.7;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.cnathia-typing-indicator .cnathia-message > div span:nth-child(1) {
  animation-delay: -0.32s;
}

.cnathia-typing-indicator .cnathia-message > div span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* ===== SUGERENCIAS Y BOTONES ===== */
.cnathia-suggested-questions {
  padding: var(--cnathia-space);
  border-top: 1px solid var(--cnathia-gray-200);
  background-color: var(--cnathia-light);
  flex-shrink: 0;
  display: none;
  flex-wrap: wrap;
  gap: var(--cnathia-space-sm);
  justify-content: center;
}

.cnathia-suggested-questions .cnathia-suggestion {
  display: inline-block;
  background-color: var(--cnathia-suggest-bg);
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--cnathia-gray-700);
  transition: all var(--cnathia-transition);
  border: 1px solid var(--cnathia-suggest-border);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cnathia-suggested-questions .cnathia-suggestion:hover {
  background-color: var(--cnathia-suggest-border);
  transform: translateY(-1px);
  box-shadow: var(--cnathia-shadow-sm);
}

/* ===== PIE DE PÁGINA Y ENTRADA ===== */
#cnathia-chat-footer {
  padding: var(--cnathia-space);
  border-top: 1px solid var(--cnathia-gray-200);
  background-color: var(--cnathia-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--cnathia-space-sm);
  width: 100%;
}

.cnathia-chat-input {
  flex-grow: 1;
  flex-shrink: 1;
  min-width: 0;
  border: 1px solid var(--cnathia-gray-300);
  border-radius: 20px;
  padding: 10px 14px;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.4;
  outline: none;
  transition: border-color var(--cnathia-transition-fast), box-shadow var(--cnathia-transition-fast);
  font-family: inherit;
}

.cnathia-chat-input:focus {
  border-color: var(--cnathia-primary);
  box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.cnathia-chat-input.disabled {
  cursor: not-allowed;
  background-color: var(--cnathia-gray-100);
}

.cnathia-send-button {
  background-color: var(--cnathia-primary);
  color: var(--cnathia-light);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--cnathia-transition);
  -webkit-tap-highlight-color: transparent;
}

.cnathia-send-button:hover {
  background-color: var(--cnathia-primary-dark);
  transform: scale(1.05);
}

.cnathia-send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cnathia-send-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ===== WHATSAPP BUTTON ===== */
#cnathia-whatsapp-placeholder {
  flex-shrink: 0;
  width: 100%;
  padding: var(--cnathia-space-sm) 0;
  display: none;
  text-align: center;
}

.cnathia-whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--cnathia-whatsapp);
  color: var(--cnathia-light) !important;
  padding: 8px 16px;
  border-radius: 18px;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--cnathia-transition);
  border: none;
  cursor: pointer;
  gap: var(--cnathia-space-sm);
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--cnathia-shadow-sm);
}

.cnathia-whatsapp-button:hover {
  background-color: var(--cnathia-whatsapp-dark);
  transform: translateY(-1px);
  box-shadow: var(--cnathia-shadow);
}

.cnathia-whatsapp-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ===== ENLACES Y ANIMACIONES ===== */
.cnathia-message a {
  color: inherit;
  text-decoration: underline;
  word-break: break-word;
}

.cnathia-message.bot a {
  color: var(--cnathia-primary);
}

.cnathia-message.user a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration-color: rgba(255, 255, 255, 0.5);
}

/* Animación de entrada de mensajes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cnathia-chat-body > div {
  animation: fadeInUp 0.25s ease forwards;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .cnathia-chat-window {
    width: var(--cnathia-window-width-mobile);
  }
  
  .cnathia-chat-icon {
    bottom: var(--cnathia-space);
    right: var(--cnathia-space);
    width: var(--cnathia-icon-size-mobile);
    height: var(--cnathia-icon-size-mobile);
  }
  
  .cnathia-chat-icon svg {
    width: 45%;
    height: 45%;
  }
  
  .cnathia-chat-header,
  .cnathia-chat-body,
  #cnathia-chat-footer,
  .cnathia-suggested-questions {
    padding: var(--cnathia-space);
  }
  
  .cnathia-message {
    max-width: 85%;
  }
}

/* Scrollbar personalizada (opcional) */
.cnathia-chat-body::-webkit-scrollbar {
  width: 5px;
}

.cnathia-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.cnathia-chat-body::-webkit-scrollbar-thumb {
  background: var(--cnathia-gray-400);
  border-radius: 10px;
}

.cnathia-chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--cnathia-gray-500);
}
/* Adaptación para altura completa en dispositivos móviles */
@media screen and (max-width: 768px) {
  .cnathia-chat-window {
    height: 100dvh;
    min-height: 100dvh;
  }
  .cnathia-chat-overlay {
    height: 100dvh;
    min-height: 100dvh;
  }
}
/* En tu archivo CSS */
.cnathia-chat-input-area { /* Asume que tienes un div que contiene input y button */
    display: flex;
    align-items: flex-end; /* Alinea el botón y el input en la parte inferior si el input crece */
    padding: 10px; /* Ajusta el padding según necesites */
    background-color: #f8f8f8; /* Color de fondo del área de input */
    border-top: 1px solid #eee; /* Separador */
}

#cnathia-chat-input {
    flex-grow: 1; /* Hace que el input ocupe todo el espacio disponible */
    margin-right: 10px; /* Espacio entre el input y el botón */
    /* Asegúrate de que tenga box-sizing: border-box; */
}

#cnathia-send-button {
    flex-shrink: 0; /* Evita que el botón se encoja */
    /* Añade estilos para el botón (padding, color, etc.) */
}