/* Page wiring of the tessairact|code chat (W1.4–W2.5): sidebar views, channel tabs, permalink
   highlight, typing line, presence, profiles and the notification control. Tokens and the shared
   classes (chat-button, chat-avatar, chat-inbox-*) come from chat.css and inbox.css. */

/* Main area: one stage holds the messages, a channel tab or a view. */

.chat-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

.chat-stage > * {
  grid-area: 1 / 1;
  min-height: 0;
}

.chat-tab-pane,
.chat-view-host,
.chat-view-pane {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-view-host {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.chat-view-pane > * {
  height: 100%;
}

.chat-view-head {
  display: none;
}

@media (max-width: 900px) {
  .chat-view-head {
    display: flex;
    min-height: 0;
    padding: 8px 12px;
  }
}

/* Channel tabs and the first-unread jump */

.chat-tabs {
  display: flex;
  gap: 2px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.chat-tab {
  padding: 7px 10px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-bright);
  font-weight: 600;
  cursor: pointer;
}

.chat-tab:hover {
  color: var(--cyan);
}

.chat-tab[aria-selected="true"] {
  border-bottom-color: var(--cyan);
  color: var(--text);
}

.chat-header-actions {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
}

.chat-message[data-highlight="true"] {
  background: rgba(140, 87, 0, 0.18);
  box-shadow: inset 3px 0 0 var(--amber);
}

.chat-typing {
  min-height: 18px;
  margin: 0;
  padding: 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* Sidebar: views, people with presence and status */

.chat-nav-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-bright);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.chat-nav-entry:hover {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.chat-nav-entry[aria-current="true"] {
  background: var(--cyan);
  color: #fff;
}

.chat-nav-dot {
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--red);
}

.chat-person-avatar {
  position: relative;
  display: inline-flex;
  flex: none;
}

.chat-presence-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.chat-presence-dot[data-online="true"] {
  background: #2e9b3e;
}

.chat-person-avatar .chat-presence-dot {
  position: absolute;
  right: -3px;
  bottom: -3px;
  border: 2px solid var(--panel-raised);
  box-sizing: content-box;
}

.chat-person-avatar .chat-presence-dot[data-online="false"] {
  display: none;
}

.chat-person-status,
.chat-me-status {
  overflow: hidden;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-person .chat-person-status {
  margin-left: auto;
  max-width: 50%;
}

.chat-me-text {
  min-width: 0;
}

.chat-avatar[data-photo="true"] {
  overflow: hidden;
  background: var(--panel-raised);
}

.chat-avatar[data-photo="true"] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sidebar foot: notifications */

.chat-notify-control {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  font-size: 12px;
}

.chat-notify-label {
  color: var(--muted-bright);
  font-weight: 700;
}

.chat-notify-state {
  color: var(--muted);
}

.chat-notify-control .chat-button {
  min-height: 26px;
  padding: 2px 8px;
  font-size: 12px;
}

/* Saved and pinned cards */

.chat-card-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.chat-card-row .chat-inbox-item {
  flex: 1;
  min-width: 0;
}

.chat-card-action {
  flex: none;
  margin-top: 4px;
}

/* Profile card and dialog */

.chat-profile-card {
  position: fixed;
  inset: auto;
  width: min(300px, calc(100vw - 16px));
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(20, 33, 38, 0.2);
}

.chat-profile-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-profile-head .chat-avatar {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.chat-profile-names {
  display: grid;
  min-width: 0;
}

.chat-profile-name {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
}

.chat-profile-handle,
.chat-profile-muted {
  color: var(--muted);
  font-size: 12px;
}

.chat-profile-title,
.chat-profile-status,
.chat-profile-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.chat-profile-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.chat-profile-photo {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-profile-preview .chat-avatar {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

.chat-profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chat-profile-status-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
}

/* The profile card in a bottom sheet (phones, profile_view.js); its action is a row of the sheet. */
.chat-profile-card[data-surface="sheet"] {
  position: static;
  width: auto;
  padding: 0 4px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
}

.chat-profile-card[data-surface="sheet"] .chat-profile-head .chat-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 20px;
}

.chat-profile-card[data-surface="sheet"] .chat-profile-name {
  font-size: 19px;
}

.chat-profile-card[data-surface="sheet"] :is(.chat-profile-handle, .chat-profile-muted) {
  font-size: 14px;
}

/* Collapsible sidebar sections (sidebar_sections.js): the title is the toggle; a collapsed section
   shows what waits there as a small badge after its label. */
.chat-sidebar-toggle .chat-section-label {
  min-width: 0;
}

.chat-section-badge {
  margin-left: auto;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 18px;
  text-transform: none;
}

.chat-me-toggle {
  border-radius: 8px;
  cursor: pointer;
}

.chat-me-toggle:hover {
  background: var(--cyan-soft);
}

.chat-account-block[hidden] {
  display: none;
}
