/* messenger/sidebar.css — 2 of 9. Needs base.css.
   The left column: everything from the brand row down to my own bar under the list.
   Sections, in order:
     - Sidebar shell and header (.sidebar, .sidebar-header)
     - Me, under the list (KAN-63): .sidebar-footer with my name (.me-text) and the
       settings gear (.account-settings-btn)
     - My avatar + status menu (KAN-39): .status-picker, .status-btn, .status-menu (opens
       upward from the footer) and its .status-option buttons, and the "for how long"
       choices (.status-durations)
     - Search box and results dropdown (.search-box, .search-results)
     - Conversation list rows: name, preview text/time, unread badge
     - Avatars: .avatar, the group two-avatar stack (.avatar-stack, KAN-35),
       .presence-dot and the "5m" .presence-ago pill
     - New group button + dialog contents (KAN-35): .new-group-*
   Driven by conversation-list.js, presence.js, search.js and avatar.js.
   No media queries here — the narrow-screen rules for the sidebar are in composer.css
   (one-pane layout), and the list row's ⋯ menu is in conversation-settings.css.
   The shared .modal shell the new-group dialog sits in is in message-actions.css. */

/* Sidebar */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0.75rem;
}

.sidebar-header h1 {
  margin: 0;
  font-size: var(--text-xl);
  color: var(--heading);
}

/* Me, under the list (KAN-63) */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem 0.7rem 1.1rem;
  border-top: 1px solid var(--border);
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
}

.me-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.me-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--heading);
}

.me-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  color: var(--muted);
}

.account-settings-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 1.15rem;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.account-settings-btn:hover,
.account-settings-btn[aria-expanded="true"] {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

/* My avatar + status menu (KAN-39) */

.status-picker {
  position: relative;
}

.status-btn {
  display: block;
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
}

.status-btn .avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  font-size: 0.8rem;
}

.status-btn .presence-dot {
  width: 13px;
  height: 13px;
}

/* Popups sit on --surface-pop; anything inside that cuts out to "the surface" (a presence
   dot's ring and notch, KAN-62) should match it, not the sidebar behind. */
.status-menu,
.search-results {
  --surface: var(--surface-pop);
}

.status-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 20;
  width: 250px;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface-pop);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.status-menu li {
  border-radius: var(--radius-md);
}

.status-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.status-option:hover {
  background: var(--bg);
}

.status-option:focus-visible {
  outline-offset: -2px;
}

.status-option[aria-pressed="true"] {
  background: var(--accent-soft);
}

.status-menu .presence-dot {
  position: relative;
  flex-shrink: 0;
  right: auto;
  bottom: auto;
  margin-top: 2px;
  border-color: transparent;
}

.status-menu-text {
  display: flex;
  flex-direction: column;
  font-size: var(--text-sm);
  color: var(--text);
}

.status-menu-text small {
  color: var(--muted);
  font-size: var(--text-xs);
}

.status-menu-text .status-until {
  color: var(--accent-ink);
  font-weight: 600;
}

.status-menu-text .status-until:empty {
  display: none;
}

/* "For how long" choices under Do Not Disturb / Offline */
/* Indented to line up with the option's text, past its 14px dot and the gap. */
.status-durations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.6rem 0.5rem calc(1.2rem + 14px);
}

.status-durations span {
  font-size: var(--text-xs);
  color: var(--muted);
}

.status-durations button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: var(--text-xs);
  cursor: pointer;
}

.status-durations button:hover {
  border-color: var(--orange);
  color: var(--accent-ink);
}

.search-box {
  position: relative;
  padding: 0 1.25rem 0.75rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-box input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  color: var(--text);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.search-results {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  top: 100%;
  z-index: 10;
  margin: 0.25rem 0 0;
  padding: 0.4rem;
  list-style: none;
  background: var(--surface-pop);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  max-height: 260px;
  overflow-y: auto;
}

.search-results li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.search-results li:hover,
.search-results li:focus-visible {
  background: var(--bg);
}

/* Rows sit flush in scrolling lists, where an outside ring would be clipped. */
.search-results li:focus-visible,
.conversation-list li:focus-visible {
  outline-offset: -2px;
}

.search-results .search-empty {
  color: var(--muted);
  font-size: var(--text-sm);
  padding: 0.5rem;
  cursor: default;
}

.sidebar-status {
  padding: 0 1.25rem;
  color: var(--muted);
  font-size: var(--text-sm);
}

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.conversation-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
}

.conversation-list li:hover,
.conversation-list li.menu-open {
  background: var(--bg);
}

.conversation-list li.active {
  background: var(--accent-soft);
}

.conversation-text {
  flex: 1;
  min-width: 0; /* lets text-overflow ellipsis actually kick in inside the flex row */
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.conversation-preview {
  display: flex;
  min-width: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.conversation-preview.unread {
  color: var(--text);
  font-weight: 700;
}

.conversation-preview.typing {
  color: var(--accent-ink);
  font-weight: 600;
}

.conversation-preview-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-preview-time {
  flex-shrink: 0;
  white-space: pre;
}

.conversation-name {
  min-width: 0;
  font-weight: 600;
  font-size: var(--text-md);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--orange);
  color: var(--on-accent);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Avatars */

.avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A deleted account's silhouette (KAN-63), sized with the avatar's own initials. */
.avatar > .icon {
  font-size: 1.7em;
  color: #fff;
}

/* A group's picture (KAN-35): two members' avatars overlapped in a 40px square. */
.avatar-stack {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
}

.avatar-stack .avatar {
  position: absolute;
  width: 26px;
  height: 26px;
  min-width: 26px;
  font-size: 0.6rem;
  border: 2px solid var(--surface);
}

.avatar-stack .avatar:first-child {
  top: 0;
  right: 0;
}

.avatar-stack .avatar:last-child {
  bottom: 0;
  left: 0;
}

/* Online indicator (KAN-39): the avatar's own overflow:hidden would clip a badge, so
   avatars that can carry one sit in this wrapper instead. */
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
}

.presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #31a24c;
  border: 2.5px solid var(--surface);
}

/* Idle: a yellow crescent moon; Do Not Disturb: red with a white bar; Offline (only on
   my own avatar and in the status menu): a grey ring. */
.presence-dot.status-idle {
  background: #f0b232;
  overflow: hidden;
}

.presence-dot.status-idle::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: var(--surface);
}

.presence-dot.status-dnd {
  background: #e5484d;
}

.presence-dot.status-dnd::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
  transform: translate(-50%, -50%);
}

.presence-dot.status-offline {
  background: var(--surface);
  box-shadow: inset 0 0 0 3px #9aa0a6;
}

/* Left within the hour: a "5m" pill where the dot would be, Messenger-style. */
.presence-ago {
  position: absolute;
  right: -6px;
  bottom: -3px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: var(--online-soft);
  color: var(--online-ink);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 13px;
  white-space: nowrap;
}

/* New group button + dialog (KAN-35) */

.new-group-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--heading);
  font-size: 1.1rem;
  cursor: pointer;
}

.new-group-btn:hover {
  color: var(--accent-ink);
}

.new-group-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  color: var(--text);
}

.new-group-input:focus {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.new-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.new-group-chips:empty {
  display: none;
}

.new-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem 0.2rem 0.2rem;
  border-radius: 999px;
  background: var(--bg);
  font-size: var(--text-sm);
  color: var(--text);
}

.new-group-chip .avatar {
  width: 22px;
  height: 22px;
  min-width: 22px;
  font-size: 0.55rem;
}

.new-group-chip button {
  display: flex;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.new-group-chip button:hover {
  color: var(--accent-ink);
}

.new-group-search {
  position: relative;
}

.new-group-results {
  left: 0;
  right: 0;
}

.new-group-hint {
  margin: -0.5rem 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.new-group-error {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--error);
}

.modal-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

