/* ==========================================================================
   BeSpokeHQ - Group Chat & Direct Collaboration Engine Styles
   Fixed-height scrolling stream, anchored input bar, real-time live sync
   ========================================================================== */

.chat-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  min-height: 480px;
  max-height: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* --- Left Column: Group Channels & Threads --- */
.chat-threads-col {
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-threads-head {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-threads-title {
  font-size: 1.05rem;
  font-family: var(--font-sans);
  font-weight: 600;
}

.chat-threads-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  list-style: none;
}

.thread-item {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.thread-item:hover {
  background-color: var(--bg-secondary);
}

.thread-item.active {
  background-color: var(--bg-primary);
  border-left: 3px solid var(--accent-gold);
}

.thread-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.thread-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.thread-service {
  font-size: 0.72rem;
  color: var(--accent-gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.thread-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Right Column: Active Group Conversation --- */
.chat-active-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  min-width: 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.chat-active-header {
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  flex-shrink: 0;
  z-index: 5;
}

.chat-active-info h3 {
  font-size: 1.35rem;
  margin-bottom: 0.2rem;
}

.chat-participants-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-avatar-stack {
  display: flex;
  align-items: center;
}

.stack-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  margin-left: -6px;
  object-fit: cover;
}

.stack-avatar:first-child {
  margin-left: 0;
}

.participants-count-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

/* --- Message Stream (Must Scroll Vertically with Anchored Input) --- */
.chat-message-stream {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background-color: var(--bg-primary);
  scroll-behavior: smooth;
}

.chat-msg-row {
  display: flex;
  gap: 1rem;
  max-width: 80%;
}

.chat-msg-row.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-sender-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-content-wrap {
  display: flex;
  flex-direction: column;
}

.chat-msg-row.outgoing .msg-content-wrap {
  align-items: flex-end;
}

.msg-meta-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.msg-sender-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-timestamp {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.msg-bubble {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-subtle);
  word-break: break-word;
}

.chat-msg-row.outgoing .msg-bubble {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

/* --- Anchored Bottom Input Bar (Never pushed off screen) --- */
.chat-input-bar {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  z-index: 10;
}

.chat-input-box {
  flex-grow: 1;
  padding: 0.85rem 1.15rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-smooth);
}

.chat-input-box:focus {
  background: var(--bg-surface);
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-soft);
}

/* Custom Sleek Scrollbar */
.chat-message-stream::-webkit-scrollbar,
.chat-threads-list::-webkit-scrollbar {
  width: 6px;
}

.chat-message-stream::-webkit-scrollbar-track,
.chat-threads-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-message-stream::-webkit-scrollbar-thumb,
.chat-threads-list::-webkit-scrollbar-thumb {
  background: var(--accent-gold-border);
  border-radius: 4px;
}

.chat-message-stream::-webkit-scrollbar-thumb:hover,
.chat-threads-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* New Group Chat Modal Checklist */
.talent-select-checklist {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* System Announcement Message */
.chat-system-msg-row {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
  width: 100%;
}

.chat-system-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-subtle);
}

.chat-system-pill span {
  font-weight: 500;
}

/* Add Member Modal List */
.add-member-item:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--accent-gold-border) !important;
}

/* Responsive Chat Layout */
@media (max-width: 800px) {
  .chat-container {
    grid-template-columns: 1fr;
  }
  .chat-threads-col {
    display: none;
  }
  .chat-active-header {
    padding: 1rem 1.25rem;
  }
  .chat-message-stream {
    padding: 1rem 1.25rem;
  }
  .chat-input-bar {
    padding: 0.75rem 1rem;
  }
}
