/* Root container */
:root {
  --chat-bar-height: 46px;
}
@media (max-width: 900px) {
  :root {
    --chat-bar-height: 38px;
  }
}

.pulsegear-chat-thread-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 24px auto 40px auto;
  /* max-width: 900px; */
  background: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* Thread row as flex card */
.pulsegear-chat-thread-row {
  display: flex;
  align-items: stretch;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 16px rgba(30, 24, 54, 0.1),
    0 1.5px 3px rgba(30, 24, 54, 0.07);
  transition: box-shadow 0.18s, background 0.16s;
  text-decoration: none !important;
  color: #222;
  min-height: 96px;
  overflow: hidden;
  margin-bottom: 0;
}
.pulsegear-chat-thread-row:hover {
  background: #f7f4fd;
  box-shadow: 0 6px 32px rgba(30, 24, 54, 0.12),
    0 1.5px 6px rgba(30, 24, 54, 0.11);
}

/* Columns */
.thread-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 20px;
  min-width: 0;
}
/* Unread/read symbol column */
.unread-col {
  align-items: center;
  width: 42px;
  flex: 0 0 42px;
  font-size: 2em;
  justify-content: center;
  padding-right: 0;
  padding-left: 20px;
}
.pulsegear-chat-unread-dot {
  color: rgb(152, 56, 141);
}
.pulsegear-chat-read-dot {
  color: #e0e0e0;
}

/* Info column: store, category, preview */
.info-col {
  flex: 3 1 0;
  min-width: 0;
  align-items: flex-start;
}
.chat-thread-store {
  font-size: 1.13em;
  margin-bottom: 3px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chat-thread-category {
  font-size: 0.94em;
  color: #7a56c4;
  margin-bottom: 7px;
  margin-top: 0;
}
.chat-thread-preview {
  color: #555;
  font-size: 0.98em;
  margin-top: 2px;
  /* Testing the responsive updates */
  display: -webkit-box; /* create a flex-like box */
  -webkit-box-orient: vertical; /* vertical text flow */
  overflow: hidden; /* hide overflowed text */
  text-overflow: ellipsis; /* add "…" */
  -webkit-line-clamp: 1; /* default: one line */
  line-clamp: 1; /* newer spec */
  white-space: normal; /* allow wraps inside the clamp */
  word-break: break-word; /* prevent overflow on long words/links */
  max-height: 1.2em; /* safe height for one line */
}

/* Date/time column */
.date-col {
  align-items: flex-end;
  flex: 0 0 120px;
  padding-right: 20px;
  color: #888;
  font-size: 0.97em;
  justify-content: center;
  text-align: right;
  min-width: 100px;
  padding-left: 0;
}
.chat-thread-date {
  font-family: "Inter", Arial, sans-serif;
  font-size: 1em;
}

/* Product image column */
.img-col {
  align-items: center;
  justify-content: center;
  flex: 0 0 90px;
  min-width: 90px;
  max-width: 90px;
  padding: 0;
  border-radius: 0 14px 14px 0;
  overflow: hidden;
  display: flex;
}
.pulsegear-chat-product-thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 0 14px 14px 0;
  display: block;
  margin: 0;
  border: none;
  background: #fafafa;
}

/* Responsive: stack columns on mobile */
@media (max-width: 900px) {
  .pulsegear-chat-thread-list {
    max-width: 99vw;
    border-radius: 0;
    box-shadow: none;
  }
  .pulsegear-chat-thread-row {
    min-width: 0;
  }
  .img-col {
    min-width: 80px;
    max-width: 80px;
  }
  .pulsegear-chat-product-thumb {
    width: 80px;
    height: 80px;
    border-radius: 0 10px 10px 0;
  }
  .date-col {
    min-width: 80px;
    padding-right: 10px;
  }
  .info-col {
    padding-right: 10px;
  }
}
@media (max-width: 600px) {
  .pulsegear-chat-thread-row {
    flex-direction: column;
    min-height: 0;
    border-radius: 12px;
    box-shadow: 0 1.5px 6px rgba(30, 24, 54, 0.08);
  }
  .chat-thread-preview {
    -webkit-line-clamp: 2;
    line-clamp: 2;
    max-height: 2.8em;
  }
  .img-col {
    min-width: 100vw;
    max-width: 100vw;
    padding: 0;
    border-radius: 0 0 12px 12px;
    justify-content: flex-start;
  }
  .pulsegear-chat-product-thumb {
    width: 100vw;
    min-width: 100px;
    max-width: 100vw;
    border-radius: 0 0 12px 12px;
  }
  .date-col {
    align-items: flex-start;
    padding-right: 20px;
    text-align: left;
    min-width: 0;
    padding-left: 20px;
  }
  .info-col,
  .unread-col {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* --- Chat thread view (unchanged, kept from your original) --- */
.pulsegear-chat-thread-header {
  margin: 16px 0 8px 0;
  font-size: 1.12em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pulsegear-chat-thread-header a {
  color: #9e77ed;
  text-decoration: none;
  font-weight: 600;
  margin-right: 8px;
}

.pulsegear-chat-messages {
  /* background: #f7f7f7; */
  padding: 14px 8px 14px 8px;
  min-height: 220px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.pulsegear-chat-message {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  margin: 14px 0;
  max-width: 95vw;
}

.pulsegear-chat-message .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 10px 0 0;
  background: #eee;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pulsegear-chat-message .avatar img {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
  background: none !important;
  box-shadow: none !important;
  vertical-align: middle !important;
}

.pulsegear-chat-message .bubble-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 72vw;
  width: 100%;
}

.pulsegear-chat-message.sent .bubble-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end !important;
  max-width: 72vw;
  width: 100%;
}

.pulsegear-chat-message .bubble {
  padding: 10px 18px;
  border-radius: 0px 18px 18px 18px;
  /* background: #e2f0ff; */
  font-size: 1.03em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  min-width: 60px;
  max-width: 95%;
  word-break: break-word;
  background: #ececec; /* Slightly darker gray for received */
  color: #222;
}

.pulsegear-chat-message.sent .bubble {
  /* background: #dcf8c6; */
  border-radius: 18px 18px 0 18px;
  background: rgb(152, 56, 141);
  color: #fff;
}

.pulsegear-chat-message .meta {
  font-size: 0.8em;
  color: #333;
  text-align: left;
  width: 100%;
  margin: 4px 0px 2px 0px;
}

.pulsegear-chat-message.sent .meta {
  text-align: right !important;
}

.pulsegear-chat-message.sent {
  margin-left: 56px; /* leaves space for avatar on received */
  align-items: flex-end !important;
}

.pulsegear-chat-message .avatar {
  align-self: flex-start;
}

/* Reply form */
.pulsegear-chat-input-bar-container {
  width: 70%;
  margin: 28px auto 0 auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(30, 24, 54, 0.13),
    0 1.5px 3px rgba(30, 24, 54, 0.09);
  padding: 14px 18px 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pulsegear-chat-reply-form {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
}

@media (max-width: 900px) {
  .pulsegear-chat-input-bar-container {
    width: 95%;
  }
  .chat-attachment-preview {
    width: 99%;
  }
}

/* Uniform height for textarea and buttons */
.pulsegear-chat-reply-form textarea {
  flex: 1 1 auto;
  border-radius: 9px;
  border: 1.5px solid #d3c5e7;
  font-size: 1.08em;
  padding: 10px 13px;
  min-height: var(--chat-bar-height);
  max-height: 110px;
  height: var(--chat-bar-height);
  box-sizing: border-box;
  background: #faf6fb;
  color: #222;
  margin: 0;
  line-height: 1.4em;
  outline: none;
  resize: vertical;
  transition: border 0.2s;
}

.pulsegear-chat-reply-form textarea:focus {
  border-color: rgb(152, 56, 141);
  background: #fff;
}

/* Send button styling */
.chat-send-btn,
.chat-attach-btn {
  min-width: var(--chat-bar-height);
  height: var(--chat-bar-height);
  max-height: var(--chat-bar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 9px;
  border: none;
  margin: 0;
  box-sizing: border-box;
}
.chat-send-btn {
  background: rgb(152, 56, 141);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 1.07em;
  font-weight: 600;
  padding: 0 18px; /* Instead of e.g. 0 32px */
  min-width: 46px;
  height: var(--chat-bar-height, 46px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  box-sizing: border-box;
  transition: background 0.18s;
}

.chat-send-btn:hover,
.chat-send-btn:focus {
  background: rgb(152, 56, 141);
}

.pulsegear-chat-error {
  color: #b22;
  margin-top: 8px;
  font-size: 0.96em;
  width: 100%;
  display: block;
}

/* Chat Reply - Display Attachment */
.chat-attachment {
  display: inline-block;
  margin-top: 7px;
  margin-right: 10px;
}
.chat-attachment img {
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(30, 24, 54, 0.09);
  max-width: 120px;
  max-height: 120px;
  display: block;
}

/* Attaching an image */
.chat-attach-btn {
  background: #f1eaf7;
  color: rgb(152, 56, 141);
  font-size: 1.45em;
  transition: background 0.16s, color 0.16s;
}
.chat-attach-btn:hover,
.chat-attach-btn:focus {
  background: #e6d3ee;
  color: #a03883;
}
.chat-attach-btn span {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: 100%;
  height: 100%;
}
.chat-attach-btn input[type="file"] {
  display: none;
}

/* Responsive: input bar */
@media (max-width: 900px) {
  .pulsegear-chat-input-bar-container {
    width: 95%;
    padding: 10px 5px;
  }
  .pulsegear-chat-reply-form textarea {
    font-size: 1em;
  }
  .chat-send-btn,
  .chat-attach-btn {
    font-size: 1.04em;
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
  }
}

.chat-attachment-preview {
  margin-top: 10px;
  margin-bottom: 5px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  box-shadow: none;
}
.attachment-ready-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  width: 100%;
  font-size: 1.03em;
  border-radius: 8px;
  background: #f9f2fa;
}
.attachment-thumb {
  width: 60px;
  height: 40px;
  border-radius: 4px;
  background: #eee;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}
.attachment-filename {
  color: #222;
  flex: 1 1 auto;
  font-size: 0.98em;
  margin-right: 8px;
  word-break: break-all;
}
.attachment-remove {
  color: #c00;
  cursor: pointer;
  font-size: 1.35em;
  margin-left: 6px;
  transition: color 0.14s;
  font-weight: bold;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
}
.attachment-remove:hover {
  color: #fff;
  background: #d22;
}
