/* ===========================
   BASE STYLES
=========================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
  background: #f2f2f2;
  height: 100%;
  overflow: hidden;
}

.app {
  display: flex;
  height: calc(var(--vh, 1vh) * 100);
}

/* ===========================
   SIDEBAR (Dark Mode)
=========================== */
.sidebar {
  width: 260px;
  background-color: #333;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  padding: 0;
  color: #fff;
  height: calc(var(--vh, 1vh) * 100);
}

/* Sticky Brand */
.sidebar .brand {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  padding: 12px 14px;
  border-bottom: 1px solid #222;
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #333;
}

/* Scrollable middle part */
.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  min-height: 0;
}

/* Sections */
.sidebar .section {
  margin-bottom: 26px;
}

.sidebar .section h3 {
  font-size: 16px;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
  margin: 0 0 10px 10px;
  border-left: 4px solid #367fa9;
  padding-left: 8px;
  letter-spacing: 0.6px;
}

/* List container */
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* List items */
.sidebar ul li {
  font-size: 17px;
  padding: 10px 14px;
  margin: 3px 0;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.25s ease;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Hover and active states */
.sidebar ul li:hover {
  background-color: #555;
}

.sidebar ul li.active {
  background-color: #367fa9;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  border-left: 4px solid #0056b3;
}

/* Logout sticky */
.logout-section {
  padding: 12px;
  border-top: 1px solid #222;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background-color: #333;
}

.logout-section button {
  width: 100%;
  background: #d9534f;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.3s;
}

.logout-section button:hover {
  background: #c9302c;
}

.logout-section button:disabled {
  background: #555;
  cursor: not-allowed;
}

/* ===========================
   CHAT AREA
=========================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  height: calc(var(--vh, 1vh) * 100);
}

.chat-header {
  padding: 12px;
  border-bottom: 1px solid #eee;
  font-weight: 700;
  background: #367fa9;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.back-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #fff;
  display: none;
}

/* Messages */
.messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: inline-block;
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 14px;
  background: #e9eef8;
  word-wrap: break-word;
  position: relative;
  margin: 6px 0;
  align-self: flex-start;
}

.message.me {
  background: #d1f0d1;
  align-self: flex-end;
}

.message-header {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #555;
}

.message-body {
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  
}

.message-time {
  font-size: 10px;
  color: #888;
  text-align: right;
  margin-top: 2px;
}

.badge {
  background: red;
  color: white;
  font-size: 11px;
  border-radius: 10px;
  padding: 2px 6px;
  margin-left: 6px;
}

/* Composer */
.composer {
  display: flex;
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.composer input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-right: 8px;
}

.composer button {
  padding: 10px 14px;
  border: none;
  background: #367fa9;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.composer textarea {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-right: 8px;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

/* ===========================
   MOBILE RESPONSIVENESS
=========================== */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    height: calc(var(--vh, 1vh) * 100);
    border-right: none;
    border-bottom: 1px solid #222;
    position: absolute;
    top: 0;
    left: 0;
    background: #333;
    z-index: 10;
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
  }

  .sidebar-inner {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  .chat-main {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    transition: height 0.25s ease;
    position: relative;
   }

   

   .chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #367fa9;
    color: #fff;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px; /* fixed height */
  }

  /* Fixed composer/input bar at bottom */
  .composer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
  }

  /* Messages container with top/bottom margin equal to header/composer height */
  .messages {
    margin-top: 50px;   /* same as header height */
    margin-bottom: 60px; /* same as composer height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth scroll for iOS */
  }
}

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

  .messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
   
  }

  .composer input,
  .composer button {
    font-size: 14px;
  }

  .back-btn {
    display: inline-block;
  }

  /* Sidebar sticky in mobile */
  .sidebar .brand {
    position: sticky;
    top: 0;
    background-color: #333;
    z-index: 20;
  }

  .logout-section {
    position: sticky;
    bottom: 0;
    background-color: #333;
    z-index: 20;
    border-top: 1px solid #222;
  }
}


/* ===========================
   FILE UPLOAD PREVIEW (WhatsApp Style)
=========================== */
/* ===========================
   WHATSAPP STYLE ATTACH BUTTON & COMPOSER
=========================== */

/* Attach button */
.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #367fa9; /* WhatsApp green */
  color: #fff;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s;
  margin-right: 6px;
}

.attach-btn:hover {
  background-color: #367fa9;
}

/* File Preview Container */
#filePreviewContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  padding-left: 10px;
}

#filePreviewContainer > div {
  display: flex;
  align-items: center;
  border-radius: 10px;
  padding: 4px 6px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  position: relative;
  max-height: 60px;
  gap: 4px;
}

#filePreviewContainer img {
  height: 50px;
  width: auto;
  border-radius: 6px;
  object-fit: cover;
}

#filePreviewContainer span {
  cursor: pointer;
  font-size: 12px;
  color: #555;
}

/* Composer adjustments */
.composer {
  display: flex;
  align-items: center;
  gap: 6px;
}

.composer textarea {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 20px;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  min-height: 40px;
}

.composer button {
  padding: 10px 14px;
  border: none;
  background: #367fa9;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.composer button:hover {
  background: #367fa9;
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
  .composer textarea {
    min-height: 36px;
  }

  #filePreviewContainer > div {
    max-height: 50px;
    padding: 3px 4px;
  }

  #filePreviewContainer img {
    height: 40px;
  }
}

.chat-image {
  max-width: 200px !important;
  max-height: 200px;
  border-radius: 6px;
  margin-top: 5px;
  cursor: pointer;
}

.file-link {
  display: inline-block;
  color: #007bff;
  text-decoration: none;
  margin-top: 4px;
  font-size: 14px;
}

.file-link:hover {
  text-decoration: underline;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 260px;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  background: #fff;
  transition: transform 0.1s ease;
}

.file-card:hover {
  transform: scale(1.02);
}

/* WhatsApp-style for PDF */
.pdf-card {
  background: #fff4f4;
  border: 1px solid #f3cfcf;
}

/* DOC / XLS / ZIP optional styles */
.doc-card { background: #f2f6ff; border: 1px solid #cddcff; }
.xls-card { background: #f3fff3; border: 1px solid #c9efc9; }
.zip-card { background: #fffaf3; border: 1px solid #f5e3c5; }

.file-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-icon-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

.file-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.3;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  color: #222;
  margin-bottom: 2px;
  word-break: break-word;
}

.file-open {
  font-size: 12px;
  color: #007bff;
  text-decoration: none;
}

.file-open:hover {
  text-decoration: underline;
}

.message.uploading {
    opacity: 0.6;
    font-style: italic;
}

.message.uploading .loader {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg);}
    100% { transform: rotate(360deg);}
}










/* === Image Preview Modal === */
#imageModal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#imageModal.show {
    display: flex;
}

#imageModal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
}

#imageModal .modal-content {
    position: relative;
    z-index: 2;
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.25s ease-in-out;
}

#imageModal img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
}

/* Optional: fade-in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}


.file-card.pdf-preview {
  display: flex;
  align-items: center;
  background-color: #a6cfae;
  padding: 8px;
  border-radius: 10px;
  margin-top: 4px;
}

.file-card .file-icon {
  width: 40px;
  height: 40px;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-card .file-icon img {
  width: 24px;
  height: 24px;
}

.file-card .file-info {
  display: flex;
  flex-direction: column;
}

.file-card .file-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.file-card .file-hint {
  font-size: 0.75rem;
  color: #666;
}

.file-card a.file-open {
  font-size: 0.75rem;
  color: #1a73e8;
  text-decoration: none;
  margin-top: 2px;
}


/* ================= MENTION POPUP STYLES ================= */
.mention-popup {
  position: absolute;
  bottom: 60px; /* above composer */
  left: 20px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  max-height: 200px;
  overflow-y: auto;
  width: 250px;
  z-index: 1000;
  font-size: 14px;
}

.mention-item {
  padding: 8px 10px;
  cursor: pointer;
}

.mention-item:hover {
  background: #f0f0f0;
}

/* mobile responsive popup position */
@media (max-width: 768px) {
  .mention-popup {
    bottom: 80px;
    left: 10px;
    width: calc(100% - 20px);
  }
}







.file-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  background: #f3f7ff;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.file-preview:hover {
  background: #e5edff;
}
.file-icon-img {
  width: 28px;
  height: 28px;
}
.file-name {
  font-weight: 500;
  color: #222;
}

/* arrow position and style */
.section-header {
  position: relative;
  padding-left: 18px; /* space for arrow on left */
}

.section-header .toggle-icon {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #999; /* adjust if needed */
  transition: transform 0.2s ease;
}

/* rotate arrow when collapsed */
.section-header.collapsed .toggle-icon {
  transform: translateY(-50%) rotate(-90deg);
}


.section-header {
  position: relative;
  padding-left: 18px; /* space for arrow */
}

.section-header .toggle-icon {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
}


.reply-preview {
    background: #e9edf0;
    padding: 6px 10px;
    border-left: 3px solid #008069;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.hidden { display: none; }




.chat-message {
    position: relative;
}




body, html {
    overflow-x: hidden !important;
}
.chat-container {
    overflow-x: hidden !important;

}

.chat-message {
    max-width: 80%;
    word-wrap: break-word;

  }

.reply-block {
    background: #e5e5e5;
    border-left: 3px solid #00a884;
    padding: 4px 8px;
    margin-bottom: 6px;
    border-radius: 5px;
    font-size: 12px;
    max-width: 250px;
}

.reply-text {
    color: #333;
}

.reply-author {
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 2px;
    color: #555;
}
.message {
    position: relative;
}

/* Reply icon hidden by default */
/* .reply-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #008069;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    transition: 0.2s ease-in-out;
} */

.reply-box {
    background: #e9e9e9;
    padding: 6px 10px;
    border-left: 4px solid #888;
    border-radius: 6px;
    margin-bottom: 6px;
    max-width: 100%;
    word-wrap: break-word;
}

.reply-label {
    font-size: 12px;
    color: #555;
    font-weight: bold;
}

.reply-text {
    font-size: 13px;
    color: #333;
}

/* LEFT SIDE MESSAGES (others) → reply icon on RIGHT */
.message:not(.me) .reply-btn {
    right: -28px;
    left: auto;
}

/* RIGHT SIDE MESSAGES (your messages) → reply icon on LEFT */
.message.me .reply-btn {
    left: -28px;
    right: auto;
}
/* Show on hover (desktop) */
.message:hover .reply-btn {
    opacity: 1;
}

.hidden {
    display: none !important;
}
#reply-preview{
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #d4d5d6;
    /* border-left: 4px solid #008069; */
    padding: 8px 10px;
    /* margin-bottom: 8px; */
    border-radius: 6px;
    max-width: 100%;
    font-size: 14px;
}

#reply-preview-text {
    flex: 1;
    color: #333;
    word-break: break-word;
}

#close-reply {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    margin-left: 10px;
    color: #555;
}



/* Mobile (≤768px) */
@media screen and (max-width: 768px) {

  /* Reply preview above input */
  #reply-preview {
    position: fixed;
    bottom: 60px; /* above keyboard + send button */
    left: 0;
    right: 0;
    background: #f0f0f0;
    border-left: 4px solid #25d366;
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
  }

  #reply-preview p {
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
  }

  #close-reply {
    font-size: 18px;
    padding: 5px;
    cursor: pointer;
  }

  /* Make reply button bigger for touch */
  .reply-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 20px;
    background: #008069;
    color: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
  }

  /* Input adjustments */
  #msg {
    max-height: 120px;
    overflow-y: auto;
    font-size: 14px;
  }

  /* Messages container full height minus header & input */
  #messages {
    height: calc(100vh - 130px); /* adjust if header/input height differs */
    overflow-y: auto;
  }

  /* Sidebar/chat toggle */
  #chatMain {
    display: none;
  }
  #sidebar {
    display: flex;
  }
  #backBtn {
    display: none;
  }
}

.reply-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reply-file-icon {
    width: 22px;
    height: 22px;
}

.reply-file-name {
    font-size: 14px;
    font-weight: 500;
    color: #444;}



 .reply-bubble-image {
    width: 60px;          /* fixed width */
    height: 60px;         /* fixed height */
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reply-bubble-image img.reply-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;    /* crop like normal image upload */
    border-radius: 6px;
}


.message {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.message.active {
  background-color: #0056b3; /* Optional visual feedback for long press */
}

.message {
    -webkit-user-select: text;
    user-select: text;
}

.message {
    position: relative;
}


.delete-popup {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.delete-popup.hidden {
    display: none;
}

.delete-popup-box {
    background: white;
    padding: 20px 25px;
    border-radius: 10px;
    text-align: center;
    width: 300px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.delete-popup-box button {
    margin: 10px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#delete-yes {
    background: #c62828;
    color: white;
}

#delete-no {
    background: #ddd;
}

/* Message container */
.message {
    position: relative;
}

/* Reply button (left side) */
.message:hover .reply-btn,
.message:hover .delete-btn {
    opacity: 1;
}

.reply-btn, .delete-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #008069;
    color: #fff;
    border: 1px solid #ccc;
    width: 26px;
    height: 26px;
    font-size: 12px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: 0.2s ease-in-out;
}

/* Position individually */
.reply-btn {
    left: -40px;
    opacity: 0; /* If you want fade-in on hover */
}

.delete-btn {
    left: -80px;
    opacity: 0; /* If you want fade-in on hover */
}

