/* =========================================================================
   DM Search (Chats / Messages / People), Overlays & Leave Group Modals
   ========================================================================= */

[hidden] { display: none !important; }

/* =========================================================================
   Sections & Titles
   ========================================================================= */

dm-search-results {
  display: block;
  margin-bottom: 8px;
}

/* Picking group members: only people matter */
direct-message-directory.group-mode dm-search-results,
direct-message-directory.group-mode .dm-people-title {
  display: none;
}

.dm-people-title { display: none; }
direct-message-directory.search .dm-people-title { display: block; }

.dm-search-section + .dm-search-section {
  margin-top: 16px;
}

.dm-search-section-title {
  margin: 0 4px 6px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #656f77);
}

/* Small lock icon before "Messages in your chats" */
.dm-search-section-messages .dm-search-section-title::before {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.8em;
  margin-right: 6px;
  vertical-align: -0.05em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.dm-search-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* =========================================================================
   Search Hit Rows (Chats & Matching Messages)
   ========================================================================= */

.dm-search-hit,
.dm-search-chat {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: background-color 0.12s ease;
}

.dm-search-chat { align-items: center; }

.dm-search-hit:hover,
.dm-search-chat:hover {
  background: var(--surface-hover, #f7f6f2);
}

.dm-search-hit:focus-visible,
.dm-search-chat:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent, #4f46e5);
}

.dm-search-hit dm-chat-avatar,
.dm-search-chat dm-chat-avatar {
  flex: 0 0 auto;
}

.hit-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.hit-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hit-chat {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary, #16181b);
}

.hit-head time {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--text-muted, #656f77);
}

.hit-snippet {
  color: var(--text-muted, #656f77);
  font-size: 0.88rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.hit-sender {
  color: var(--text-primary, #16181b);
  font-weight: 550;
}

.hit-snippet mark {
  background: rgba(79, 70, 229, 0.14);
  color: var(--accent, #4f46e5);
  font-weight: 600;
  border-radius: 4px;
  padding: 0 3px;
}

.hit-note {
  font-size: 0.82rem;
  color: var(--text-muted, #656f77);
}

.dm-search-hit.is-left .hit-chat,
.dm-search-chat.is-left .hit-chat {
  color: var(--text-muted, #656f77);
}

/* =========================================================================
   Status Line & "See All" Link
   ======================================================================== */

.dm-search-status {
  margin: 6px 6px;
  font-size: 0.88rem;
  color: var(--text-muted, #656f77);
}

.dm-search-see-all {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent, #4f46e5);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.dm-search-see-all:hover {
  background: var(--surface-hover, #f7f6f2);
}

.dm-search-see-all:focus-visible {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: -2px;
}

/* =========================================================================
   Skeleton Loader Rows
   ========================================================================= */

.dm-search-skeleton {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 10px 10px 56px;
}

.dm-search-skeleton span {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: var(--border-subtle, #edebe6);
}

.dm-search-skeleton span:first-child { width: 40%; }
.dm-search-skeleton span:last-child  { width: 85%; }

@media (prefers-reduced-motion: no-preference) {
  .dm-search-skeleton span {
    background: linear-gradient(90deg, #edebe6 0%, #f7f6f2 50%, #edebe6 100%);
    background-size: 200% 100%;
    animation: dm-skeleton 1.3s ease-in-out infinite;
  }
}

@keyframes dm-skeleton {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

/* =========================================================================
   "See All" & Archived Slide-over Panels
   ========================================================================= */

dm-message-search-overlay,
dm-archived-chats {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  visibility: hidden;
  transform: translateX(100%);
}

dm-message-search-overlay.active,
dm-archived-chats.active {
  visibility: visible;
  transform: none;
}

@media (prefers-reduced-motion: no-preference) {
  dm-message-search-overlay,
  dm-archived-chats {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.25s;
  }
  dm-message-search-overlay.active,
  dm-archived-chats.active {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }
}

dm-message-search-overlay panel-header,
dm-archived-chats panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-subtle, #edebe6);
}

dm-message-search-overlay panel-label,
dm-archived-chats panel-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

/* Filter Chips */
.dm-search-chips {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  flex: 0 0 auto;
  scrollbar-width: none;
}

.dm-search-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 14rem;
  padding: 5px 12px;
  border: 1px solid var(--border-subtle, #edebe6);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-primary, #16181b);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dm-search-chip span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-search-chip .count {
  color: var(--text-muted, #656f77);
}

.dm-search-chip.selected {
  border-color: var(--accent, #4f46e5);
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent, #4f46e5);
}

.dm-search-chip:focus-visible {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 1px;
}

.dm-overlay-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 20px;
}

/* =========================================================================
   Left Groups & Read-Only Bars
   ========================================================================= */

dm-chat-item.is-left dm-chat-title,
dm-chat-item.is-left .preview-text,
dm-chat-item.is-left .unread-summary {
  color: var(--text-muted, #656f77);
}

dm-chat-item.is-left .preview-text,
dm-chat-item.is-left .unread-summary {
  font-style: italic;
}

dm-readonly-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle, #edebe6);
  background: #f7f6f2;
  color: var(--text-muted, #656f77);
  font-size: 0.9rem;
}

.dm-readonly-delete {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: #ef4444;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dm-readonly-delete:hover {
  background: rgba(239, 68, 68, 0.08);
}

.dm-readonly-delete:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

dm-messages-module.is-read-only dm-reply-preview { display: none; }


/* =========================================================================
   Leave Group Modal Dialog
   ========================================================================= */

dm-leave-group {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 12, 16, 0.4);
  backdrop-filter: blur(4px);
}

dm-leave-group.active { display: flex; }

dm-leave-group .dm-modal-panel {
  width: min(420px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle, #edebe6);
  background: #ffffff;
  color: var(--text-primary, #16181b);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

dm-leave-group .dm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

dm-leave-group .dm-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

dm-leave-group .dm-modal-close {
  border: 0;
  background: transparent;
  color: var(--text-muted, #656f77);
  font-size: 1.1rem;
  cursor: pointer;
}

.dm-leave-text {
  margin: 0 0 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-primary, #16181b);
}

.dm-leave-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dm-leave-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-subtle, #edebe6);
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary, #16181b);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dm-leave-option .label { font-weight: 600; font-size: 0.92rem; }
.dm-leave-option .hint  { font-size: 0.8rem; color: var(--text-muted, #656f77); }

.dm-leave-option:hover { background: var(--surface-hover, #f7f6f2); }
.dm-leave-option.danger .label { color: #ef4444; }

.dm-leave-option:focus-visible,
.dm-leave-cancel:focus-visible {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 1px;
}

.dm-leave-cancel {
  margin-top: 4px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--text-muted, #656f77);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

dm-leave-group.is-busy .dm-leave-option { opacity: 0.6; cursor: progress; }

.dm-leave-error {
  margin: 10px 0 0;
  color: #ef4444;
  font-size: 0.88rem;
}

/* =========================================================================
   Archived Entry Row
   ========================================================================= */

.dm-archived-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border-subtle, #edebe6);
  background: transparent;
  color: var(--text-primary, #16181b);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.dm-archived-entry:hover { background: var(--surface-hover, #f7f6f2); }
.dm-archived-entry:focus-visible { outline: 2px solid var(--accent, #4f46e5); outline-offset: -2px; }

.dm-archived-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background: var(--text-muted, #656f77);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm1 5v7.5h12V8zm-.5-3.5v2h13v-2zM7.5 10h5v1.5h-5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm1 5v7.5h12V8zm-.5-3.5v2h13v-2zM7.5 10h5v1.5h-5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* =========================================================================
   People Results: @handle after the nickname (DmMember, DmAddMember)
   ========================================================================= */

.dm-member-handle {
  margin-left: 2px;
  color: var(--text-muted, #656f77);
  font-size: 0.85em;
  font-weight: 400;
}