/* ===== CHAT STYLES ===== */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 140px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow);
}
.chat-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(200,221,200,0.4);
  transition: var(--transition);
}
.chat-item:hover, .chat-item.active { background: rgba(30,107,30,0.06); }
.chat-item-avatar {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview { font-size: 0.75rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-meta { text-align: right; }
.chat-item-time { font-size: 0.7rem; color: var(--text-light); }
.chat-unread {
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
  margin-left: auto;
}

.chat-main {
  display: flex;
  flex-direction: column;
}
.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 700; font-size: 0.9rem; color: var(--text-dark); }
.chat-header-status { font-size: 0.72rem; color: var(--text-light); }
.chat-header-notice {
  font-size: 0.72rem;
  color: var(--warning);
  font-weight: 500;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafcfa;
}
.chat-notice {
  background: #fff8e1;
  border: 1px solid #ffecb3;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.78rem;
  color: #795548;
  text-align: center;
  margin-bottom: 8px;
}
.message-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.message-wrapper.own { flex-direction: row-reverse; }
.message-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.855rem;
  line-height: 1.4;
  position: relative;
}
.message-bubble.received {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
}
.message-bubble.own {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.message-time { font-size: 0.65rem; color: var(--text-light); margin-top: 4px; text-align: right; }
.message-bubble.own .message-time { color: rgba(255,255,255,0.7); }
.message-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.system-message {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 4px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 20px;
  align-self: center;
}

.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.875rem;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 100px;
  overflow-y: auto;
  transition: var(--transition);
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  width: 38px; height: 38px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  gap: 10px;
}
.chat-empty-icon { font-size: 3rem; }
.chat-empty p { font-size: 0.9rem; }

@media (max-width: 768px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
  .chat-sidebar.show { display: flex; position: fixed; inset: 0; z-index: 200; width: 280px; border-radius: 0; }
}
