/* ACCESO EN LA BARRA SUPERIOR
   Antes era un botón flotante fijo en la esquina inferior derecha, que tapaba contenido.
   Ahora es una pastilla en la barra, al lado del acceso a Tickets y con su mismo alto. */

/* La barra suma un botón: se declara su columna para que no se desacomode el resto */
#elements .taskbar {
  grid-template-columns: min-content min-content auto min-content min-content min-content min-content min-content;
}

#elements .taskbar button.acceso-excobot,
#elements .taskbar button.acceso-excobot:focus,
#elements .taskbar button.acceso-excobot:active {
  position: relative;
  width: auto !important;
  height: 30px;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
  background: #e8edf9 !important;
  background-color: #e8edf9 !important;
  border: 1px solid #c9d5f0 !important;
  outline: none !important;
  box-shadow: none !important;
  transition: background-color 0.15s !important;
}

#elements .taskbar button.acceso-excobot:hover {
  background: #d6e0f6 !important;
  background-color: #d6e0f6 !important;
  border: 1px solid #b3c4ea !important;
  outline: none !important;
  box-shadow: none !important;
}

#elements .taskbar button.acceso-excobot img {
  width: 18px !important;
  height: 18px;
  flex-shrink: 0;
}

#elements .taskbar button.acceso-excobot i {
  color: #3a58a1;
  font-size: 14px;
}

#elements .taskbar button.acceso-excobot span {
  font-family: 'Segoe UI', Roboto, Arial, sans-serif !important;
  color: #3a58a1 !important;
  font-weight: 800 !important;
  font-size: 13px;
  line-height: 1;
  background: transparent !important;
  background-color: transparent !important;
  padding: 0 !important;
}

/* En pantallas angostas se deja sólo el logo, igual que el acceso a Tickets */
@media (max-width: 400px) {
  #elements .taskbar button.acceso-excobot span {
    display: none !important;
  }
  #elements .taskbar button.acceso-excobot {
    width: 30px !important;
    padding: 0 !important;
    justify-content: center;
  }
}

.chat-window {
  position: fixed;
  top: 58px;
  right: 16px;
  width: 320px !important;
  height: 420px !important;
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0);
  transform-origin: top right;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.chat-window.open {
  transform: scale(1);
}

.chat-window .header {
  background: white;
  color: #fff;
  padding: 12px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
}

.chat-window .close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;

  i {
    font-size: 20px;
    cursor: pointer;
    color: #e7342a;
  }
}

.chat-window .close-btn:active,
.chat-window .close-btn:focus,
.chat-window .close-btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.chat-window .messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f7f7f7;
}

.chat-window .messages .message {
  position: relative;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.4;
  word-wrap: break-word;
}

/* El widget es angosto (320px): las respuestas del bot (tablas, listas, gráficos)
   necesitan casi todo el ancho para no quedar ilegibles. */
.chat-window .messages .message.bot {
  max-width: 92%;
}

/* Burbuja BOT en blanco: el gris anterior con texto blanco no llegaba al contraste mínimo
   y dejaba ilegible el contenido claro (listas, etiquetas de grupo). */
.chat-window .messages .message.bot {
  align-self: flex-start;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e3e8ef;
  border-bottom-left-radius: 4px;
  font-size: 1.1rem;
}

/* Flecha de la burbuja BOT */
.chat-window .messages .message.bot::before {
  content: '';
  position: absolute;
  top: 10px;
  left: -6px;
  border: 6px solid transparent;
  border-right-color: #ffffff;
}

/* Estilo de mensaje de USUARIO */
.chat-window .messages .message.user {
  align-self: flex-end;
  background: #3a58a1;
  color: #fff;
  border-bottom-right-radius: 4px;
  font-size: 1.1rem;
}

/* Flecha de la burbuja USUARIO */
.chat-window .messages .message.user::before {
  content: '';
  position: absolute;
  top: 10px;
  right: -6px;
  border: 6px solid transparent;
  border-left-color: #3a58a1;
}

/* Timestamp pequeño en cada burbuja */
.chat-window .messages .message .timestamp {
  display: block;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
  text-align: right;
}

/* La burbuja del bot es clara: la hora necesita color propio para verse. */
.chat-window .messages .message.bot .timestamp {
  color: #a3adbd;
}

.chat-window .input-group {
  display: flex;
  padding: 8px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
  margin: 1px;
  height: 31px;
}

.chat-window .input-group .form-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #3a58a1;
  font-size: 1.1rem;
  outline: none;
  border-radius: 0px;
  border-left: none;
  border-right: none;
}

.chat-window .input-group .form-input:active,
.chat-window .input-group .form-input:focus,
.chat-window .input-group .form-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  border-color: #3a58a1;
}

.chat-window .input-group .form-btn-new-session {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid #3a58a1;
  border-left: none;
  border-top-right-radius: 0px;
  border-bottom-right-radius: 0px;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  background-color: #3a58a1;

  i {
    cursor: pointer;
  }
}

.chat-window .input-group .form-btn-send-message {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #3a58a1;
  padding: 0 16px;
  border-left: none;
  border-top-left-radius: 0px;
  border-bottom-left-radius: 0px;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  background-color: #3a58a1;

  i {
    cursor: pointer;
  }
}

.char-count {
  align-self: center;
  margin-left: 8px;
  font-size: 0.75rem;
  color: #666;
}

/* Tarjetas de reportes sugeridos (lista de "¿qué sabes hacer?"): toda la fila es clickeable. */
.report-btn {
  transition:
    border-color 0.15s,
    background-color 0.15s,
    box-shadow 0.15s;
}
.report-btn:hover {
  border-color: #3a58a1 !important;
  background: #f5f8ff !important;
  box-shadow: 0 2px 6px rgba(58, 88, 161, 0.12);
}
.report-btn:hover i.fa-arrow-right {
  color: #3a58a1 !important;
}
.report-btn:active {
  background: #eef2fb !important;
}

/* 1 ▸ El mensaje que contenga HTML no debe romper palabras a lo loco */
.message-html {
  overflow-x: auto; /* scroll si es realmente estrecho */
  word-wrap: normal; /* desactiva el corte indiscriminado */
  border-radius: 3px;
}

/* 2 ▸ Tabla dentro de mensajes */
.message-html table.chat-table {
  width: 100%; /* se adapta al “bubble” */
  min-width: 280px; /* evita el efecto acordeón en móviles */
  border-collapse: collapse;
  background: #fff;
  font-size: 1rem;

  td {
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* 3 ▸ Celdas legibles */
.message-html th,
.message-html td {
  white-space: nowrap; /* ¡no más letras en vertical! */
  border: 1px solid #e0e0e0;
  padding: 3px 5px;
  text-align: left;
  color: black;
}

.message-html code {
  background: #f5f5f5;
  border-radius: 4px;
  padding: 2px 4px;
}

.div-html .btn-export {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  font-size: 0.7rem;
  background: #198754;
  color: #fff;
  border: none;
  border-radius: 4px;
  transition: opacity 0.15s;
  cursor: pointer !important;
}
.div-html {
  position: relative;
}
.div-html .btn-export:hover {
  opacity: 0.8;
}

.message-chart-wrapper {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 12px;
}

.message-chart-wrapper .btn-export {
  position: absolute;
  top: 3px;
  right: 8px;
  background: #198754;
  color: #fff;
  border: none;
  padding: 2px 8px;
  font-size: 0.7rem;
  border-radius: 4px;
  cursor: pointer !important;
}

.message-chart-wrapper .btn-download {
  position: absolute;
  top: 3px;
  right: 52px;
  padding: 2px 8px;
  font-size: 0.7rem;
  background: #3a58a1;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer !important;
  transition: opacity 0.15s;
}
.btn-download:hover {
  opacity: 0.8;
}

.message-chart-wrapper canvas {
  width: 100% !important;
  height: 240px !important;
}
