/* Shlack — Messaging */

/* ── Layout ── */

.shlack {
  height: 100%;
  display: flex;
  overflow: hidden;
}

.shlack-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shlack-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shlack-sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.shlack-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.shlack-channel-group {
  margin-bottom: 4px;
}

.shlack-channel-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 8px 16px 4px;
  font-weight: 500;
}

.shlack-channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: background var(--speed) var(--ease);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.shlack-channel-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.shlack-channel-item.active {
  background: var(--bg-active);
  color: var(--text);
}

.shlack-channel-item .channel-hash {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.9em;
  flex-shrink: 0;
}

.shlack-channel-item .channel-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Slack-style: unread channels are bold white */
.shlack-channel-item.unread {
  color: var(--text);
  font-weight: 600;
}

.shlack-channel-item.unread .channel-hash {
  color: var(--text);
}

/* Sidebar tree: unread shlack channels */
.tree-item.shlack-unread .tree-title {
  color: var(--text);
  font-weight: 600;
}

/* Sidebar subsection headers (Channels / DMs) */
.shlack-subsection-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 2px;
  cursor: pointer;
  user-select: none;
}

.shlack-subsection-header span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 500;
}

.shlack-subsection-header .btn-icon {
  margin-left: auto;
}

.shlack-subsection-header .shlack-chevron {
  color: var(--text-faint);
  flex-shrink: 0;
  transition: transform var(--speed) var(--ease);
}

.shlack-subsection-header.collapsed .shlack-chevron {
  transform: rotate(-90deg);
}

/* ── Main chat area ── */

.shlack-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.shlack-chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.shlack-chat-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.shlack-chat-topic {
  font-size: 0.78rem;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shlack-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.shlack-messages-inner {
  margin-top: auto;
  padding: 0 20px;
}

.shlack-msg {
  padding: 4px 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.shlack-msg:hover {
  background: var(--bg-hover);
  margin: 0 -20px;
  padding: 4px 20px;
}

.shlack-msg + .shlack-msg-same-author {
  padding-top: 0;
}

.shlack-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.shlack-msg-same-author .shlack-msg-avatar {
  visibility: hidden;
  height: 0;
}

.shlack-msg-body {
  flex: 1;
  min-width: 0;
}

.shlack-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 1px;
}

.shlack-msg-same-author .shlack-msg-header {
  display: none;
}

.shlack-msg-author {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.shlack-msg-time {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.shlack-msg-content {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.shlack-msg-content code {
  background: var(--bg-input);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.82em;
}

.shlack-msg-content pre {
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 4px 0;
}

.shlack-msg-content pre code {
  padding: 0;
  background: none;
}

.shlack-msg-content a {
  color: var(--accent);
  text-decoration: none;
}

.shlack-msg-content a:hover {
  text-decoration: underline;
}

.shlack-msg-edited {
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-left: 4px;
}

/* ── Reactions ── */

.shlack-msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.shlack-reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--speed);
}

.shlack-reaction:hover {
  background: var(--bg-hover);
}

.shlack-reaction.mine {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.shlack-reaction .count {
  color: var(--text-secondary);
  font-size: 0.7rem;
}

/* ── Thread indicator ── */

.shlack-msg-thread {
  margin-top: 4px;
}

.shlack-msg-thread button {
  font-size: 0.75rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}

.shlack-msg-thread button:hover {
  text-decoration: underline;
}

/* ── Attachments ── */

.shlack-msg-attachments {
  margin-top: 4px;
}

.shlack-msg-attachment {
  display: inline-block;
  margin: 2px 0;
}

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

.shlack-msg-attachment a {
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
}

.shlack-msg-attachment a:hover {
  text-decoration: underline;
}

/* ── Message actions (hover) ── */

.shlack-msg-actions {
  display: none;
  position: absolute;
  top: -12px;
  right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 1px;
  z-index: 5;
}

.shlack-msg {
  position: relative;
}

.shlack-msg:hover .shlack-msg-actions {
  display: flex;
}

.shlack-msg-actions button {
  width: 28px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shlack-msg-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ── Input area ── */

.shlack-input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.shlack-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color var(--speed);
}

.shlack-input-wrap:focus-within {
  border-color: var(--border-focus);
}

.shlack-input-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  min-height: 20px;
  font-family: inherit;
  outline: none;
}

.shlack-input-wrap textarea::placeholder {
  color: var(--text-faint);
}

.shlack-send-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--speed);
}

.shlack-send-btn:hover {
  background: var(--accent-hover);
}

.shlack-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.shlack-upload-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.shlack-upload-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ── Typing indicator ── */

.shlack-typing {
  font-size: 0.72rem;
  color: var(--text-faint);
  padding: 2px 20px 0;
  min-height: 18px;
}

/* ── Thread panel ── */

.shlack-thread-panel {
  width: 360px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.shlack-thread-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shlack-thread-header h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

.shlack-thread-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-faint);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.shlack-thread-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.shlack-thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.shlack-thread-input {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

/* ── Empty state ── */

.shlack-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ── Day separator ── */

.shlack-day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 500;
}

.shlack-day-sep::before,
.shlack-day-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── New channel modal ── */

.shlack-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
}

.shlack-modal-overlay.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.shlack-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 380px;
  max-width: 90vw;
}

.shlack-modal h3 {
  margin: 0 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
}

.shlack-modal label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.shlack-modal input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.shlack-modal input:focus {
  border-color: var(--border-focus);
}

.shlack-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.shlack-modal-actions button {
  padding: 6px 16px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

.shlack-modal-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.shlack-modal-actions button.primary:hover {
  background: var(--accent-hover);
}

/* ── Presence dots ── */

.shlack-presence {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.shlack-presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #44b553;
}

.shlack-presence-count {
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ── Emoji picker (simple) ── */

.shlack-emoji-picker {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.shlack-emoji-picker button {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shlack-emoji-picker button:hover {
  background: var(--bg-hover);
}

/* ── @Mentions ── */

.shlack-mention {
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
  cursor: default;
}

/* ── Mention autocomplete ── */

.shlack-mention-list {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
  z-index: 50;
  margin-bottom: 4px;
}

.shlack-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.shlack-mention-item:hover,
.shlack-mention-item.selected {
  background: var(--bg-hover);
}

.shlack-mention-item .mention-avatar {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.65rem;
  flex-shrink: 0;
}

.shlack-mention-item .mention-name {
  font-weight: 500;
}

.shlack-mention-item .mention-username {
  color: var(--text-faint);
  font-size: 0.75rem;
}

/* ── Scrollbar ── */

.shlack-messages::-webkit-scrollbar,
.shlack-channel-list::-webkit-scrollbar,
.shlack-thread-messages::-webkit-scrollbar {
  width: 6px;
}

.shlack-messages::-webkit-scrollbar-thumb,
.shlack-channel-list::-webkit-scrollbar-thumb,
.shlack-thread-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Mini widget ── */

#shlack-widget {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
}

#shlack-widget-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--speed) var(--ease);
}

#shlack-widget-toggle:hover {
  transform: scale(1.05);
}

#shlack-widget-toggle .widget-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
}

#shlack-widget-panel {
  position: absolute;
  bottom: 56px;
  right: 0;
  width: 340px;
  height: 440px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

#shlack-widget-panel.open {
  display: flex;
}

#shlack-widget-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

#shlack-widget-header select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  padding: 4px 8px;
  font-family: inherit;
}

#shlack-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

#shlack-widget-messages .shlack-msg {
  padding: 3px 0;
}

#shlack-widget-messages .shlack-msg-avatar {
  width: 24px;
  height: 24px;
  font-size: 0.65rem;
}

#shlack-widget-messages .shlack-msg-content {
  font-size: 0.8rem;
}

#shlack-widget-messages .shlack-msg-author {
  font-size: 0.78rem;
}

#shlack-widget-messages .shlack-msg-time {
  font-size: 0.65rem;
}

#shlack-widget-input {
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

#shlack-widget-input textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  padding: 6px 8px;
  resize: none;
  min-height: 32px;
  max-height: 60px;
  font-family: inherit;
  outline: none;
}

#shlack-widget-input button {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
}
