/* Message search (client/js/search.js) and notification settings and mutes
   (client/js/notificationSettings.js). Uses the theme tokens from styles.css. */

/* The search box sits at the right end of the channel header; the header leaves room for it. */
.channel-search { position: absolute; top: 8px; right: 16px; z-index: 6; width: 168px; height: 32px; transition: width 0.15s; }
.channel-search[hidden] { display: none; }
.channel-search:focus-within, .channel-search.has-text { width: 240px; }
.chat:has(> .channel-search:not([hidden])) > .chat-header { padding-right: 200px; }
.search-input { width: 100%; height: 100%; padding: 0 30px 0 10px; border: 0; border-radius: 4px; background: var(--bg-rail); color: var(--text); font: inherit; font-size: 14px; outline: none; }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { box-shadow: 0 0 0 1px var(--accent); }
.search-glass, .search-clear { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: grid; place-items: center; width: 20px; height: 20px; color: var(--text-muted); }
.search-glass { pointer-events: none; }
.search-clear { display: none; padding: 0; border: 0; border-radius: 50%; background: none; }
.search-clear:hover { color: var(--text-strong); }
.channel-search.has-text .search-glass { display: none; }
.channel-search.has-text .search-clear { display: grid; }

/* Autocomplete under the box. */
.search-suggestions { position: absolute; top: 38px; right: 0; width: 320px; max-height: min(420px, 70vh); max-height: min(420px, 70dvh); overflow-y: auto; padding: 8px; background: var(--bg-rail); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.search-suggestions[hidden] { display: none; }
.search-suggestions-title { padding: 4px 8px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.search-suggestion { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 8px; border-radius: 4px; cursor: pointer; color: var(--text); }
.search-suggestion:hover, .search-suggestion.active { background: var(--bg-hover); }
.search-suggestion-main { font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-suggestion-hint { margin-left: auto; color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-suggestion .avatar { width: 24px; height: 24px; font-size: 11px; }
.search-suggestion > .icon { color: var(--text-muted); flex: none; }

/* The results panel replaces the member list while a search is open. */
.app.search-open { grid-template-columns: 72px 240px minmax(0, 1fr) 420px; }
.app.search-open .member-list { display: none; }
.search-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-sidebar); border-left: 1px solid var(--border); }
.search-panel[hidden] { display: none; }
.search-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 48px; padding: 0 8px 0 16px; background: var(--bg-rail); flex: none; }
.search-panel-header h3 { margin: 0; font-size: 15px; color: var(--text-strong); }
.search-panel-close { display: grid; place-items: center; }
.search-results { flex: 1; overflow-y: auto; padding: 8px 12px 12px; }
.search-group-header { display: flex; align-items: center; gap: 4px; padding: 10px 2px 6px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.search-group-header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; margin-bottom: 8px; background: var(--bg-chat); border: 1px solid var(--border); border-radius: 6px; }
.search-result:hover { border-color: var(--bg-active); }
.search-result-body { flex: 1; min-width: 0; }
.search-result-meta { display: flex; align-items: baseline; gap: 8px; }
.search-result-meta .author { font-weight: 600; color: var(--text-strong); }
.search-result .content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.375; max-height: 14em; overflow: hidden; }
.search-highlight { background: rgba(250, 166, 26, 0.32); color: var(--text-strong); border-radius: 2px; padding: 0 1px; }
.search-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.search-thumb { max-width: 160px; max-height: 120px; border-radius: 4px; object-fit: cover; }
.search-file { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }
.search-jump { position: absolute; top: 8px; right: 8px; padding: 2px 8px; font-size: 12px; border-radius: 4px; border: 0; background: var(--bg-active); color: var(--text); opacity: 0; }
.search-result:hover .search-jump, .search-jump:focus-visible { opacity: 1; }
.search-jump:hover { background: var(--accent); color: #fff; }
.search-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 32px 16px; color: var(--text-muted); }
.search-empty > .icon { opacity: 0.6; margin-bottom: 8px; }
.search-empty p { margin: 2px 0; }
.search-empty > p:first-of-type { color: var(--text-strong); font-weight: 600; }
.search-error { color: var(--danger); }
.search-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); flex: none; }
.search-page-button { padding: 6px 14px; border: 0; border-radius: 4px; background: var(--bg-active); color: var(--text); }
.search-page-button:hover:not(:disabled) { background: var(--accent); color: #fff; }
.search-page-button:disabled { opacity: 0.4; cursor: not-allowed; }
.app.voice-chat-open.search-open { grid-template-columns: 72px 240px minmax(0, 1fr) 380px; }
@media (max-width: 1000px) {
  .app.search-open, .app.voice-chat-open.search-open { grid-template-columns: 72px 220px minmax(0, 1fr) min(360px, 45vw); }
  .channel-search { width: 140px; }
  .chat:has(> .channel-search:not([hidden])) > .chat-header { padding-right: 172px; }
}

/* Muted channels are dimmed in the channel list (they show no unread dot). */
.channel.muted-channel:not(.active) { color: var(--text-faint); }
.channel.muted-channel:not(.active) > .icon { opacity: 0.45; }
.channel.muted-channel:not(.active):hover { color: var(--text-muted); }

/* The Notification Settings dialog. */
.notify-dialog { width: min(540px, 94vw); max-height: 88vh; max-height: 88dvh; overflow-y: auto; }
.notify-dialog h2 { margin-bottom: 2px; }
.notify-dialog-server { margin: 0 0 8px; }
.notify-dialog input[type='radio'] { width: auto; margin: 0; accent-color: var(--accent); }
.notify-section { margin: 16px 0; }
.notify-section h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.notify-row .perm-text { display: flex; flex-direction: column; gap: 2px; }
.notify-row .perm-label { color: var(--text-strong); font-weight: 600; }
.notify-radio { display: flex; align-items: center; gap: 10px; margin: 6px 0; padding: 10px 12px; border-radius: 4px; background: var(--bg-rail); cursor: pointer; }
.notify-radio:hover { background: var(--bg-hover); }
.notify-radio.selected { box-shadow: inset 0 0 0 1px var(--accent); }
.notify-mute { display: flex; align-items: center; gap: 8px; flex: none; }
.notify-mute.muted-now { color: var(--text-muted); }
.notify-override select { width: 100%; }
.notify-dialog select { background: var(--bg-rail); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; font: inherit; font-size: 13px; max-width: 100%; }
.notify-override { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 210px) minmax(0, 130px) 28px; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.notify-override-name { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--text-strong); }
.notify-override-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notify-override-name .icon { flex: none; color: var(--text-muted); }
.notify-override-remove { display: grid; place-items: center; }
.notify-add-override { margin-top: 10px; }
