/* -----------------------------
   MESSAGES VIEW STYLES
----------------------------- */

.chat-layout {
  display: flex;
  height: calc(100vh - 250px);
  min-height: 500px;
  overflow: hidden;
}

/* Chat Sidebar */
.chat-sidebar {
  width: 320px;
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
}

.chat-search {
  padding: 16px;
  border-bottom: 1px solid var(--panel-border);
}

.chat-search .search-bar {
  width: 100%;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.chat-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
  background-color: rgba(124, 58, 237, 0.1);
  border-left: 3px solid var(--primary);
}

.chat-item-info {
  flex: 1;
  overflow: hidden;
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-item-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-header span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item.unread p {
  font-weight: 600;
  color: var(--text-main);
}

.unread-badge {
  background-color: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Window */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.15);
}

.chat-window-header {
  height: 70px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  background-color: rgba(15, 17, 21, 0.5);
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-user-info h4 {
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.status-text {
  font-size: 0.8rem;
}

.online-text {
  color: var(--accent);
}

.chat-actions {
  display: flex;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.date-separator {
  text-align: center;
  margin: 16px 0;
  position: relative;
}

.date-separator::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--panel-border);
  z-index: 1;
}

.date-separator span {
  position: relative;
  z-index: 2;
  background-color: var(--bg-panel);
  padding: 0 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: 12px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.message.received {
  align-self: flex-start;
}

.message.sent {
  align-self: flex-end;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  position: relative;
}

.message.received .message-bubble {
  background-color: rgba(255, 255, 255, 0.05);
  border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  border-bottom-right-radius: 4px;
}

.message-bubble p {
  font-size: 0.95rem;
  line-height: 1.4;
}

.msg-time {
  font-size: 0.7rem;
  display: block;
  text-align: right;
  margin-top: 4px;
  opacity: 0.7;
}

.msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--secondary);
  cursor: pointer;
}

/* Chat Input */
.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--panel-border);
  background-color: rgba(15, 17, 21, 0.5);
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-input-area input {
  flex: 1;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 12px 20px;
  color: var(--text-main);
  transition: var(--transition);
}

.chat-input-area input:focus {
  border-color: var(--primary);
  background-color: rgba(0, 0, 0, 0.5);
}

.attachment-btn {
  font-size: 1.25rem;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ── Messages Responsive ── */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
    height: auto;
    min-height: unset;
  }

  .chat-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
    max-height: 280px;
  }

  .chat-window {
    min-height: 420px;
  }

  .chat-messages {
    padding: 16px;
  }

  .message {
    max-width: 88%;
  }

  .chat-input-area {
    padding: 12px 16px;
  }
}
