/* The open conversation's thread pieces and its reply box (inbox/_thread.view.php, _composer.view.php, assets/composer.js),
   Switchboard's in Enquiry Desk's look: app.css tokens, square corners, hairline rules, pine for ours. */

/* the thread: a heading for each day, each email's From / To / Cc, its files, Original and Reply */
.msg-day { align-self: center; margin: 6px 0 0; }
.msg-day span { display: inline-block; padding: 3px 10px; background: var(--card); border: 1px solid var(--rule); font-size: 12px; color: var(--n700); }
.msg-head { margin: 0 0 8px; padding: 0 0 6px; border-bottom: 1px solid var(--rule); min-width: 0; }
.msg-parties { display: flex; flex-wrap: wrap; gap: 0 14px; margin: 0; font-size: 12.5px; color: var(--n700); min-width: 0; }
.msg-parties span { min-width: 0; overflow-wrap: anywhere; }
.msg-parties b { font-weight: 500; color: var(--ink); margin-right: 2px; }
.msg-head .msg-subj { margin: 4px 0 0; }
.msg-rich p, .msg-rich div, .msg-rich blockquote { margin: 0; }
.msg-rich ul, .msg-rich ol { margin: 4px 0; padding-left: 20px; }
.msg-rich, .msg-sig { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.msg-sig { margin: 10px 0 0; }
.msg-sig table { max-width: 100%; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.msg-files > span, .msg-files > a:not(.msg-file-photo) { display: inline-flex; align-items: center; gap: 4px; color: inherit; min-width: 0; overflow-wrap: anywhere; }
.msg-files > a:not(.msg-file-photo) { color: var(--p700); }
.msg-file-photo { flex-basis: 100%; display: block; }
.msg-file-photo img { display: block; max-width: min(100%, 320px); max-height: 320px; width: auto; height: auto; }
.msg-when { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.msg-ack { display: inline-flex; color: var(--n700); margin-left: 2px; }
.msg-ack.is-read { color: #34B7F1; }
.msg-when .bad { color: var(--err); }
.msg-link { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.msg-link:focus-visible { outline: 2px solid var(--p600); outline-offset: 2px; }
.msg-call.missed { color: var(--err); }
.ib-thread:has(.cmp.has-draft) .bot-wait { display: none; }

/* the reply box: one line until clicked into, the chevron shuts it again; More room fills the screen */
.cmp { position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 10px 20px 14px; background: var(--card); border-top: 1px solid var(--rule); flex: none; }
.cmp [hidden] { display: none !important; }
.cmp-corner { position: absolute; top: 6px; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; background: none; border: 0; color: var(--n700); cursor: pointer; z-index: 1; }
.cmp-corner:hover { color: var(--ink); }
.cmp-shut { right: 12px; }
.cmp-big { right: 44px; }
.cmp.shut { cursor: text; }
.cmp.shut .cmp-corner, .cmp.shut .cmp-rcpt, .cmp.shut .rich-tools, .cmp.shut .cmp-sigpick, .cmp.shut .cmp-chips, .cmp.shut .cmp-steps { display: none; }
.cmp.shut[data-email="1"] .cmp-send, .cmp.shut[data-email="1"] .cmp-discard, .cmp.shut[data-email="1"] .cmp-later, .cmp.shut[data-email="1"] .cmp-arch { display: none; }
.cmp.shut { flex-direction: row; align-items: flex-end; }
.cmp.shut .cmp-write { flex: 1; }
.cmp.shut textarea { height: 44px; min-height: 44px; }
.cmp.shut .rich-body { min-height: 0; height: 44px; overflow: hidden; }
.cmp-rcpt { margin: 0; padding-right: 72px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-rcpt .sub { font-size: 13px; margin-right: 2px; }
.cmp-cc { margin-left: 12px; }
.cmp-from { width: auto; max-width: 45%; height: auto; padding: 2px 4px; margin: 0 12px 0 0; border: 0; background: transparent; font-size: 13px; }
.cmp-write { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cmp-write textarea { width: 100%; min-height: 44px; max-height: 40vh; field-sizing: content; resize: none; line-height: 1.5; }
.cmp.shut:not([data-email="1"]) .cmp-write textarea { padding-right: 12px; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cmp-chips:not(:has(> :not([hidden]))) { display: none; }
.cmp-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-size: 13px; white-space: nowrap; overflow: hidden; background: none; padding: 0; color: var(--ink); letter-spacing: 0; text-transform: none; font-weight: 400; }
.cmp-chip > span, .cmp-chip b { overflow: hidden; text-overflow: ellipsis; }
.cmp-chip b { font-weight: 600; }
.cmp-chip .i { flex: none; color: var(--p700); }
.cmp-x, .ib-invite-chip .link { all: unset; display: inline-flex; cursor: pointer; color: var(--n700); padding: 2px; }
.cmp-x:hover { color: var(--ink); }
.cmp-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmp-grow { flex: 1; }
.cmp-foot .check { margin: 0; white-space: nowrap; }
.cmp-foot .btn-secondary, .cmp-foot .btn { padding: 9px 12px; }
.cmp-send span { margin-left: 2px; }
.cmp-discard { display: none; }
.cmp.has-draft .cmp-discard, .cmp.has-text .cmp-discard { display: inline-flex; }
.cmp.has-draft textarea, .cmp.has-draft .rich-body { background: #fdf8ef; }
.cmp-ai.is-busy::after, .rich-tool.is-busy::after { border-color: var(--ink); border-right-color: transparent; }

/* the bot's plan for its reply: what it looked up (dashed), then what it does when approved, each with an X */
.cmp-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cmp-steps li { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 10px; border: 1px solid var(--rule); background: var(--card); font-size: 13px; }
.cmp-steps li > span:first-of-type { flex: 1; min-width: 0; }
.cmp-steps li.looked { border-style: dashed; color: var(--n700); }
.cmp-steps li.done { color: var(--n700); }
.cmp-step-x { flex: none; display: inline-flex; cursor: pointer; color: var(--n700); position: relative; }
.cmp-step-x input { position: absolute; opacity: 0; pointer-events: none; }
.cmp-steps li:has(.cmp-step-x input:checked) > span:first-of-type { text-decoration: line-through; color: var(--n700); }

/* the editor: a row of tools over a writing area */
.rich { display: flex; flex-direction: column; border: 1px solid var(--n300); background: #fff; min-width: 0; }
.rich:focus-within { border-color: var(--p600); }
.rich-tools { display: flex; align-items: center; gap: 2px; padding: 3px; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.rich-tools::-webkit-scrollbar { display: none; }
.rich-tools button { flex: none; height: 32px; min-width: 32px; padding: 0 8px; background: none; border: 0; color: var(--ink); font: 500 14px var(--f-body); cursor: pointer; display: inline-grid; place-items: center; position: relative; }
.rich-tools button:hover { background: var(--p100); }
.rich-tools .rich-tool { padding: 0; width: 34px; color: var(--n700); }
.rich-tools .rich-tool:hover { color: var(--ink); }
.rich-gap { flex: 1; }
.rich-body { min-height: calc(4.5em + 20px); max-height: calc(15em + 20px); overflow-y: auto; scrollbar-width: none; padding: 10px 12px; outline: 0; overflow-wrap: anywhere; line-height: 1.5; }
.rich-body:empty::before { content: attr(data-placeholder); color: var(--n700); }
.rich-body p, .rich-body div { margin: 0; }
.rich-body ul, .rich-body ol { margin: 4px 0; padding-left: 20px; }
.cmp-tools-extra { display: contents; }
.cmp-tools-extra .ib-invite { display: none; }

/* the signature: a quiet select under the editor; the company one shown as it will look, with Edit */
.cmp-sigpick { display: flex; flex-direction: column; gap: 6px; }
.cmp-sigpick select { width: auto; max-width: 100%; height: auto; padding: 2px 4px; border: 0; background: transparent; color: var(--n700); font-size: 13px; }
.cmp-sig { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.cmp-sig.has-sig { padding: 10px 12px; border: 1px solid var(--rule); }
.cmp-sig table { opacity: .8; max-width: 100%; }
.cmp-sig .btn-secondary { flex: none; padding: 6px 10px; font-size: 15px; }
.cmp:not(.sig-company) .cmp-sig { display: none; }
.cmp-sig-logo { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.cmp-sig-logo img { max-height: 48px; width: auto; }
.cmp-sig-logo .check { margin: 0; }

/* More room: the reply box large over the conversation, everything in it as it was */
html.cmp-big-on { overflow: hidden; }
.cmp.big { position: fixed; z-index: 60; top: 5vh; bottom: 5vh; left: max(16px, calc(50% - 440px)); right: max(16px, calc(50% - 440px)); overflow-y: auto; padding: 48px 20px 16px; border: 1px solid var(--ink); box-shadow: 0 0 0 100vmax rgba(18, 61, 47, .35); }
.cmp.big .cmp-write { flex: 1; }
.cmp.big .rich-body, .cmp.big textarea { height: calc(90vh - 300px) !important; min-height: 200px; max-height: none !important; }

/* saved replies: a menu under the button */
.snip-menu { position: absolute; z-index: 70; min-width: 220px; max-width: min(360px, 90vw); max-height: 320px; overflow-y: auto; scrollbar-width: none; background: var(--card); border: 1px solid var(--rule); box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 4px 0; }
.snip-menu .snip { display: flex; align-items: center; }
.snip-menu .snip > button:first-child { flex: 1; min-width: 0; text-align: left; padding: 8px 12px; background: none; border: 0; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snip-menu .snip > button:first-child:hover { background: var(--p100); }
.snip-menu .snip-x { flex: none; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; background: none; border: 0; color: var(--n700); cursor: pointer; position: relative; }
.snip-menu .snip-x.is-busy::after { border-color: var(--ink); border-right-color: transparent; }
.snip-menu .snip-save { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-top: 1px solid var(--rule); background: none; font: 600 14px var(--f-body); color: var(--p700); cursor: pointer; }
.snip-menu .snip-none { padding: 8px 12px; font-size: 14px; color: var(--n700); }

/* dialogs: Send later, a signature, an email's Original */
dialog.cmp-dlg { border: 1px solid var(--rule); padding: 22px; max-width: 560px; width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog.cmp-dlg::backdrop { background: rgba(18,61,47,.35); }
dialog.cmp-dlg h2 { font-size: 20px; overflow-wrap: anywhere; }
dialog.cmp-dlg .cmp-foot { justify-content: flex-end; margin-top: 6px; }
dialog.cmp-dlg input[type=datetime-local], dialog.cmp-dlg input[type=tel] { width: 100%; height: 44px; padding: 0 10px; font: inherit; border: 1px solid var(--n300); border-radius: 0; background: #fff; color: var(--ink); }
dialog.cmp-orig { max-width: 900px; }
.cmp-orig-head { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: 14px; }
.cmp-orig-head dt { color: var(--n700); font-size: 13px; }
.cmp-orig-head dd { margin: 0; overflow-wrap: anywhere; }
.cmp-orig-head [hidden], .cmp-orig-tools [hidden] { display: none; }
.cmp-orig-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 14px; margin-bottom: 10px; }
.cmp-orig-tools .btn-secondary { padding: 6px 12px; font-size: 15px; }
.cmp-orig-raw { flex-basis: 100%; }
.cmp-orig-raw summary { cursor: pointer; font-size: 14px; color: var(--n700); padding: 4px 0; }
.cmp-orig-raw pre { max-height: 240px; overflow: auto; margin: 6px 0 0; padding: 10px; background: var(--bg); border: 1px solid var(--rule); font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmp-orig-frame { display: block; width: 100%; height: min(65vh, 720px); border: 1px solid var(--rule); background: #fff; }

@media (max-width: 760px) {
  .cmp { padding: 8px 16px 12px; }
  .cmp-send span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .cmp:not(.shut) .rich-body, .cmp:not(.shut) textarea { min-height: calc(6em + 20px); }
  .cmp.big { top: 0; bottom: 0; left: 0; right: 0; border: 0; padding-top: 44px; }
  .cmp.big .rich-body, .cmp.big textarea { height: calc(100dvh - 300px) !important; }
  .msg-parties { gap: 0 10px; }
}
