/* ===================== GENERAL RESET ===================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: #36393f;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 10px;
  overflow: hidden;
}

/* ===================== CHAT APP CONTAINER ===================== */
.chat-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  height: 90vh;
  background-color: #2f3136;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  border: 1px solid #1c1c1c;
}

/* ===================== CHAT HEADER ===================== */
.chat-header {
  background-color: #202225;
  padding: 15px 20px;
  border-bottom: 1px solid #1c1c1c;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================== CHAT MESSAGES ===================== */
.chat-messages {
  flex: 1;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  background-color: #36393f;
  scroll-behavior: smooth;
  max-height: calc(100% - 130px);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: #202225;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background-color: #2f3136;
}

.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: #202225 #2f3136;
}

/* ===================== INDIVIDUAL MESSAGE ===================== */
.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.2s;
}

.message:hover {
  background-color: rgba(79, 84, 92, 0.2);
  border-radius: 5px;
}

/* ===================== AVATAR ===================== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #7289da url('https://fwrobby.site/images/nopfp.jpg') center/cover no-repeat;
  flex-shrink: 0;
  transition: border 0.2s;
}

.message:hover .avatar {
  border: 2px solid #fff;
}

/* ===================== MESSAGE CONTENT ===================== */
.message-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-header strong {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}

.timestamp {
  font-size: 11px;
  color: #b9bbbe;
  margin-left: 4px;
}

.message-text {
  background-color: #40444b;
  padding: 8px 12px;
  border-radius: 5px;
  max-width: 100%;
  word-wrap: break-word;
  color: #dcddde;
  font-size: 14px;
  margin-top: 2px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  overflow-wrap: break-word;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Hover effect for messages */
.message:hover .message-text {
  background-color: #4f545c;
}

/* ===================== INPUT AREA ===================== */
.chat-input {
  display: flex;
  padding: 10px;
  border-top: 1px solid #1c1c1c;
  background-color: #36393f;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

#messageInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background-color: #40444b;
  color: #dcddde;
  outline: none;
  font-size: 14px;
  transition: background 0.2s;
}

#messageInput:focus {
  background-color: #50555c;
}

#messageInput::placeholder {
  color: #b9bbbe;
}

#sendBtn {
  padding: 10px 20px;
  margin-left: 10px;
  border-radius: 8px;
  border: none;
  background-color: #40444b;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

#sendBtn:hover {
  background-color: #50555c;
}

#sendBtn:active {
  transform: scale(0.98);
}

/* ===================== INLINE CODE, EMOJI, MENTION ===================== */
.message-text code {
  background: rgba(220, 221, 222, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
}

.message-text span.mention {
  color: #00b0f4;
  font-weight: 600;
}

.message-text img.emoji {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

/* ===================== ADVANCED DISCORD STYLING ===================== */
.message.you .message-text {
  background-color: #3ba55d;
  color: white;
}

.chat-header {
  background: linear-gradient(90deg, #2c2f33, #202225);
}

.message-text {
  word-break: break-word;
}

/* ===================== MOBILE RESPONSIVENESS ===================== */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .chat-app {
    max-width: 100%;
    height: 95vh;
  }

  .chat-header h2 {
    font-size: 14px;
  }

  #sendBtn {
    padding: 10px 12px;
  }

  .chat-input {
    padding: 8px;
    bottom: 10px; /* 🔥 FIX: moved input slightly up */
    left: 0;
    right: 0;
    flex-wrap: wrap;
    background-color: #36393f;
    border-top: 1px solid #1c1c1c;
    position: sticky;
  }

  #messageInput {
    font-size: 13px;
  }

  .message-text {
    font-size: 13px;
    max-width: 90%;
  }

  .avatar {
    width: 35px;
    height: 35px;
  }

  .chat-messages {
    max-height: calc(95vh - 140px);
  }
}

/* ===================== BACKGROUND ANIMATION ===================== */
body {
  background: linear-gradient(270deg, #2f3136, #36393f, #2f3136);
  background-size: 600% 600%;
  animation: gradientFlow 20s ease infinite;
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===================== EXTRA TRANSITIONS & SHADOWS ===================== */
.message-text {
  transition: background 0.2s, color 0.2s;
}

#messageInput, #sendBtn {
  transition: background 0.2s, transform 0.1s;
}

.message:hover {
  transition: background 0.2s;
}

#messageInput::placeholder {
  color: #b9bbbe;
  font-style: italic;
}

.chat-input {
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* ===================== END OF STYLE.CSS ===================== */