/* GLOBAL STYLES */
body {
  font-family: "Inter", Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.3s ease;
  box-sizing: border-box;
}

/* LIGHT THEME */
body.light {
  --bg: #f5f5f5;
  --bg2: #ffffff;
  --text: #000000;
  --bubble-me: #d1eaff;
  --bubble-other: #ececec;
  --accent: #007bff;
}

/* DARK THEME */
body.dark {
  --bg: #121212;
  --bg2: #1e1e1e;
  --text: #e5e5e5;
  --bubble-me: #2F5EC4;
  --bubble-other: #6D2FC4;
  --accent: #2F5EC4;
  --bubble-text: #ffffff;
  --username-color: #CCCCCC;
}

#main-container {
  height: calc(100% - 60px); /* header height */
  width: 90vw;
  max-width: 1200px;
}

/* PRIVATE CHAT PANEL */
#private-chat-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
}

#privateChatsList button {
  width: 100%;
  text-align: left;
  margin-bottom: 6px;
}

/* CHAT APP CONTAINER */
#chat-app {
  width: 90vw;
  max-width: 1200px;
  height: 80vh;
  max-height: 800px;
  background: var(--bg2);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 25px rgba(0,0,0,0.25);
}

/* HEADER */
#header {
  padding: 14px 18px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(128,128,128,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#header h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

#right-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

#themeToggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

/* REACTIONS CONTAINER */
.msg .reactions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}

.msg .reaction {
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(0,0,0,0.05);
  transition: 0.2s;
}

body.dark .msg .reaction {
  background: rgba(255,255,255,0.1);
}

.msg .reaction:hover {
  transform: scale(1.2);
}

/* MESSAGES AREA */
#messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
}

.msg {
  margin-bottom: 12px;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  transform: translateY(10px);
  opacity: 0;
  animation: pop 0.15s forwards ease-out;
  position: relative;
}
/* IMAGE MESSAGES */
.msg img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 12px;
  display: block;
  margin-top: 5px;
}

/* GIF/STICKER MESSAGES */
.msg .sticker {
  max-width: 150px;
  max-height: 150px;
  border-radius: 12px;
  display: block;
  margin-top: 5px;
}

@keyframes pop {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* MESSAGE BUBBLES - LIGHT MODE */
body.light .msg.me {
  background: var(--bubble-me);
  margin-left: auto;
  color: var(--text);
}

body.light .msg.other {
  background: var(--bubble-other);
  margin-right: auto;
  color: var(--text);
}

/* MESSAGE BUBBLES - DARK MODE WITH GRADIENTS */
body.dark .msg.me {
  background: linear-gradient(135deg, #2F5EC4, #4CA3FF);
  margin-left: auto;
  color: var(--bubble-text);
}

body.dark .msg.other {
  background: linear-gradient(135deg, #6D2FC4, #9B59B6);
  margin-right: auto;
  color: var(--bubble-text);
}

/* USERNAME */
.msg .name {
  font-weight: bold;
  margin-bottom: 5px;
  display: block;
  color: var(--username-color);
}

/* REPLY PREVIEW */
#reply-preview {
  font-size: 14px;
  margin-bottom: 5px;
  padding: 5px 10px;
  border-left: 3px solid var(--accent);
  background: rgba(0,0,0,0.05);
  border-radius: 5px;
}

#reply-preview button {
  padding: 0 5px;
  font-size: 14px;
  line-height: 1;
}

/* INPUT AREA */
#input-area {
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  padding: 10px;
  border-top: 1px solid rgba(128,128,128,0.2);
}

#msgInput {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(128,128,128,0.3);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

#msgInput::placeholder {
  color: rgba(128,128,128,0.6);
}

/* SEND BUTTON */
#sendBtn {
  margin-top: 5px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 17px;
  transition: 0.2s;
}

#sendBtn:hover {
  opacity: 0.8;
}

/* REPLY BUTTON ON MESSAGE */
.msg .reply-btn {
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-size: 12px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
}

body.light .msg .reply-btn {
  color: rgba(0,0,0,0.5);
}
