/* Indicador visual de que hay más contenido arriba/abajo */
.chatbot-therapy-messages::before {
  content: "";
  position: sticky;
  top: 0;
  height: 8px;
  background: linear-gradient(to bottom, rgba(248, 249, 250, 1) 0%, rgba(248, 249, 250, 0) 100%);
  margin: -24px -24px 8px -24px;
  z-index: 1;
  pointer-events: none;
}

.chatbot-therapy-messages::after {
  content: "";
  position: sticky;
  bottom: 0;
  height: 8px;
  background: linear-gradient(to top, rgba(248, 249, 250, 1) 0%, rgba(248, 249, 250, 0) 100%);
  margin: 8px -24px -24px -24px;
  z-index: 1;
  pointer-events: none;
}

/* Asegurar que el scroll siempre sea visible */
.chatbot-therapy-container {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: visible; /* Cambiado para asegurar que el scroll sea visible */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  border: 1px solid #e1e8ed;
  position: relative; /* Para mejor control del scroll */
}

/* Header del chatbot terapéutico */
.chatbot-therapy-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 24px;
  text-align: center;
}

.chatbot-therapy-header h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
}

.therapy-disclaimer {
  margin: 0;
  opacity: 0.9;
  line-height: 1.4;
}

.therapy-disclaimer small {
  font-size: 13px;
}

/* Área de mensajes */
.chatbot-therapy-messages {
  min-height: 400px;
  overflow-y: auto;
  padding: 24px;
  background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeInUp 0.4s ease;
  max-width: 90%;
}

.user-message {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.user-message .message-avatar {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.user-message .message-avatar:before {
  content: "👤";
}

.message-content {
  background: white;
  padding: 16px 20px;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #e1e8ed;
  word-wrap: break-word;
  line-height: 1.5;
}

.user-message .message-content {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  border: none;
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin: 0;
}

.message-content strong {
  font-weight: 600;
}

.message-time {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  padding-left: 52px;
}

.user-message .message-time {
  padding-left: 0;
  padding-right: 52px;
  text-align: right;
}

/* Área de input */
.chatbot-therapy-input-area {
  padding: 10px;
  background: white;
  border-top: 1px solid #e1e8ed;
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

#chatbot-therapy-input {
  flex: 1;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  transition: all 0.2s ease;
  line-height: 1.4;
  min-height: 20px;
  max-height: 120px;
}

#chatbot-therapy-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-therapy-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-height: 44px;
}

.chatbot-therapy-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chatbot-therapy-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Indicador de escritura */
.typing-indicator .message-content {
  background: #f1f3f4 !important;
  color: #5f6368 !important;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-indicator .typing-dots {
  display: flex;
  gap: 4px;
}

.typing-indicator .typing-dots span {
  width: 6px;
  height: 6px;
  background: #5f6368;
  border-radius: 50%;
  animation: bounce 1.4s infinite both;
}

.typing-indicator .typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator .typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Animaciones */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Scrollbar personalizada */
.chatbot-therapy-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-therapy-messages::-webkit-scrollbar-track {
  background: #f1f3f4;
  border-radius: 3px;
}

.chatbot-therapy-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.chatbot-therapy-messages::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* Estilos para crisis y mensajes importantes */
.crisis-message {
  background: linear-gradient(135deg, #fc8181 0%, #f56565 100%) !important;
  color: white !important;
  border: 2px solid #e53e3e !important;
  font-weight: 500;
}

.crisis-message strong {
  font-weight: 700;
}

.resource-list {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

.resource-list ul {
  margin: 0;
  padding-left: 16px;
}

.resource-list li {
  margin: 4px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chatbot-therapy-container {
    margin: 10px;
    border-radius: 12px;
  }
  
  .chatbot-therapy-header {
    padding: 16px 20px;
  }
  
  .chatbot-therapy-header h3 {
    font-size: 18px;
  }
  
  .chatbot-therapy-messages {
    height: 350px;
    padding: 16px;
  }
  
  .message {
    max-width: 95%;
  }
  
  .message-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  .message-content {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .chatbot-therapy-input-area {
    padding: 16px;
    gap: 12px;
  }
  
  #chatbot-therapy-input {
    font-size: 16px; /* Previene zoom en iOS */
  }
  
  .chatbot-therapy-send-btn {
    padding: 10px 16px;
    min-height: 40px;
  }
  
  .message-time {
	 
    padding-left: 48px;
  }
  
  .user-message .message-time {
    padding-right: 48px;
  }
}

@media (max-width: 480px) {
	#chatbot-therapy-send > span{
		display:none;
	}
  .chatbot-therapy-messages {
    height: 300px;
    padding: 12px;
  }
  #chatbot-therapy-input{
	  width:100%!important;
  }
  
  .chatbot-therapy-input-area {
    padding: 6px;
  }
  
  .message-avatar {
	  display:none;
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .message-content {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .message-time {
	  display:none;
    padding-left: 44px;
    font-size: 10px;
  }
  
  .user-message .message-time {
    padding-right: 44px;
  }
}

/* Estados especiales */
.chatbot-therapy-container.loading {
  pointer-events: none;
  opacity: 0.7;
}

.error-message {
  background: #fee2e2 !important;
  border: 1px solid #fca5a5 !important;
  color: #dc2626 !important;
}

.success-message {
  background: #d1fae5 !important;
  border: 1px solid #6ee7b7 !important;
  color: #059669 !important;
}

/* Accesibilidad */
.chatbot-therapy-send-btn:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

#chatbot-therapy-input:focus {
  outline: none;
}

/* Animación de carga personalizada */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-radius: 50%;
  border-top: 2px solid #667eea;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.message-time , .message-avatar{
	display:none;
}