/* —— Inbox flotante WhatsApp (OpenWA) —— abajo derecha (junto a Multi RL / asistente) —— */
.openwa-inbox,
.openwa-inbox.openwa-inbox--br,
.openwa-inbox.openwa-inbox--bl {
  position: fixed;
  z-index: 109;
  font-family: inherit;
  /* A la izquierda del FAB del asistente Kairo (right: 1.25rem) */
  right: 6.25rem !important;
  bottom: 1.25rem !important;
  left: auto !important;
  top: auto !important;
  width: max-content;
  max-width: calc(100vw - 1.5rem);
}

.openwa-inbox.is-docked-hidden .openwa-inbox__fab-wrap {
  display: none;
}

.openwa-inbox.is-docked-hidden .openwa-inbox__panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  left: auto;
  top: auto;
  transform-origin: bottom right;
  z-index: 120;
}

.openwa-inbox.is-docked-hidden.is-open .openwa-inbox__panel {
  transform: translateY(0) scale(1);
}

.openwa-inbox__fab-wrap {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-direction: row;
  cursor: pointer;
}

.openwa-inbox__label {
  padding: 0.35rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(135deg, #128c7e, #25d366);
  box-shadow: 0 6px 16px rgba(18, 140, 126, 0.35);
  pointer-events: auto;
  opacity: 0.95;
}

.openwa-inbox.is-open .openwa-inbox__label,
.openwa-inbox[data-open="1"] .openwa-inbox__label {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.openwa-inbox__fab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.75rem;
  height: 3.75rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  color: #fff;
  font-size: 1.85rem;
  background: linear-gradient(145deg, #25d366, #128c7e);
  box-shadow:
    0 10px 28px rgba(18, 140, 126, 0.45),
    0 0 0 3px rgba(37, 211, 102, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.openwa-inbox__fab:hover {
  transform: translateY(-2px) scale(1.05);
}

.openwa-inbox.is-open .openwa-inbox__fab {
  transform: scale(0.94);
}

.openwa-inbox__badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  border: 2px solid #fff;
  pointer-events: none;
}

html.dark .openwa-inbox__badge {
  border-color: #0f1824;
}

.openwa-inbox__panel {
  position: absolute;
  right: 0;
  left: auto;
  bottom: calc(3.75rem + 2.4rem);
  width: min(26rem, calc(100vw - 2rem));
  height: min(34rem, calc(100vh - 7rem));
  z-index: 1;
  display: none !important;
  flex-direction: column;
  border-radius: 1.1rem;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.openwa-inbox.is-open .openwa-inbox__panel,
.openwa-inbox[data-open="1"] .openwa-inbox__panel {
  display: flex !important;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.openwa-inbox__panel[hidden] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.dark .openwa-inbox__panel {
  background: #111827;
  border-color: rgba(255, 255, 255, 0.08);
}

.openwa-inbox__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem;
  background: linear-gradient(135deg, #075e54, #128c7e);
  color: #fff;
  flex-shrink: 0;
}

.openwa-inbox__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  font-size: 1.35rem;
  flex-shrink: 0;
}

.openwa-inbox__head-text {
  min-width: 0;
  flex: 1;
}

.openwa-inbox__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.openwa-inbox__status {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  opacity: 0.9;
}

.openwa-inbox__icon-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.openwa-inbox__icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.openwa-inbox__body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  background: #ece5dd;
}

html.dark .openwa-inbox__body {
  background: #0b141a;
}

.openwa-inbox__chats {
  flex: 1;
  overflow-y: auto;
  background: #fff;
  min-width: 0;
}

html.dark .openwa-inbox__chats {
  background: #111b21;
}

.openwa-inbox__chat {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem;
  border: 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.openwa-inbox__chat:hover,
.openwa-inbox__chat.is-active {
  background: rgba(37, 211, 102, 0.08);
}

html.dark .openwa-inbox__chat {
  border-bottom-color: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
}

.openwa-inbox__chat-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.openwa-inbox__chat-name {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.dark .openwa-inbox__chat-name {
  color: #f3f4f6;
}

.openwa-inbox__chat-time {
  font-size: 0.68rem;
  color: #64748b;
  flex-shrink: 0;
}

.openwa-inbox__chat-preview {
  margin: 0;
  font-size: 0.75rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.openwa-inbox__chat-unread {
  margin-top: 0.2rem;
  display: inline-flex;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: #25d366;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.openwa-inbox__empty,
.openwa-inbox__error {
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
}

.openwa-inbox__error a {
  color: #128c7e;
  font-weight: 600;
  text-decoration: underline;
}

.openwa-inbox__thread {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #ece5dd;
  z-index: 2;
}

/* Tailwind/[hidden] sin !important: el display:flex del hilo tapaba siempre la lista */
.openwa-inbox__thread[hidden],
.openwa-inbox__chats[hidden] {
  display: none !important;
}

html.dark .openwa-inbox__thread {
  background: #0b141a;
}

.openwa-inbox__thread-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #f0f2f5;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

html.dark .openwa-inbox__thread-head {
  background: #1f2c34;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.openwa-inbox__back {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html.dark .openwa-inbox__back {
  color: #e5e7eb;
}

.openwa-inbox__thread-meta {
  min-width: 0;
}

.openwa-inbox__thread-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.dark .openwa-inbox__thread-name {
  color: #f3f4f6;
}

.openwa-inbox__thread-id {
  margin: 0;
  font-size: 0.68rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.openwa-inbox__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.openwa-inbox__msg {
  display: flex;
  max-width: 88%;
}

.openwa-inbox__msg--in {
  align-self: flex-start;
}

.openwa-inbox__msg--out {
  align-self: flex-end;
}

.openwa-inbox__bubble {
  margin: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 0.55rem;
  font-size: 0.84rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
}

.openwa-inbox__msg--in .openwa-inbox__bubble {
  background: #fff;
  color: #0f172a;
  border-top-left-radius: 0.15rem;
}

.openwa-inbox__msg--out .openwa-inbox__bubble {
  background: #d9fdd3;
  color: #0f172a;
  border-top-right-radius: 0.15rem;
}

html.dark .openwa-inbox__msg--in .openwa-inbox__bubble {
  background: #202c33;
  color: #e5e7eb;
}

html.dark .openwa-inbox__msg--out .openwa-inbox__bubble {
  background: #005c4b;
  color: #e5e7eb;
}

.openwa-inbox__msg-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.62rem;
  opacity: 0.65;
  text-align: right;
}

.openwa-inbox__form {
  display: flex;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  background: #f0f2f5;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

html.dark .openwa-inbox__form {
  background: #1f2c34;
  border-top-color: rgba(255, 255, 255, 0.06);
}

.openwa-inbox__input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 9999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  background: #fff;
  color: #0f172a;
  outline: none;
}

html.dark .openwa-inbox__input {
  background: #2a3942;
  color: #e5e7eb;
}

.openwa-inbox__send {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 9999px;
  background: #25d366;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.openwa-inbox__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .openwa-inbox,
  .openwa-inbox.openwa-inbox--br,
  .openwa-inbox.openwa-inbox--bl {
    right: 5.5rem !important;
    bottom: 0.85rem !important;
    left: auto !important;
  }

  .openwa-inbox__panel {
    width: min(22rem, calc(100vw - 1.5rem));
    height: min(70vh, calc(100vh - 6rem));
  }

  .openwa-inbox__label {
    display: none;
  }
}
