/* AIBuy 私信界面 7 项。不改动比价库、评论区布局与其它页面。 */

/* 1. 刷新按钮旋转一圈 */
:root:not(#_v3) .direct-messages .dm-refresh svg {
  transform-origin: 50% 50%;
}
:root:not(#_v3) .direct-messages .dm-refresh.is-spinning svg {
  animation: dm-refresh-spin 500ms ease;
}
@keyframes dm-refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 2. 桌面端可拖动分隔 */
:root:not(#_v3) .direct-messages {
  --dm-inbox-width: 340px;
}
@media (min-width: 761px) {
  :root:not(#_v3) .direct-messages:not(.comment-messages) {
    grid-template-columns: minmax(280px, var(--dm-inbox-width, 340px)) 10px minmax(0, 1fr) !important;
  }
  :root:not(#_v3) .direct-messages .dm-inbox {
    border-right: 0;
  }
  :root:not(#_v3) .dm-resizer {
    z-index: 3;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 2;
    cursor: col-resize;
    touch-action: none;
    outline: none;
  }
  :root:not(#_v3) .dm-resizer:before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    width: 1px;
    background: var(--dm-line, #e8e9ed);
    transition: background-color .16s ease;
  }
  :root:not(#_v3) .dm-resizer span {
    z-index: 1;
    width: 3px;
    height: 34px;
    border: 3px solid var(--dm-surface, #fff);
    border-radius: 8px;
    background: #b0c6cb;
    box-sizing: content-box;
    transition: background-color .16s ease;
  }
  :root:not(#_v3) .dm-resizer:hover:before,
  :root:not(#_v3) .dm-resizer:focus-visible:before,
  :root:not(#_v3) .direct-messages.is-resizing .dm-resizer:before {
    width: 2px;
    background: var(--dm-accent, #1d9bf0);
  }
  :root:not(#_v3) .dm-resizer:hover span,
  :root:not(#_v3) .dm-resizer:focus-visible span,
  :root:not(#_v3) .direct-messages.is-resizing .dm-resizer span {
    background: var(--dm-accent, #1d9bf0);
  }
  :root:not(#_v3) .dm-resizer:focus-visible {
    box-shadow: inset 0 0 0 2px var(--dm-accent, #1d9bf0);
  }
  :root:not(#_v3) .direct-messages.is-resizing {
    user-select: none;
  }
}
@media (max-width: 760px) {
  :root:not(#_v3) .dm-resizer {
    display: none !important;
  }
}

/* 3. 搜索框可见边框，风格与输入框一致 */
:root:not(#_v3) .direct-messages .dm-search {
  border: 1px solid color-mix(in srgb, var(--dm-ink, #111827) 16%, transparent) !important;
  background: var(--dm-soft, #f3f4f6);
}
:root:not(#_v3) .direct-messages .dm-search:focus-within {
  border-color: var(--dm-accent, #1d9bf0);
}

/* 4. 去掉输入框焦点方框，改为整圈柔和发光 */
:root:not(#_v3) .direct-messages .dm-composer-row,
:root:not(#_v3) .direct-messages .dm-composer-row:focus,
:root:not(#_v3) .direct-messages .dm-composer-row:focus-visible,
:root:not(#_v3) .direct-messages .dm-composer-row:focus-within,
:root:not(#_v3) .direct-messages .dm-composer textarea,
:root:not(#_v3) .direct-messages .dm-composer textarea:focus,
:root:not(#_v3) .direct-messages .dm-composer textarea:focus-visible,
:root:not(#_v3) .direct-messages .dm-composer :focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
:root:not(#_v3) .direct-messages .dm-composer textarea,
:root:not(#_v3) .direct-messages .dm-composer textarea:focus,
:root:not(#_v3) .direct-messages .dm-composer textarea:focus-visible {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
}
:root:not(#_v3) .direct-messages .dm-composer-row {
  position: relative;
  align-items: flex-end;
  overflow: hidden;
  transition: border-color .16s ease, box-shadow .16s ease;
}
:root:not(#_v3) .direct-messages .dm-composer-row:focus-within {
  border-color: color-mix(in srgb, var(--dm-accent, #1d9bf0) 70%, var(--dm-line, #e8e9ed));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-accent, #1d9bf0) 22%, transparent);
}

/* 5. 去掉 Enter 提示，避免输入区上跳（JS 已移除节点，这里再藏一层） */
:root:not(#_v3) .direct-messages .dm-composer-hint {
  display: none !important;
}

/* 6. 输入框随内容增高，按钮留在底部，达上限后内部滚动 */
:root:not(#_v3) .direct-messages .dm-composer textarea {
  height: 34px;
  min-height: 34px;
  max-height: 168px;
  overflow-y: auto;
  resize: none;
  field-sizing: fixed;
  transition: height 200ms ease;
}

/* 7. 多行后显示发帖同款字数圆环，放在输入区右下角 */
:root:not(#_v3) .direct-messages .dm-composer-row .abc-ring {
  position: absolute;
  right: 44px;
  bottom: 6px;
  z-index: 1;
  pointer-events: none;
  gap: 4px;
}
:root:not(#_v3) .direct-messages .dm-composer-row.is-multiline textarea {
  padding-right: 40px;
  padding-bottom: 4px;
}

@media (prefers-reduced-motion: reduce) {
  :root:not(#_v3) .direct-messages .dm-refresh.is-spinning svg {
    animation: none;
  }
  :root:not(#_v3) .direct-messages .dm-composer textarea,
  :root:not(#_v3) .direct-messages .dm-composer-row,
  :root:not(#_v3) .dm-resizer:before,
  :root:not(#_v3) .dm-resizer span {
    transition: none;
  }
}

html[data-theme="dark"] .dm-resizer span {
  border-color: var(--dm-surface, #000);
  background: #525252;
}
