.main-container {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: row;
  overflow: hidden;
}

/* Solo cuando estamos en /chat, forzamos que el layout padre
   sea flex column y limitado al viewport, así el chat toma
   exactamente el espacio restante después del nav superior.
   :has() está soportado en todos los navegadores modernos. */
#page-content-wrapper:has(.main-container) {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
#page-content-wrapper:has(.main-container) > .container-fluid {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.contact-list {
  width: 100%;
  background-color: #f0f0f0;
  border-right: 1px solid #ccc;
  padding: 10px;
  order: -1;
  /* Flex column con scroll interno solo en la lista de items.
     Usamos flex + min-height:0 en vez de height:100vh para que
     respete el espacio del contenedor padre (después del nav). */
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.contact-list .searchContact,
.contact-list h5 {
  flex-shrink: 0;
}
.contact-list h5 {
  margin-bottom: 15px;
}

/* El div con los chats es el único que scrollea */
.contact-list #lastIdMessage {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  /* margen negativo para que el scrollbar no coma padding del contenedor */
  margin-right: -4px;
}

/* Scrollbar más discreto */
.contact-list #lastIdMessage::-webkit-scrollbar {
  width: 6px;
}
.contact-list #lastIdMessage::-webkit-scrollbar-track {
  background: transparent;
}
.contact-list #lastIdMessage::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}
.contact-list #lastIdMessage::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.35);
}

.contact-item {
  padding: 10px;
  border-radius: 5px;
  background-color: #fff;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.contact-item:hover {
  background-color: #e2f0d9;
}
.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: #fff;
}
.chat-header {
  background-color: #075e54;
  color: white;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header .bot-name {
  font-weight: bold;
}
.chat-body {
  flex: 1;
  padding: 15px;
  padding-bottom:80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-image: url('https://crm.oneflowcrm.com/views/assets/files/6812890bcf30915.png');
  background-size: auto;
  background-repeat: repeat;
}
.msg {
  position: relative;
  max-width: 75%;
  padding: 10px;
  border-radius: 10px;
  line-height: 1.4;
}
.msg.user {
  align-self: flex-start;
  background-color: #D9FDD3;
}

.msg.user span {
  position: inherit;
  bottom:0;
  right:0;
}
.msg.bot {
  align-self: flex-end;
  background-color: #fff;
}
.chat-footer {
  display: flex;
  padding: 10px;
  border-top: 1px solid #ddd;
  background-color: #fff;
  bottom:0px;
}
.chat-footer input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 20px;
}

.chat-footer button.attach {
  border: 1px solid #bbb;
  background-color: #eee;
  border-radius: 50%;
  color:#333;
  width: 40px;
  height: 40px;
  margin-left: 10px;
  cursor: pointer;
}

.chat-footer button.send {
  background-color: #075e54;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-left: 10px;
  cursor: pointer;
}
@media (min-width: 992px) {
  /*.chat-container {
    display:flex;
  }*/
  .contact-list {
    max-width:250px;
  }
}
@media (max-width: 768px) {
  .chat-body {
    padding: 10px;
  }
  .msg {
    max-width: 85%;
  }
}

.offcanvas-end{
  width: 85% !important;
}