/* Page-level layout and background for the conversations screen. */
body.conversations-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f1f7f0 0%, #e6efe5 100%);
  color: #1f2e2a;
}

/* Main wrapper around the conversation promo/app area. */
#conversationsMain {
  flex: 1;
  padding: 2rem clamp(1.5rem, 4vw, 4rem);
  box-sizing: border-box;
  display: flex;
  justify-content: center;
}

/* Card-like shell that constrains promo + app content. */
.conversation-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-sizing: border-box;
}

/* Logged-out promo block encouraging members to sign in. */
.conversation-promo {
  border: 1px dashed #cbd6d0;
  border-radius: 28px;
  padding: clamp(1.5rem, 4vw, 3rem);
  text-align: center;
  background: rgba(255, 255, 255, 0.75);
}

/* Headline style inside the promo card. */
.conversation-promo h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  color: #174533;
}

/* Supporting copy beneath the promo headline. */
.conversation-promo p {
  margin: 0.75rem auto 1.5rem;
  max-width: 640px;
  color: #43554d;
  line-height: 1.5;
}

/* Small uppercase eyebrow used in empty states. */
.empty-eyebrow {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: #6a7c73;
  margin: 0 0 0.4rem;
}

/* Paragraph block describing empty states or helpers. */
.empty-copy {
  margin: 0 auto;
  max-width: 420px;
  color: #3d5148;
}

/* Button row inside the promo card. */
.conversation-promo .promo-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Informational pill shown alongside promo actions. */
.promo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  background: #e7f4ec;
  color: #1a4b36;
}

/* Container for the active messaging UI. */
.conversation-card {
  background: #fff;
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.1);
  border: 1px solid #dfe6e3;
  display: flex;
  flex-direction: column;
  height: 800px;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

/* Top-of-panel header for both promo + chat cards. */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Compact spacing variation when used inside nested cards. */
.panel-header.compact {
  margin-bottom: 1rem;
}

/* Eyebrow text shared between cards/lists. */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  color: #6a7c73;
  margin: 0 0 0.3rem 0;
}

/* Secondary subtitle copy used under headings. */
.subtitle {
  margin: 0.3rem 0 0;
  color: #4a5c55;
}

/* Status area above list/composer for inline feedback. */
.inline-status {
  min-height: 1.25rem;
  font-size: 0.95rem;
  color: #2a6a4f;
  margin-bottom: 0.5rem;
}

/* Error variant for inline status text. */
.inline-status.error {
  color: #b00020;
}

/* Default “ghost” button style for subtle CTAs. */
.ghost-btn {
  border: 1px solid rgba(28, 74, 56, 0.3);
  background: none;
  color: #1c4a38;
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Hover tint for ghost buttons. */
.ghost-btn:hover {
  background-color: rgba(42, 106, 79, 0.08);
}

/* Compact variation of the ghost button. */
.ghost-btn.small {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

/* Primary call-to-action styling (e.g., start chatting). */
.primary-btn {
  border: none;
  background-color: #2a6a4f;
  color: #fff;
  padding: 0.85rem 2rem;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

/* Darker hover for the primary button. */
.primary-btn:hover {
  background-color: #1f513c;
}

/* Utility to hard-hide the app when promo should display. */
.conversation-app[hidden] {
  display: none;
}

/* Grid layout for the conversation list + thread. */
.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  min-height: 0;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Allow both columns to shrink as needed. */
.chat-layout>* {
  min-width: 0;
}

/* Left column container that houses the conversation list. */
.chat-sidebar {
  border: 1px solid #dfe8e2;
  border-radius: 18px;
  padding: 1rem;
  background: #f9fbf7;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
  height: 100%;
  overflow: hidden;
}

/* Wrapper so the conversation list consumes remaining sidebar space. */
.chat-list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Status text above the sidebar list showing load state. */
.conversation-status {
  margin: 0;
  min-height: 0;
  font-size: 0.85rem;
}

/* Sidebar list container for all conversation items. */
.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Individual list item housing each conversation summary. */
.conversation-item {
  border-radius: 16px;
  border: 1px solid #dfe8e2;
  background: #ffffff;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  padding: 0.2rem 0.25rem 0.3rem;
  position: relative;
}

/* Highlight the active conversation in the list. */
.conversation-item.active {
  border-color: #b7d2c4;
  background: #e9f5ef;
  box-shadow: 0 6px 14px rgba(42, 106, 79, 0.08);
}

/* Button that fills the entire conversation list item. */
.conversation-button {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.45rem 0.65rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  cursor: pointer;
}

/* Footer row showing timestamps and profile button. */
.conversation-footer {
  margin-top: 0.15rem;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

/* Conversation partner name text inside the list. */
.conversation-name {
  margin: 0;
  font-weight: 600;
  color: #1f2e2a;
  font-size: 0.95rem;
}

/* Preview snippet beneath the partner name. */
.conversation-snippet {
  margin: 0;
  color: #4a5c55;
  font-size: 0.82rem;
  line-height: 1.3;
}

/* Timestamp text below the snippet. */
.conversation-meta {
  margin: 0;
  font-size: 0.75rem;
  color: #7c8a85;
}

/* Indicator dot that flips filled when unread messages exist. */
.conversation-dot {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #2a6a4f;
  background: transparent;
}

/* Filled version of the indicator when conversation is unread. */
.conversation-dot.unread {
  background: #2a6a4f;
}

/* Mini button linking to the partner’s public profile. */
.conversation-profile-btn {
  border: 1px solid #b7c9bf;
  background: #ffffff;
  color: #1f4a38;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.15rem 0.65rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Hover state for the profile button. */
.conversation-profile-btn:hover {
  background: #edf5f0;
}

/* Empty-state shown when sidebar has no conversations. */
.conversation-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  font-size: 0.95rem;
  color: #5a6a63;
  border: 1px dashed #cbd6d0;
  border-radius: 14px;
  background: #fff;
}

/* Right-hand column housing chat messages + composer. */
.chat-window {
  border: 1px solid #dfe8e2;
  border-radius: 20px;
  background: #fdfefd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
}

/* Flex column inside the chat window to stack sections. */
.chat-window-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  box-sizing: border-box;
}

/* Header row (mostly used on mobile to show close button). */
.chat-window-header {
  display: none;
}

/* Close button on mobile thread view. */
.chat-close-btn {
  display: none;
}

/* Scroll container for the actual chat messages. */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.15rem 0.3rem 0.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  font-size: 0.85rem;
}

/* Placeholder shown when a thread has no messages. */
.chat-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed #d7e2db;
  border-radius: 16px;
  background: #fbfdfb;
}

/* General message bubble style inside the live chat view. */
.chat-message {
  max-width: 72%;
  padding: 0.5rem 0.7rem;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  align-self: flex-start;
  line-height: 1.25;
  font-size: 0.85rem;
}

/* Overrides for outgoing bubbles on the right. */
.chat-message.outgoing {
  background: #2a6a4f;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

/* Ensure outgoing timestamps maintain contrast. */
.chat-message.outgoing .chat-time {
  color: rgba(255, 255, 255, 0.8);
}

/* Incoming bubbles keep the default rounded corner shape. */
.chat-message.incoming {
  border-bottom-left-radius: 6px;
}

/* Ensure message bodies wrap nicely even without spaces. */
.chat-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Timestamp under each bubble. */
.chat-time {
  margin: 0.2rem 0 0;
  font-size: 0.7rem;
  color: #5f6b66;
}

/* Slim scrollbars for the chat UI sections. */
.chat-window::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

/* Rounded thumb styling for the custom scrollbars. */
.chat-window::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(31, 74, 56, 0.25);
  border-radius: 999px;
}

/* Composer footer containing textarea + send button. */
.chat-composer {
  border-top: 1px solid #dfe8e2;
  margin-top: 0.65rem;
  padding-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Positioning context for the textarea + send icon. */
.chat-input-wrapper {
  position: relative;
}

/* Textarea in the composer for typing messages. */
.chat-composer textarea {
  border: 1px solid #cfd8d5;
  border-radius: 16px;
  padding: 0.65rem 3.2rem 0.65rem 0.75rem;
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
  font-size: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

/* Focus outline when the composer is active. */
.chat-composer textarea:focus {
  outline: 2px solid #2a6a4f;
  border-color: transparent;
}

/* Circular send button anchored inside the textarea. */
.composer-send-btn {
  position: absolute;
  right: 0.4rem;
  bottom: 0.6rem;
  border: none;
  background: #2a6a4f;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

/* Dim send button when message cannot be sent. */
.composer-send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Hover color for an active send button. */
.composer-send-btn:not(:disabled):hover {
  background: #1f513c;
}

/* Responsive behavior for stacking the chat list/thread. */
@media (max-width: 1024px) {
  #conversationsMain {
    padding: 2rem 1.5rem;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    max-height: none;
    height: auto;
  }

  .chat-layout[data-view="list"] .chat-sidebar {
    display: block;
  }

  .chat-layout[data-view="list"] .chat-window {
    display: none;
  }

  .chat-layout[data-view="thread"] .chat-sidebar {
    display: none;
  }

  .chat-layout[data-view="thread"] .chat-window {
    display: flex;
  }

  .chat-window-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 0.3rem;
  }

  .chat-close-btn {
    display: inline-flex;
  }
}

/* Adjust padding on very small screens. */
@media (max-width: 640px) {
  .conversation-card {
    padding: 1.5rem;
  }

  .conversation-promo {
    padding: 1.5rem;
  }
}
