@charset "UTF-8";
/*
 * TrilùTable 6.0 · Messaggi (prefix ms-), «Scuro premium» (docs/sviluppo/DESIGN-V6.md).
 * Shared components (.page-header, .panel, .search, .segmented, .chip, .count, .tag, .pill, .avatar, .banner, .empty,
 * .btn, .kbd) come from styles.css; this file adds the two-pane inbox, the thread and the composer.
 */

.ms-sub-alert { color: var(--amber); font-weight: 500; }

/* ---------- Shell ---------- */
.ms-shell {
  display: grid; grid-template-columns: 344px minmax(0, 1fr); height: clamp(540px, calc(100dvh - 208px), 1000px);
  padding: 0; overflow: hidden;
}
.ms-shell button, .ms-shell textarea { font: inherit; }
.ms-shell h2, .ms-shell h3, .ms-shell p { margin: 0; }

/* ---------- List ---------- */
.ms-list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.ms-list-tools { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line-soft); }
.ms-filters { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ms-search { flex: 1; min-width: 0; height: 32px; }
.ms-boxes { display: flex; width: 100%; }
.ms-boxes > button { flex: 1 1 0; min-width: 0; justify-content: center; gap: 6px; }
.ms-boxes .count { height: 16px; min-width: 16px; padding: 0 4px; font-size: 11px; line-height: 16px; }
.ms-channel { flex: none; }
.ms-channel .select { width: 124px; height: 32px; min-height: 32px; }
.ms-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ms-rows { margin: 0; padding: 4px 0; list-style: none; }
.ms-row {
  position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 12px; width: 100%;
  padding: 12px 14px 12px 16px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease);
}
.ms-rows > li + li .ms-row::before { content: ""; position: absolute; top: 0; left: 64px; right: 14px; height: 1px; background: var(--line-soft); }
.ms-row:hover { background: rgba(255, 255, 255, .025); }
.ms-row:focus-visible { outline-offset: -2px; }
.ms-row.is-selected { background: rgba(255, 255, 255, .05); }
.ms-row.is-selected::after { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); }
.ms-rows > li + li .ms-row.is-selected::before, .ms-rows > li:has(.is-selected) + li .ms-row::before { display: none; }
.ms-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ms-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.ms-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-1); }
.ms-row-top time { flex: none; font-size: 12px; color: var(--text-3); }
.ms-row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ms-row-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 18px; color: var(--text-3); }
.ms-row.is-unread .ms-row-name { font-weight: 600; }
.ms-row.is-unread .ms-row-preview { color: var(--text-1); }
.ms-row.is-unread .ms-row-top time { color: var(--text-1); }
.ms-unread { flex: none; height: 18px; min-width: 18px; padding: 0 5px; font-size: 11.5px; line-height: 18px; font-weight: 600; }
.ms-row-meta { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 4px; }
.ms-row-meta .tag { flex: 0 1 auto; min-width: 0; }
.ms-row-channel { flex: none; font-size: 12px; color: var(--text-3); }
.ms-list-empty { padding: 40px 20px; }

/* ---------- Avatars with the channel badge ---------- */
.ms-avatar { position: relative; width: 36px; height: 36px; font-size: 12px; }
.ms-avatar.is-lg { width: 40px; height: 40px; font-size: 13px; }
.ms-avatar-ch {
  position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-3); box-shadow: 0 0 0 2px var(--bg-2), inset 0 0 0 1px var(--line-strong); color: var(--text-2);
}
.ms-avatar.is-whatsapp .ms-avatar-ch { color: var(--green); }
.ms-avatar.is-agent .ms-avatar-ch { color: var(--violet); }
.ms-avatar.is-site .ms-avatar-ch, .ms-avatar.is-app .ms-avatar-ch { color: var(--blue); }

/* ---------- Thread ---------- */
.ms-thread-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #121417; }
.ms-thread-head { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2); }
.ms-back { display: none; margin-left: -6px; }
.ms-thread-title { flex: 1 1 auto; min-width: 0; }
.ms-thread-title h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; line-height: 22px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-thread-title p { display: flex; align-items: center; flex-wrap: wrap; gap: 0 2px; font-size: 13px; line-height: 18px; color: var(--text-2); }
.ms-thread-title .sep { margin: 0 6px; }
.ms-thread-channel { display: inline-flex; align-items: center; gap: 6px; }
.ms-thread-channel .icon { color: var(--text-3); }
.ms-phone { color: var(--text-1); text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .22); text-underline-offset: 3px; }
.ms-phone:hover { text-decoration-color: var(--text-1); }
.ms-muted { color: var(--text-3); }
.ms-thread-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.ms-res { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 6px 14px 6px 18px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2); font-size: 13px; color: var(--text-2); }
.ms-res > .icon { color: var(--text-3); }
.ms-res-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-res-text b { font-weight: 500; color: var(--text-1); }
.ms-res-text .sep { margin: 0 6px; }
.ms-res .text-button { flex: none; color: var(--text-1); }
.ms-res-short { display: none; }
.ms-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 24px 12px; }
.ms-messages:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ms-bubbles { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.ms-day { display: flex; align-items: center; gap: 12px; margin: 10px 0 14px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.ms-day::before, .ms-day::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.ms-msg { display: flex; flex-direction: column; margin-bottom: 12px; }
.ms-msg.is-grouped { margin-bottom: 3px; }
.ms-msg.is-in { align-items: flex-start; }
.ms-msg.is-out { align-items: flex-end; }
.ms-bubble { max-width: min(560px, 78%); padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 20px; color: var(--text-1); }
.ms-bubble p { white-space: pre-wrap; overflow-wrap: anywhere; }
.ms-msg.is-in .ms-bubble { background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line); }
.ms-msg.is-out .ms-bubble { background: #262A31; box-shadow: inset 0 0 0 1px var(--line-strong), var(--highlight); }
.ms-msg.is-in:not(.is-grouped) .ms-bubble { border-bottom-left-radius: 4px; }
.ms-msg.is-out:not(.is-grouped) .ms-bubble { border-bottom-right-radius: 4px; }
.ms-msg.is-agent .ms-bubble { background: var(--violet-soft); box-shadow: inset 0 0 0 1px var(--violet-line); }
.ms-bubble-tag { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 3px; font-size: 12px; font-weight: 500; color: var(--violet); }
.ms-msg-meta { display: flex; align-items: center; gap: 0; margin-top: 4px; padding: 0 4px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.ms-msg-meta .sep { margin: 0 5px; }
.ms-system { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 4px auto 14px; max-width: 520px; padding: 6px 12px; border-radius: 8px; background: rgba(255, 255, 255, .025); box-shadow: inset 0 0 0 1px var(--line-soft); font-size: 12.5px; line-height: 18px; color: var(--text-2); text-align: center; }
.ms-system .icon { color: var(--text-3); }
.ms-system time { color: var(--text-3); }
.ms-skeleton { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.ms-skeleton .skeleton { height: 40px; width: 52%; border-radius: 14px; }
.ms-skeleton .is-short { width: 34%; }
.ms-skeleton .is-out { align-self: flex-end; width: 44%; }
.ms-thread-state { display: grid; place-items: center; min-height: 100%; }
.ms-thread-state .banner { width: min(460px, 100%); }
.ms-inline-banner { margin-top: 12px; }
.ms-placeholder { display: grid; place-items: center; height: 100%; padding: 24px; }

/* ---------- Composer ---------- */
.ms-composer { padding: 10px 16px 12px; border-top: 1px solid var(--line-soft); background: var(--bg-2); }
.ms-handoff { margin-bottom: 10px; }
.ms-wa-button .icon { color: var(--green); }
.ms-quick { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
.ms-quick::-webkit-scrollbar { display: none; }
.ms-quick-chip { flex: none; height: 28px; padding: 0 10px; font-size: 12.5px; }
.ms-quick-chip:disabled { opacity: .5; cursor: not-allowed; }
.ms-compose { display: flex; align-items: flex-end; gap: 8px; }
.ms-input { flex: 1; min-width: 0; min-height: 40px !important; max-height: 160px; padding: 9px 12px !important; resize: none; line-height: 20px; overflow-y: auto; }
.ms-send { --btn-h: 40px; flex: none; }
.ms-send-error { margin: 8px 0 0; }
.ms-delivery { display: flex; align-items: center; gap: 8px; margin-top: 8px !important; font-size: 12.5px; line-height: 18px; color: var(--text-3); }
.ms-delivery > .icon { flex: none; }
.ms-delivery > span:first-of-type { flex: 1; min-width: 0; }
.ms-kbd-hint { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.ms-kbd-hint .kbd { height: 18px; line-height: 18px; padding: 0 4px; font-size: 11px; }

/* ---------- Dialogs ---------- */
.ms-dialog .field { margin-bottom: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .ms-shell { grid-template-columns: 312px minmax(0, 1fr); }
  .ms-thread-actions .ms-btn-label { display: none; }
  .ms-thread-actions .btn { width: 32px; padding: 0; }
}
@media (max-width: 1100px) {
  .ms-shell { height: clamp(520px, calc(100dvh - 176px), 1000px); }
}
@media (max-width: 900px) {
  .ms-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .ms-kbd-hint { display: none; }
}
@media (max-width: 768px) {
  .module-messages[data-ms-pane="thread"] > .page-header { display: none; }
  .ms-shell { grid-template-columns: minmax(0, 1fr); height: auto; scroll-margin-top: calc(var(--topbar-h) + 8px); }
  .ms-shell[data-pane="list"] .ms-thread-pane { display: none; }
  .ms-shell[data-pane="thread"] .ms-list-pane { display: none; }
  .ms-shell[data-pane="thread"] { height: calc(100dvh - var(--topbar-h) - 40px); min-height: 460px; }
  .ms-list-pane { border-right: 0; }
  .ms-list { overflow: visible; }
  .ms-back { display: inline-grid; }
  .ms-thread-head { padding: 8px 10px; gap: 10px; min-height: 56px; }
  .ms-thread-head .ms-avatar { display: none; }
  .ms-res { padding: 6px 10px 6px 14px; }
  .ms-messages { padding: 14px 12px 10px; }
  .ms-bubble { max-width: 86%; }
  .ms-composer { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .ms-send { width: 44px; padding: 0; }
  .ms-send .ms-btn-label { display: none; }
}
@media (max-width: 560px) {
  .ms-res-long { display: none; }
  .ms-res-short { display: inline; }
  /* Phones: booking on the first line, status and «Apri» on the second. */
  .ms-res { flex-wrap: wrap; row-gap: 4px; padding-block: 8px; }
  .ms-res-text { flex: 1 1 calc(100% - 30px); }
  .ms-res .pill { margin-left: 25px; }
  .ms-res .text-button { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { .ms-row { transition: none; } }
