*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  flex-direction: column;
}

h1 {
  font-size: 2rem;
  margin-bottom: 20px;
  color: #bb86fc;
}

#username-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

#username {
  padding: 10px;
  border: 1px solid #6200ea;
  border-radius: 5px;
  background-color: #333;
  color: #fff;
  width: 200px;
}

#join-chat {
  padding: 10px 20px;
  background-color: #6200ea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#join-chat:hover {
  background-color: #3700b3;
}

#chat-container {
  width: 100%;
  max-width: 800px;
  background-color: #1f1f1f;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  gap: 20px;
  height: 80vh;
  padding: 10px;
  box-sizing: border-box;
  flex-wrap: nowrap;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* make online users a fixed sidebar but smaller and not force layout overflow */
#online-users {
  flex: 0 0 200px;
  width: 200px;
  border-left: 1px;
  padding-left: 10px;
  box-sizing: border-box;
}

.logo-img {
  max-width: 100px;
}

@media (max-width: 768px) {
  body {
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 60px;
  }

  .logo-img {
    max-width: 33.333px;
  }

  #toggle-online-users {
    display: block !important;
  }

  #chat-container {
    flex-direction: column;
    height: auto;
    gap: 10px;
    position: relative;
  }

  #online-users {
    display: none;
    width: 100%;
    border-left: none;
    border-top: 1px;
    padding-left: 0;
    padding-top: 10px;
    position: absolute;
    left: 0;
    background-color: #1f1f1f;
    z-index: 10000;
    height: 600px;
    width: 600px;
    overflow-y: auto;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }

  .chat-main {
    height: 80vh;
  }
}

#messages {
  list-style-type: none;
  padding: 10px;
  overflow-y: auto;
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

#messages li {
  background-color: #333;
  margin: 5px 0;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  opacity: 0;
  animation: fadeIn 0.5s forwards;
  position: relative;
  z-index: 0;
}

.message-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.username {
  font-weight: bold;
  color: #bb86fc;
  font-size: 0.95em;
}

.timestamp {
  font-size: 0.8em;
  color: #999;
  opacity: 0.8;
}

.message-content {
  color: #e0e0e0;
  line-height: 1.4;
}

/* ensure media and embeds stay within the message column */
.message-content img,
.message-content iframe {
  width: 300px;
  height: 300px;
  object-fit: cover;
  display: block;
  max-width: none;
}

@media (max-width: 768px) {
  .message-content img,
  .message-content iframe {
    width: 100%;
    height: auto;
    object-fit: contain;
  }
}

/* allow the chat main column to shrink inside the flex container */
.chat-main {
  min-width: 0;
}

.message-buttons {
  display: none;
  flex-direction: column;
  gap: 4px;
  background-color: #444;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  min-width: 80px;
  position: fixed !important;
}

.message-buttons button {
  padding: 6px 12px;
  font-size: 0.8em;
  background-color: #555;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: left;
}

.message-buttons button:hover {
  background-color: #666;
}

.sent {
  background-color: #6200ea;
  color: white;
  text-align: right;
}

.received {
  background-color: #03dac5;
  color: black;
  text-align: left;
}

.status {
  background-color: transparent;
  color: #999;
  font-style: italic;
  font-size: 0.85em;
  text-align: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

form {
  display: flex;
  padding: 10px;
  background-color: #121212;
  border-top: 1px solid #333;
  position: relative;
}

input {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid #6200ea;
  border-radius: 5px;
  background-color: #333;
  color: #fff;
  max-width: 350px;
}

button {
  padding: 10px;
  background-color: #6200ea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #3700b3;
}

.home-container {
  max-width: 800px;
  margin: 50px auto;
  padding: 20px;
  text-align: center;
}

.home-container h1 {
  color: #bb86fc;
  margin-bottom: 20px;
}

.home-container p {
  color: #e0e0e0;
  font-size: 18px;
  margin-bottom: 30px;
  line-height: 1.6;
}

.cta-button {
  display: inline-block;
  padding: 15px 30px;
  background-color: #6200ea;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-size: 16px;
  transition: background-color 0.3s;
  border: none;
  cursor: pointer;
}

.cta-button:hover {
  background-color: #3700b3;
}

.features {
  margin-top: 50px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  text-align: left;
}

.feature {
  padding: 20px;
  background-color: #1f1f1f;
  border-radius: 8px;
  border-left: 4px solid #6200ea;
}

.feature h3 {
  color: #bb86fc;
  margin-bottom: 10px;
}

.feature p {
  color: #e0e0e0;
  font-size: 14px;
  line-height: 1.5;
}

.image-upload-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #1f1f1f;
  margin: 15% auto;
  padding: 20px;
  border-radius: 8px;
  width: 300px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid #6200ea;
}

.close-modal {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transform: translateY(-10%);
}

.close-modal:hover {
  color: #e0e0e0;
}

#imageUploadForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#imageURL {
  padding: 10px;
  border: 1px solid #6200ea;
  border-radius: 5px;
  background-color: #333;
  color: #fff;
  width: 100%;
}

#imageUploadForm button {
  padding: 10px 16px;
  background-color: #6200ea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

#imageUploadForm button:hover {
  background-color: #3700b3;
}

.upload-button {
  padding: 10px;
  background-color: #6200ea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 10px;
  transition: background-color 0.3s;
  transform: translateX(30%);
}

.upload-button:hover {
  color: #bb86fc;
}

.img-center {
  transform: translateX(-10%);
}

.reply-info {
  font-size: 0.8em;
  color: #999;
  margin-bottom: 5px;
  padding-left: 10px;
  border-left: 2px solid #6200ea;
}

#reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #1f1f1f;
  border: none;
  margin-bottom: 8px;
}

#reply-preview #reply-text {
  color: #cfcfcf;
  font-size: 0.85em;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cancel-reply-btn {
  background: transparent;
  border: none;
  color: #bb86fc;
  font-weight: 600;
  cursor: pointer;
}

#cancel-reply-btn:hover {
  color: #fff;
}

#reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 56px;
  z-index: 10003;
  border-radius: 8px;
  max-width: 600px;
  width: calc(100%);
  transform: translateX(-50%) translateY(-10%);
  background: linear-gradient(180deg, #6200ea, #1f1f1f);
  border: 1px solid #6200ea;
}

#reply-preview #reply-text {
  color: #e0e0e0;
  font-size: 0.9em;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cancel-reply-btn {
  background: transparent;
  border: none;
  color: #bb86fc;
  font-weight: 600;
  cursor: pointer;
}

#cancel-reply-btn:hover {
  color: #fff;
}

.input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
}

.input-wrapper input[type="password"],
.input-wrapper input[type="text"] {
  flex-grow: 1;
  box-sizing: border-box;
}

.input-wrapper button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-wrapper button img {
  width: 20px;
  height: 20px;
}

.zoom-modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
}

.zoom-modal-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transform-origin: center center;
}

.close-zoom {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}

.zoom-slider {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  max-width: 300px;
  cursor: pointer;
}

.gif-button {
  transform: translateX(10%);
}

.klipy-modal {
  display: none;
  position: fixed;
  z-index: 10002;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

#klipy-search {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #6200ea;
  border-radius: 5px;
  background-color: #333;
  color: #fff;
}

#klipy-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  height: 300px;
  overflow-y: auto;
}

#klipy-results img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  cursor: pointer;
  border-radius: 5px;
}

.close-klipy-modal {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-klipy-modal:hover {
  color: #e0e0e0;
}

.more-actions {
  position: relative;
}

.plus-btn {
  display: none;
  width: 50px;
  height: 50px;
  font-size: 25px;
  line-height: 25px;
  padding: 10px;
  text-align: center;
}

.more-actions-buttons {
  display: flex;
  transform: translateX(15%);
}

.send-button{
  gap : 8px;
  padding-left: 8px;
  padding-right: 8px;
}

@media (max-width: 768px) {

  .send-button{
    gap : 8px;
    padding-left: 8px;
    padding-right: 8px;
    transform: translateX(-50%);
  }

  .plus-btn {
    display: block;
  }

  .more-actions-buttons {
    display: none;
    position: absolute;
    bottom: 100%;
    right: auto;
    left: auto;
    flex-direction: column-reverse;
    padding: 8px;
    background-color: #2a2a2a;
    border: 1px solid #6200ea;
    border-radius: 5px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
    margin-bottom: 10px;
    z-index: 10001;
    /*align-items: center;*/
    transform: translateX(-20%);
  }

  .more-actions.active .more-actions-buttons {
    display: flex;
  }

  .more-actions-buttons button {
    margin-top: 10px;
    transition: all 0.2s ease-out;
    opacity: 0;
    transform: translateY(10px) translateX(50%);
  }

  .more-actions.active .more-actions-buttons button {
    opacity: 1;
    transform: translateY(0);
  }

  .more-actions.active .plus-btn {
    background-color: #7f39fb;
  }
}
