/* COMPOSER-wa (owner, 24 Oct 2026, key cw1): the /channex/ message composer in the WhatsApp spirit, Madalena colours.
   One row, vertically centred, 8 px gaps: thin "+" (quick messages, no circle) | slim pill input (attach clip inside it on the right,
   or the "Convidar" chip while a closed WhatsApp window can take an invite) | solid round navy send (muted when disabled).
   Same elements, ids and listeners as before; only the order inside .guesty-chat-input-row changed (quick, invite, attach, file, text, send).
   Loaded after materialize-madalena.css; every rule is scoped to #guesty-chat-form so it wins over the older composer rules
   (theme 2364/2640/2996, the pointer:fine dock sizes) without touching them. */
body.rm-admin #guesty-chat-form.guesty-chat-composer {
  --cw-h: 44px;
  --cw-navy: #16304d;
  gap: 6px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid #eef0f4;
  background: #fff;
}
/* keyboard up (phones): the safe-area gap would sit above the keyboard; same rule as theme 2494, kept here so it is not outranked */
body.rm-admin #guesty-chat-modal.is-keyboard-open #guesty-chat-form.guesty-chat-composer { padding-bottom: 8px; }

body.rm-admin #guesty-chat-form .guesty-chat-input-row {
  position: relative;
  display: flex;
  align-items: flex-end; /* one line: everything centred (all 44 px); several lines: the buttons stay on the last line, like WhatsApp */
  gap: 8px;
  min-width: 0;
}

/* ---- thin icon buttons: "+" and the clip. No outline, no circle at rest; a soft round wash on hover/press. ---- */
body.rm-admin #guesty-chat-form .guesty-chat-quick,
body.rm-admin #guesty-chat-form .guesty-chat-attach {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--cw-h);
  min-width: var(--cw-h);
  height: var(--cw-h);
  min-height: var(--cw-h);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cw-navy);
  box-shadow: none;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body.rm-admin #guesty-chat-form .guesty-chat-quick[hidden],
body.rm-admin #guesty-chat-form .guesty-chat-attach[hidden],
body.rm-admin #guesty-chat-form .guesty-chat-invite[hidden] { display: none; }
body.rm-admin #guesty-chat-form .guesty-chat-quick i { margin: 0; font-size: 27px; line-height: 1; transition: transform .18s ease; }
body.rm-admin #guesty-chat-form .guesty-chat-attach i { margin: 0; font-size: 21px; line-height: 1; }
body.rm-admin #guesty-chat-form .guesty-chat-quick:hover,
body.rm-admin #guesty-chat-form .guesty-chat-attach:hover:not(:disabled) { border: 0; background: rgba(22, 48, 77, .06); color: var(--cw-navy); }
body.rm-admin #guesty-chat-form .guesty-chat-quick:active,
body.rm-admin #guesty-chat-form .guesty-chat-attach:active:not(:disabled) { background: rgba(22, 48, 77, .12); }
body.rm-admin #guesty-chat-form .guesty-chat-quick:focus-visible,
body.rm-admin #guesty-chat-form .guesty-chat-attach:focus-visible,
body.rm-admin #guesty-chat-form .guesty-chat-invite:focus-visible,
body.rm-admin #guesty-chat-form .guesty-chat-send:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(201, 165, 90, .45); }
/* open quick menu: the "+" turns into an "x" on a light navy wash (was a filled navy circle) */
body.rm-admin #guesty-chat-form .guesty-chat-quick.is-open,
body.rm-admin #guesty-chat-form .guesty-chat-quick.is-open:hover { border: 0; background: rgba(22, 48, 77, .1); color: var(--cw-navy); }
body.rm-admin #guesty-chat-form .guesty-chat-quick.is-open i { transform: rotate(45deg); }

/* ---- the clip and the invite chip sit inside the pill, on its right edge (on the last line when the text grows) ---- */
body.rm-admin #guesty-chat-form .guesty-chat-attach {
  position: absolute;
  right: calc(var(--cw-h) + 8px);
  bottom: 0;
  z-index: 1;
  color: #5b6676;
}
body.rm-admin #guesty-chat-form .guesty-chat-attach:disabled { opacity: .4; cursor: not-allowed; }
body.rm-admin #guesty-chat-form .guesty-chat-invite {
  position: absolute;
  right: calc(var(--cw-h) + 8px + 6px);
  bottom: calc((var(--cw-h) - 30px) / 2);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 999px;
  background: #e5f5eb;
  color: #11703f;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body.rm-admin #guesty-chat-form .guesty-chat-invite i { margin: 0; font-size: 16px; line-height: 1; }
body.rm-admin #guesty-chat-form .guesty-chat-invite:hover { background: #d6efdf; color: #0d5f35; }
body.rm-admin #guesty-chat-form .guesty-chat-invite:active { background: #c7e9d3; }
/* a usable invite replaces the (then disabled) clip inside the pill */
body.rm-admin #guesty-chat-form .guesty-chat-invite:not([hidden]) ~ .guesty-chat-attach { display: none; }

/* ---- the slim pill input; grows with the text up to 140 px (admin.js), then scrolls ---- */
body.rm-admin #guesty-chat-form .guesty-chat-input-row textarea {
  flex: 1 1 auto;
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  height: var(--cw-h);
  min-height: var(--cw-h);
  max-height: 140px;
  margin: 0;
  padding: 11px 16px;
  overflow-y: auto;
  border: 1px solid #dde2e9;
  border-radius: 22px;
  background: #f7f8fa;
  color: #111827;
  font-family: inherit;
  font-size: 16px; /* 16 px: iOS never zooms into the field */
  line-height: 20px;
  resize: none;
  box-shadow: none;
  scrollbar-width: thin;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
body.rm-admin #guesty-chat-form .guesty-chat-attach:not([hidden]) ~ textarea { padding-right: 46px; }
body.rm-admin #guesty-chat-form .guesty-chat-invite:not([hidden]) ~ textarea { padding-right: 110px; }
body.rm-admin #guesty-chat-form .guesty-chat-input-row textarea:focus { border-color: #c9a55a; background: #fff; outline: 0; box-shadow: 0 0 0 2px rgba(201, 165, 90, .16); }
body.rm-admin #guesty-chat-form .guesty-chat-input-row textarea::placeholder { color: #8a93a2; opacity: 1; }
/* the hint is always one line: the texts are short (admin.js), an ellipsis is the last resort; a typed draft still wraps */
body.rm-admin #guesty-chat-form .guesty-chat-input-row textarea:placeholder-shown { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* blocked composer (closed window, no route, read-only): same size as the live one, muted (was 62 px / 14 px) */
body.rm-admin #guesty-chat-form.is-window-closed .guesty-chat-input-row textarea { min-height: var(--cw-h); background: #f3f4f6; color: #9aa2ae; font-size: 16px; line-height: 20px; cursor: not-allowed; }
body.rm-admin #guesty-chat-form.is-window-closed .guesty-chat-input-row textarea::placeholder { color: #8d95a3; }

/* ---- send: solid round Madalena navy, filled plane; muted grey when it cannot send ---- */
body.rm-admin #guesty-chat-form .guesty-chat-send {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--cw-h);
  min-width: var(--cw-h);
  height: var(--cw-h);
  min-height: var(--cw-h);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--cw-navy);
  color: #fff;
  box-shadow: 0 2px 6px -2px rgba(20, 47, 83, .45);
  opacity: 1;
  transition: background-color .15s ease, box-shadow .15s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body.rm-admin #guesty-chat-form .guesty-chat-send i {
  margin: 0 0 0 2px;
  font-size: 20px;
  line-height: 1;
  --svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 13h6v-2H3V1.846a.5.5 0 0 1 .741-.438l18.462 10.154a.5.5 0 0 1 0 .876L3.741 22.592A.5.5 0 0 1 3 22.154V13Z'/%3E%3C/svg%3E");
}
body.rm-admin #guesty-chat-form .guesty-chat-send:hover:not(:disabled) { border: 0; background: #1f4268; color: #fff; box-shadow: 0 4px 10px -3px rgba(20, 47, 83, .5); }
body.rm-admin #guesty-chat-form .guesty-chat-send:active:not(:disabled) { transform: scale(.94); }
body.rm-admin #guesty-chat-form .guesty-chat-send:disabled,
body.rm-admin #guesty-chat-form.is-window-closed .guesty-chat-send { background: #e6e9ee; color: #a3abb7; box-shadow: none; opacity: 1; cursor: not-allowed; }

/* ---- docked chat on a desktop mouse: 40 px row (the old dock rule shrank the clip to 32 and send to 36) ---- */
@media (pointer: fine) and (min-width: 781px) {
  body.rm-admin #guesty-chat-form.guesty-chat-composer { --cw-h: 40px; padding: 8px 12px 10px; }
  body.rm-admin #guesty-chat-form .guesty-chat-input-row textarea { padding: 9px 15px; border-radius: 20px; }
  body.rm-admin #guesty-chat-form .guesty-chat-attach:not([hidden]) ~ textarea { padding-right: 42px; }
  body.rm-admin #guesty-chat-form .guesty-chat-quick i { font-size: 25px; }
  body.rm-admin #guesty-chat-form .guesty-chat-attach i { font-size: 19px; }
  body.rm-admin #guesty-chat-form .guesty-chat-send i { font-size: 18px; }
  body.rm-admin #guesty-chat-form .guesty-chat-invite { bottom: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  body.rm-admin #guesty-chat-form .guesty-chat-quick i,
  body.rm-admin #guesty-chat-form .guesty-chat-send { transition: none; }
}
/* CHAT-confirm-theme (owner 27 Oct 2026): themed confirm for the /channex/ chat (cxConfirm in admin.js), replacing the native
   confirm(). Title + two buttons; centred card on a desktop, bottom sheet on a phone (<= 780 px). Madalena navy/gold. */
body.rm-admin dialog.cx-confirm { box-sizing: border-box; width: min(380px, calc(100vw - 32px)); max-width: none; max-height: none; margin: auto; padding: 0;
  border: 0; border-radius: .75rem; background: var(--rm-paper, #fff); color: var(--rm-text, #676a7b); box-shadow: 0 22px 60px rgba(15, 34, 58, .26);
  overflow: hidden; }
body.rm-admin dialog.cx-confirm[open] { display: block; animation: cx-confirm-in .18s ease-out; }
body.rm-admin dialog.cx-confirm::backdrop { background: rgba(15, 34, 58, .42); }
body.rm-admin .cx-confirm-card { display: flex; flex-direction: column; align-items: center; padding: 24px 22px 20px; text-align: center; }
body.rm-admin .cx-confirm-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0 0 12px;
  border-radius: 50%; background: var(--rm-accent-soft, #faf3e5); color: #9a7330; font-size: 22px; box-shadow: inset 0 0 0 1px rgba(210, 170, 97, .45); }
body.rm-admin dialog.cx-confirm[data-tone="danger"] .cx-confirm-icon { background: var(--rm-danger-soft, #ffe8e7); color: #b23a37; box-shadow: inset 0 0 0 1px rgba(217, 75, 72, .3); }
body.rm-admin .cx-confirm-title { margin: 0; color: var(--rm-primary, #142f53); font-size: 17px; font-weight: 700; line-height: 1.3; letter-spacing: 0; }
body.rm-admin .cx-confirm-text { margin: 6px 0 0; color: var(--rm-text, #676a7b); font-size: 14px; line-height: 1.4; }
body.rm-admin .cx-confirm-text[hidden] { display: none; }
body.rm-admin .cx-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 20px 0 0; }
body.rm-admin .cx-confirm-actions button { min-height: 44px; padding: 0 14px; border-radius: .5rem; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }
body.rm-admin .cx-confirm-cancel { border: 1px solid var(--rm-line, #e5e6e8); background: #fff; color: var(--rm-heading, #303548); }
body.rm-admin .cx-confirm-ok { border: 1px solid var(--rm-primary, #142f53); background: var(--rm-primary, #142f53); color: #fff; }
body.rm-admin dialog.cx-confirm[data-tone="danger"] .cx-confirm-ok { border-color: var(--rm-danger, #d94b48); background: var(--rm-danger, #d94b48); }
@media (hover: hover) {
  body.rm-admin .cx-confirm-cancel:hover { background: var(--rm-body, #f7f7f9); border-color: #d5d8de; }
  body.rm-admin .cx-confirm-ok:hover { background: var(--rm-primary-hover, #0f2848); border-color: var(--rm-primary-hover, #0f2848); }
  body.rm-admin dialog.cx-confirm[data-tone="danger"] .cx-confirm-ok:hover { background: #c23f3c; border-color: #c23f3c; }
}
body.rm-admin .cx-confirm-actions button:active { transform: scale(.97); }
body.rm-admin .cx-confirm-actions button:focus-visible { outline: 2px solid var(--rm-accent, #d2aa61); outline-offset: 2px; }
@keyframes cx-confirm-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cx-confirm-up { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 780px) {
  body.rm-admin dialog.cx-confirm { width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(15, 34, 58, .22); }
  body.rm-admin dialog.cx-confirm[open] { animation: cx-confirm-up .22s cubic-bezier(.2, .8, .2, 1); }
  body.rm-admin .cx-confirm-card { padding: 10px 20px calc(18px + env(safe-area-inset-bottom, 0px)); }
  body.rm-admin .cx-confirm-card::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 0 16px; border-radius: 2px; background: #d9dce2; }
}
@media (prefers-reduced-motion: reduce) {
  body.rm-admin dialog.cx-confirm[open] { animation: none; }
  body.rm-admin .cx-confirm-actions button { transition: none; }
  body.rm-admin .cx-confirm-actions button:active { transform: none; }
}

/* MSG-wa-format (owner 28 Oct 2026): WhatsApp bubbles as the guest sees them - *bold*, _italic_, ~strike~, ```mono```,
   the template header in bold and the template button as a non-clickable chip under a thin divider (label only). */
body.rm-admin .guesty-chat-bubble p.wa-text strong { font-weight: 700; color: inherit; }
body.rm-admin .guesty-chat-bubble p.wa-text em { font-style: italic; }
body.rm-admin .guesty-chat-bubble p.wa-text s { text-decoration: line-through; }
body.rm-admin .guesty-chat-bubble p.wa-text code.wa-mono { padding: 0; border: 0; background: none; color: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .93em; white-space: pre-wrap; }
body.rm-admin .guesty-chat-bubble p.wa-text .wa-tpl-head { display: block; margin-bottom: 4px; font-size: 15px; font-weight: 700; line-height: 1.35; }
body.rm-admin .guesty-chat-bubble .wa-tpl-buttons { margin: 6px -10px -6px; border-top: 1px solid rgba(17, 24, 39, .12); }
body.rm-admin .guesty-chat-bubble .wa-tpl-button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 12px; color: #1e3a5f; font-size: 14px; font-weight: 600; line-height: 1.25; text-align: center; cursor: default; user-select: none; -webkit-user-select: none; }
body.rm-admin .guesty-chat-bubble .wa-tpl-button i { flex: none; font-size: 16px; line-height: 1; }
body.rm-admin .guesty-chat-bubble .wa-tpl-button span { min-width: 0; overflow-wrap: anywhere; }
body.rm-admin .guesty-chat-message.is-host .guesty-chat-bubble .wa-tpl-buttons { border-top-color: rgba(255, 255, 255, .22); }
body.rm-admin .guesty-chat-message.is-host .guesty-chat-bubble .wa-tpl-button { color: #e9c97f; }
body.rm-admin .guesty-chat-message.is-host.is-failed .guesty-chat-bubble .wa-tpl-buttons { border-top-color: rgba(164, 70, 43, .25); }
body.rm-admin .guesty-chat-message.is-host.is-failed .guesty-chat-bubble .wa-tpl-button { color: #a4462b; }
/* WA-channel-phone (28 Oct 2026): continuous guest history. A sticky reservation-context bar at the start of every stay
   segment (same-size opaque cards: a later card covers an earlier stuck one); the sticky day pill sits under it. */
body.rm-admin .guesty-chat-list > .chat-stay-bar { position: sticky; top: 0; z-index: 4; display: flex; justify-content: center; align-items: center; height: 42px; margin: 4px 0; padding: 0 4px; box-sizing: border-box; pointer-events: none; }
/* Every bar card has the same width, so the newest stuck card fully covers an older stuck one. */
body.rm-admin .chat-stay-bar-card { pointer-events: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: min(100%, 420px); min-width: 0; height: 34px; padding: 0 12px; box-sizing: border-box; border: 1px solid #d9e1ec; border-radius: 999px; background: #f4f7fb; color: #16304d; font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; overflow: hidden; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
body.rm-admin button.chat-stay-bar-card { cursor: pointer; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { body.rm-admin button.chat-stay-bar-card:hover { background: #e9eff8; } }
body.rm-admin button.chat-stay-bar-card:active { background: #e1e9f4; }
body.rm-admin button.chat-stay-bar-card:focus-visible { outline: 2px solid #c9a24a; outline-offset: 1px; }
body.rm-admin .chat-stay-bar-card > .brand-logo, body.rm-admin .chat-stay-bar-card > .ri:first-child { flex: none; width: 16px; height: 16px; font-size: 15px; }
body.rm-admin .chat-stay-bar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.rm-admin .chat-stay-bar-text b { font-weight: 700; }
body.rm-admin .chat-stay-bar-card small { flex: none; color: #6b778a; font-size: 11px; font-weight: 600; }
body.rm-admin .chat-stay-bar-go { flex: none; margin-right: -4px; color: #6b778a; font-size: 16px; }
body.rm-admin .chat-stay-bar.is-current .chat-stay-bar-card { border-color: #cfe6d7; background: #eef7f1; }
body.rm-admin .chat-stay-bar.is-out .chat-stay-bar-card { border-style: dashed; background: #f6f6f8; color: #6b778a; }
body.rm-admin .guesty-chat-list.has-stay-bars > .guesty-chat-day:not(.is-system) { top: 46px; }
/* CHAT-no-current-bar (28 Oct 2026): no bar for the chat's own current stay (the header shows it), only a zero-height marker;
   past it (is-stay-unpinned, admin.js chatStayPinSync) no stay bar stays pinned and the day pill returns to the very top. */
body.rm-admin .guesty-chat-list > .chat-stay-mark { display: block; height: 0; margin: 0; padding: 0; overflow: hidden; pointer-events: none; }
body.rm-admin .guesty-chat-list.is-stay-unpinned > .chat-stay-bar { position: static; }
body.rm-admin .guesty-chat-list.has-stay-bars.is-stay-unpinned > .guesty-chat-day:not(.is-system) { top: 0; }
/* MSGFIX HDR-8 (19 Nov 2026): when scrolling crosses the current-stay marker the pinned day pill glides to its new offset
   instead of jumping 46 px. is-stay-glide is set by admin.js for a scroll-caused change only (about 220 ms), never by a render.
   The stay bars themselves switch at once on purpose (a previous-stay bar must never cover current-stay messages). */
@media (prefers-reduced-motion: no-preference) {
  body.rm-admin .guesty-chat-list.is-stay-glide > .guesty-chat-day:not(.is-system) { transition: top .16s ease-out; }
}
/* The invite confirm previews the approved template text with its line breaks; a tall dialog scrolls instead of leaving the screen. */
body.rm-admin .cx-confirm-text { white-space: pre-line; }
body.rm-admin dialog.cx-confirm[open] { max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
