/* Chat page */

.chat-layout {
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0; bottom: 0;
  display: flex;
}

/* Sidebar */
.chat-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.chat-sidebar-header {
  padding: 16px 12px 8px;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 12px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
}

.channel-item:hover { background: var(--bg-hover); color: var(--text); }
.channel-item.active { background: var(--accent-dim); color: var(--accent-2); }

.channel-hash { color: var(--text-3); font-weight: 700; }
.channel-name { flex: 1; }
.channel-locked { font-size: 11px; }
.channel-hash-lg { font-size: 1.2rem; color: var(--text-3); font-weight: 700; }

/* Chat main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
  gap: 12px;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-channel-name {
  font-weight: 600;
  font-size: 14px;
}

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

/* Pins panel */
.pins-panel {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
  flex-shrink: 0;
}

.pins-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pin-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.pin-item:last-child { border-bottom: none; }
.pin-username { font-size: 12px; font-weight: 600; color: var(--text); }
.pin-body { color: var(--text-2); margin-top: 2px; }

/* Messages */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-message {
  display: flex;
  gap: 10px;
  padding: 4px 8px;
  border-radius: var(--r);
  transition: background var(--transition);
  position: relative;
}

.chat-message:hover { background: var(--bg-2); }
.chat-message:hover .msg-actions { opacity: 1; }
.chat-message.pinned { background: rgba(139,92,246,0.05); border-left: 2px solid var(--accent); }

.msg-avatar { flex-shrink: 0; margin-top: 2px; }

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

.msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.msg-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.msg-time {
  font-size: 11px;
  flex-shrink: 0;
}

.pin-badge { font-size: 11px; }

.msg-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-actions {
  position: absolute;
  right: 8px;
  top: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 2px 4px;
}

.msg-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  color: var(--text-2);
  transition: all var(--transition);
}

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

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 16px;
  font-size: 12px;
  color: var(--text-3);
  min-height: 20px;
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: var(--text-3);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Input */
.chat-input-area {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-main);
  outline: none;
  resize: none;
  max-height: 120px;
  transition: border-color var(--transition);
  line-height: 1.5;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-3); }
.chat-input:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 8px 12px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--accent-2); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    left: -220px;
    top: var(--nav-height);
    bottom: 0;
    z-index: 300;
    transition: left 0.25s ease;
  }
  .chat-sidebar.open { left: 0; }
}
