/*
 * Compact view (on by default since 2026-11-23): WhatsApp Web style message layout so many more messages fit on a
 * screen. Loaded after the main stylesheet (layouts/app.blade.php). Only conversation messages get denser:
 * the conversations list keeps its normal size and last-message preview, and message text keeps its normal size.
 *
 * How: each bubble becomes a wrapping flex row. The sender name (groups) and reply quote take the first line, then
 * the text, then the sent/read status and the time + ⋮ button, which sit beside the end of a short text or drop to
 * the right of the next line when the text is long. .message-meta uses display:contents so its name and time can be
 * placed separately without changing the HTML.
 */

/* ── Conversations list: not compacted (undo the older compact rules) ───────────────────────── */
.flow-compact .thread { padding: 10px; }
.flow-compact .thread-copy small { display: block; }

/* ── Message list spacing ───────────────────────────────────────────────────────────────────── */
.flow-compact .messages { padding: 8px clamp(10px, 4vw, 64px) 10px; gap: 3px; }
.flow-compact .message.mine + .message:not(.mine),
.flow-compact .message:not(.mine) + .message.mine { margin-top: 7px; } /* a little air when the sender changes */
.flow-compact .message-date-divider { margin: 8px 0 4px; }
.flow-compact .message-date-divider time { padding: 3px 10px; }

/* ── Bubble ─────────────────────────────────────────────────────────────────────────────────── */
.flow-compact .message {
    display: flex; flex-wrap: wrap; align-items: flex-end; column-gap: 8px; row-gap: 2px;
    max-width: min(75%, 640px); padding: 5px 8px 4px 9px; border-radius: 8px;
}
.flow-compact .message.mine { border-radius: 8px; }
.flow-compact .message-meta { display: contents; }

/* first line: sender name (group chats only) and the quoted reply */
.flow-compact .message-meta > strong { order: 0; flex: 0 0 100%; font-size: 12px; line-height: 1.3; }
.flow-compact .reply-quote { order: 0; flex: 0 0 100%; margin: 1px 0 2px; padding: 4px 7px; }

/* the text keeps the normal 14px */
.flow-compact .message p { order: 1; flex: 0 1 auto; margin: 0; line-height: 1.4; min-width: 0; }
.flow-compact .message p ~ p { flex-basis: 100%; }

/* pictures, voice notes, files, records and approval cards: their own line */
.flow-compact .message > .chat-image,
.flow-compact .message > .voice-player,
.flow-compact .message > .record-card,
.flow-compact .message > .approval-card { order: 1; flex: 0 0 100%; margin-top: 3px; }
.flow-compact .message > .attachment { order: 1; flex: 0 1 auto; margin-top: 2px; }
.flow-compact .chat-image { max-width: 240px; max-height: 240px; }
/* bubbles with a picture, voice note, record or approval: one column (caption, media, then the time on the right) */
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) { flex-direction: column; align-items: flex-start; }
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) > * { flex: 0 0 auto; }
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) > .voice-player,
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) > .record-card,
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) > .approval-card { align-self: stretch; }
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) .message-meta-right,
.flow-compact .message:has(> .chat-image, > .voice-player, > .record-card, > .approval-card) > .message-status { align-self: flex-end; margin-left: 0; }
.flow-compact .message-unsent { order: 1; }

/* sent / read / edited, then the time and the ⋮ button, at the bottom right */
.flow-compact .message-status { order: 2; flex: 1 0 auto; justify-content: flex-end; text-align: right; margin: 0 0 1px; font-size: 10px; line-height: 1.2; gap: 4px; } /* grows, so "sent" always sits at the right, next to (or just above) the time */
.flow-compact .message-status:empty { display: none; }
.flow-compact .message-status:has(strong, button) { flex: 0 0 100%; margin: 4px 0 0; } /* "Important" + Acknowledge keep a row */
.flow-compact .message-meta-right { order: 3; margin: 0 0 0 auto; gap: 1px; line-height: 1.2; }
.flow-compact .message:has(> .message-status:not(:empty):not(:has(strong, button))) .message-meta-right { margin-left: 0; }
.flow-compact .message-meta-right time { font-size: 11px; }
.flow-compact .message-menu-button { min-width: 18px; min-height: 18px; width: 18px; height: 18px; font-size: 14px; border-radius: 4px; opacity: 0; transition: opacity .12s; }
.flow-compact .message:hover .message-menu-button,
.flow-compact .message:focus-within .message-menu-button,
.flow-compact .message-menu-button[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .flow-compact .message-menu-button { opacity: .7; } } /* touch screens: always reachable */
.flow-compact .message-menu { top: auto; bottom: calc(100% + 4px); } /* opens upwards, so it is not cut off at the bottom */
