/* ============================================================
   Rsale Chat & Offer Negotiation Styles
   ============================================================ */

/* Chat Inbox List */
.chat-inbox-header {
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
}
.inbox-tabs {
  display: flex;
  gap: 12px;
  border-bottom: 2px solid var(--border-light);
}
.inbox-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.inbox-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.chat-thread-list {
  background: #fff;
  display: flex;
  flex-direction: column;
}
.chat-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
.chat-thread-item:hover {
  background: #f8fafb;
}
.chat-thread-item.unread {
  background: #f0f7f7;
}

.chat-avatar-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.chat-user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #cfd8dc;
}
.chat-item-thumb {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid #fff;
  object-fit: cover;
}

.chat-thread-info {
  flex: 1;
  min-width: 0;
}
.chat-thread-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.chat-thread-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.chat-thread-time {
  font-size: 11px;
  color: var(--text-muted);
}
.chat-thread-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-last-msg {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-item.unread .chat-thread-last-msg {
  color: var(--text-primary);
  font-weight: 700;
}

/* --- Active Chat Window --- */
.chat-window {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  background: #f8fafb;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  animation: slideInRight 0.25s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.chat-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.chat-back-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.chat-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-header-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.chat-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}
.chat-header-status {
  font-size: 11px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header-actions {
  display: flex;
  gap: 6px;
}

/* Chat Item Bar (Sticky below chat header) */
.chat-item-bar {
  background: #ffffff;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chat-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.chat-item-pic {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-item-meta {
  overflow: hidden;
}
.chat-item-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-price {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}
.btn-make-offer {
  background: var(--accent);
  color: var(--primary);
  border: none;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 18px;
  cursor: pointer;
  white-space: nowrap;
}

/* Scam Warning Banner (Safety & Moderation) */
.scam-warning-banner {
  background: #fff8e1;
  border: 1px solid #ffe082;
  color: #8d6e00;
  padding: 8px 12px;
  margin: 10px 14px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.scam-warning-banner svg {
  color: #f57f17;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Message Feed */
.chat-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
  margin: 6px 0;
}
.chat-messages::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}
.chat-messages::-webkit-scrollbar-button {
  display: none !important;
  width: 0;
  height: 0;
}

.message-bubble {
  width: fit-content;
  max-width: 78%;
  min-width: 68px;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
  text-align: left;
  display: flex;
  flex-direction: column;
}
.message-bubble .message-text {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
}
.message-bubble.incoming {
  align-self: flex-start;
  background: #ffffff;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-left: 2px;
}
.message-bubble.outgoing {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 102, 255, 0.25);
  margin-right: 6px;
}

.message-meta {
  font-size: 10px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0.75;
  user-select: none;
}

/* --- Make an Offer Card Inside Chat --- */
.offer-card {
  align-self: center;
  width: 90%;
  max-width: 320px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--accent);
  box-shadow: var(--shadow-md);
  padding: 14px;
  margin: 8px 0;
  text-align: center;
}
.offer-card-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.offer-amount {
  font-size: 22px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 8px;
}
.offer-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.offer-status-badge.pending {
  background: #fff3e0;
  color: #e65100;
}
.offer-status-badge.accepted {
  background: #e8f5e9;
  color: #2e7d32;
}
.offer-status-badge.rejected {
  background: #ffebee;
  color: #c62828;
}

.offer-actions {
  display: flex;
  gap: 8px;
}
.offer-actions button {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
}
.btn-accept-offer {
  background: #28a745;
  color: #fff;
}
.btn-reject-offer {
  background: #f1f3f4;
  color: #5f6368;
}

/* Chat Input Bar */
.chat-input-bar {
  background: #ffffff;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-input-box {
  flex: 1;
  background: #f0f2f3;
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  color: var(--text-primary);
}
.chat-input-box:focus {
  border-color: var(--primary);
  background: #fff;
}
.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.chat-send-btn:active {
  transform: scale(0.92);
}
