/* MESSAGES PAGE */

.page-messages {
  padding: 3rem 0;
}

/* Wrapper */
.messages-wrapper {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 2.5rem;
  height: 78vh;
}

/* Sidebar */
.messages-sidebar {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 22px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.conversation-list,
#conversations-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overflow-y: auto;
}

/* Single conversation item */
.conversation-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 1rem;
  transition: 0.25s ease;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-3px);
}

.conversation-item.active {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.25),
    rgba(118, 75, 162, 0.25)
  );
  border-color: rgba(102, 126, 234, 0.35);
  box-shadow: 0 12px 40px rgba(118, 75, 162, 0.25);
}

.conversation-text h4,
.card-title {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.conversation-text p,
.card-subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.8rem;
}

.conversation-time {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* Thread */
.messages-thread {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.thread-header {
  padding: 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.thread-sub {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
}

/* Body area */
.thread-body,
#messages-thread {
  flex: 1;
  padding: 1.6rem 1.7rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Message bubble layout */
.msg {
  display: flex;
  gap: 1rem;
  max-width: 75%;
}

.msg.sent {
  flex-direction: row-reverse;
  margin-left: auto;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.bubble {
  padding: 1rem 1.2rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.msg.received .bubble {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.msg.sent .bubble {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.25),
    rgba(118, 75, 162, 0.25)
  );
  border: 1px solid rgba(102, 126, 234, 0.35);
}

.time {
  font-size: 0.75rem;
  opacity: 0.55;
  margin-top: 0.4rem;
  text-align: right;
}

/* Input row */
.thread-input,
.messages-input-row {
  padding: 1.05rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 0.8rem;
}

.thread-input input,
.messages-input-row input {
  flex: 1;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 0.84rem;
  outline: none;
  transition: 0.25s;
}

.thread-input input:focus,
.messages-input-row input:focus {
  border-color: rgba(147, 51, 234, 0.6);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.25);
}

/* Responsive */
@media (max-width: 900px) {
  .messages-wrapper {
    grid-template-columns: 1fr;
    height: auto;
  }
}
