/* ============================================================
   chat.css — Real-time Messaging  |  Blue × Indigo
   ============================================================ */

body { overflow: hidden; }

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 66px);
}

/* ── Sidebar ── */
.chat-sidebar {
  border-radius: 0 !important;
  border-right: 1px solid var(--border) !important;
  border-top: none !important;
  border-left: none !important;
  border-bottom: none !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.3s ease;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.chat-sidebar-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text);
  margin: 0;
}

.chat-unread-badge {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

.chat-search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); }

.chat-search {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.88rem;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-search:focus {
  border-color: var(--blue-border);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.chat-search::placeholder { color: var(--text-3); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.conv-empty {
  padding: 20px 18px;
  text-align: center;
}

/* Conversation item */
.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0;
}

.conv-item:hover  { background: var(--surface); }
.conv-item.active { background: var(--blue-dim); border-left: 3px solid var(--blue); }

.conv-avatar-wrap { position: relative; flex: 0 0 auto; }

.conv-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-h), var(--indigo-h));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 900;
  font-size: 1rem;
}

.conv-online-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg);
}

.conv-info { flex: 1; min-width: 0; }

.conv-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-last {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 0 0 auto;
}

.conv-time { white-space: nowrap; }

.conv-unread {
  min-width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ── Main chat ── */
.chat-main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  transition: background 0.3s ease;
}

/* Empty state */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 40px;
}

.chat-empty-icon  { font-size: 3.5rem; }
.chat-empty-title { font-size: 1.2rem; font-weight: 900; color: var(--text); margin: 0; }

/* Chat window */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat header */
.chat-win-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  flex: 0 0 auto;
}

.chat-win-avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-h), var(--indigo-h));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 900;
  font-size: 1rem;
  flex: 0 0 auto;
}

.chat-win-info { flex: 1; min-width: 0; }
.chat-win-name { font-weight: 800; color: var(--text); font-size: 0.95rem; }
.chat-win-status { margin-top: 1px; color: #22c55e; }

.chat-win-actions { display: flex; gap: 8px; }

.chat-win-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.chat-win-btn:hover {
  background: var(--blue-dim);
  border-color: var(--blue-border);
  text-decoration: none;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-loading { text-align: center; padding: 20px 0; }

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 68%;
}

.chat-msg--mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg--theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg--mine .chat-msg-bubble {
  background: linear-gradient(135deg, var(--blue-h), var(--indigo-h));
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.chat-msg--theirs .chat-msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
}

.chat-msg-time { font-size: 0.7rem; margin-top: 3px; padding: 0 4px; }

/* Typing indicator */
.chat-typing {
  padding: 6px 20px;
  font-size: 0.8rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingDot 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
  40%           { transform: scale(1.3); opacity: 1; }
}

/* Input area */
.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 0 !important;
  border-top: 1px solid var(--border) !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  flex: 0 0 auto;
}

.chat-attach-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  font-size: 1rem;
  cursor: pointer;
  display: grid; place-items: center;
  flex: 0 0 auto;
  transition: background 0.2s;
}

.chat-attach-btn:hover { background: var(--bg-3); }

.chat-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 16px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
  border-color: var(--blue-border);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.chat-input::placeholder { color: var(--text-3); }

.chat-send-btn {
  width: auto;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  flex: 0 0 auto;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  body { overflow: auto; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-sidebar { height: 280px; border-right: none !important; border-bottom: 1px solid var(--border) !important; }
  .chat-main    { height: calc(100vh - 66px - 280px); }
}