/* ===========================================
   CHATBOT WIDGET - Estilos
   Widget flotante con IA integrada (Ollama)
   =========================================== */

/* Botón flotante del chat */
.chatbot-toggle {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: all 0.3s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-toggle-icon {
  font-size: 28px;
  transition: transform 0.3s ease;
}

.chatbot-toggle.active .chatbot-toggle-icon {
  transform: rotate(180deg);
}

/* Indicador de estado de conexión */
.chatbot-status-indicator {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  transition: background-color 0.3s ease;
}

.chatbot-status-indicator.online {
  background-color: #4caf50;
}

.chatbot-status-indicator.offline {
  background-color: #f44336;
}

.chatbot-status-indicator.checking {
  background-color: #ff9800;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Contenedor principal del chat */
.chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
  overflow: hidden;
}

.chatbot-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header del chat */
.chatbot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.chatbot-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin: 2px 0 0 0;
}

/* Selector de proveedor de IA */
.chatbot-provider-selector {
  margin-right: 8px;
}

.chatbot-provider-select {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  min-width: 100px;
}

.chatbot-provider-select:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-provider-select:focus {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.5);
}

.chatbot-provider-select option {
  background: #667eea;
  color: #fff;
  padding: 8px;
}

.chatbot-provider-select option:disabled {
  color: rgba(255, 255, 255, 0.5);
}

/* Selector de modelo (OpenRouter) */
.chatbot-model-selector {
  margin-top: 6px;
}

.chatbot-model-select {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  color: #fff;
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  min-width: 100px;
  width: 100%;
}

.chatbot-model-select:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chatbot-model-select:focus {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
}

.chatbot-model-select option {
  background: #5a67d8;
  color: #fff;
  padding: 6px;
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.chatbot-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  transition: background 0.2s;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Área de mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #ccc;
}

/* Mensaje individual */
.chatbot-message {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-message.bot {
  align-self: flex-start;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chatbot-message.user .chatbot-message-avatar {
  background: #667eea;
  color: #fff;
}

.chatbot-message.bot .chatbot-message-avatar {
  background: #e9ecef;
}

.chatbot-message-content {
  background: #fff;
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 14px;
  line-height: 1.5;
}

.chatbot-message.user .chatbot-message-content {
  background: #667eea;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-message.bot .chatbot-message-content {
  border-bottom-left-radius: 4px;
}

/* Contenido del mensaje bot */
.chatbot-message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chatbot-message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
}

.chatbot-message-text table th,
.chatbot-message-text table td {
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  text-align: left;
}

.chatbot-message-text table th {
  background: #f5f5f5;
  font-weight: 600;
}

.chatbot-message-text table tr:hover {
  background: #f9f9f9;
}

/* Código en mensajes */
.chatbot-message-text code {
  background: #f1f3f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
}

.chatbot-message-text pre {
  background: #282c34;
  color: #abb2bf;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
}

.chatbot-message-text pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* Gráfico en mensaje */
.chatbot-chart-container {
  margin-top: 12px;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chatbot-chart-container canvas {
  width: 100% !important;
  min-height: 500px;
  max-height: 600px;
  height: 500px !important;
}

/* Título del gráfico */
.chatbot-chart-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

/* Tabla resumen del gráfico */
.chatbot-chart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 12px;
  background: #fafafa;
  border-radius: 8px;
  overflow: hidden;
}

.chatbot-chart-table th,
.chatbot-chart-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e8e8e8;
}

.chatbot-chart-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chatbot-chart-table tr:last-child td {
  border-bottom: none;
}

.chatbot-chart-table tr:hover td {
  background: #f0f4ff;
}

.chatbot-chart-table td:last-child {
  text-align: right;
  font-weight: 600;
  color: #667eea;
}

.chatbot-chart-table-footer {
  background: #f5f5f5;
  font-weight: 600;
}

.chatbot-chart-table-footer td {
  border-top: 2px solid #667eea;
}

.chatbot-chart-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.chatbot-chart-btn {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.chatbot-chart-btn:hover {
  background: #e8e8e8;
}

/* Indicador de escritura */
.chatbot-typing {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 90%;
}

.chatbot-typing-dots {
  background: #fff;
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 4px;
  align-items: center;
}

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: 0s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Sugerencias rápidas */
.chatbot-suggestions {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
}

.chatbot-suggestions-title {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 8px;
  font-weight: 500;
}

.chatbot-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chatbot-suggestion-btn {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: #495057;
}

.chatbot-suggestion-btn:hover {
  background: #667eea;
  border-color: #667eea;
  color: #fff;
}

/* Input del chat */
.chatbot-input-container {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  flex: 1;
  position: relative;
}

.chatbot-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.chatbot-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input::placeholder {
  color: #adb5bd;
}

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mensaje de bienvenida */
.chatbot-welcome {
  text-align: center;
  padding: 30px 20px;
}

.chatbot-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chatbot-welcome-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.chatbot-welcome-text {
  font-size: 14px;
  color: #6c757d;
  line-height: 1.5;
  margin-bottom: 20px;
}

.chatbot-welcome-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: #f8f9fa;
  padding: 16px;
  border-radius: 12px;
}

.chatbot-welcome-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #495057;
}

.chatbot-welcome-feature-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Mensaje de error */
.chatbot-error {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
}

.chatbot-error-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.chatbot-error-text {
  font-size: 13px;
  color: #c53030;
  line-height: 1.4;
}

/* KPIs rápidos */
.chatbot-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.chatbot-kpi-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.chatbot-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

.chatbot-kpi-label {
  font-size: 11px;
  color: #6c757d;
  margin-top: 4px;
}

.chatbot-kpi-change {
  font-size: 11px;
  margin-top: 4px;
}

.chatbot-kpi-change.positive {
  color: #28a745;
}

.chatbot-kpi-change.negative {
  color: #dc3545;
}

/* Responsive */
@media (max-width: 480px) {
  .chatbot-container {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 80px;
    height: calc(100vh - 100px);
    border-radius: 12px;
  }

  .chatbot-toggle {
    bottom: 15px;
    right: 15px;
    width: 54px;
    height: 54px;
  }

  .chatbot-suggestions-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .chatbot-suggestion-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* ===========================================
   RESPONSE TIME - Tiempo de respuesta
   =========================================== */

.chatbot-response-time {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: linear-gradient(135deg, #f0f4f8 0%, #e8ecf0 100%);
  border-radius: 12px;
  width: fit-content;
  animation: fadeIn 0.3s ease;
}

/* ===========================================
   FEEDBACK BUTTONS - Sistema de Aprendizaje
   =========================================== */

.chatbot-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.chatbot-feedback-label {
  font-size: 12px;
  color: #666;
  margin-right: 4px;
}

.chatbot-feedback-btn {
  padding: 4px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-feedback-btn:hover {
  transform: scale(1.05);
}

.chatbot-feedback-btn.like:hover {
  background: #e8f5e9;
  border-color: #4caf50;
}

.chatbot-feedback-btn.dislike:hover {
  background: #ffebee;
  border-color: #f44336;
}

.chatbot-feedback-btn:active {
  transform: scale(0.95);
}

.chatbot-feedback.feedback-sent {
  justify-content: center;
  border-top: none;
  padding-top: 8px;
}

.chatbot-feedback-thanks {
  font-size: 12px;
  color: #666;
  font-style: italic;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animación de entrada del contenedor */
.chatbot-container.entering {
  animation: chatEnter 0.3s ease forwards;
}

@keyframes chatEnter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal de expansión de gráfico */
.chatbot-chart-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.chatbot-chart-modal.open {
  opacity: 1;
  visibility: visible;
}

.chatbot-chart-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.chatbot-chart-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f5f5f5;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-chart-modal-close:hover {
  background: #e8e8e8;
}

/* Tema oscuro (opcional) */
.chatbot-container.dark-theme {
  background: #1e1e1e;
}

.chatbot-container.dark-theme .chatbot-messages {
  background: #2d2d2d;
}

.chatbot-container.dark-theme .chatbot-message.bot .chatbot-message-content {
  background: #3d3d3d;
  color: #e0e0e0;
}

.chatbot-container.dark-theme .chatbot-input-container {
  background: #1e1e1e;
  border-color: #3d3d3d;
}

.chatbot-container.dark-theme .chatbot-input {
  background: #2d2d2d;
  border-color: #3d3d3d;
  color: #e0e0e0;
}

.chatbot-container.dark-theme .chatbot-suggestions {
  background: #1e1e1e;
  border-color: #3d3d3d;
}

.chatbot-container.dark-theme .chatbot-suggestion-btn {
  background: #3d3d3d;
  border-color: #4d4d4d;
  color: #e0e0e0;
}

/* ===========================================
   CHATBOT FULLPAGE - Modo pantalla completa (LEGACY - deshabilitado)
   Los estilos actuales están en la sección "CHATBOT FULLPAGE CON SESIONES"
   =========================================== */

/* LEGACY: Comentado porque entra en conflicto con los nuevos estilos
.chatbot-fullpage-legacy {
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatbot-fullpage-legacy .card-header {
  flex-shrink: 0;
}
*/

.chatbot-container-full {
  display: flex;
  flex: 1;
  gap: 20px;
  padding: 20px;
  overflow: hidden;
  background: #f8f9fa;
}

/* Panel principal del chat */
.chatbot-main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* Área de mensajes fullpage */
.chatbot-messages-full {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Mensaje de bienvenida fullpage */
.chatbot-welcome-full {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.chatbot-welcome-full .welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.chatbot-welcome-full h3 {
  color: #333;
  margin-bottom: 8px;
}

.chatbot-welcome-full p {
  margin-bottom: 20px;
}

.welcome-topics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.topic-tag {
  background: #e3f2fd;
  color: #1976d2;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* Mensajes del chat fullpage */
.chat-message-full {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.chat-message-full.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message-full.bot {
  align-self: flex-start;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.chat-message-full.user .message-avatar {
  background: #1976d2;
  color: white;
}

.chat-message-full.bot .message-avatar {
  background: #f5f5f5;
}

.message-content {
  background: #f5f5f5;
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 100%;
}

.chat-message-full.user .message-content {
  background: #1976d2;
  color: white;
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.message-content th,
.message-content td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  text-align: left;
}

.message-content th {
  background: #f0f0f0;
  font-weight: 600;
}

/* Área de gráfico en mensaje fullpage */
.message-chart {
  margin-top: 16px;
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.message-chart canvas {
  max-height: 300px;
}

/* Input de mensaje fullpage */
.chatbot-input-full {
  padding: 16px 20px;
  background: #f8f9fa;
  border-top: 1px solid #eee;
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chatbot-input-full textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
}

.chatbot-input-full textarea:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.chatbot-input-full .btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  height: fit-content;
  font-size: 14px;
  min-width: auto;
}

.chatbot-input-full .btn span:first-child {
  display: none;
}

.send-icon {
  font-size: 18px;
}

/* Panel lateral fullpage */
.chatbot-side-panel {
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.side-panel-section {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.side-panel-section h4 {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

/* Selector de proveedor en fullpage */
.provider-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.provider-section h4 {
  color: white;
}

.chatbot-provider-select-full {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.chatbot-provider-select-full:hover {
  background: rgba(255,255,255,0.3);
}

.chatbot-provider-select-full:focus {
  outline: none;
  background: rgba(255,255,255,0.35);
  border-color: rgba(255,255,255,0.5);
}

.chatbot-provider-select-full option {
  background: #667eea;
  color: white;
  padding: 8px;
}

.chatbot-provider-select-full option:disabled {
  color: rgba(255,255,255,0.5);
}

.provider-section .status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
}

.provider-section .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffc107;
}

.provider-section .status-dot.online {
  background: #4caf50;
  box-shadow: 0 0 8px #4caf50;
}

.provider-section .status-dot.offline {
  background: #f44336;
}

.provider-section .status-text {
  font-size: 13px;
  opacity: 0.9;
}

/* Sugerencias fullpage */
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-item-full {
  padding: 10px 12px;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.suggestion-item-full:hover {
  background: #e3f2fd;
  color: #1976d2;
}

.suggestion-loading {
  color: #999;
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

/* =======================================
   VISTA DUAL - Tabla de Detalle + Resumen
   ======================================= */

/* Sección de detalle (contratos individuales) */
.chatbot-detail-section {
  margin: 12px 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.chatbot-detail-header {
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chatbot-summary-header {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: #1565c0;
  border-radius: 8px 8px 0 0;
  margin: 12px 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Botones de exportar */
.chatbot-export-btns {
  display: flex;
  gap: 6px;
}

.chatbot-export-btn {
  padding: 4px 10px;
  font-size: 11px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.chatbot-detail-header .chatbot-export-btn {
  background: #fff;
  color: #555;
  border: 1px solid #ddd;
}

.chatbot-detail-header .chatbot-export-btn:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.chatbot-summary-header .chatbot-export-btn {
  background: rgba(255,255,255,0.7);
  color: #1565c0;
  border: 1px solid rgba(21,101,192,0.3);
}

.chatbot-summary-header .chatbot-export-btn:hover {
  background: #1565c0;
  color: white;
  border-color: #1565c0;
}

/* Wrapper para scroll horizontal en tablas */
.chatbot-detail-table-wrapper {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
}

/* Tabla de detalle */
.chatbot-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.chatbot-detail-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.chatbot-detail-table th {
  background: #f9f9f9;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

.chatbot-detail-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatbot-detail-table tbody tr:hover {
  background: #f8f9fa;
}

.chatbot-detail-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.chatbot-detail-table tbody tr:nth-child(even):hover {
  background: #f0f5ff;
}

/* Mensaje de "más registros" */
.chatbot-detail-more td {
  text-align: center;
  font-style: italic;
  color: #888;
  background: #f5f5f5;
  padding: 10px;
}

/* Tipos de gráficos */
.chart-types-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-type-btn {
  padding: 8px 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.chart-type-btn:hover {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #1976d2;
}

/* Ejemplos de consultas */
.examples-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.example-item {
  padding: 8px 12px;
  background: #fff8e1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #f57c00;
  transition: all 0.2s;
}

.example-item:hover {
  background: #ffe0b2;
}

/* Estado de Ollama fullpage */
.ollama-status {
  margin-top: auto;
}

.status-indicator-full {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffc107;
  animation: pulse 1.5s infinite;
}

.status-dot.online {
  background: #4caf50;
  animation: none;
}

.status-dot.offline {
  background: #f44336;
  animation: none;
}

.status-text-full {
  font-size: 13px;
  color: #666;
}

/* Typing indicator fullpage */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}

/* Tiempo de respuesta fullpage */
.response-time {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: linear-gradient(135deg, #f0f4f8 0%, #e8ecf0 100%);
  border-radius: 12px;
  width: fit-content;
}

/* Feedback buttons fullpage */
.message-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.feedback-label {
  font-size: 12px;
  color: #666;
}

.feedback-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  background: #f8f9fa;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.feedback-btn:hover {
  transform: scale(1.1);
}

.feedback-btn.like:hover {
  background: #e8f5e9;
  border-color: #4caf50;
}

.feedback-btn.dislike:hover {
  background: #ffebee;
  border-color: #f44336;
}

.feedback-thanks {
  font-size: 12px;
  color: #4caf50;
  font-weight: 500;
}

/* Responsive fullpage */
@media (max-width: 1024px) {
  .chatbot-container-full {
    flex-direction: column;
  }

  .chatbot-side-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .side-panel-section {
    flex: 1;
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .chatbot-container-full {
    padding: 10px;
  }

  .chat-message-full {
    max-width: 95%;
  }

  .chatbot-side-panel {
    display: none;
  }
}

/* ===========================================
   CHATBOT FULLPAGE CON SESIONES
   Nueva interfaz de pantalla completa
   =========================================== */

/* Contenedor principal */
.chatbot-fullpage-container {
  padding: 20px;
}

.chatbot-fullpage {
  display: flex;
  flex-wrap: nowrap; /* NUNCA envolver los paneles */
  height: calc(100vh - 180px);
  background: #f5f7fa;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* =======================================
   PANEL DE SESIONES (IZQUIERDA)
   ======================================= */

.chatbot-sessions-panel {
  width: 260px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s, margin 0.3s;
}

.chatbot-sessions-panel.collapsed {
  width: 0;
  margin-left: -1px;
  overflow: hidden;
}

.sessions-header {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
}

.sessions-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.btn-new-session {
  padding: 8px 14px;
  border-radius: 6px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-new-session:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Tabs de sesiones */
.sessions-tabs {
  display: flex;
  border-bottom: 1px solid #e8e8e8;
}

.session-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.session-tab:hover {
  background: #f5f5f5;
  color: #333;
}

.session-tab.active {
  color: #667eea;
  background: #f0f4ff;
}

.session-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #667eea;
}

/* Lista de sesiones */
.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sessions-list::-webkit-scrollbar {
  width: 6px;
}

.sessions-list::-webkit-scrollbar-track {
  background: transparent;
}

.sessions-list::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.sessions-loading {
  text-align: center;
  padding: 20px;
  color: #888;
  font-size: 13px;
}

.session-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
  position: relative;
}

.session-item:hover {
  background: #f5f5f5;
}

.session-item.active {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
  border: 1px solid #c7d2fe;
}

.session-item-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}

.session-item-meta {
  font-size: 11px;
  color: #888;
  display: flex;
  gap: 8px;
}

.session-item-menu,
.session-menu-btn {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #999;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.session-item:hover .session-item-menu,
.session-item:hover .session-menu-btn {
  opacity: 1;
}

.session-item-menu:hover,
.session-menu-btn:hover {
  background: #e8e8e8;
  color: #333;
}

/* Estado vacío de sesiones */
.sessions-empty {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

.sessions-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* =======================================
   PANEL CENTRAL (CHAT)
   ======================================= */

.chatbot-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
  min-height: 0; /* Importante para que flex + overflow funcione */
}

/* Header bar del chat */
.chatbot-header-bar {
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.btn-toggle-sessions {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-toggle-sessions:hover {
  background: rgba(255, 255, 255, 0.3);
}

.session-title {
  font-size: 16px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Selectores de proveedor y modelo */
.provider-selector,
.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-selector label,
.model-selector label {
  font-size: 12px;
  opacity: 0.9;
}

.provider-select,
.model-select {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  min-width: 130px;
  transition: all 0.2s;
}

.provider-select:hover,
.model-select:hover {
  background: rgba(255, 255, 255, 0.3);
}

.provider-select:focus,
.model-select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.5);
}

.provider-select option,
.model-select option {
  background: #667eea;
  color: #fff;
}

/* Badge de estado */
.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  font-size: 12px;
}

.status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffc107;
  animation: pulse 1.5s infinite;
}

.status-badge .status-dot.online {
  background: #4caf50;
  box-shadow: 0 0 6px #4caf50;
  animation: none;
}

.status-badge .status-dot.offline {
  background: #f44336;
  animation: none;
}

.status-badge .status-text {
  opacity: 0.9;
}

/* Área de mensajes */
.chatbot-messages-area {
  flex: 1;
  min-height: 0; /* Importante para que flex + overflow funcione */
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8f9fa;
}

.chatbot-messages-area::-webkit-scrollbar {
  width: 8px;
}

.chatbot-messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages-area::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* Mensaje de bienvenida */
.chatbot-welcome {
  text-align: center;
  padding: 60px 40px;
  max-width: 500px;
  margin: auto;
}

.chatbot-welcome .welcome-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.chatbot-welcome h2 {
  font-size: 24px;
  color: #333;
  margin: 0 0 12px 0;
}

.chatbot-welcome p {
  font-size: 15px;
  color: #666;
  margin: 0 0 24px 0;
  line-height: 1.6;
}

.chatbot-welcome .welcome-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chatbot-welcome .feature {
  padding: 8px 16px;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mensajes individuales */
.chat-message {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-message .message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-message.user .message-avatar {
  background: #667eea;
  color: #fff;
}

.chat-message.assistant .message-avatar {
  background: #f0f0f0;
}

.chat-message .message-body {
  background: #fff;
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  max-width: 100%;
  min-width: 0;
}

.chat-message.user .message-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-body {
  border-bottom-left-radius: 4px;
}

.chat-message .message-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message .response-time {
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-message.user .response-time {
  color: rgba(255,255,255,0.8);
}

/* Sugerencias en panel derecho */
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-loading {
  text-align: center;
  padding: 12px;
  color: #888;
  font-size: 13px;
}

.suggestion-item {
  padding: 10px 12px;
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestion-item:hover {
  background: #f0f4ff;
  border-color: #667eea;
  color: #667eea;
}

/* Sugerencias con clase suggestion-btn (usado en renderSuggestions) */
.suggestions-list .suggestion-btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.suggestions-list .suggestion-btn:hover {
  background: #f0f4ff;
  border-color: #667eea;
  color: #667eea;
}

/* Área de input */
.chatbot-input-area {
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  flex-shrink: 0;
}

.input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =======================================
   PANEL DE AYUDA (DERECHA)
   ======================================= */

.chatbot-help-panel {
  width: 260px;
  background: #fff;
  border-left: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.help-section {
  padding: 16px;
  border-bottom: 1px solid #e8e8e8;
}

.help-section:last-child {
  border-bottom: none;
}

.help-section h4 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

/* Botones de tipos de gráfico */
.chart-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-btn {
  padding: 8px 12px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-btn:hover {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #1976d2;
}

/* Ejemplos de consultas */
.example-queries {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.example-btn {
  padding: 10px 12px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  font-size: 12px;
  color: #f57c00;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.example-btn:hover {
  background: #ffe0b2;
  border-color: #ffb74d;
}

/* =======================================
   MODAL DE GRÁFICOS
   ======================================= */

.chart-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.chart-modal.visible {
  display: flex;
}

.chart-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.chart-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f5f5f5;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chart-modal-close:hover {
  background: #e8e8e8;
}

/* =======================================
   MENÚ CONTEXTUAL DE SESIONES
   ======================================= */

.session-context-menu {
  position: fixed;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 6px 0;
  min-width: 160px;
  z-index: 10000;
  display: none;
}

.session-context-menu.visible {
  display: block;
}

.session-context-menu .context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.2s;
}

.session-context-menu .context-menu-item:hover {
  background: #f5f5f5;
}

.session-context-menu .context-menu-item.danger {
  color: #dc3545;
}

.session-context-menu .context-menu-item.danger:hover {
  background: #fff5f5;
}

/* =======================================
   GRÁFICOS EN MENSAJES
   ======================================= */

.chart-section {
  margin-top: 16px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  color: #333;
}

.chart-actions {
  display: flex;
  gap: 8px;
}

.chart-action-btn {
  padding: 6px 10px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.chart-action-btn:hover {
  background: #e8e8e8;
}

/* IMPORTANTE: Contenedor con altura fija para evitar scroll infinito */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Tabla resumen debajo del gráfico */
.summary-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e8e8e8;
}

.summary-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
}

.summary-table tbody tr:hover {
  background: #f5f8ff;
}

.summary-table tfoot td {
  font-weight: 600;
  background: #f0f4ff;
  border-top: 2px solid #667eea;
}

/* Tablas Markdown en mensajes del chatbot */
.markdown-table {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.markdown-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 500;
  text-transform: capitalize;
}

.markdown-table td {
  background: white;
}

.markdown-table tbody tr:nth-child(even) td {
  background: #f8f9ff;
}

.markdown-table tbody tr:hover td {
  background: #e8ecff;
}

/* =======================================
   ESTILOS ADICIONALES PARA SESIONES
   ======================================= */

.session-info {
  flex: 1;
  min-width: 0;
  padding-right: 28px;
}

.session-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-date {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* =======================================
   RESPONSIVE
   ======================================= */

@media (max-width: 1200px) {
  .chatbot-help-panel {
    display: none;
  }
}

@media (max-width: 900px) {
  .chatbot-sessions-panel {
    width: 220px;
  }

  .header-right {
    flex-wrap: wrap;
    gap: 8px;
  }

  .provider-selector label,
  .model-selector label {
    display: none;
  }
}

@media (max-width: 768px) {
  .chatbot-fullpage-container {
    padding: 10px;
  }

  .chatbot-fullpage {
    flex-direction: column;
    height: calc(100vh - 100px);
  }

  .chatbot-sessions-panel {
    width: 100%;
    height: auto;
    max-height: 180px;
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
  }

  .chatbot-sessions-panel.collapsed {
    width: 100%;
    height: 0;
    max-height: 0;
    margin-left: 0;
  }

  .sessions-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 8px;
    padding: 8px 12px;
  }

  .session-item {
    flex-shrink: 0;
    width: 180px;
    margin-bottom: 0;
  }

  .chat-message {
    max-width: 90%;
  }

  .chatbot-header-bar {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .session-title {
    font-size: 14px;
  }
}
