/* La Maldives — messaging (agency ↔ La Maldives ↔ property) */

.chat {
  display: grid; grid-template-columns: 300px 1fr; grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel); height: calc(100vh - 210px); min-height: 440px;
}
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.chat-list .ct { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.chat-list .ct:hover { background: var(--panel-2); }
.chat-list .ct.active { background: var(--nav-active-bg); }
.chat-list .ct-sub { font-size: 12.5px; font-weight: 500; display: flex; align-items: center; }
.chat-list .ct-sub .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-left: 0.45rem; flex: none; }
.chat-list .ct-last { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list .ct-meta { font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-faint); margin-top: 4px; display: flex; justify-content: space-between; gap: 0.5rem; }
.chat-list .ct-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .ct-meta span:last-child { flex: none; }

/* .chat's one row defaults to auto-sized (fits content) rather than filling
   the grid's own fixed height — a long conversation would then grow
   .chat-log past the card instead of scrolling inside it, with the outer
   page left to pick up the overflow. .chat's grid-template-rows pins the
   row to the container's height; min-height: 0 here lets this flex child
   actually shrink to that row instead of pushing back out to its content
   size (the default "auto" minimum keeps a flex item at least as tall as
   its content unless told otherwise) */
.chat-conv { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-conv > header { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line-soft); }
.chat-conv > header h3 { font-size: 0.98rem; }
.chat-conv > header .who { font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.chat-back { display: none; margin-bottom: 0.55rem; }

.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.msg { max-width: 78%; }
.msg .m-who { font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-faint); margin-bottom: 3px; letter-spacing: 0.03em; }
.msg .m-body { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 11px; border-top-left-radius: 3px; padding: 0.55rem 0.8rem; font-size: 13px; line-height: 1.5; }
.msg .m-ts { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; color: var(--ink-faint); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.msg.me { align-self: flex-end; text-align: right; }
.msg.me .m-body { background: color-mix(in srgb, var(--teal) 15%, var(--panel)); border-color: color-mix(in srgb, var(--teal) 28%, var(--line-soft)); border-radius: 11px; border-top-right-radius: 3px; text-align: left; }
.msg.me .m-ts { justify-content: flex-end; }

/* ops-only moderation: flag a message to hide it from the other party
   without deleting it (see chat.js's threadMsgs() and routes/chat.js's
   GET / for where it actually gets filtered out for them) */
.msg-flag { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; color: var(--ink-faint); display: inline-flex; align-items: center; }
.msg-flag:hover { color: var(--coral); }
.msg-flag.on { color: var(--coral); }
.msg.flagged .m-body { border-color: var(--coral); box-shadow: 0 0 0 1px color-mix(in srgb, var(--coral) 35%, transparent); }
.m-flagged-lbl { color: var(--coral); font-weight: 600; }
.chat-monitor-note {
  margin: 0.7rem; padding: 0.6rem 0.75rem; border: 1px dashed var(--line-soft); border-radius: 8px;
  font-size: 11.5px; color: var(--ink-faint);
}

.chat-quickpills { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.6rem 0.7rem 0; }
.chat-quickpills button {
  font: inherit; font-size: 12px; padding: 0.32rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--panel-2); color: var(--ink-soft); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.chat-quickpills button:hover { border-color: var(--teal); color: var(--ink); }

.chat-compose { border-top: 1px solid var(--line-soft); padding: 0.7rem; display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-compose textarea {
  flex: 1; resize: none; font: inherit; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem;
  background: var(--panel); color: var(--ink); min-height: 40px; max-height: 120px; overflow-y: auto;
}
.chat-compose textarea:focus { outline: 2px solid color-mix(in srgb, var(--teal) 45%, transparent); outline-offset: 1px; border-color: transparent; }

.chat-empty { flex: 1; display: grid; place-items: center; color: var(--ink-faint); font-size: 13px; padding: 2rem; text-align: center; }

@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 180px); }
  .chat-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat.viewing .chat-list { display: none; }
  .chat:not(.viewing) .chat-conv { display: none; }
  .chat-back { display: inline-flex; }
}
