/* ---------- Inbox (inbox.php) ---------- */
.inbox { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: var(--space-5); align-items: stretch;
  height: calc(100vh - 220px); height: calc(100dvh - 220px); min-height: 520px; }
.inbox > .card { margin: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.inbox__search { position: relative; padding: var(--space-3) var(--space-3) 0; }
.inbox__search > .icon { position: absolute; left: calc(var(--space-3) + 12px); top: calc(var(--space-3) + 11px); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.inbox__search input { width: 100%; padding-left: 38px; }
.inbox__filters { display: flex; flex-wrap: wrap; gap: 4px; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.inbox__filter { flex: none; padding: 5px 10px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.inbox__filter:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.inbox__filter.is-active { background: var(--primary-soft); color: var(--primary); }
.inbox__warn { display: flex; gap: var(--space-2); margin: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); font-size: .85rem; }
.inbox__warn .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.inbox__empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); font-size: .92rem; }
.inbox__items { list-style: none; margin: 0; padding: var(--space-2); overflow-y: auto; flex: 1; min-height: 0; }

.inbox-item { position: relative; display: flex; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.inbox-item:hover { background: var(--surface-2); text-decoration: none; }
.inbox-item.is-active { background: var(--primary-soft); }
.inbox-item__ch { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--primary); }
.inbox-item__ch .icon { width: 17px; height: 17px; }
.inbox-item__ch--whatsapp { background: #e3f4ea; color: #1f8a4c; }
.inbox-item__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.inbox-item__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.inbox-item__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item__time { flex: none; font-size: .76rem; color: var(--muted); }
.inbox-item__subject, .inbox-item__snippet { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item__snippet { color: var(--muted); }
.inbox-item__client { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; font-size: .76rem; font-weight: 600; color: var(--primary); }
.inbox-item__client .icon { width: 13px; height: 13px; }
.inbox-item.is-unread .inbox-item__name, .inbox-item.is-unread .inbox-item__subject { font-weight: 800; }
.inbox-item.is-unread .inbox-item__snippet { color: var(--text); }
.inbox-item__dot { position: absolute; right: var(--space-3); bottom: calc(var(--space-3) + 4px); width: 9px; height: 9px; border-radius: 50%; background: var(--oker); }

.pane-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.pane-head__who { flex: 1; min-width: 0; }
.pane-head__who h2 { margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-head__who .small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-back { display: none; }
.pane-subject { margin: 0; padding: var(--space-3) var(--space-4) 0; font-weight: 700; }
.pane-client { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); font-size: .88rem; }
.pane-client label .icon { width: 16px; height: 16px; color: var(--muted); }
.pane-client select { width: auto; max-width: 60%; min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: .88rem; }
.pane-messages { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); background: var(--surface-sunken, var(--bg)); }
.pane-form { padding: var(--space-4); overflow-y: auto; }
.pane-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: var(--space-2); color: var(--muted); }
.pane-empty .icon { width: 32px; height: 32px; }

.msg-day { text-align: center; font-size: .76rem; color: var(--muted); margin: var(--space-2) 0; }
.msg-day span { padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.msg { max-width: min(78%, 680px); padding: var(--space-3) var(--space-4); border-radius: 14px; background: var(--surface); border: 1px solid var(--border); line-height: 1.5; overflow-wrap: anywhere; }
.msg--in { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg--out { align-self: flex-end; background: var(--primary-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg--failed { border-color: var(--danger); }
.msg__head { font-size: .84rem; margin-bottom: var(--space-1); }
.msg__text { font-size: .94rem; }
.msg__text a { word-break: break-all; }
.msg__tag { display: inline-block; margin-bottom: 4px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); font-size: .72rem; font-weight: 700; color: var(--muted); }
.msg__quote { margin-top: var(--space-2); font-size: .86rem; color: var(--muted); }
.msg__quote > summary { cursor: pointer; font-size: .8rem; font-weight: 600; }
.msg__quote .msg__text { margin-top: var(--space-2); padding-left: var(--space-3); border-left: 3px solid var(--border); font-size: .86rem; }
.msg__meta { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; font-size: .72rem; color: var(--muted); }
.msg__status--read { color: #2b8fd6; font-weight: 700; }
.msg__status--failed { color: var(--danger); font-weight: 800; }
.msg__error { margin: 4px 0 0; font-size: .8rem; color: var(--danger); }
.msg__files { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.msg-file { display: inline-flex; flex-direction: column; gap: 2px; max-width: 260px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: .84rem; text-decoration: none; }
.msg-file:hover { text-decoration: none; background: var(--border); }
.msg-file__name { display: inline-flex; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file__name .icon { flex: none; width: 14px; height: 14px; }
.msg-file--img img { display: block; max-width: 240px; max-height: 240px; border-radius: 8px; margin-bottom: 4px; }

.composer { border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4); background: var(--surface); }
.composer textarea { width: 100%; resize: none; min-height: 44px; max-height: 320px; }
.composer__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); }
.composer__attach { position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: .86rem; font-weight: 600; cursor: pointer; }
.composer__attach:hover { background: var(--surface-2); color: var(--text); }
.composer__attach .icon { flex: none; width: 16px; height: 16px; }
.composer__attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.composer__snippet { width: auto; max-width: 12rem; margin-left: auto; padding: 6px 28px 6px 10px; font-size: .86rem; min-height: 0; }
.composer__snippet + .btn { flex: none; }
.composer__attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.composer--template p { display: flex; gap: 6px; margin: 0 0 var(--space-3); }
.composer--template p .icon { flex: none; width: 15px; height: 15px; margin-top: 2px; }
.btn.is-busy { opacity: .7; }

/* Telefoon: lijst óf gesprek */
@media (max-width: 860px) {
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .inbox > .card { min-height: calc(100dvh - 190px); }
  .inbox.has-thread .inbox__list { display: none; }
  .inbox:not(.has-thread) .inbox__pane { display: none; }
  .pane-back { display: grid; place-items: center; width: 34px; height: 34px; margin-left: -6px; border-radius: 50%; color: var(--text); flex: none; }
  .pane-back:hover { background: var(--surface-2); }
  .inbox.has-thread > .inbox__pane { height: calc(100dvh - 150px); min-height: 420px; }
  .msg { max-width: 88%; }
  .pane-client select { max-width: 100%; flex: 1; }
  /* Gesprek open: alleen het gesprek, zonder paginakop en uitleg. */
  .content:has(.inbox.has-thread) .page-head, .content:has(.inbox.has-thread) .help-panel { display: none; }
  .content:has(.inbox) .help-panel { display: none; }
  .content:has(.inbox) .page-head__intro { display: none; }
  .inbox.has-thread > .inbox__pane { height: calc(100dvh - 110px); }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .inbox-item__ch--whatsapp { background: #17402b; color: #6fd29a; } }
:root[data-theme="dark"] .inbox-item__ch--whatsapp { background: #17402b; color: #6fd29a; }

/* Berichten bij een klant (client_edit.php) */
.client-msgs { list-style: none; margin: 0; padding: 0; }
.client-msgs li + li { border-top: 1px solid var(--border); }
.client-msgs a { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); color: var(--text); text-decoration: none; }
.client-msgs a:hover { background: var(--surface-2); text-decoration: none; }
.client-msgs .inbox-item__main { gap: 0; }

/* Teller bij Inbox in het menu */
.nav__badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--oker); color: #1b2a30; font-size: .72rem; font-weight: 800; line-height: 1.4; text-align: center; }

/* Instellingen → Inbox */
.ib-servers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.ib-server { display: flex; gap: var(--space-2); }
.ib-server input[type=text] { flex: 1; min-width: 0; }
.ib-server .ib-port { width: 5.5rem; flex: none; }
.ib-server select { width: auto; flex: none; }
#inbox-whatsapp .notice label { display: block; margin-top: var(--space-2); font-weight: 600; }
@media (max-width: 860px) { .ib-servers { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .ib-server { flex-wrap: wrap; } .ib-server input[type=text] { flex-basis: 100%; } }

/* Communicatie bij een klant (client_edit.php) */
.comm-form textarea { width: 100%; resize: vertical; min-height: 72px; }
.comm-form__kinds { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--space-2); }
.comm-kind { position: relative; cursor: pointer; }
.comm-kind input { position: absolute; opacity: 0; pointer-events: none; }
.comm-kind span { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .82rem; font-weight: 600; color: var(--muted); }
.comm-kind span .icon { width: 14px; height: 14px; }
.comm-kind input:checked + span { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.comm-kind input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.comm-actions { margin-top: var(--space-3); }
.comm-empty { border-top: 1px solid var(--border); }
.comm-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.comm-item { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.comm-item + .comm-item { border-top: 1px solid var(--border); }
.comm-item__ic { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--primary); }
.comm-item__ic .icon { width: 15px; height: 15px; }
.comm-item--note .comm-item__ic { background: color-mix(in srgb, var(--oker) 22%, transparent); color: var(--text); }
.comm-item__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.comm-item__link { text-decoration: none; border-radius: var(--radius-sm); }
.comm-item__link:hover { text-decoration: none; }
.comm-item__link:hover strong { color: var(--primary); }
.comm-item__top { display: flex; align-items: center; gap: var(--space-2); font-size: .88rem; }
.comm-item__top .muted { margin-left: auto; white-space: nowrap; }
.comm-item__del { margin: -4px -6px -4px 0; }
.comm-item__del .icon-btn { width: 28px; height: 28px; }
.comm-item__del .icon { width: 14px; height: 14px; }
.comm-item__subject { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comm-item__text { margin: 0; font-size: .86rem; line-height: 1.5; overflow-wrap: anywhere; }
.comm-more { border-top: 1px solid var(--border); text-align: center; font-size: .88rem; }

.comm-form__bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin-top: var(--space-2); }
.comm-form__when { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .78rem; font-weight: 600; color: var(--muted); }
.comm-form__when input { width: 100%; min-width: 0; min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: .86rem; }
.comm-form__submit { display: flex; justify-content: flex-end; margin-top: var(--space-2); }
.comm-follow { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); padding: 4px 4px 4px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .82rem; font-weight: 600; }
.comm-follow span { display: inline-flex; align-items: center; gap: 5px; }
.comm-follow .icon { width: 14px; height: 14px; }
.comm-follow.is-due { background: var(--warning-soft); color: var(--warning); }
.comm-follow.is-done { color: var(--muted); }
@media (max-width: 400px) { .comm-form__bar { grid-template-columns: minmax(0, 1fr); } }
