/* Chatbot del gemelo digital: boton flotante + panel de chat.
   Todo es CSS propio y sin dependencias: la pagina solo carga Bootstrap de
   rebote (viene incrustado en el HTML que genera folium), asi que no conviene
   apoyarse en el. */

.chat-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #38a3a5;
  border-radius: 24px;
  background-color: #ddfff3;
  color: #14746f;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.chat-toggle:hover {
  background-color: #c7f9cc;
}

.chat-toggle-icon {
  font-size: 18px;
  line-height: 1;
}

.chat-panel {
  position: fixed;
  top: 66px;
  right: 18px;
  z-index: 1999;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(70vh, 560px);
  border: 1px solid #38a3a5;
  border-radius: 10px;
  background-color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.chat-panel[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background-color: #ddfff3;
  border-bottom: 1px solid #b9e7dc;
}

.chat-status {
  display: block;
  font-size: 11px;
  color: #4f6d68;
}

.chat-status.is-ready {
  color: #1b7f4c;
}

.chat-status.is-error {
  color: #b3261e;
}

.chat-close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #14746f;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 14px;
}

.chat-msg {
  margin-bottom: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  max-width: 85%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg-user {
  margin-left: auto;
  background-color: #c7f9cc;
}

.chat-msg-bot {
  margin-right: auto;
  background-color: #f1f3f4;
}

.chat-msg-error {
  margin-right: auto;
  background-color: #fdecea;
  color: #b3261e;
}

.chat-msg-pending {
  color: #6b7674;
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #e2e8e6;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #c4d4d0;
  border-radius: 16px;
  font-size: 14px;
}

.chat-input:disabled,
.chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send {
  padding: 7px 14px;
  border: none;
  border-radius: 16px;
  background-color: #38a3a5;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 640px) {
  .chat-toggle-label {
    display: none;
  }

  .chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    height: min(75vh, 520px);
  }
}
