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

:root {
  --sidebar: #ffffff;
  --header: #f0f2f5;
  --chat-bg: #efeae2;
  --input: #ffffff;
  --text: #111b21;
  --secondary: #667781;
  --border: #e9edef;
  --hover: #f0f2f5;
  --received: #ffffff;
  --received_others: rgb(228, 228, 228);
  --sent: #d9fdd3;
  --green: #00a884;
}

/* ================= DARK THEME ================= */

body.dark {
  --sidebar: #111b21;
  --header: #202c33;
  --chat-bg: #0b141a;
  --input: #202c33;
  --text: #e9edef;
  --secondary: #d3d2ca;
  --border: #2a3942;
  --hover: #202c33;
  --received: #202c33;
  --sent: #005c4b;
}

/* ================= BODY ================= */

body {
  font-family: Arial, Helvetica, sans-serif;
  background: #d1d7db;
  color: var(--text);
  overflow: hidden;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--secondary);
}

/* ================= APP ================= */

.app {
  width: 100%;
  height: calc(100vh - 5px);
  display: flex;
}

/* ================= SIDEBAR ================= */

.sidebar {
  width: 380px;
  /* height: 100vh; */
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* ================= SIDEBAR HEADER ================= */

.sidebar-header {
  height: 68px;
  padding: 10px 14px;
  background: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ================= AVATAR ================= */

.avatar,
.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid #ccc;
  overflow: hidden;
  flex-shrink: 0;
  /* background: #fff; */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.avatar img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar {
  width: 44px;
  height: 44px;
}

/* ================= HEADER ICONS ================= */

.header-icons {
  display: flex;
  gap: 20px;
}

.header-icons button {
  font-size: 22px;
}

/* ================= SEARCH ================= */

.search-box {
  height: 60px;
  padding: 10px 0px 10px 10px;
  display: flex;
  align-items: center;
  background: var(--sidebar);
}

.search-box span {
  margin-right: -35px;
  position: relative;
  z-index: 2;
}

.search-box input {
  width: 100%;
  height: 40px;
  border: none;
  outline: none;
  border-radius: 20px;
  margin-left: 10px;
  padding-left: 35px;
  padding-right: 15px;
  background: var(--header);
  color: var(--text);
  font-size: 14px;
}

.search-box input::placeholder {
  color: var(--secondary);
}

/* ================= CHAT LIST ================= */

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat {
  /* height: 80px; */
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.chat:hover,
.chat.active {
  background: var(--hover);
}

.chat-details {
  flex: 1;
  min-width: 0;
}

.chat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-row h3 {
  font-size: 16px;
  font-weight: 500;
}

.chat-row span {
  font-size: 12px;
  color: var(--secondary);
}

.chat-details p {
  margin-top: 0px;
  margin-bottom: 0px;
  color: var(--secondary);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-details p.processing {
    color: var(--green);
    font-weight: 600;
}

/* ================= CHAT AREA ================= */

.chat-area {
  flex: 1;
  min-width: 0;
  /* height: calc(100vh -5px); */
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
}

/* ================= CHAT HEADER ================= */

.chat-header {
  height: 68px;
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--header);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user .avatar {
  width: 44px;
  height: 44px;
}

.header-user h3 {
  font-size: 16px;
  font-weight: 500;
}

.header-user span {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  color: var(--secondary);
}

/* ================= CHAT ACTIONS ================= */

.chat-actions {
  display: flex;
  gap: 20px;
}

.chat-actions button {
  /*font-size: 23px;*/
}

/* ================= BACK BUTTON ================= */

.back-button {
  display: none;
  font-size: 27px;
}

/* ================= MESSAGES ================= */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 25px 7%;
}

.message {
  width: fit-content;
  max-width: 65%;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 5px;
  color: var(--text);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  position: relative;
}

.message p {
  font-size: 14px;
  line-height: 20px;
  word-break: break-word;
  margin-bottom: 6px;
}

.message-time {
  display: block;
  text-align: right;
  margin-top: 3px;
  font-size: 10px;
  color: var(--secondary);
}

.delivery-status-tick {
  color: #bbb;
  display: inline-flex;
  width: auto;
  height: auto;
}

.delivery-status-tick.read {
  color: rgb(11, 157, 241);
}

.delivery-status-tick.failed {
  color: rgb(241, 57, 11);
}

.received {
  background: var(--received);
  margin-right: auto;
  border-top-left-radius: 0px;
}

.received:before {
  content: '';
  display: inline-block;
  left: -8px; /* Distance to the left of the element */
  top: 9px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 10px solid rgb(255, 255, 255);
  position: absolute;
  /* top: 0px;
    right: -0px; */
}

.interactive {
  background: var(--received_others);

}
.sent {
  background: var(--sent);
  margin-left: auto;
  border-top-right-radius: 0px;
}

.sent:before {
  content: '';
  display: inline-block;
  right: -112%; /* Distance to the left of the element */
  top: 9px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid var(--sent);
  position: absolute;
  /* top: 0px; */
  right: -8px;
}

.template {
  background: rgb(230, 236, 248);
}
/* ================= MESSAGE INPUT ================= */

.message-input {
  min-height: 68px;
  padding: 10px 15px;
  /* position: relative;
  right: 0px;
  bottom: 0px;
  width: 100% ; */
  background: var(--header);
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-input > button {
  font-size: 22px;
}

.message-input input {
  flex: 1;
  height: 44px;
  border: none;
  outline: none;
  border-radius: 20px;
  padding: 0 15px;
  background: var(--input);
  color: var(--text);
  font-size: 15px;
}

.message-input input::placeholder {
  color: var(--secondary);
}

.send-button {
  width: 42px;
}

/* ================= PHOTO PREVIEW ================= */

.photo-preview {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.photo-preview.show {
  display: flex;
}

.photo-preview img {
  width: min(450px, 80vw);
  height: min(450px, 80vw);
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid white;
}

.photo-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 38px;
  cursor: pointer;
}

/* ================= SCROLLBAR ================= */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #9ca3a8;
  border-radius: 10px;
}

/* ================= MOBILE ================= */

@media (max-width: 768px) {
  body {
    background: var(--sidebar);
  }

  .sidebar {
    width: 100%;
  }

  .chat-area {
    display: none;
    width: 100%;
    /* height: 100vh; */
  }

  .sidebar.mobile-hidden {
    display: none;
  }

  .chat-area.mobile-open {
    display: flex;
  }

  .back-button {
    display: block;
  }

  .messages {
    padding: 20px 4%;
  }

  .message {
    max-width: 82%;
  }

  .chat-actions {
    gap: 12px;
  }
}

/* ================= SMALL MOBILE ================= */

@media (max-width: 480px) {
  .chat {
    height: 75px;
  }

  .message-input {
    padding: 8px;
    position: relative;
    right: 0px;
  bottom: 0px;
  width: 100% ;
  }

  .message-input input {
    font-size: 14px;
  }
}
