/* The Messaging add-on: the inbox rows, a conversation's bubbles and its composer. Tokens only. Shared by the app and
   the web console (both link it after components.css). */

/* ── inbox rows: hub-row's grid, with the time and the unread count in the trailing column ── */

.messages-row__trail {
    grid-column: 3;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
}

.messages-row__preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

/* A row with no icon (the job and work order cards, whose head already carries one). */
.messages-row--bare {
    grid-template-columns: minmax(0, 1fr) auto;
}

.messages-row--bare .hub-row__label,
.messages-row--bare .hub-row__value {
    grid-column: 1;
}

.messages-row--bare .messages-row__trail {
    grid-column: 2;
}

.messages-row--unread .hub-row__label {
    font-weight: var(--weight-semibold);
}

/* The unread count: the accent, the one badge on the row - and only when there is something to read. */
.messages-badge {
    min-width: 1.5rem;
    padding: 0 var(--space-1);
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-text-on-accent);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1.5rem;
    text-align: center;
}

.messages-page__group + .messages-page__group {
    margin-top: var(--space-4);
}

/* ── a conversation: the scroller is column-reverse, so it opens at the newest message and stays there ── */

.conversation-page__scroll {
    display: flex;
    flex-direction: column-reverse;
}

.message-list {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
}

.message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
}

.message--first {
    margin-top: var(--space-3);
}

.message--mine {
    align-items: flex-end;
}

.message__meta {
    padding: 0 var(--space-2) var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.message__bubble {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-width: min(32rem, 80%);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    background: var(--color-card);
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-base);
    line-height: var(--leading-base);
    text-align: left;
    overflow-wrap: anywhere;
}

.message--mine .message__bubble {
    border-color: transparent;
    background: var(--color-primary-soft);
}

.message__bubble--tap {
    cursor: pointer;
}

.message__bubble--tap:active {
    background: var(--color-primary-softer);
}

.message__bubble--tap:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.message__text {
    white-space: pre-wrap;
}

/* A removed message ("Removed by an admin") or one from someone you blocked ("Hidden message"): it keeps its place, in
   the muted voice of a status, never in the author's colours. */
.message__bubble--placeholder,
.message--mine .message__bubble--placeholder {
    border: 1px dashed var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    font-style: italic;
}

/* "Also block Dana" under a report's reason: the label is the tap target. */
.report-sheet__check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch-target-min);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.report-sheet__check input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}

/* The line that stands in for the composer once a block ends a person-to-person conversation, and the terms line the
   first message waits on. */
.composer--blocked,
.composer--terms {
    align-items: center;
    justify-content: space-between;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.composer--terms {
    gap: var(--space-3);
}

.composer--terms a {
    color: var(--color-primary-text);
}

.message__photo {
    display: block;
    max-width: 100%;
    max-height: 18rem;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.message__photo--waiting {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10rem;
    height: 7rem;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
}

/* ── the composer: a page-dock (it already clears the phone's tab bar and the safe area) ── */

.composer {
    align-items: flex-end;
}

.composer__field {
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--touch-target-min);
    max-height: 8rem;
    resize: none;
}

.composer__send {
    flex: 0 0 auto;
}

.composer__note {
    flex: 0 0 auto;
    margin: 0;
    padding: var(--space-2) var(--space-4) 0;
    color: var(--color-warning-text);
    font-size: var(--text-sm);
}

.composer__pending {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4) 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.composer__pending img {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-sm);
    object-fit: cover;
}
