@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;900&display=swap');

body {
	background-color: #f5f5f5;
	font-family: Roboto, Arial, Helvetica, sans-serif;
}

#chat-container {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 15px;
  overflow: hidden;
}

.chat-body {
  height: 65vh;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 1.5rem;
}

.user-avatar, .assistant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #007bff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.assistant-avatar {
  background-color: #6c757d;
}

.message-container {
  max-width: 80%;
}

.user-message {
  background-color: #007bff;
  color: white;
  border-radius: 15px 15px 0 15px;
  padding: 10px 15px;
}

.assistant-message {
  background-color: #e9ecef;
  color: #212529;
  border-radius: 15px 15px 15px 0;
  padding: 10px 15px;
}

.typing-indicator {
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

textarea.form-control {
  resize: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

#send-button {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Para el mensaje que se está generando en streaming */
.streaming-message {
  border-left: 3px solid #007bff;
  animation: blink 1s infinite;
}

@keyframes blink {
  0% { border-left-color: #007bff; }
  50% { border-left-color: transparent; }
  100% { border-left-color: #007bff; }
}

/* Ajusta la altura del textarea */
textarea.form-control {
  max-height: 100px;
  min-height: 38px;
}

/* Estilos para los visores de archivos */
.pdf-container {
  min-height: 75vh;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
}

#pdfViewerFrame {
  width: 100%;
  height: 100%;
  border: none;
}

.btn.view-file-btn {
	gap: 1px;
	color: blue;
	padding: 0;
	word-break: break-all;
}

.btn.view-file-btn:hover {
	color: red;
}

#txtContent {
  font-family: 'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Estilos para resaltar archivos en mensajes */
.file-reference {
  background-color: rgba(0, 123, 255, 0.1);
  border-radius: 3px;
  padding: 1px 3px;
}

/* Estilos para la gestión documental */
.document-item {
  cursor: pointer;
  transition: background-color 0.2s;
}

.document-item:hover {
  background-color: rgba(0, 123, 255, 0.05);
}

.document-name {
	cursor: pointer;
	color: #007bff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: .9rem;
}

.document-name:hover {
  text-decoration: underline;
}

#visorPDF pre {
  height: 100%;
  white-space: pre-wrap;
  overflow-y: auto;
  margin: 0;
  padding: 1rem;
  background-color: #f5f5f5;
  font-family: Consolas, monospace;
  font-size: 0.9rem;
}

/* ========================================
   ESTILOS PARA DISPOSITIVOS MÓVILES
   ======================================== */

/* Tablets y pantallas medianas */
@media (max-width: 992px) {
  .chat-body {
    padding: 1rem;
  }
  
  .message-container {
    max-width: 85%;
  }
}

/* Tablets pequeñas */
@media (max-width: 768px) {
  #chat-container {
    border-radius: 10px;
  }
  
  .chat-body {
    height: 70vh;
    padding: 0.8rem;
  }
  
  .user-avatar, .assistant-avatar {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .message-container {
    max-width: 90%;
  }
  
  .user-message, .assistant-message {
    padding: 8px 12px;
    font-size: 0.95rem;
  }
  
  .document-name {
    font-size: 0.85rem;
  }
  
  .pdf-container {
    min-height: 70vh;
  }
}

/* Móviles grandes */
@media (max-width: 576px) {
  body {
    font-size: 14px;
  }
  
  #chat-container {
    border-radius: 8px;
    margin: 0.5rem;
  }
  
  .chat-body {
    height: 75vh;
    padding: 0.5rem;
  }
  
  .user-avatar, .assistant-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }
  
  .message-container {
    max-width: 95%;
  }
  
  .user-message, .assistant-message {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 12px 12px 2px 12px;
  }
  
  .user-message {
    border-radius: 12px 12px 2px 12px;
  }
  
  .assistant-message {
    border-radius: 12px 12px 12px 2px;
  }
  
  textarea.form-control {
    min-height: 44px; /* Mejor para touch */
    font-size: 16px; /* Evita zoom en iOS */
    padding: 10px 12px;
  }
  
  #send-button {
    min-height: 44px;
    padding: 0 15px;
  }
  
  .btn.view-file-btn {
    font-size: 0.8rem;
    padding: 2px 4px;
  }
  
  .document-name {
    font-size: 0.8rem;
  }
  
  .typing-indicator {
    padding: 8px;
    gap: 3px;
  }
  
  .pdf-container {
    min-height: 65vh;
  }
  
  #visorPDF pre {
    padding: 0.5rem;
    font-size: 0.8rem;
  }
  
  /* Mejoras para el touch en móviles */
  .document-item {
    padding: 12px 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Ajustes para el streaming message */
  .streaming-message {
    border-left: 2px solid #007bff;
  }
}

/* Móviles muy pequeños */
@media (max-width: 375px) {
  #chat-container {
    margin: 0.25rem;
    border-radius: 6px;
  }
  
  .chat-body {
    padding: 0.25rem;
    height: 78vh;
  }
  
  .user-avatar, .assistant-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }
  
  .user-message, .assistant-message {
    padding: 5px 8px;
    font-size: 0.85rem;
    border-radius: 10px;
  }
  
  .user-message {
    border-radius: 10px 10px 2px 10px;
  }
  
  .assistant-message {
    border-radius: 10px 10px 10px 2px;
  }
  
  .document-name {
    font-size: 0.75rem;
  }
  
  #visorPDF pre {
    font-size: 0.75rem;
    padding: 0.25rem;
  }
}

/* Landscape mode para móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .chat-body {
    height: 60vh;
  }
  
  .pdf-container {
    min-height: 55vh;
  }
  
  .user-avatar, .assistant-avatar {
    width: 25px;
    height: 25px;
    font-size: 0.7rem;
  }
  
  .user-message, .assistant-message {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
}

/* Mejoras de accesibilidad para touch */
@media (hover: none) and (pointer: coarse) {
  .document-item:hover {
    background-color: transparent;
  }
  
  .document-item:active {
    background-color: rgba(0, 123, 255, 0.1);
  }
  
  .btn.view-file-btn:hover {
    color: blue;
  }
  
  .btn.view-file-btn:active {
    color: red;
  }
}

/* Tablets pequeñas */
@media (max-width: 768px) {
  /* Ocultar opciones de menú en móviles */
  #manage-documents-btn,
  #new-scorm {
    display: none !important;
  }
  
  #chat-container {
    border-radius: 10px;
  }
  
  .chat-body {
    height: 70vh;
    padding: 0.8rem;
  }
  
  .user-avatar, .assistant-avatar {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
  
  .message-container {
    max-width: 90%;
  }
  
  .user-message, .assistant-message {
    padding: 8px 12px;
    font-size: 0.95rem;
  }
  
  .document-name {
    font-size: 0.85rem;
  }
  
  .pdf-container {
    min-height: 70vh;
  }
}