/* === Layout container === */
.messages-container {
  display: flex;
  height: calc(100vh - 60px);
}

/* === Sidebar === */
.conversation-list {
  width: 250px;
  background: var(--background-color);
  border-right: 1px solid var(--border-color, #444);
  overflow-y: auto;
  padding: 20px;
  color: var(--text-color);
}

.conversation-list.hidden {
  display: none;
}

.conversation-list h2 {
  margin-bottom: 15px;
  color: var(--text-color);
}

.conversation-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.conversation-list li {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.conversation-list li:hover {
  background: var(--hover-color, rgba(255,255,255,0.05));
}

.conversation-list img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}

.conversation-list span {
  font-weight: 500;
}

/* === Chat window === */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--background-color);
  padding: 20px;
  color: var(--text-color);
}

.chat-window.hidden {
  display: none;
}

#chatTitle {
  margin-bottom: 15px;
  color: var(--text-color);
}

.messages-container-inner {
  flex: 1;
  overflow-y: auto;
  padding-right: 10px;
}

/* === Message bubble === */
.message-bubble {
  display: flex;
  align-items: flex-start;
  margin-bottom: 15px;
  max-width: 70%;
}

.message-bubble img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}

.message-bubble .message-content {
  background: var(--bubble-color, #f0f0f0);
  border-radius: 10px;
  padding: 10px 15px;
  color: var(--text-color);
}

.message-bubble.self {
  flex-direction: row-reverse;
  margin-left: auto;
}

.message-bubble.self img {
  margin-left: 10px;
  margin-right: 0;
}

.message-bubble.self .message-content {
  background: var(--self-bubble-color, #dcf8c6);
}

.message-content strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.message-content .time {
  display: block;
  font-size: 0.7rem;
  color: var(--muted-text, #888);
  margin-top: 4px;
}

/* === Input area === */
.message-input {
  display: flex;
  border-top: 1px solid var(--border-color, #444);
  padding: 10px;
  background: var(--background-color);
}

.message-input input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color, #444);
  border-radius: 20px;
  outline: none;
  font-size: 16px;
  background: var(--input-background, #1e1e1e);
  color: var(--text-color);
}

.message-input button {
  margin-left: 10px;
  padding: 0 20px;
  border: none;
  background: var(--primary-color);
  color: #fff;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 16px;
}

.message-input button:hover {
  background: var(--primary-color-hover);
}

/* === Footer === */
footer {
  text-align: center;
  padding: 10px;
  color: var(--text-color);
}

/* === Back button === */
.back-button {
  display: none;
}

@media (max-width: 768px) {
  .messages-container {
    flex-direction: column;
  }

  .conversation-list {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color, #444);
  }

  .conversation-list.hidden {
    display: none;
  }

  .back-button {
    display: inline-block;
    margin-bottom: 10px;
    cursor: pointer;
    color: var(--primary-color);
    font-weight: bold;
  }

  .chat-window {
    height: calc(100vh - 60px);
    padding-bottom: 70px;
  }

  .chat-window.hidden {
    display: none !important;
  }

  .message-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
  }
}

/* === Dark mode bubble override === */
[data-theme="dark"] .message-bubble .message-content {
  background: #2b2b2b;
}

[data-theme="dark"] .message-bubble.self .message-content {
  background: #076c47;
}
