/* Private, listing-linked in-site messaging. */
.listing-message-details { margin: 9px 0; }
.listing-message-details > summary { display: flex; justify-content: center; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.listing-message-details > summary::-webkit-details-marker { display: none; }
.listing-message-details > summary::marker { content: ""; }
.listing-message-start-form, .message-compose-form { display: grid; gap: 10px; margin-top: 12px; padding: 15px; border: 1px solid #dfe7dc; border-radius: 14px; background: #fffefa; }
.listing-message-start-form label, .message-compose-form label { color: #254b3b; font-size: 13px; font-weight: 800; }
.listing-message-start-form textarea, .message-compose-form textarea { display: block; width: 100%; min-height: 100px; padding: 12px; border: 1px solid #d6dfd3; border-radius: 10px; background: white; color: #20372b; font: inherit; resize: vertical; }
.listing-message-start-form textarea:focus, .message-compose-form textarea:focus { border-color: #47785c; outline: 3px solid rgba(71, 120, 92, .16); }
.listing-message-start-form small, .message-compose-footer small { color: #647368; font-size: 12px; line-height: 1.5; }
.message-center { max-width: 980px; }
.message-center-heading, .message-thread-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.message-center-heading h1, .message-thread-header h1 { margin: 5px 0 8px; color: #173f32; }
.message-center-heading p, .message-thread-header p { margin: 0; color: #637267; }
.message-thread-list { display: grid; gap: 10px; }
.message-thread-card { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 17px; border: 1px solid #e0e7dd; border-radius: 16px; background: #fffefa; color: inherit; text-decoration: none; box-shadow: 0 4px 12px rgba(23, 63, 50, .035); }
.message-thread-card:hover { border-color: #abc6ad; transform: translateY(-1px); }
.message-thread-avatar { display: flex; flex: 0 0 44px; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 50%; background: #e3eddf; color: #234b39; font-weight: 850; font-size: 18px; }
.message-thread-summary { flex: 1; min-width: 0; }
.message-thread-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.message-thread-title-row strong { color: #173f32; }
.message-thread-title-row time { color: #768176; font-size: 11px; white-space: nowrap; }
.message-thread-listing { display: block; margin-top: 4px; color: #486d55; font-size: 12px; font-weight: 750; }
.message-thread-summary p { margin: 5px 0 0; color: #657168; font-size: 13px; overflow-wrap: anywhere; }
.message-unread-badge { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: #b64132; color: white; font-size: 12px; font-weight: 800; }
.message-empty-state { padding: 45px 24px; border: 1px dashed #cbd9ca; border-radius: 18px; background: #fffefa; text-align: center; }
.message-empty-state > span { display: block; margin-bottom: 12px; color: #47785c; font-size: 36px; }
.message-empty-state h2 { margin: 0 0 8px; color: #173f32; }
.message-empty-state p { max-width: 560px; margin: 0 auto 18px; color: #657168; }
.message-pagination { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 22px; color: #627267; }
.message-pagination a, .message-back-link { color: #24553c; font-weight: 750; text-decoration: none; }
.message-thread-page { max-width: 900px; }
.message-thread-header { align-items: flex-end; padding-bottom: 18px; border-bottom: 1px solid #e1e8df; }
.message-back-link { flex: 0 0 auto; }
.message-thread-header > div { flex: 1; min-width: 0; }
.message-chat { display: grid; gap: 12px; max-height: min(640px, 62vh); overflow-y: auto; padding: 18px; border: 1px solid #dfe7dc; border-radius: 18px; background: #f6f8f3; overscroll-behavior: contain; }
.chat-message { justify-self: start; width: min(82%, 650px); padding: 12px 15px; border: 1px solid #e2e7df; border-radius: 13px 13px 13px 4px; background: #fffefa; box-shadow: 0 2px 8px rgba(23, 63, 50, .035); overflow-wrap: anywhere; }
.chat-message.is-mine { justify-self: end; border-color: #c9dfc8; border-radius: 13px 13px 4px 13px; background: #e9f3e6; }
.chat-message-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.chat-message-meta strong { color: #315844; font-size: 12px; }
.chat-message-meta time { color: #748074; font-size: 10px; white-space: nowrap; }
.chat-message p { margin: 0; color: #2f3f34; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-message-read { display: block; margin-top: 5px; color: #50775a; font-size: 10px; text-align: right; }
.message-empty-inline { padding: 22px; color: #677368; text-align: center; }
.message-compose-form { margin-top: 16px; }
.message-compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.message-form-errors { color: #a52b27; font-size: 13px; }
.message-form-errors ul { margin: 0; padding-left: 18px; }
@media (max-width: 640px) {
  .message-center-heading, .message-thread-header { flex-direction: column; align-items: stretch; gap: 14px; }
  .message-thread-card { gap: 10px; padding: 12px; }
  .message-thread-avatar { flex-basis: 38px; width: 38px; height: 38px; }
  .message-thread-title-row { align-items: flex-start; flex-direction: column; gap: 3px; }
  .message-thread-title-row time { font-size: 10px; }
  .chat-message { width: min(94%, 650px); padding: 11px 12px; }
  .chat-message-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
  .message-compose-footer { align-items: stretch; flex-direction: column; gap: 10px; }
  .message-compose-footer .btn { width: 100%; }
}

.dashboard-top-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.dashboard-top-actions .btn { white-space: nowrap; }
.dashboard-message-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: #b64132; color: #fff; font-size: 11px; font-weight: 800; }
@media (max-width: 720px) { .dashboard-top-actions { width: 100%; } }

.mobile-menu-messages-link { display: none; }
@media (max-width: 720px) {
  .header-messages-link { display: none; }
  .nav-open .header-actions .mobile-menu-messages-link { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border: 1px solid #dce5db; border-radius: 9px; color: #173f32; background: #fffefa; font-size: 12px; font-weight: 750; }
  .mobile-menu-messages-link span { display: inline-flex; min-width: 19px; height: 19px; align-items: center; justify-content: center; padding: 0 4px; border-radius: 99px; background: #b64132; color: white; font-size: 10px; }
}

/* Private image, video and document attachments inside message threads. */
.message-attachment-input {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 10px;
  border: 1px dashed #b9cbbb;
  border-radius: 10px;
  background: #f8faf6;
  color: #344b3b;
  font: inherit;
  font-size: 13px;
}
.message-attachment-input:focus-visible { outline: 3px solid rgba(71, 120, 92, .24); outline-offset: 2px; }
.chat-message-attachments { display: grid; gap: 9px; margin-top: 9px; max-width: 100%; }
.chat-attachment-image-link { display: inline-flex; width: fit-content; max-width: 100%; overflow: hidden; border: 1px solid #dce5da; border-radius: 10px; background: #fff; }
.chat-attachment-image { display: block; width: auto; max-width: min(100%, 260px); max-height: 220px; object-fit: contain; }
.chat-attachment-video-wrap { display: grid; gap: 5px; max-width: 360px; }
.chat-attachment-video { display: block; width: 100%; max-height: 260px; border-radius: 10px; background: #1a211c; }
.chat-attachment-download { color: #315d42; font-size: 12px; overflow-wrap: anywhere; }
.chat-attachment-file { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px 12px; border: 1px solid #dce5da; border-radius: 10px; background: #fffefa; color: #294534; text-decoration: none; }
.chat-attachment-file:hover { border-color: #a9c6ab; background: #fbfdf9; }
.chat-attachment-file-icon { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 8px; background: #e7f0e3; font-size: 20px; }
.chat-attachment-file-info { display: grid; flex: 1; min-width: 0; gap: 3px; }
.chat-attachment-file-info strong { overflow-wrap: anywhere; font-size: 12px; }
.chat-attachment-file-info small { color: #6c796e; font-size: 11px; }
.chat-attachment-file-action { flex: 0 0 auto; color: #315d42; font-size: 11px; font-weight: 800; }
@media (max-width: 640px) {
  .chat-attachment-image { max-width: 100%; max-height: 200px; }
  .chat-attachment-video-wrap { max-width: 100%; }
  .chat-attachment-file { max-width: 100%; gap: 8px; padding: 9px; }
  .chat-attachment-file-action { font-size: 10px; }
}


/* v0.1.36 live updates: keep read receipts and attachment cards readable. */
.chat-message { scroll-margin-block: 16px; }
.chat-message-read::before { content: "✓✓ "; letter-spacing: -2px; }
.chat-live-status { margin: 0; color: #758276; font-size: 11px; text-align: center; }
.header-messages-count[hidden], [data-message-unread-count][hidden], .mobile-menu-messages-count[hidden] { display: none !important; }
.message-form-errors[hidden] { display: none !important; }
.mobile-menu-messages-count { display: inline-flex; min-width: 19px; height: 19px; align-items: center; justify-content: center; padding: 0 4px; border-radius: 99px; background: #b64132; color: white; font-size: 10px; }

/* v0.1.37: keep counters hidden at zero and preserve chat composer status. */
.message-compose-form button[disabled] { opacity: .72; cursor: wait; }
