/* ==========================================================================
   IRONITT v2 — Nests: the channel list
   --------------------------------------------------------------------------
   The Nest's own column (shown when the chats column is collapsed, and as
   the phones' channel drawer): the Nest name with its menu, categories, and
   the channels as rows or tiles. Flat like the rest of v2: rows highlight
   with a fill, the active one with the accent; nothing lifts or casts a
   shadow except the menu and the drawer, which float.
   ========================================================================== */

.servers-body.server-switching .channel-sidebar {
  animation: slideInLeft 250ms ease forwards;
}

.servers-body.server-switching .channel-tile {
  animation: slideInLeft 200ms ease forwards;
  opacity: 0;
}

.servers-body.server-switching .channel-category:nth-child(1) .channel-tile { animation-delay: 30ms; }

.servers-body.server-switching .channel-category:nth-child(2) .channel-tile { animation-delay: 80ms; }

.servers-body.server-switching .channel-category:nth-child(3) .channel-tile { animation-delay: 130ms; }

.channel-sidebar {
  width: 220px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal);
}

.channel-header {
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--border-color);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  height: 56px;
  box-sizing: border-box;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.channel-category {
  margin-bottom: var(--space-sm);
}

/* Category titles read like the chats column's group titles (.v2-eyebrow);
   the chevron still folds the category. */
.channel-category-name {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-xs) 10px;
  font-family: var(--font-display);
  font-stretch: 125%;
  font-size: var(--font-size-2xs);
  line-height: 16px;
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
}

.channel-category-name i {
  font-size: 10px;
  transition: transform var(--transition-fast);
}

@media (max-width: 640px) {
  .channel-category-name span,
  .channel-category-name i { display: none; }
  .channel-category-name { padding: 4px 0; min-height: 0; }
}

.channel-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
}

.channel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: background-color var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}

.channel-tile i {
  font-size: 18px;
}

.channel-tile span {
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
}

.channel-tile:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.channel-tile.active {
  background: var(--accent-subtle);
  color: var(--accent-color);
  border-color: transparent;
  border-color: var(--accent-color);
}

.channel-type-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  transform: scale(0.75);
  transform-origin: top right;
  color: var(--text-muted);
  opacity: 0.4;
}

/* List view: the same rows as the chats column (css/v2/shell.css .chat-row):
   a 40px glyph tile, the name, and what the channel is (or how many are
   unread / in voice) underneath. */
.channel-list-item {
  display: none; /* hidden by default, shown when data-channel-view="list" */
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.channel-glyph {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: var(--font-size-md);
}
.channel-glyph--voice { color: var(--color-online); }
.channel-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.channel-item-name,
.channel-item-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.channel-item-name { font-weight: var(--font-weight-semibold); }
.channel-item-sub { color: var(--text-secondary); font-size: var(--font-size-sm); }
.channel-list-item.is-unread .channel-item-sub { color: var(--text-primary); }
.channel-list-item:hover { background: var(--bg-secondary); }
.channel-list-item.active { background: var(--bg-secondary); box-shadow: inset 0 0 0 1px var(--border-color); }

[data-channel-view="list"] .channel-tiles {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
}

[data-channel-view="list"] .channel-tile,
[data-channel-view="list"] .channel-type-badge {
  display: none;
}

[data-channel-view="list"] .channel-list-item {
  display: flex;
}

.channel-tile,
.channel-list-item { position: relative; }

.channel-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-color);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  line-height: 18px;
  text-align: center;
}

.channel-tile .channel-unread {
  position: absolute;
  top: 4px;
  right: 4px;
}

.channel-list-item .channel-unread {
  margin-left: auto;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .channel-sidebar {
    width: 240px;
  }
}

.channel-add-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 4px;
  margin-left: auto;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s, color 0.2s, background 0.2s;
  border-radius: var(--radius-sm);
}

.channel-category-name:hover .channel-add-btn {
  opacity: 1;
}

.channel-add-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.server-settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.server-settings-btn:hover {
  color: var(--text-primary);
}

.server-settings-btn.open {
  transform: rotate(180deg);
  color: var(--text-primary);
}

.server-dropdown {
  position: absolute;
  top: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: dropdownFadeIn 0.15s ease;
}

.server-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.server-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.server-dropdown-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.server-dropdown-item.danger {
  color: var(--color-danger);
}

.server-dropdown-item.danger:hover {
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  color: var(--color-danger);
}

.server-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

@media (max-width: 960px) {
  .channel-sidebar {
    width: 200px;
  }
}

@media (max-width: 640px) {
  .channel-sidebar {
    width: 68px;
    min-width: 68px;
  }

  .channel-tile {
    width: 48px;
    height: 48px;
  }

  .channel-tile span,
.channel-type-badge {
    display: none;
  }

  .channel-list-item .channel-item-body {
    display: none;
  }

  .channel-list-item {
    justify-content: center;
    padding: 8px 4px;
  }
}

@media (max-width: 480px) {
  .channel-sidebar {
    width: 56px;
    min-width: 56px;
  }

  .channel-tile {
    width: 40px;
    height: 40px;
  }

  .channel-tile i {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  .channel-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 80vw;
    max-width: 280px;
    min-width: 0;
    background: var(--bg-secondary);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }

  .servers-body.drawer-open .channel-sidebar { transform: translateX(0); }

  .channel-sidebar .channel-tile,
.channel-sidebar .channel-list-item {
    width: auto;
    height: auto;
    justify-content: flex-start;
    padding: 8px 10px;
  }
  .channel-sidebar .channel-list-item .channel-item-body { display: flex; }

  .channel-sidebar .channel-tile span,
.channel-sidebar .channel-category-name span,
.channel-sidebar .channel-category-name i {
    display: inline-block;
  }

  .channel-sidebar .channel-tile i { font-size: 14px; }

  .channel-sidebar .channel-category-name {
    padding: 8px 12px 4px;
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .channel-sidebar {
    width: 84vw;
    max-width: 260px;
  }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .channel-sidebar {
    width: 200px;
  }
}

@media (max-aspect-ratio: 4/3) and (min-width: 641px) and (min-height: 641px) {
  .channel-sidebar { width: 188px; }
}

/* Phones and tablets */
@media (max-width: 1024px) {
  .channel-sidebar { width: 210px; }
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Rows: the height of the chats column's rows, a little more air. */
.channel-header { height: 64px; padding: 0 var(--space-md) 0 var(--space-lg); }
.channel-header > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Channel messages: groups (avatar, name, time) and the lines under them,
   their hover actions, and inline editing. Moved from style.css; the edit
   buttons no longer lift or dip, they change fill.
   ========================================================================== */

.message-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.message-group-avatar {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-strong);
  font-weight: var(--font-weight-bold);
  font-size: 13px;
  color: var(--accent-color);
}

.message-group-author {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

.message-group-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.message-group-messages {
  padding-left: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-group-item {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

.message-group-item:hover {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.message-group-item .message-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: var(--space-xs);
}

.message-group-item:hover .message-actions {
  display: flex;
}

.message-group-item:hover .reaction-add-btn {
  opacity: 1;
}

.message-text del {
  opacity: 0.6;
}

.message-text strong {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.message {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}

.message-content {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  word-wrap: break-word;
}

.msg-attachment {
  margin-top: var(--space-xs);
}

.msg-attachment--image img {
  max-width: 300px;
  max-height: 300px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.msg-attachment--file a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  color: var(--accent-color);
  font-size: var(--font-size-xs);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.msg-attachment--file a:hover {
  background: var(--bg-hover);
}

.msg-attachment-size {
  color: var(--text-muted);
  font-size: 11px;
}

[data-message-display="compact"] .message-group-header {
  gap: 6px;
  margin-bottom: 1px;
}

[data-message-display="compact"] .message-group-avatar {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

[data-message-display="compact"] .message-group-messages {
  padding-left: 28px;
}

[data-message-display="compact"] .message-group-item {
  padding: 1px 0;
  font-size: var(--font-size-xs);
}

[data-message-display="compact"] .message-group-author {
  font-size: var(--font-size-xs);
}

[data-message-display="compact"] .message-group-time {
  font-size: 10px;
}

[data-message-display="compact"] .message {
  padding: 3px var(--space-md);
  gap: 8px;
}

[data-message-display="compact"] .message-content {
  font-size: var(--font-size-xs);
}

.message {
  position: relative;
}

.message-actions {
  position: absolute;
  top: 4px;
  right: 8px;
  display: none;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.message:hover .message-actions {
  display: flex;
}

.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: color 0.2s, background 0.2s;
}

.msg-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.msg-edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--accent-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: inherit;
  margin-bottom: 4px;
}

.msg-edit-actions {
  display: flex;
  gap: 6px;
}

.msg-edit-save,
.msg-edit-cancel {
  padding: 2px 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.msg-edit-save { background: var(--accent-color); color: var(--accent-text); }
.msg-edit-save:hover { background: var(--accent-hover); }
.msg-edit-cancel { background: var(--bg-tertiary); color: var(--text-muted); }
.msg-edit-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }

@media (max-width: 480px) {
  .message-group-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .message-group-messages {
    padding-left: 36px;
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
