/* Messages (text conversations) and the Voicemail inbox — views/messages.js */

.badge[data-k="sms"] { background: var(--info); color: #04121f; }
.tab-dot[data-k="sms"] { background: var(--info); }
:root[data-theme="light"] .badge[data-k="sms"] { color: #fff; }

/* the screen fills the outlet: the list and the conversation scroll, the page does not */
.msg-page { height: 100%; max-width: 1280px; padding-bottom: 16px; gap: 12px; }
.msg-page[data-tab="voicemail"] { height: auto; max-width: 860px; padding-bottom: 40px; }
.msg-tabs { padding: 0; margin-top: -4px; }
.msg-tab-n { margin-left: 6px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--info); color: #04121f; font-size: 10.5px; font-weight: 600; display: inline-grid; place-items: center; }
:root[data-theme="light"] .msg-tab-n { color: #fff; }
.msg-notices { display: flex; flex-direction: column; gap: 8px; }
.msg-notices:empty { display: none; }
.msg-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.msg-line { width: auto; max-width: 220px; }

.msg { flex: 1 1 auto; min-height: 320px; display: grid; grid-template-columns: minmax(250px, 330px) minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; }
.msg-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.msg-search { flex: none; max-width: none; margin: 10px; }
.msg-threads { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.msg-threads > .empty, .msg-threads > .skel { padding: 20px 14px; }
.msg-status { flex: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 36px; padding: 4px 6px 4px 12px; border-top: 1px solid var(--line); }
.msg-status:empty { display: none; }
.msg-status-a { margin-left: auto; display: inline-flex; gap: 2px; }
.msg-ops { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.msg-ops li[data-ok="0"] strong { color: var(--err); }

.msg-th { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; position: relative; }
.msg-th:hover { background: var(--raised); }
.msg-th[aria-current="true"] { background: var(--raised); }
.msg-th[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ink); }
.msg-th:focus-visible { outline-offset: -2px; }
.msg-av { flex: none; }
.msg-th-m { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.msg-th-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-th-who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.msg-th[data-unread] .msg-th-who { font-weight: 700; }
.msg-th-t { flex: none; font-size: var(--fs-xs); }
.msg-th-snip { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-th[data-unread] .msg-th-snip { color: var(--ink); }
.msg-th-line { font-size: var(--fs-xs); }
.msg-th-n { margin-left: 0; }

.msg-convo { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.msg-pick { flex: 1; display: grid; place-items: center; }
.msg-pick .empty { align-items: center; text-align: center; }
.msg-h { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.msg-h-t { display: flex; flex-direction: column; min-width: 0; }
.msg-h-t h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-back { display: none; }
.msg-new { padding: 18px 16px; max-width: 420px; }
.msg-to { font-family: var(--mono); font-size: var(--fs-md); }
.msg-to-match { min-height: 1.4em; }

.msg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0; padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 6px; outline-offset: -2px; }
.msg-day { align-self: center; margin: 8px 0 2px; font-size: var(--fs-xs); color: var(--ink-3); }
.msg-day span { padding: 2px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.msg-none { align-self: center; margin: auto 0; padding: 30px 10px; font-size: var(--fs-sm); text-align: center; }
.msg-m { display: flex; flex-direction: column; align-items: flex-start; max-width: min(78%, 560px); align-self: flex-start; }
.msg-m[data-dir="out"] { align-items: flex-end; align-self: flex-end; }
.msg-b { padding: 7px 11px; border: 1px solid var(--line-2); border-radius: 12px 12px 12px 3px; background: var(--raised); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; line-height: 1.4; }
.msg-m[data-dir="out"] .msg-b { border-radius: 12px 12px 3px 12px; background: color-mix(in srgb, var(--info) 17%, var(--panel)); border-color: color-mix(in srgb, var(--info) 38%, var(--line)); }
.msg-m[data-status="sending"] .msg-b { opacity: .7; }
.msg-m[data-status="failed"] .msg-b { border-style: dashed; border-color: var(--err); background: color-mix(in srgb, var(--err) 9%, var(--panel)); }
.msg-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 4px 0; font-size: var(--fs-xs); color: var(--ink-3); }
.msg-m[data-dir="out"] .msg-meta { justify-content: flex-end; text-align: right; }
.msg-st { display: inline-flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.msg-st .ic { align-self: center; }
.msg-st[data-s="failed"] { display: block; color: var(--err); max-width: 46ch; text-align: right; }
.msg-st[data-s="failed"] .ic { display: inline-block; vertical-align: -1px; margin-right: 4px; }
.msg-m[data-status="failed"] .msg-meta { flex-direction: column; align-items: flex-end; gap: 1px; }
.msg-st[data-s="failed"] .msg-retry { margin-left: 8px; }
.msg-st[data-s="sending"] { color: var(--ink-2); }
.msg-retry { font-size: var(--fs-xs); font-weight: 600; color: var(--ink); white-space: nowrap; }

.msg-compose { flex: none; display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 10px; border-top: 1px solid var(--line); background: var(--panel); }
.msg-compose-r { display: flex; align-items: flex-end; gap: 8px; }
.msg-box { flex: 1 1 auto; min-height: 38px; max-height: 160px; resize: none; overflow-y: auto; }
.msg-compose-r .btn { height: 38px; flex: none; }
.msg-compose-f { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-xs); }
.msg-hint { min-width: 0; }
.msg-count { flex: none; color: var(--ink-3); }
.msg-count[data-over="1"] { color: var(--err); font-weight: 600; }
.msg-why { color: var(--ring); }
.msg-err { display: block; }

/* ---- voicemail inbox ---- */
.vm-host { display: flex; flex-direction: column; gap: 10px; }
.vm-host > .msg-status { border: 0; padding: 0; }
.vm-list { display: flex; flex-direction: column; gap: 10px; }
.vm { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.vm[data-unread] { border-left: 3px solid var(--info); padding-left: 12px; }
.vm[data-gone] { opacity: .8; }
.vm-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.vm-dot { display: none; }
.vm-who { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.vm-who .num { font-size: var(--fs-sm); }
.vm-meta { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vm-new { padding: 0 6px; border-radius: 8px; background: var(--info); color: #04121f; font-size: 10.5px; font-weight: 600; line-height: 16px; }
:root[data-theme="light"] .vm-new { color: #fff; }
.vm-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; max-width: 70ch; }
.vm-play { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: var(--ctl-sm); }
.vm-audio { width: min(100%, 420px); height: 36px; }
.vm-wait { display: inline-flex; align-items: center; gap: 6px; }
.vm-act { display: flex; gap: 8px; flex-wrap: wrap; }
.vm-act a.btn { text-decoration: none; }

/* the "Text this number" row of the dialer's number card and the settings block */
.ins-r[data-k="text"] a { font-weight: 550; }

@media (max-width: 860px) {
  .msg-page { padding: 10px 10px 8px; gap: 8px; }
  .msg-page .page-h { min-height: 0; }
  .msg-page .page-t p { display: none; }
  .msg-page[data-tab="voicemail"] { padding-bottom: 24px; }
  .msg { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .msg[data-pane="list"] .msg-convo { display: none; }
  .msg[data-pane="convo"] .msg-side { display: none; }
  .msg-side { border-right: 0; }
  .msg-back { display: inline-flex; }
  /* a conversation gets the whole screen: the page title, the tabs and the notices come back with the list */
  .msg-page:has(.msg[data-pane="convo"]) > .page-h, .msg-page:has(.msg[data-pane="convo"]) > .msg-tabs, .msg-page:has(.msg[data-pane="convo"]) > .msg-notices { display: none; }
  .msg-h { padding-left: 4px; }
  .msg-m { max-width: 88%; }
  .msg-scroll { padding: 10px 10px 8px; }
  .msg-hint { display: none; }
  .msg-line { max-width: 150px; }
  .vm-meta { margin-left: 0; flex-basis: 100%; }
}

@media (pointer: coarse) {
  .msg-th { min-height: 56px; }
  .msg-box { min-height: 44px; font-size: 16px; }
  .msg-compose-r .btn { height: 44px; }
  .msg-to { height: 44px; font-size: 16px; }
  .msg-retry { min-height: 32px; padding: 0 4px; }
  .vm-audio { height: 44px; }
}
