@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");

:root {
  --primary-color: #333;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f7f7f7;
  padding: 0 10px;
  transform: 0.5s;
}

.wrapper {
  background: #fff;
  max-width: 450px;
  width: 100%;
  border-radius: 16px;
  box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1),
    0 32px 64px -48px rgba(0, 0, 0, 0.5);
}

/* dark mode */
body.active .wrapper {
  background: #444; 
  color: #eee;       
  box-shadow: 0 0 10px rgba(0,0,0,0.6);
}

/* Chat messages */
body.active .chat-box {
  background: #555;
  color: #eee;
}

/* Message bubbles */
body.active .chat.outgoing .details, 
body.active .chat.incoming .details {
  background: #666;
  color: #fff;
}

/* Input fields */
body.active .input-field, 
body.active .input-file {
  background: #333;
  color: #eee;
  border: 1px solid #555;
}

/* Buttons */
body.active .button input[type="submit"], 
body.active .button button {
  background: #222;
  color: #eee;
}

/* Reaction bar & dropdown menu */
body.active .reaction-bar,
body.active .dropdown-menu {
  background: #333;
  color: #eee;
}

body.active a {
  color: #aaccff;
}

/* login & signup page */

.form {
  padding: 25px 30px;
}

.form header {
  font-size: 25px;
  font-weight: 600;
  padding-bottom: 10px;
  border-bottom: 1px solid #e6e6e6;
}

.form form {
  margin: 20px 0;
}

.form form .error-text {
  color: #721c24;
  padding: 8px 10px;
  text-align: center;
  border-radius: 5px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  margin-bottom: 10px;
  display: none;
}

.form form .name-details {
  display: flex;
}

.form .name-details .field:first-child {
  margin-right: 10px;
}

.form .name-details .field:last-child {
  margin-left: 10px;
}

.form form .field {
  display: flex;
  margin-bottom: 10px;
  flex-direction: column;
  position: relative;
}

.form form .field label {
  margin-bottom: 2px;
}

.form form .input input {
  height: 40px;
  width: 100%;
  font-size: 16px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid #ccc;
}

.form form .field input {
  outline: none;
}

.form form .image input {
  font-size: 17px;
}

.form form .button input {
  height: 45px;
  border: none;
  color: #fff;
  font-size: 17px;
  background: var(--primary-color);
  border-radius: 5px;
  cursor: pointer;
  margin-top: 13px;
}

.form form .field i {
  position: absolute;
  right: 15px;
  top: 70%;
  color: #ccc;
  cursor: pointer;
  transform: translateY(-50%);
}

.form form .field i.active::before {
  color: var(--primary-color);
  content: "\f070";
}

.form .link {
  text-align: center;
  margin: 10px 0;
  font-size: 17px;
}

.form .link a {
  color: var(--primary-color);
}

.form .link a:hover {
  text-decoration: underline;
}

.field.image {
  display: flex;
  flex-direction: column;
}

.field.image input[type="file"] {
  display: none;
}

.field.image label.custom-file-upload {
  background-color: #2e2e2e;
  color: #fff;
  padding: 10px 15px;
  border-radius: 5px;
  text-align: center;
  cursor: pointer;
  margin-top: 5px;
  transition: background-color 0.2s ease;
}

.field.image label.custom-file-upload:hover {
  background-color: #444;
}

#file-chosen {
  margin-top: 8px;
  font-size: 0.9em;
  color: #555;
}


/* Users page */

.users {
  padding: 25px 30px;
}

.users header,
.users-list a {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  justify-content: space-between;
  border-bottom: 1px solid #e6e6e6;
}

.wrapper img {
  object-fit: cover;
  border-radius: 50%;
}

:is(.users, .users-list) .content {
  display: flex;
  align-items: center;
}

.users header .content img {
  height: 50px;
  width: 50px;
}

:is(.users, .users-list) .details {
  margin-left: 15px;
  color: #000;
}

:is(.users, .users-list) .details span {
  font-size: 18px;
  font-weight: 500;
}

.users header .logout {
  color: #fff;
  font-size: 17px;
  padding: 7px 15px;
  background: var(--primary-color);
  border-radius: 10px;
}

.users header .status {
  border-radius: 16px;
  background: var(--primary-color);
  padding: 6px;
  color: #fff;
  margin: 15px;
  font-size: 14px;
}

.users .search {
  margin: 20px 0;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
}

.users .search .text {
  font-size: 18px;
}

.users .search input {
  position: absolute;
  height: 42px;
  width: calc(100% - 50px);
  border: 1px solid #ccc;
  padding: 0 13px;
  font-size: 16px;
  border-radius: 6px;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s ease;
}

.users .search input.active {
  opacity: 1;
  pointer-events: auto;
}

.users .search button {
  width: 47px;
  height: 42px;
  border: none;
  outline: none;
  color: var(--primary-color);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  border-radius: 0 5px 5px 0;
  transition: all 0.5s ease;
}

.users .search button.active {
  color: #fff;
  background: var(--primary-color);
}

.users .search button.active i::before {
  content: "\f00d";
}

.users-list {
  max-height: 350px;
  overflow-y: auto;
}

:is(.chat-box, .users-list)::-webkit-scrollbar {
  width: 0px;
}

.users-list a {
  margin-bottom: 10px;
  page-break-after: 10px;
  padding-right: 15px;
  border-bottom-color: #f1f1f1;
}

.users-list a:last-child {
  border: none;
  margin-bottom: 0px;
}

.users-list a .content img {
  height: 40px;
  width: 40px;
}

.users-list a .content p {
  color: #67676a;
}

.users-list a .status-dot {
  font-size: 12px;
  color: #468669;
}

.users-list a .status-dot.offline {
  color: #ccc;
}

/* Chat page */

.chat-area header {
  display: flex;
  align-items: center;
  padding: 18px 30px;
}

.chat-area header .back-icon {
  font-size: 18px;
  color: var(--primary-color);
}

.chat-area header img {
  height: 50px;
  width: 50px;
  margin: 0 15px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-area header span {
  font-size: 17px;
  font-weight: 500;
}

.chat-box {
  overflow-y: auto;
  height: 500px;
  background: #f7f7f7;
  padding: 10px 30px 20px 30px;
  box-shadow: inset 0 32px 32px -32px rgb(0 0 0 / 5%),
    inset 0 -32px 32px -32px rgb(0 0 0 / 5%);
}

.chat-box .chat {
  display: flex;
  align-items: flex-end;
  margin: 15px 0;
}

.chat-box .chat .details {
  max-width: calc(100% - 130px);
  display: flex;
  flex-direction: column;
}

.chat-box .chat .details p {
  padding: 8px 16px;
  word-wrap: break-word;
  box-shadow: 0 0 32px rgb(0 0 0 / 8%), 0 16px 16px -16px rgb(0 0 0 / 15%);
  border-radius: 18px;
  background: var(--primary-color);
  color: #fff;
}

.chat-box .chat .details img {
  margin-left: auto;
  padding: 10px;
  background: var(--primary-color);
  border-radius: 18px;
  max-width: 100%;
  object-fit: cover;
  box-shadow: 0 0 32px rgb(0 0 0 / 8%), 0 16px 16px -16px rgb(0 0 0 / 15%);
  cursor: pointer;
}

.chat-box .chat.incomming {
  justify-content: flex-start;
}

.chat-box .chat.outgoing {
  justify-content: flex-end;
}

.chat-box .chat.incomming .details p {
  background: #fff;
  color: var(--primary-color);
  border-radius: 18px 18px 18px 0px;
}

.chat-box .chat.incomming .details img {
  background: #fff;
  border-radius: 18px 18px 18px 0px;
}

.chat-area .typing-area {
  padding: 18px 30px 18px 40px;
  display: flex;
  justify-content: space-between;
}

.typing-area input#picture {
  display: none;
}

.typing-area label {
  padding: 4px 10px 0px 0px;
}

.typing-area input#msg {
  height: 45px;
  width: calc(100% - 130px);
  font-size: 17px;
  border: 1px solid #ccc;
  padding: 0 13px;
  border-radius: 5px 0 0 5px;
  outline: none;
}

.typing-area button {
  border-radius: 0px 5px 5px 0px;
  width: 55px;
  border: none;
  outline: none;
  background: var(--primary-color);
  font-size: 22px;
  cursor: pointer;
  color: #fff;
}

/* light dark switch */

body.active {
  background: #333;
}

#toggle {
  bottom: 300px;
  right: 160px;
  position: relative;
  display: block;
  width: 64px;
  height: 32px;
  border-radius: 16px;
  background: #222;
  transition: 0.5s;
  cursor: pointer;
  box-shadow: inset 0 8px 60px rgba(0, 0, 0, 0.1),
    inset 0 8px 8px rgba(0, 0, 0, 0.1), inset 0 -4px 4px rgba(0, 0, 0, 0.1);
}

#toggle.active {
  background: #fff;
  box-shadow: inset 0 2px 60px rgba(0, 0, 0, 0.1),
    inset 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 -4px 4px rgba(0, 0, 0, 0.05);
}

#toggle .indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  background: #ffffff;
  border-radius: 50%;
  transform: scale(0.9);
  transition: 0.5s;
}

#toggle.active .indicator {
  left: 32px;
  background: linear-gradient(to bottom, #eaeaea, #f9f9f9);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5),
    inset 0 4px 4px rgba(255, 255, 255, 0.2),
    inset 0 -4px 4px rgba(255, 255, 255, 0.2);
}

.reset_img {
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background-color 0.2s ease, transform 0.1s ease;
  position: relative;
  top: 120px;
  right: 80px;
  z-index: 999;
}

.reset_img:hover {
  background-color: #2a2e37;
}

.reset_img:active {
  transform: scale(0.98);
}

.btn_reset {
  display: none;
}

.chat-image {
  max-width: 100px;
  max-height: 130px;
  border-radius: 10px;
  margin-top: 5px;
  object-fit: cover;
  display: block;
}

.profile-pic {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 5px;
  cursor: pointer;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: opacity 0.3s ease;
}

.image-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.image-wrapper {
  position: relative;
  animation: zoomIn 0.3s ease;
}

.image-wrapper img {
  width: 400px;
  height: 400px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
  background: #fff;
}

.image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  color: white;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  cursor: pointer;
  padding: 12px;
  border-radius: 50%;
  z-index: 1001;
}

.image-nav.left {
  left: -60px;
}

.image-nav.right {
  right: -60px;
}

.download-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 18px;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.download-btn:hover {
  background-color: #e0e0e0;
  transform: scale(1.05);
}

.download-btn i {
  font-style: normal;
}


.image-wrapper:hover .download-btn {
  opacity: 1;
}

@keyframes zoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.delete-msg {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fff;
  border-radius: 50%;
  font-size: 12px;
  padding: 3px 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: none;
  cursor: pointer;
}

.details:hover .delete-msg {
  display: inline-block;
}

.details {
  position: relative;
}

/* delete modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  padding: 20px;
  width: 300px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
}

.modal-btn {
  display: block;
  width: 100%;
  background-color: #3d4451;
  color: #fff;
  border: none;
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}

.modal-cancel {
  margin-top: 10px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
}

.inline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #28c76f;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot {
  position: relative;
}

img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

img[loading="lazy"].loaded {
  opacity: 1;
}

img {
  opacity: 1;
}

/* edit message */

.details .edit-msg {
  display: none;
  cursor: pointer;
  font-size: 14px;
  color: #888;
}

.details:hover .edit-msg {
  display: inline-block;
}

.edit-inline-input {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 18px 18px 0 18px;
  padding: 8px 16px;
  font-size: 14px;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.08), 0 16px 16px -16px rgba(0, 0, 0, 0.15);
  outline: none;
  max-width: 100%;
  width: auto;
}

.message-wrap {
  position: relative;
}

.dropdown-container {
  position: absolute;
  top: 0;
  right: 0;
  display: none;
  z-index: 10;
}

.message-wrap:hover .dropdown-container {
  display: block;
}

.menu-trigger {
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  color: white;
  display: inline-block;
  line-height: 1;
  z-index: 10;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 20px;
  background-color: #2e2e2e;
  list-style: none;
  padding: 5px 0;
  margin: 0;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.dropdown-menu li {
  padding: 6px 12px;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

.dropdown-menu li:hover {
  background-color: #444;
}

.hidden {
  display: none !important;
}

/* Emoji button styling */
#emoji-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--primary-color);
  transition: transform 0.2s ease;
}

#emoji-btn:hover {
  transform: scale(1.2);
}

.emoji-picker-container {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

/* reactions */

.message-wrap {
  position: relative;
}

.reaction-bar {
  position: absolute;
  bottom: 100%;
  left: 10px;
  background: #2e2e2e;
  padding: 4px 8px;
  border-radius: 20px;
  display: flex;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.message-wrap:hover .reaction-bar,
.reaction-bar:hover {
  opacity: 1;
  pointer-events: auto;
}

.react-emoji {
  cursor: pointer;
  font-size: 18px;
  color: #fff;
  transition: transform 0.2s ease;
}

.react-emoji:hover {
  transform: scale(1.3);
}