/* S9 styles (s9-comms) -- consumes pomio.css tokens only; no new global tokens here. */
/* Communications panel + composer/detail modals (communications.js), e-mail
   templates settings section (communications.js), timeline e-mail rows
   (activityView.js). Light/dark via tokens; 44px tap targets. */

/* ---------------------------------------------------------------- drawer panel */
.comm-panel { min-width: 0; }
.comm-panel[hidden] { display: none; }
.comm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.comm-head h4 { margin: 0; font-size: 14px; }
.comm-send-btn { min-height: var(--tap-primary); }
.comm-note {
  margin: 0 0 10px; padding: 8px 10px; font-size: 13px; line-height: 1.45;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius-control);
}
.comm-empty { margin: 4px 0; }
.comm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.comm-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: var(--tap-primary); min-width: 0;
  padding: 8px 10px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control);
}
.comm-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.comm-item:focus-visible { outline: 2px solid var(--focus-edge, var(--accent)); outline-offset: 2px; }
.comm-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; }
.comm-item-subject { font-weight: 600; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.comm-item-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- modals */
.comm-modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.comm-modal.comm-modal-wide { width: 640px; max-width: calc(100vw - 24px); }
.comm-modal .modal-actions { flex-wrap: wrap; }
.comm-modal .modal-actions button { min-height: var(--tap-primary); }
.comm-modal select, .comm-modal input, .comm-modal textarea { width: 100%; min-height: var(--tap-primary); box-sizing: border-box; }
.comm-modal textarea { min-height: 160px; resize: vertical; font: inherit; line-height: 1.5; }
.comm-field-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-top: 4px; min-height: 16px; }
.comm-field-err { font-size: 12px; color: var(--danger-text); overflow-wrap: anywhere; }
.comm-modal .field > .comm-field-err { display: block; margin-top: 4px; }
.comm-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.comm-count[data-state="near"] { color: var(--warning-text); }
.comm-count[data-state="over"] { color: var(--danger-text); font-weight: 600; }
.comm-modal [aria-invalid="true"] { border-color: var(--danger); }
.comm-undo { margin-top: 6px; min-height: var(--tap); }
.comm-undo[hidden] { display: none; }

.comm-vars { margin: 4px 0 12px; font-size: 13px; }
.comm-vars summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--text-muted); }
.comm-var-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.comm-var-list code { font-family: var(--font-mono); font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--text); }

/* message text: shown as TEXT with line breaks kept (never HTML) */
.comm-body {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-control);
  padding: 10px 12px; max-height: 50vh; overflow-y: auto; margin: 0 0 12px;
}
.comm-preview { margin: 0 0 12px; }
.comm-preview[hidden] { display: none; }
.comm-preview-label { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.comm-preview-subject { margin: 0 0 6px; font-weight: 600; overflow-wrap: anywhere; }
.comm-preview-body { max-height: 30vh; }

.comm-detail-subject { overflow-wrap: anywhere; }
.comm-detail-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 10px; }
.comm-dl { margin: 0 0 12px; display: grid; gap: 4px; }
.comm-dl-row { display: grid; grid-template-columns: 120px 1fr; gap: 8px; font-size: 13px; }
.comm-dl-row dt { color: var(--muted); margin: 0; }
.comm-dl-row dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* ---------------------------------------------------------------- settings: templates */
.comm-tpl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.comm-tpl-head .btn-primary { min-height: var(--tap-primary); }
.comm-archived-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap-primary); margin: 4px 0 6px; }
.comm-tpl-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.comm-tpl-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface);
}
.comm-tpl-row.is-archived { background: var(--surface-2); }
.comm-tpl-main { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
.comm-tpl-subject { overflow-wrap: anywhere; }
.comm-tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.comm-tpl-actions button { min-height: var(--tap-primary); }

/* ---------------------------------------------------------------- timeline e-mail rows */
.tl-email .tl-dot { background: var(--trust); }
/* ROADMAP S9 tijdlijnpresentatie: the e-mail row text opens the message */
.tl-text-link { display: block; width: 100%; min-height: 32px; padding: 0; border: 0; border-radius: 4px; background: none; text-align: left; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.tl-text-link:hover { text-decoration-color: currentColor; }
.tl-via-ownership { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------------------------------------------------------------- phone width */
@media (max-width: 600px) {
  .comm-modal.comm-modal-wide { width: auto; max-width: none; }
  .comm-modal .modal-actions button { width: 100%; }
  .comm-dl-row { grid-template-columns: 1fr; gap: 0; }
  .comm-dl-row dt { font-size: 12px; }
  .comm-head .comm-send-btn { width: 100%; }
  .comm-tpl-head .btn-primary { width: 100%; }
  .comm-tpl-actions { width: 100%; }
  .comm-tpl-actions button { flex: 1 1 auto; }
}

/* ======================================================================
   S10 -- personal mailbox integration + CRM documents (mailboxSettings.js,
   mailboxMail.js, documents.js). Tokens only; light/dark via pomio.css.
   ====================================================================== */
/* ---------------------------------------------------------------- settings: E-mailintegratie */
.mbx-section { min-width: 0; }
.mbx-rule {
  margin: 0 0 14px; padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--text);
  background: var(--trust-soft); border: 1px solid var(--border); border-left: 3px solid var(--trust-text); border-radius: var(--radius-control);
}
.mbx-rule p { margin: 0; }
.mbx-rule p + p { margin-top: 4px; color: var(--text-muted); }
.mbx-ok { margin: 0 0 10px; font-size: 13px; color: var(--success-text); }
.mbx-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0 0 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
}
.mbx-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.mbx-card-who { min-width: 0; flex: 1 1 200px; }
.mbx-card-provider { font-weight: 600; }
.mbx-card-address { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.mbx-card .badge { white-space: nowrap; }
.mbx-card .comm-note, .mbx-card .comm-dl { margin: 0; }
.mbx-help { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.mbx-help-admin { padding: 8px 10px; background: var(--warning-soft); color: var(--text); border-radius: var(--radius-control); }
.mbx-dl .comm-dl-row { grid-template-columns: 200px 1fr; }
.mbx-actions, .mbx-providers { display: flex; flex-wrap: wrap; gap: 8px; }
.mbx-actions button, .mbx-provider-btn { min-height: var(--tap-primary); }
.mbx-provider-opt { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.mbx-provider-opt .hint { font-size: 12px; }
.mbx-overview { margin-top: 6px; }
.mbx-overview h4 { margin: 0 0 2px; font-size: 14px; }
.mbx-ov-address { overflow-wrap: anywhere; }
.mbx-ov-table .badge { white-space: nowrap; }

/* ---------------------------------------------------------------- composer */
.mbx-from, .comm-from { margin: -6px 0 12px; font-size: 13px; overflow-wrap: anywhere; }
.mbx-field { min-width: 0; }
.mbx-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.mbx-tokens {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: var(--tap-primary); padding: 4px 6px; box-sizing: border-box;
  background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: var(--radius-control); cursor: text; min-width: 0;
}
.mbx-tokens:focus-within { outline: 2px solid var(--focus-edge, var(--accent)); outline-offset: 1px; }
.mbx-chips { display: contents; list-style: none; margin: 0; padding: 0; }
.mbx-chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; padding: 2px 2px 2px 8px; font-size: 13px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-pill);
}
.mbx-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mbx-chip-x {
  width: 28px; height: 28px; min-height: 0 !important; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text-muted);
  font-size: 16px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.mbx-chip-x:hover { background: var(--surface-3); color: var(--text); }
.comm-modal .mbx-tokens .mbx-token-input {
  flex: 1 1 140px; width: auto; min-width: 120px; min-height: 34px; border: 0; padding: 4px; background: transparent; color: var(--text); outline: none; box-shadow: none;
}
.mbx-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 10px; }
.mbx-suggest .hint { font-size: 12px; }
.mbx-suggest-btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbx-ccbcc-toggle { margin: -4px 0 10px; min-height: var(--tap); }
.mbx-editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--input-bg); min-width: 0; }
.mbx-editor-wrap:focus-within { outline: 2px solid var(--focus-edge, var(--accent)); outline-offset: 1px; }
.mbx-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-control) var(--radius-control) 0 0; }
.comm-modal .mbx-tool {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text); font: inherit; font-size: 15px; cursor: pointer;
}
.mbx-tool:hover { background: var(--surface-3); }
.mbx-tool[aria-pressed="true"], .mbx-tool[aria-expanded="true"] { background: var(--surface); border-color: var(--border-strong); }
.mbx-tool:focus-visible { outline: 2px solid var(--focus-edge, var(--accent)); outline-offset: 1px; }
.mbx-link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-bottom: 1px solid var(--border); }
.comm-modal .mbx-link-row input { flex: 1 1 200px; width: auto; min-width: 0; }
.mbx-link-row .comm-field-err { flex-basis: 100%; }
.mbx-editor {
  min-height: 180px; max-height: 45vh; overflow-y: auto; padding: 10px 12px; font-size: 14px; line-height: 1.55; color: var(--text);
  overflow-wrap: anywhere; outline: none; cursor: text;
}
.mbx-editor p, .mbx-editor div { margin: 0 0 8px; }
.mbx-editor ul, .mbx-editor ol { margin: 0 0 8px; padding-left: 22px; }
.mbx-editor blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.mbx-editor a { color: var(--trust-text); }
.mbx-editor[aria-disabled="true"] { opacity: .6; }
.mbx-files { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mbx-file {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface);
}
.mbx-file.is-error { border-color: var(--danger); }
.mbx-file-main { display: flex; flex-direction: column; flex: 1 1 160px; min-width: 0; }
.mbx-file-name { font-size: 13px; overflow-wrap: anywhere; }
.mbx-file progress { flex: 1 1 100px; min-width: 80px; height: 8px; accent-color: var(--trust-text); }
.mbx-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mbx-cta button { min-height: var(--tap); }

/* ---------------------------------------------------------------- message detail */
.mbx-dir { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.mbx-dir-in { background: var(--trust-soft); color: var(--trust-text); border-color: transparent; }
.mbx-body-wrap { margin: 0 0 12px; min-width: 0; }
.mbx-body-wrap .comm-body { margin-bottom: 8px; }
/* the sanitized HTML body is "paper": always light, whatever the app theme */
.mbx-frame {
  display: block; width: 100%; height: 360px; max-height: 50vh; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; margin: 0 0 8px;
}
.mbx-body-toggle { min-height: var(--tap); }
.mbx-sub { margin: 0 0 6px; font-size: 14px; }
.mbx-att-wrap, .mbx-thread-wrap { margin: 0 0 12px; min-width: 0; }
.mbx-atts, .mbx-docs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mbx-att, .mbx-doc {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface);
}
.mbx-att.is-skipped { background: var(--surface-2); color: var(--text-muted); }
.mbx-att-main, .mbx-doc-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; min-width: 0; }
.mbx-att-name, .mbx-doc-title { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.mbx-att.is-skipped .mbx-att-name { font-weight: 400; }
.mbx-att-main .hint, .mbx-doc-main .hint { font-size: 12px; overflow-wrap: anywhere; }
.mbx-att-actions, .mbx-doc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mbx-att-actions button, .mbx-doc-actions button { min-height: var(--tap); }
.mbx-promote { flex-basis: 100%; display: grid; gap: 4px; padding-top: 6px; border-top: 1px dashed var(--border); }
.mbx-promote .field { margin: 0; }
.mbx-promote-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.mbx-promote-actions button { min-height: var(--tap); }
.mbx-thread > summary, .mbx-thread-msg > summary { cursor: pointer; min-height: var(--tap); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.mbx-thread > summary { font-weight: 600; font-size: 14px; }
.mbx-thread-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mbx-thread-msg { border: 1px solid var(--border); border-radius: var(--radius-control); padding: 4px 10px; background: var(--surface); }
.mbx-thread-msg.is-current { border-color: var(--border-strong); background: var(--surface-2); }
.mbx-thread-subject { font-size: 13.5px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.mbx-thread-meta { flex-basis: 100%; font-size: 12px; }
.mbx-thread-body { padding: 6px 0; }
.mbx-thread-msg > .btn-ghost { margin: 0 0 8px; min-height: var(--tap); }

/* ---------------------------------------------------------------- drawer: Documenten */
.s10-docs-slot[hidden] { display: none; }
.s10-docs-slot { margin-top: 12px; min-width: 0; }
.mbx-docs-panel { min-width: 0; }
.mbx-doc-prov { font-style: italic; }

/* ---------------------------------------------------------------- phone width */
@media (max-width: 600px) {
  .mbx-dl .comm-dl-row { grid-template-columns: 1fr; }
  .mbx-actions button, .mbx-provider-btn, .mbx-cta button { width: 100%; }
  .mbx-provider-opt { flex-basis: 100%; }
  .mbx-frame { height: 300px; }
  .mbx-att-actions, .mbx-doc-actions { width: 100%; }
  .mbx-att-actions button, .mbx-doc-actions button { flex: 1 1 auto; }
  .mbx-promote-actions button { flex: 1 1 auto; }
  .comm-modal .mbx-tokens .mbx-token-input { min-width: 100px; }
}
