/* The staff inbox (app/js/messages.js, the AQARI agent's logic and hooks; the look is the UI agent's): on a desktop two panes, the list of conversations on the start
   side and the open one beside it; on a phone the list, then the conversation as its own screen. Same language as the rest of the app: soft corners, capsules, the company
   colour for what is mine, calm lines. Logical properties throughout (Arabic mirrors), transform and opacity for motion, nothing moves under Reduce Motion. */

/* ---- the filters and the controls above the list ---- */
.msgchips{ display:flex; flex-wrap:nowrap; gap:8px; overflow-x:auto; scrollbar-width:none; padding:2px 0 8px } .msgchips::-webkit-scrollbar{ display:none }
.msgchips .cchip{ flex:none; white-space:nowrap }
.msgtools{ margin:0 0 8px } .msgtools input{ width:100%; min-height:44px; padding:0 18px; border-radius:100px; border:1.5px solid var(--line); background:var(--card); font:inherit }
.msgselects{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:0 0 12px } .msgselects select{ width:100%; min-height:40px; padding:0 14px; font-size:calc(14px * var(--dt,1)) }
.msgbulk{ display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:10px 14px; margin:0 0 12px; border-radius:var(--r-card, 22px); background:var(--ink); color:var(--paper, #fff) }
.msgbulk .btn{ background:rgba(255,255,255,.14); color:inherit; box-shadow:none } .msgbulk select{ min-height:36px }

/* ---- the list: one calm row per conversation ---- */
.msglist{ padding:0 } .msglist > h3{ border-bottom:1px solid var(--line-soft) }
.msgrow{ position:relative; display:grid; grid-template-columns:auto 1fr; align-items:start; border-bottom:1px solid var(--line-soft); transition:background-color .15s }
.msgrow:last-of-type{ border-bottom:0 }
/* No coloured bar on the side of a row: an unread conversation is said by its heavier name and its count, the open one by its tint. */
.msgrow.cur{ background:color-mix(in srgb, var(--dp, var(--nile)) 9%, var(--card)) }
.msgrow.kfocus:focus-within{ box-shadow:inset 0 0 0 2px var(--teal, #00D1C1) }
.msgpick{ display:flex; align-items:center; justify-content:center; width:44px; min-height:44px; padding-top:14px; cursor:pointer } .msgpick input{ width:18px; height:18px; accent-color:var(--dp, var(--nile)) }
.msgopen{ display:block; width:100%; padding:14px 16px 14px 0; text-align:start; background:none; border:0; font:inherit; color:inherit; cursor:pointer; min-width:0 }
html[dir="rtl"] .msgopen{ padding:14px 0 14px 16px }
.msgopen .ent-top{ display:flex; justify-content:space-between; gap:10px; align-items:baseline } .msgopen .ent-top b{ font-weight:700 }
.msgrow.unread .ent-top b{ font-weight:800 }
.msgopen .ent-meta{ margin-top:5px; font-size:calc(13px * var(--dt,1)); display:flex; flex-wrap:wrap; gap:6px; align-items:center } .msgopen .ent-meta.muted{ color:var(--muted) }
.msgprev{ color:var(--ink-soft, var(--ink)); display:-webkit-box !important; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden }
.msgopen .navbadge{ display:inline-block; min-width:20px; padding:0 6px; border-radius:100px; background:var(--clay); color:#fff; font-size:calc(12px * var(--dt,1)); font-weight:700; text-align:center; line-height:20px }
@media(hover:hover) and (pointer:fine){ .msgrow:hover{ background:color-mix(in srgb, var(--line-soft) 60%, transparent) } .msgrow.cur:hover{ background:color-mix(in srgb, var(--dp, var(--nile)) 12%, var(--card)) } }

/* ---- the conversation ---- */
.msgthread{ display:flex; flex-direction:column; padding:0; overflow:visible }
.msghead{ position:sticky; top:0; z-index:2; background:color-mix(in srgb, var(--card) 92%, transparent); -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px); border-bottom:1px solid var(--line-soft); border-radius:var(--r-card, 22px) var(--r-card, 22px) 0 0; padding:14px 18px }
.msghead .ent-top{ display:flex; justify-content:space-between; gap:10px; align-items:center; font-size:calc(15px * var(--dt,1)) } .msghead .ent-meta{ margin-top:4px; font-size:calc(13px * var(--dt,1)) }
.msgctl{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-top:10px }
.msglbl{ display:inline-flex; align-items:center; gap:6px; font-size:calc(13px * var(--dt,1)); color:var(--muted) } .msglbl select, .msgctl select{ min-height:36px; padding:0 12px; font-size:calc(13.5px * var(--dt,1)) }
.msgs{ display:flex; flex-direction:column; gap:8px; padding:16px 18px; min-height:220px }
.msgb{ max-width:78%; display:flex; flex-direction:column; gap:3px } .msgb.in{ align-self:flex-start } .msgb.out{ align-self:flex-end }
.msgmeta{ font-size:calc(12px * var(--dt,1)); color:var(--muted); padding-inline:6px } .msgb.out .msgmeta{ text-align:end }
.msgtext{ padding:10px 14px; border-radius:20px; background:var(--card); box-shadow:var(--sh); border:1px solid var(--line-soft); line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere }
.msgb.out .msgtext{ background:var(--dp, var(--nile)); color:var(--dpf, #fff); border-color:transparent; border-end-end-radius:6px; box-shadow:none }
.msgb.in .msgtext{ border-end-start-radius:6px }
.msgb.note .msgtext{ background:color-mix(in srgb, var(--brass) 14%, var(--card)); color:var(--ink); border:1.5px dashed color-mix(in srgb, var(--brass) 60%, transparent) }
.msgb.hidden .msgtext{ opacity:.45; text-decoration:line-through }
.msgphotos{ display:flex; gap:6px; flex-wrap:wrap }
.msgb{ position:relative }
.msghide{ position:absolute; top:-8px; inset-inline-end:8px; min-height:32px; padding:0 10px; border-radius:100px; background:var(--card); box-shadow:var(--sh-soft, var(--sh)); font-size:calc(12px * var(--dt,1)); opacity:0; transition:opacity .15s } .msgb:hover .msghide, .msgb:focus-within .msghide{ opacity:1 }
/* A touch screen has no hover to bring the button up, so it is always there: on its own line under the message, at the bubble's side, no longer
   floating over the name and the time. The negative margin keeps the line short while the pressing area stays full height. */
@media(hover:none){ .msghide{ position:static; opacity:1; align-self:flex-start; margin-block:-8px } .msgb.out .msghide{ align-self:flex-end } }
.msgsys{ align-self:center; padding:4px 12px; border-radius:100px; background:var(--line-soft); color:var(--muted); font-size:calc(12.5px * var(--dt,1)) }
.msgb:last-child .msgtext{ animation:msgPop .3s cubic-bezier(.2,.9,.3,1.15) both }
@keyframes msgPop{ from{ opacity:0; transform:scale(.94) translateY(6px) } to{ opacity:1; transform:none } }

/* ---- the composer: a card at the foot of the conversation ---- */
.msgcompose{ border-top:1px solid var(--line-soft); padding:14px 18px 16px; background:color-mix(in srgb, var(--line-soft) 35%, var(--card)); border-radius:0 0 var(--r-card, 22px) var(--r-card, 22px) }
.msgcompose textarea{ width:100%; min-height:84px; margin:10px 0; padding:12px 14px; border:1.5px solid var(--line); border-radius:18px; background:var(--card); font:inherit; line-height:1.45; resize:vertical }
.msgcompose textarea:focus{ outline:none; border-color:var(--dp, var(--nile)); box-shadow:0 0 0 4px color-mix(in srgb, var(--dp, var(--nile)) 16%, transparent) }
.msgcompose .tools{ display:flex; flex-wrap:wrap; gap:8px; align-items:center } .msgcompose .spacer{ flex:1 }
.msgkeys{ margin:10px 0 0; font-size:calc(12px * var(--dt,1)) }
@media(max-width:1099px){ .msgkeys{ display:none } .msgb{ max-width:88% } }

/* ---- the routing screen's table ---- */
table.msgroutes{ width:100% } table.msgroutes td, table.msgroutes th{ padding:10px 12px } .msgsub{ margin:14px 0 6px; font-size:calc(14px * var(--dt,1)); color:var(--muted) }
/* a tick box with its words: one per line, a full-height row to press, the role (when there is one) at the far end.
   Without this the boxes ran together on one wrapping line. */
.switchrow{ display:flex; align-items:center; gap:12px; min-height:calc(44px * var(--dt,1)); padding:6px 0; font-size:calc(15px * var(--dt,1)); line-height:1.35; cursor:pointer }
.switchrow + .switchrow{ border-top:.5px solid var(--line) }
.switchrow input{ flex:none; width:22px; height:22px; margin:0; accent-color:var(--nile) }
.switchrow input:disabled{ cursor:default }
.switchrow bdi{ min-width:0; overflow-wrap:anywhere }
.switchrow .muted{ margin-inline-start:auto; flex:none; font-size:calc(13px * var(--dt,1)) }

@media(prefers-reduced-motion:reduce){ .msgrow, .msghide{ transition:none } .msgb:last-child .msgtext{ animation:none } }

/* Resident requests and work orders, the staff side (resident-requests.js, migration 070): the list reuses the Dashboard's rows (.ditem); these are the
   few things of its own: the filters, the summary line kept to two lines, the story of one request and its staff-only lines */
.rrtools select{ min-height:44px; padding:0 14px; border-radius:100px; font-size:calc(14px * var(--dt,1)); max-width:100% }
.rrtools .btn.primary{ margin-inline-start:auto }
.rrcount{ margin:0 0 8px; font-size:calc(13px * var(--dt,1)) }
.rrrow .dt{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px }
.rrrow .dt b, .rrrow .dt small{ white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:anywhere }   /* the number, type and Urgent must all show: wrap, never cut */
.rrrow .dt small{ font-size:calc(13px * var(--dt,1)); color:var(--muted) }
.rrrow .dt small.rrsum{ display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; color:var(--ink) }
.rrrow .damt{ flex:none; display:flex; flex-direction:column; align-items:flex-end; gap:4px; text-align:end }
.rrrow .damt small{ font-size:calc(12px * var(--dt,1)); color:var(--muted); white-space:nowrap }
.rrone h3{ display:flex; flex-wrap:wrap; align-items:center; gap:8px }
.rrone .setrow .v{ overflow-wrap:anywhere }
.rrone .rrwho{ display:flex; flex-direction:column; align-items:flex-end; gap:4px; text-align:end } .rrone .rrwho .num{ white-space:nowrap }
.rrcost{ margin-top:12px } .rrcost p{ margin:6px 0 0; font-size:calc(13px * var(--dt,1)) }
.rracts{ display:flex; flex-wrap:wrap; gap:8px; margin-top:12px }
.rrdecl{ color:var(--clay-ink) }
.rrhist{ display:flex; flex-direction:column; gap:12px }
.rrev{ padding-inline-start:12px; border-inline-start:3px solid var(--line) }
.rrev.rrmsg{ border-inline-start-color:var(--nile) }
.rrev.rrinternal{ border-inline-start-color:var(--brass) }
.rrevhead{ font-size:calc(13px * var(--dt,1)); color:var(--muted) } .rrevhead b{ color:var(--ink); font-weight:600 }
.rrevbody{ margin-top:4px; white-space:pre-wrap; overflow-wrap:anywhere; font-size:calc(15px * var(--dt,1)) }
.rrphotos{ display:flex; flex-wrap:wrap; gap:6px; margin-top:6px }
#rrText{ width:100%; min-height:88px }
