/* Shared question chat UI (question page + list drawers) */

.wm-qchat {
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #ffffff;
  border-radius: 0.75rem;
  overflow: hidden;
}

.wm-qchat:not(.hidden) {
  display: flex;
}

#questionChatWrap.hidden,
tr[data-qchat-drawer].hidden,
.wm-qchat-drawer-row.hidden {
  display: none !important;
}

html.dark .wm-qchat,
html.theme-dark .wm-qchat {
  background: rgb(31 41 55);
}

.wm-qchat--page:not(.hidden) {
  min-height: 320px;
  height: min(420px, 72vh);
  max-height: min(72vh, 640px);
  border: 1px solid rgb(229 231 235);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html.dark .wm-qchat--page,
html.theme-dark .wm-qchat--page {
  border-color: rgb(55 65 81);
}

.wm-qchat--drawer {
  border-radius: 0;
  background: transparent;
}

.wm-qchat-messages {
  flex: 1 1 auto;
  min-height: 8rem;
  overflow-y: auto;
  padding: 0.75rem 0.625rem;
  background: #f8fafc;
}

html.dark .wm-qchat-messages,
html.theme-dark .wm-qchat-messages {
  background: rgb(17 24 39 / 0.35);
}

.wm-qchat--drawer .wm-qchat-messages {
  min-height: 5.5rem;
  max-height: min(48vh, 330px);
  padding: 0.625rem 0.5rem;
}

.wm-qchat-drawer-row > .wm-qchat-drawer-cell {
  padding: 0 !important;
  border-top: 1px solid rgb(229 231 235);
}

html.dark .wm-qchat-drawer-row > .wm-qchat-drawer-cell,
html.theme-dark .wm-qchat-drawer-row > .wm-qchat-drawer-cell {
  border-top-color: rgb(55 65 81);
}

.wm-qchat-table-host {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.wm-qchat-msg {
  margin-bottom: 0.75rem;
}

.wm-qchat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 100%;
}

.wm-qchat-msg--mine .wm-qchat-msg-row {
  flex-direction: row-reverse;
  margin-left: auto;
  max-width: min(92%, 34rem);
}

.wm-qchat-msg--peer .wm-qchat-msg-row {
  margin-right: auto;
  max-width: min(92%, 34rem);
}

.wm-qchat-avatar {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid rgb(229 231 235);
  background: rgb(243 244 246);
}

html.dark .wm-qchat-avatar,
html.theme-dark .wm-qchat-avatar {
  border-color: rgb(55 65 81);
  background: rgb(31 41 55);
}

.wm-qchat-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wm-qchat-bubble {
  min-width: 3rem;
  max-width: 100%;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.625rem 0.75rem 0.5rem;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
}

.wm-qchat-msg--mine .wm-qchat-bubble {
  background: #eff6ff;
  border-color: #bfdbfe;
}

html.dark .wm-qchat-msg--mine .wm-qchat-bubble,
html.theme-dark .wm-qchat-msg--mine .wm-qchat-bubble {
  background: rgb(30 58 138 / 0.35);
  border-color: rgb(59 130 246 / 0.45);
}

.wm-qchat-msg--peer .wm-qchat-bubble {
  background: #ffffff;
  border-color: #e5e7eb;
}

html.dark .wm-qchat-msg--peer .wm-qchat-bubble,
html.theme-dark .wm-qchat-msg--peer .wm-qchat-bubble {
  background: rgb(55 65 81);
  border-color: rgb(75 85 99);
}

.wm-qchat-bubble-text {
  font-size: 0.875rem;
  line-height: 1.45;
  color: rgb(31 41 55);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

html.dark .wm-qchat-bubble-text,
html.theme-dark .wm-qchat-bubble-text {
  color: rgb(243 244 246);
}

.wm-qchat-bubble-time {
  margin-top: 0.375rem;
  font-size: 0.6875rem;
  line-height: 1.2;
  color: rgb(107 114 128);
}

.wm-qchat-msg-meta {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: rgb(107 114 128);
}

.wm-qchat-msg--mine .wm-qchat-msg-meta {
  text-align: right;
}

.wm-qchat-typing {
  flex-shrink: 0;
  padding: 0 0.75rem 0.35rem;
  font-size: 0.75rem;
  color: rgb(107 114 128);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.wm-qchat-typing.hidden {
  display: none !important;
}

.wm-qchat-typing-dots {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}

.wm-qchat-typing-dots span {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 9999px;
  background: rgb(59 130 246);
  animation: wmQchatTypingDot 1.2s ease-in-out infinite;
}

.wm-qchat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.wm-qchat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wmQchatTypingDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.wm-qchat-compose {
  flex-shrink: 0;
  border-top: 1px solid rgb(229 231 235);
  background: #ffffff;
  padding: 0.625rem 0.5rem 0.75rem;
}

html.dark .wm-qchat-compose,
html.theme-dark .wm-qchat-compose {
  border-top-color: rgb(55 65 81);
  background: rgb(31 41 55);
}

.wm-qchat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.wm-qchat-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 2.75rem;
  max-height: 11rem;
  resize: none;
  overflow-y: hidden;
  border: 1px solid rgb(209 213 219);
  border-radius: 0.75rem;
  background: #ffffff;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: rgb(17 24 39);
  box-sizing: border-box;
}

html.dark .wm-qchat-input,
html.theme-dark .wm-qchat-input {
  border-color: rgb(75 85 99);
  background: rgb(55 65 81);
  color: rgb(243 244 246);
}

.wm-qchat-input:focus {
  outline: none;
  border-color: rgb(59 130 246);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.wm-qchat-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 9999px;
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.wm-qchat-send.is-ready {
  background: #156fe3;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(21, 111, 227, 0.35);
}

.wm-qchat-send.is-ready:hover {
  background: #125fc2;
}

.wm-qchat-send.is-ready:active {
  transform: scale(0.96);
}

.wm-qchat-send:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 1;
}

html.dark .wm-qchat-send,
html.theme-dark .wm-qchat-send {
  background: #475569;
  color: #94a3b8;
}

html.dark .wm-qchat-send.is-ready,
html.theme-dark .wm-qchat-send.is-ready {
  background: #156fe3;
  color: #ffffff;
}

.wm-qchat-send svg {
  width: 1.125rem;
  height: 1.125rem;
}

.wm-qchat-error {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgb(220 38 38);
}

.wm-qchat-notice {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem 0.65rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  text-align: center;
  color: rgb(75 85 99);
  border-top: 1px solid rgb(243 244 246);
}

.wm-qchat--drawer .wm-qchat-notice {
  display: block;
}

html.dark .wm-qchat-notice,
html.theme-dark .wm-qchat-notice {
  color: rgb(209 213 219);
  border-top-color: rgb(55 65 81);
}

/* Drawer shell on question lists */
.wm-qchat-drawer-shell {
  margin-top: 0;
  width: 100%;
  max-width: 100%;
  border-radius: 0;
  border: none;
  border-top: 1px solid #bfdbfe;
  background: rgba(240, 249, 255, 0.65);
  overflow: hidden;
  box-sizing: border-box;
}

tr.wm-qchat-drawer-row .wm-qchat-drawer-shell {
  border-radius: 0;
  margin-top: 0;
}

html.dark .wm-qchat-drawer-shell,
html.theme-dark .wm-qchat-drawer-shell {
  border-color: rgb(30 58 138);
  background: rgba(30, 58, 138, 0.2);
}

[data-question-chat-mount] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  box-sizing: border-box;
}

[data-question-chat-card] > [data-question-chat-mount]:not(.hidden) {
  width: calc(100% + 0.75rem);
  max-width: calc(100% + 0.75rem);
  margin-left: -0.375rem;
  margin-right: -0.375rem;
}

.wm-qchat-drawer-shell-host {
  width: 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  [data-question-chat-mount] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  [data-question-chat-card] > [data-question-chat-mount]:not(.hidden) {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .wm-qchat-messages {
    padding: 0.875rem 0.75rem;
  }

  .wm-qchat-compose {
    padding: 0.75rem;
  }
}
